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;
// 설 명 : 해피오더 취소 사유
//#20180611 해피오더 주문취소 사유 start
//#20180611 해피오더 주문취소 사유 end
namespace Cosmos.Win
{
public partial class frmHPOrderCancelReason : 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; // 마스터 인터페이스
///
/// 리스트 데이터
///
private DataTable m_dtGridList;
///
/// 사유코드 그룹
///
private string m_sReasonGroup = "";
public string ReasonGroup { set { this.m_sReasonGroup = value; } }
///
/// 사유 코드
///
private string m_sReasonCode = "";
public string ReasonCode { get { return this.m_sReasonCode; } }
///
/// 사유 명
///
private string m_sReasonName = "";
public string ReasonName { get { return this.m_sReasonName; } }
#endregion 변수 선언
#region 생성자 & 소멸자 & 폼초기화
public frmHPOrderCancelReason()
{
InitializeComponent();
base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true);
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);
}
#region 폼 컨트롤 초기화
///
/// 폼 컨트롤 초기화
///
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 = "";
btnEnter.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0225); // 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);
}
}
#endregion
#region 그리드 초기화
///
/// 그리드 초기화
///
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();
// up/down 사이즈 조절
btnUp.Top = gridList.Top;
btnUp.Height = gridList.Height / 2;
btnDown.Top = btnUp.Top + btnUp.Height;
btnDown.Height = gridList.Height / 2;
}
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 사유 코드 화면 표시
///
/// 사유 코드 화면 표시
///
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);
}
}
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
#endregion
#region 버튼 입력 처리
///
/// 버튼 입력 처리
///
///
///
private void btnProc_Click(object sender, EventArgs e)
{
try
{
// 저장
if (((Cosmos.UI.CsmButton)sender) == btnEnter)
{
CompleteTxtInPut();
}
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);
}
}
///
/// 닫기
///
///
///
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 입력 완료 처리
///
/// 입력 선택 처리
///
///
private bool CompleteTxtInPut()
{
try
{
if (txtReasonName.Text == "")
{
WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0791));
return false;
}
else
{
if (m_sReasonCode == "0")
{
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
#region 그리드 선택 이벤트
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);
// 기타 선택 시
if (m_sReasonCode == "0")
{
txtReasonName.ReadOnly = false;
txtReasonName.Tag = gridList.CsmGridGetCell(nRow, 0);
txtReasonName.Text = "";
}
// 그 외 취소사유 선택 시
else
{
txtReasonName.ReadOnly = true;
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);
}
}
#endregion
}
}