spc-kiosk-pb/Window/WinSale/frmHappyOrderPopup.cs

468 lines
24 KiB
C#
Raw Permalink Normal View History

2019-06-16 05:12:09 +00:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using Cosmos.BaseFrame;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using Cosmos.Common;
using Cosmos.CommonManager;
namespace Cosmos.Win
{
public partial class frmHappyOrderPopup : Form
{
private SManager sManager = new SManager(); //이 객체를 통해 업무 Service 호출
private StateServer StateObject = (StateServer)StateServer.GetInstance(); // StateObject : StateServer Object (객체)
private PosStatus m_cPosStatus = new PosStatus(); // 기본정보 참조
private string m_sPosMenuKeyIn;
public string PosMenuKeyIn { set { m_sPosMenuKeyIn = value; } get { return m_sPosMenuKeyIn; } }
SaleMainProcess m_cSaleMainProc = null;
public frmHappyOrderPopup()
{
InitializeComponent();
base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true);
//this.UpdateStyles();
m_cPosStatus = (PosStatus)StateObject.POS;
m_cSaleMainProc = new SaleMainProcess();
}
private void frmHappyOrderPopup_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();
}
private void frmHappyOrderPopup_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
{
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);
this.Location = new Point((1024 - this.Size.Width) / 2, (768 - this.Size.Height) / 2);
picBack.Image = ImageManager.GetImage(Cosmos.BaseFrame.BaseCom.NxImgPath, ImageManager.POP_SIZE_S);
btnExit.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.BTN_CLOSE);
if (btnExit.Image != null) btnExit.Text = "";
lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0437);
btnHappyOrderWeb.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0466);
btnHappyOrderList.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0467);
btnTodayPrint.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0833);
if (PosMenuKeyIn == "NORMAL")
{
lblMessage.Text = MessageManager.GetGuideMessage(POS_MESSAGE.GUIDE.MSG_0002);
}
else if (PosMenuKeyIn == "ALARM")
{
//lblMessage.Text = string.Format(MessageManager.GetGuideMessage(POS_MESSAGE.GUIDE.MSG_0001),
// int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderRegCnt, "0")),
// //int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryRequestCnt, "0"))
// //+ int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryRegCnt, "0"))
// //+ int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryingCnt, "0")));
// int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryRegCnt, "0")));
lblMessage.Text = MessageManager.GetGuideMessage(POS_MESSAGE.GUIDE.MSG_0011);
}
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
}
//#16366 해피오더 당월누적주문내역 + 당일 해피오더주문 상세내역 자동 출력기능 start
#region
/*
/// <summary>
/// 해피오더 오늘 픽업/배달 주문서출력 처리
/// </summary>
private void TodayHappyOrderPrintProc()
{
string sHappyOrderUrl = "";
IHappyOrderList cHappyOrder = null;
ArrayList cHappyOrderHeader = new ArrayList();
Hashtable[] htOrderLists = null;
try
{
cHappyOrder = (IHappyOrderList)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.HAPPY_ORDER_LIST);
// 조회중 POP-UP 시작
WinManager.ShowSearchMessage(string.Format(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0231), MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0437)), this);
// 승인업체 코드 조회
string sVanCD = PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.ORDER_ITEM, ItemConst.TR_ITEM_ID.ORDER.HAPPYORDER_PAY, PosMst.MST_PAY_DC.DATA.APPR_VEND_CD);
// 승인 URL 조회
sHappyOrderUrl = PosMstManager.GetMstVan(sVanCD, PosMst.MST_VAN.DATA.IP);
Hashtable htRequest = new Hashtable();
htRequest.Add("storeCode", m_cPosStatus.Base.StoreNo);
htRequest.Add("status", 4);
htRequest.Add("deviceType", "POS");
Hashtable htResponse = null;
int iReturn = BaseCom.NG;
htOrderLists = cHappyOrder.SendReceiveForHappyOrder(new object[] { sHappyOrderUrl, ItemConst.HAPPYORDER_WORK_TYPE.SELECT_ORDER_LIST, htRequest }, ref htResponse, ref iReturn);
cHappyOrderHeader.Clear();
//#20171215, 해피오더 주문리스트 조회 시 해피오더 테이블 데이터 삭제 후 저장하도록 수정 Start
// 해피오더 헤더정보 DB 삭제
cHappyOrder.DeleteHappyOrderAllData();
//#20171215, 해피오더 주문리스트 조회 시 해피오더 테이블 데이터 삭제 후 저장하도록 수정 End
foreach (Hashtable htData in htOrderLists)
{
Column.TR_HPORD.HPORD_HEADER header;
header = cHappyOrder.ParseHappyOrderList(htData);
// 해피오더 헤더정보 DB 처리
cHappyOrder.SaveHappyOrderData(header);
// 해피오더 주문 리스트 조회 및 저장
cHappyOrderHeader.Add(header);
}
// 오늘 픽업/배달 주문서출력 건 주문번호 조회
DataTable dtData = cHappyOrder.GetTodayHappyOrder();
if (dtData == null || dtData.Rows.Count == 0)
{
// 조회중 POP-UP 종료
WinManager.HideSearchMessage(this);
// 오늘 픽업/배달 주문서 출력 건 없을 경우 안내 POP-UP
WinManager.ConfirmMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0513));
return;
}
else
{
// 접수된 주문에 대한 안내 POP-UP
WinManager.ConfirmMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0514));
}
int iTotalCnt = dtData.Rows.Count;
int iCompletedCnt = 0;
// 주문번호 별 Loop
for (int nLoop = 0; nLoop < dtData.Rows.Count; nLoop++)
{
ArrayList cHappyOrderItem = new ArrayList();
Hashtable[] htOrderDetails = null;
DataRow drData = dtData.Rows[nLoop];
// 주문번호
string sOrderNum = CmUtil.GetDataRowStr(drData, "ORD_NO");
// 해피오더 주문 상세 조회
cHappyOrder.GetHappyOrderListDetail(sOrderNum, sHappyOrderUrl, ref cHappyOrderItem, ref htOrderDetails);
bool bReturn = PrintTodayOrderSheet(sOrderNum, ref cHappyOrderHeader, ref cHappyOrderItem);
if (bReturn == true)
{
iCompletedCnt++;
}
}
// 조회중 POP-UP 종료
WinManager.HideSearchMessage(this);
// 출력 결과 POP-UP
WinManager.ConfirmMessage(string.Format(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0515), iTotalCnt, iCompletedCnt, (iTotalCnt - iCompletedCnt)));
}
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>
private void TodayHappyOrderPrintProc()
{
try
{
IHappyOrderList cHappyOrder = (IHappyOrderList)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.HAPPY_ORDER_LIST);
// 조회중 POP-UP 시작
WinManager.ShowSearchMessage(string.Format(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0231), MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0437)), this);
try
{
bool bRet = false;
bRet = cHappyOrder.HappyOrderTodayPrint(false);
if (bRet == true)
{
UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +
System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
"당일 주문서 출력 완료!");
}
}
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
{
// 조회중 POP-UP 종료
WinManager.HideSearchMessage(this);
}
}
#endregion
//#16366 해피오더 당월누적주문내역 + 당일 해피오더주문 상세내역 자동 출력기능 end
//#16366 해피오더 당월누적주문내역 + 당일 해피오더주문 상세내역 자동 출력기능 start
#region
/*
/// <summary>
/// 해피오더 오늘 픽업/배달 주문서 출력
/// </summary>
/// <param name="sOrderNum"></param>
/// <param name="cHappyOrderHeader"></param>
/// <param name="cHappyOrderItem"></param>
/// <returns></returns>
private bool PrintTodayOrderSheet(string sOrderNum, ref ArrayList cHappyOrderHeader, ref ArrayList cHappyOrderItem)
{
bool bReturn = false;
Column.TR_HPORD.HPORD_HEADER header;
IHappyOrderList cHappyOrder = null;
try
{
cHappyOrder = (IHappyOrderList)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.HAPPY_ORDER_LIST);
cHappyOrder.PrintBufClear();
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_VER, PosConst.PRT_FMT.F103, "[ 해피오더 주문내역 ]");
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, " ");
for (int i = 0; i < cHappyOrderHeader.Count; i++)
{
if (((Column.TR_HPORD.HPORD_HEADER)cHappyOrderHeader[i]).OrderNum != sOrderNum)
{
continue;
}
header = (Column.TR_HPORD.HPORD_HEADER)cHappyOrderHeader[i];
if (header.OrderStatus == ItemConst.HAPPYORDER_STATUS.PICKUP_COMPLETED)
{
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F103, "[ 픽업 완료 ]");
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, " ");
}
if (header.OrderStatus == ItemConst.HAPPYORDER_STATUS.ORDER_CANCEL)
{
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F103, "[ 주문 취소 ]");
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, " ");
}
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, " 픽업시간 : " + header.PickupTime);
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, " 주문번호 : " + header.OrderNum);
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, " 주문일시 : " + header.OrderDate);
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, " 연 락 처 : " + header.ReceiverHp);
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, "-");
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, " ITEM QTY AMT");
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, "-");
for (int nLoop = 0; nLoop < cHappyOrderItem.Count; nLoop++)
{
Column.TR_HPORD.HPORD_ITEM item = (Column.TR_HPORD.HPORD_ITEM)cHappyOrderItem[nLoop];
int itemPrice = 0;
int itemQty = 0;
int itemDiscountPrice = 0;
itemPrice = int.Parse(item.SupplyPrice.Trim() == "" ? "0" : item.SupplyPrice.Trim());
itemQty = int.Parse(item.Qty.Trim() == "" ? "0" : item.Qty.Trim());
itemDiscountPrice = int.Parse(item.DiscountPrice.Trim() == "" ? "0" : item.DiscountPrice.Trim());
if (CmUtil.StringNullEmpty(item.FlavourFlag).Equals("N") == false)
{
if (PosMstManager.GetPosOption(POS_OPTION.OPT414) == "2")
{
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, " >" + CmUtil.RPadH(item.GoodsName, 40));
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, CmUtil.RPadH("", 27) +
CmUtil.LPadH(item.Qty, 4) +
CmUtil.LPadH(CmUtil.GetToMoney(Convert.ToString((itemPrice - itemDiscountPrice) * itemQty)), 11));
}
else
{
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101,
" >" + CmUtil.RPadH(item.GoodsName, 25) +
CmUtil.LPadH(item.Qty, 4) +
CmUtil.LPadH(CmUtil.GetToMoney(Convert.ToString((itemPrice - itemDiscountPrice) * itemQty)), 11));
}
}
else
{
if (PosMstManager.GetPosOption(POS_OPTION.OPT414) == "2")
{
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, CmUtil.RPadH(item.GoodsName, 42));
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, CmUtil.RPadH("", 27) +
CmUtil.LPadH(item.Qty, 4) +
CmUtil.LPadH(CmUtil.GetToMoney(Convert.ToString((itemPrice - itemDiscountPrice) * itemQty)), 11));
}
else
{
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101,
CmUtil.RPadH(item.GoodsName, 27) +
CmUtil.LPadH(item.Qty, 4) +
CmUtil.LPadH(CmUtil.GetToMoney(Convert.ToString((itemPrice - itemDiscountPrice) * itemQty)), 11));
}
}
}
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, "-");
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, " 합계금액 " + CmUtil.LPadH(CmUtil.GetToMoney(header.PayMoney), 11));
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, " ");
if (header.CustMsg != string.Empty)
{
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, "************** 고객요청사항 **************");
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, header.CustMsg);
cHappyOrder.AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, "*");
}
ArrayList alPrintData = cHappyOrder.GetPrintBufferData();
// 주문서 출력
bReturn = cHappyOrder.PrintOrderSheet();
if (bReturn == true)
{
// 해당 주문의 주문서 출력여부 Update
cHappyOrder.UpdateHappyOrderData(new string[] { "PRINT", "1", header.OrderNum, header.OrderDate.Substring(0, 10).Replace("-", "") });
}
System.Threading.Thread.Sleep(100);
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return bReturn;
}
*/
#endregion
//#16366 해피오더 당월누적주문내역 + 당일 해피오더주문 상세내역 자동 출력기능 end
private void btnProc_Click(object sender, EventArgs e)
{
string sMenuKey = "";
try
{
this.Visible = false;
this.DialogResult = DialogResult.OK;
this.Close();
if((Cosmos.UI.CsmButton)sender == btnHappyOrderWeb) // 점주WEB 연결
{
sMenuKey = PosKey.MENU_KEY.WEB_HP_ORD;
}
else if ((Cosmos.UI.CsmButton)sender == btnHappyOrderList) // 해피오더 내역 조회
{
sMenuKey = PosKey.MENU_KEY.HAPPY_ORDERS;
}
else if ((Cosmos.UI.CsmButton)sender == btnTodayPrint) // 오늘 픽업/배달 주문서출력
{
sMenuKey = PosKey.MENU_KEY.TODAY_HPORD_PRINT;
}
if (WinBasic.CheckMenuKeyAuth(sMenuKey) == false) return; // 기능키 판매원 권한 체크
//string sMngAuth = PosMstManager.GetMstPicAuth(m_cPosStatus.Base.CashierNo + sMenuKey);
//switch (sMngAuth)
//{
// case PosConst.MNG_AUTH_DIV.NON_PERMISSION:
// WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0308), MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0505), false);
// return;
// case PosConst.MNG_AUTH_DIV.PERMISSION:
// break;
// case PosConst.MNG_AUTH_DIV.SUPERVISOR:
// if (WinBasic.ShowForm(new string[] { FormManager.FORM_LOG_ON, PosKey.MENU_KEY.REGISTER_ADMIN }) == UserCom.RST_ERR) return;
// //string sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_CASHIER_INPUT, "Supervisor" });
// //if (sRet != UserCom.RST_OK)
// //{
// // return;
// //}
// break;
//}
if((Cosmos.UI.CsmButton)sender == btnHappyOrderWeb) // 점주WEB 연결
{
//WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_HAPPY_ORDER, PosKey.MENU_KEY.WEB_HP_ORD });
m_cPosStatus.Base.HappyOrderMode = FormManager.FORM_WEB_HAPPY_ORDER;
}
else if((Cosmos.UI.CsmButton)sender == btnHappyOrderList) // 해피오더 내역 조회
{
// 해피오더 내역조회
WinSale.ShowForm(new string[] { FormManager.FORM_SAL_HPORD, "01" });
//m_cPosStatus.Base.HappyOrderMode = FormManager.FORM_SAL_HPORD;
}
else if((Cosmos.UI.CsmButton)sender == btnTodayPrint) // 해피오더 오늘 픽업/배달 주문서출력
{
m_cPosStatus.Base.HappyOrderMode = string.Empty;
TodayHappyOrderPrintProc();
}
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);
}
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}