spc-kiosk-pb/Window/WinBasic/frmSelReasonCode.cs

490 lines
21 KiB
C#
Raw Normal View History

2019-06-16 05:12:09 +00:00
using System;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Collections;
using System.Data;
using Cosmos.Win;
using Cosmos.BaseFrame;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using Cosmos.Common;
using Cosmos.CommonManager;
/*-----------------------------------------------------------------------------------------------*/
// 설 명 : 반품 사유코드 등록
// 작 성 자 :
// 변경 이력 :
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.Win
{
public partial class frmSelReasonCode : Form
{
#region
private SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출
private StateServer StateObject = (StateServer)StateServer.GetInstance(); // StateObject : StateServer Object (객체)
private PosStatus m_cPosStatus = new PosStatus(); // 기본정보 참조
private TranStatus m_cTrnStatus = new TranStatus(); // 거래정보 참조
private IDataProcessUs m_cDataSrv = null;
private IDataCommonUs m_cDataCommon = null; // POS 공통함수 인터페이스
protected IMasterUs m_cMstService = null; // 마스터 인터페이스
/// <summary>
/// 리스트 데이터
/// </summary>
private DataTable m_dtGridList;
/// <summary>
/// 사유코드 그룹
/// </summary>
private string m_sReasonGroup = "";
public string ReasonGroup { set { this.m_sReasonGroup = value; } }
/// <summary>
/// 사유 코드
/// </summary>
private string m_sReasonCode = "";
public string ReasonCode { get { return this.m_sReasonCode; } }
/// <summary>
/// 사유 명
/// </summary>
private string m_sReasonName = "";
public string ReasonName { get { return this.m_sReasonName; } }
#endregion
#region & &
public frmSelReasonCode()
{
InitializeComponent();
base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true);
//this.UpdateStyles();
m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보
m_cTrnStatus = (TranStatus)StateObject.TRAN; // POS 거래정보
m_cDataSrv = (IDataProcessUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE);
m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON);
m_cMstService = (IMasterUs)sManager.InitServiceInstance(ServiceLists.ASV_MASTER.DLL, ServiceLists.ASV_MASTER.POS_MASTER);
}
private void frmSelReasonCode_Load(object sender, EventArgs e)
{
UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "");
InitControl();
InitializeGrid();
DisplayGrid();
}
private void frmSelReasonCode_Activated(object sender, EventArgs e)
{
}
private void frmSelReasonCode_Deactivate(object sender, EventArgs e)
{
}
private void frmSelReasonCode_FormClosing(object sender, FormClosingEventArgs e)
{
UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", lblTitle.Text);
}
/// <summary>
/// 폼 컨트롤 초기화
/// </summary>
private void InitControl()
{
try
{
// 이미지 로딩 처리
picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.POP_SIZE_S);
FormManager.SetFormAllControlFont(this, m_cPosStatus.Base.FONT);
FormManager.SetTextBoxGlobalInfo(this, m_cPosStatus.Global.m_stCultureMaster.nGroupingDigits, m_cPosStatus.Global.m_stCultureMaster.strGroupingSymbol
, m_cPosStatus.Global.m_stCultureMaster.nDecimalDigits, m_cPosStatus.Global.m_stCultureMaster.strDecimalSymbol);
FormManager.MovePopUpForm(this, false, m_cPosStatus.Sale.ScreenSizeUser);
//테마색상 적용!
btnEnter.BackColor = CmUtil.GetColorToString(m_cPosStatus.ScnMst.ThemeColor);
btnExit.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.BTN_CLOSE);
if (btnExit.Image != null) btnExit.Text = "";
btnUp.Image = CmUtil.LoadImage(BaseCom.NxImgPath + ImageManager.NAVIBTN_14X9_UP1_BASIC);
btnDown.Image = CmUtil.LoadImage(BaseCom.NxImgPath + ImageManager.NAVIBTN_14X9_DOWN1_BASIC);
if (btnUp.Image != null) btnUp.Text = "";
if (btnDown.Image != null) btnDown.Text = "";
btnSave.Visible = false;
btnDel.Visible = false;
if (m_sReasonGroup == PosConst.COMMON_CODE_GROUP.Z0008)
{
lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0383);
if (PosMstManager.GetPosOption(POS_OPTION.OPT320) != "0")
{
btnSave.Visible = true;
btnDel.Visible = true;
}
}
btnSave.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0225);
btnDel.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0021);
btnEnter.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0126);
txtReasonName.Tag = "";
txtReasonName.Text = "";
txtReasonName.Select();
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
}
/// <summary>
/// 그리드 초기화
/// </summary>
private void InitializeGrid()
{
try
{
gridList.CsmGridColumnHeadersFont = new Font(m_cPosStatus.Base.FONT, 12, gridList.CsmGridColumnHeadersFont.Style);
//DataGridView 자체의 컬럼 헤더 Visible 여부
gridList.CsmGridColumnHeadersVisible = false;
//gridList.CsmGridColumnHeadersHeight = 40;
gridList.CsmGridRowsHeight = 38;
//그리드의 컬럼 수
gridList.CsmGridColumnCount = 3;
//그리드의 한 화면에 보이는 로우수
gridList.CsmGridShowPageRowsCount = 6;
gridList.CsmGridSetHeaderBackColor(236, 238, 239); //그리드 헤더 배경색
gridList.CsmGridDefaultRowBackColor = Color.FromArgb(255, 255, 255); //그리드 홀수(Default)행의 배경색 지정
gridList.CsmGridAlternateRowBackColor = Color.FromArgb(251, 253, 255); //그리드 짝수(Alternate)행의 배경색 지정
gridList.CsmGridBackGroundColor = Color.FromArgb(251, 253, 255); //기본 백그라운드 컬러
gridList.CsmGridHighlightColor = Color.FromArgb(255, 251, 211); //그리드 선택 백 컬러
gridList.CsmGridHighlightTextColor = Color.Black; //그리드 선택 글자 컬러
//각 컬럼별 이름 지정
gridList.CsmGridColumnName(0, "");
gridList.CsmGridColumnName(1, "");
gridList.CsmGridColumnName(2, "");
//컬럼넓이 지정(710)
gridList.CsmGridSetColumnWidth(new int[] { 0, 660, 50 });
//컬럼 정렬 0:왼쪽, 1:가운데, 2:오른쪽
gridList.CsmGridAlignment(new int[] {1, 0, 1});
m_dtGridList = new DataTable("GRID_LIST");
m_dtGridList.Columns.Add(new DataColumn("REASON_CD", typeof(string)));
m_dtGridList.Columns.Add(new DataColumn("REASON_NM", typeof(string)));
m_dtGridList.Columns.Add(new DataColumn("REASON_ETC", typeof(string)));
m_dtGridList.Clear();
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
}
/// <summary>
/// 사유 코드 화면 표시
/// </summary>
private void DisplayGrid()
{
try
{
m_dtGridList.Clear();
DataTable dtData = m_cDataCommon.SeletCommonCode(m_sReasonGroup, "");
if (dtData != null && dtData.Rows.Count > 0)
{
foreach (DataRow dr in dtData.Rows)
{
DataRow drNewRow = m_dtGridList.NewRow();
drNewRow["REASON_CD"] = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CMM_CD);
drNewRow["REASON_NM"] = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CD_NM);
drNewRow["REASON_ETC"] = "WEB";
m_dtGridList.Rows.Add(drNewRow);
}
}
if (m_sReasonGroup == PosConst.COMMON_CODE_GROUP.Z0008 && PosMstManager.GetPosOption(POS_OPTION.OPT320) != "0")
{
// 반품 사유(자체관리)
string sQuery = "";
sQuery += " SELECT * FROM POSMST..MST_POS_LOCAL";
sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
sQuery += " AND GRP_CD = '" + m_sReasonGroup + "'";
sQuery += " AND USE_YN = '" + PosConst.MST_USE_YN.YES + "'";
sQuery += " ORDER BY ENTRY_NM ";
dtData = m_cMstService.Select(new string[] { sQuery });
if (dtData != null && dtData.Rows.Count > 0)
{
foreach (DataRow dr in dtData.Rows)
{
DataRow drNewRow = m_dtGridList.NewRow();
drNewRow["REASON_CD"] = CmUtil.GetDataRowStr(dr, "ENTRY_CD");
drNewRow["REASON_NM"] = CmUtil.GetDataRowStr(dr, "ENTRY_NM");
drNewRow["REASON_ETC"] = "POS";
m_dtGridList.Rows.Add(drNewRow);
}
}
}
gridList.CsmGridDataSource = m_dtGridList;
gridList.CsmGridSelectRow(0);
gridList_GridClickEvent(gridList, "");
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
}
#endregion
#region
/// <summary>
/// 버튼 입력 처리
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnProc_Click(object sender, EventArgs e)
{
try
{
if (((Cosmos.UI.CsmButton)sender) == btnEnter) // 등록
{
CompleteTxtInPut();
}
else if (((Cosmos.UI.CsmButton)sender) == btnSave) // 저장
{
SaveTxtInPut();
}
else if (((Cosmos.UI.CsmButton)sender) == btnDel) // 삭제
{
DelTxtInPut();
}
else if (((Cosmos.UI.CsmButton)sender) == btnUp)
{
gridList.CsmGridScroll("UP");
txtReasonName.Focus();
}
else if (((Cosmos.UI.CsmButton)sender) == btnDown)
{
gridList.CsmGridScroll("DOWN");
txtReasonName.Focus();
}
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
finally
{
}
}
/// <summary>
/// 닫기
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnExit_Click(object sender, EventArgs e)
{
try
{
m_sReasonCode = "";
m_sReasonName = "";
this.DialogResult = DialogResult.Cancel;
this.Close();
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
}
#endregion
#region
/// <summary>
/// 입력 선택 처리
/// </summary>
/// <returns></returns>
private bool CompleteTxtInPut()
{
try
{
if (m_sReasonName != txtReasonName.Text)
{
m_sReasonCode = "";
m_sReasonName = txtReasonName.Text;
}
this.DialogResult = DialogResult.OK;
this.Close();
return true;
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
return false;
}
#endregion
private void gridList_GridClickEvent(object sender, string rowIndex)
{
try
{
if (gridList.CsmGridRowsCount == 0) return;
int nRow = gridList.CsmGridSelectedRowIndex;
if (nRow < 0) return;
m_sReasonCode = gridList.CsmGridGetCell(nRow, 0);
m_sReasonName = gridList.CsmGridGetCell(nRow, 1);
txtReasonName.Tag = gridList.CsmGridGetCell(nRow, 0);
txtReasonName.Text = gridList.CsmGridGetCell(nRow, 1);
txtReasonName.Focus();
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
}
/// <summary>
/// 저장 처리
/// </summary>
private void SaveTxtInPut()
{
try
{
if (m_sReasonGroup == PosConst.COMMON_CODE_GROUP.Z0008 && PosMstManager.GetPosOption(POS_OPTION.OPT320) != "0")
{
// 반품 사유
int nMaxEntryCode = 1;
for (int i = 0; i < gridList.CsmGridRowsCount; i++ )
{
int nCode = CmUtil.IntParse(gridList.CsmGridGetCell(i, 0));
if (nMaxEntryCode <= nCode) nMaxEntryCode = nCode + 1;
string nName = gridList.CsmGridGetCell(i, 1);
if (txtReasonName.Text == nName) return; // 같은 값이 등록 되어 있는지 체크
}
string sReasonName = txtReasonName.Text;
string sQuery = "";
sQuery += " INSERT INTO POSMST..MST_POS_LOCAL";
sQuery += " (CMP_CD,STOR_CD,GRP_CD,ENTRY_CD,ENTRY_NM,DISP_SEQ,USE_YN,UPD_DT,REG_DT) VALUES (";
sQuery += " '" + m_cPosStatus.Base.CmpCd + "'";
sQuery += " ,'" + m_cPosStatus.Base.StoreNo + "'";
sQuery += " ,'" + m_sReasonGroup + "'";
sQuery += " ,'" + nMaxEntryCode + "'";
sQuery += " ,N'" + txtReasonName.Text + "'";
sQuery += " ,'" + nMaxEntryCode + "'";
sQuery += " ,'" + PosConst.MST_USE_YN.YES + "'";
sQuery += " ,'" + DateTime.Now.ToString("yyyyMMddHHmmss") + "'";
sQuery += " ,'" + DateTime.Now.ToString("yyyyMMddHHmmss") + "'";
sQuery += ")";
if (m_cMstService.Update(new string[] { sQuery }) != UserCom.OK)
{
WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0417));
return;
}
DisplayGrid();
m_sReasonCode = nMaxEntryCode.ToString();
m_sReasonName = sReasonName;
txtReasonName.Tag = m_sReasonCode;
txtReasonName.Text = m_sReasonName;
}
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
}
/// <summary>
/// 삭제 처리
/// </summary>
private void DelTxtInPut()
{
try
{
if (m_sReasonGroup == PosConst.COMMON_CODE_GROUP.Z0008 && PosMstManager.GetPosOption(POS_OPTION.OPT320) != "0")
{
// 반품 사유
if (gridList.CsmGridRowsCount == 0) return;
int nRow = gridList.CsmGridSelectedRowIndex;
if (nRow < 0) return;
string sEntryCode = gridList.CsmGridGetCell(nRow, 0);
if (gridList.CsmGridGetCell(nRow, 2) != "POS")
{
return;
}
string sQuery = "";
sQuery += " DELETE POSMST..MST_POS_LOCAL";
sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
sQuery += " AND GRP_CD = '" + m_sReasonGroup + "'";
sQuery += " AND ENTRY_CD = '" + sEntryCode + "'";
if (m_cMstService.Update(new string[] { sQuery }) != UserCom.OK)
{
WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0417));
return;
}
DisplayGrid();
}
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
}
}
}