public PackingEntryUIDM LoadPackingByPackingNo(NZString PackingNo) { PackingEntryUIDM model = new PackingEntryUIDM(); InventoryTransBIZ biz = new InventoryTransBIZ(); PackingEntryDTO dto = biz.LoadPackingByPackingNo(PackingNo); if (dto == null) { return(null); } model.TRANS_ID = dto.TRANS_ID; model.PACKING_NO = dto.PACKING_NO; model.PACKING_DATE = dto.PACKING_DATE; model.SHIFT_CLS = dto.SHIFT_CLS; model.MASTER_NO = dto.MASTER_NO; model.PART_NO = dto.PART_NO; model.CUSTOMER_NAME = dto.CUSTOMER_NAME; model.PACK_NO = dto.PACK_NO; model.PERSON_IN_CHARGE = dto.PERSON_IN_CHARGE; model.TOTAL_QTY = dto.TOTAL_QTY; model.REMARK = dto.REMARK; model.SOURCE_LOC = dto.SOURCE_LOC; model.DEST_LOC = dto.DEST_LOC; model.FG_NO = dto.FG_NO; DataTable dt = biz.LoadPackingLotByPackingNo(PackingNo); model.DATA_VIEW = dt; return(model); }
private void InitialData() { PackingEntryUIDM model = new PackingEntryUIDM(); shtView.DataSource = model.DATA_VIEW; CtrlUtil.SpreadSetColumnsLocked(shtView, false, (int)eColView.LOT_NO); CtrlUtil.SpreadSetColumnsLocked(shtView, false, (int)eColView.EXTERNAL_LOT_NO); CtrlUtil.SpreadSetColumnsLocked(shtView, false, (int)eColView.QTY); }
private void tsbOk_Click(object sender, EventArgs e) { fpView.StopCellEditing(); if (m_bRowHasModified) { // ถ้า Row กำลังแก้ไขอยู่ if (!ValidateRowSpread(shtView.ActiveRowIndex, false)) { return; } } // ต้องเรียกก่อน Save เสมอ เพื่อ Commit ข้อมูลการแก้ไขล่าสุดบน Grid // ใช้ได้เฉพาะกับ Sheet ที่ผูก DataSource CtrlUtil.SpreadSheetRowEndEdit(shtView, shtView.ActiveRowIndex); RemoveRowUnused(shtView); try { if (txtRemainQty.Decimal < txtQty.Decimal) { MessageDialog.ShowInformation(this, "Information", new Message(TKPMessages.eValidate.VLM0214.ToString()).MessageDescription); return; } PackingEntryUIDM model = dmc.SaveData(new PackingEntryUIDM()); model.DATA_VIEW = (DataTable)shtView.DataSource; model.DATA_VIEW.AcceptChanges(); UpdateRecord(model.DATA_VIEW); if (!ValidateBeforeSave(model)) { return; } DialogResult = DialogResult.OK; //this.Close(); } catch (ValidateException err) { MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message); err.ErrorResults[0].FocusOnControl(); } catch (BusinessException err) { MessageDialog.ShowBusiness(this, err.Error.Message); err.Error.FocusOnControl(); } catch (Exception err) { MessageDialog.ShowBusiness(this, null, err.Message); } }
private bool ValidateBeforeSave(PackingEntryUIDM model) { if (shtView.RowCount == 0) { ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0186.ToString())); } for (int iRow = 0; iRow < shtView.RowCount; iRow++) { if (!ValidateRowSpread(iRow, true)) { return(false); } } return(true); }
private void loadData() { try { dt = m_Data; if (dt.Rows.Count > 0) { DataTable dd = new DataTable(); dd = dt.Clone(); for (int ind = 0; ind < dt.Rows.Count; ind++) { if (dt.Rows[ind]["REF_NO"].ToString() == OrderNo && dt.Rows[ind]["ITEM_CD"].ToString() == ItemCd) { dd.Rows.Add(dt.Rows[ind].ItemArray); } } if (dd.Rows.Count > 0) { shtView.Rows.Count = 0; DataTable data = new DataTable(); data.Columns.Add("TRANS_ID", typeof(String)); data.Columns.Add("LOT_NO", typeof(String)); data.Columns.Add("EXTERNAL_LOT_NO", typeof(String)); data.Columns.Add("QTY", typeof(Decimal)); for (int i = 0; i < dd.Rows.Count; i++) { DataRow row = data.NewRow(); row["TRANS_ID"] = dd.Rows[i]["REF_NO"]; row["LOT_NO"] = dd.Rows[i]["LOT_NO"]; row["EXTERNAL_LOT_NO"] = dd.Rows[i]["EXTERNAL_LOT_NO"]; row["QTY"] = dd.Rows[i]["QTY"]; data.Rows.Add(row); } PackingEntryUIDM model = new PackingEntryUIDM(); model.DATA_VIEW = data; dmc.LoadData(model); shtView.DataSource = model.DATA_VIEW; } } else { DataTable d = new DataTable(); for (int i = 0; i < 5; i++) { DataRow r = d.NewRow(); d.Rows.Add(r); } PackingEntryUIDM model = new PackingEntryUIDM(); model.DATA_VIEW = d; dmc.LoadData(model); shtView.DataSource = model.DATA_VIEW; } //for (int i = 0; i < m_Data.Rows.Count; i++) //{ // shtView.Rows.Count = i + 1; // shtView.Cells[i, (int)eColView.LOT_NO].Value = m_Data.Rows[i][(int)eColCustomerOrderDetail.LOT_NO]; // shtView.Cells[i, (int)eColView.EXTERNAL_LOT_NO].Value = m_Data.Rows[i][(int)eColCustomerOrderDetail.EXTERNAL_LOT_NO]; // shtView.Cells[i, (int)eColView.QTY].Value = m_Data.Rows[i][(int)eColCustomerOrderDetail.QTY]; //} //dt = m_Data;//.Copy(); //fpView.DataSource = dt; CalTotatValue(); } catch (Exception ex) { MessageDialog.ShowBusiness(this, ex.Message); } }
public void SaveNewPacking(PackingEntryUIDM data, int NumberOfBox) { try { #region Validate ItemValidator itemValidator = new ItemValidator(); ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(data.MASTER_NO)); BusinessException businessException = itemValidator.CheckItemNotExist(data.MASTER_NO); if (businessException != null) { ValidateException.ThrowErrorItem(businessException.Error); } #endregion InventoryBIZ biz = new InventoryBIZ(); SysConfigBIZ sysBiz = new SysConfigBIZ(); SysConfigDTO defaultSourceLoc = sysBiz.LoadByPK(DataDefine.eSYSTEM_CONFIG.TRN320.SYS_GROUP_ID, (NZString)DataDefine.eSYSTEM_CONFIG.TRN320.SYS_KEY.SOURCE_LOC.ToString()); SysConfigDTO defaultDestinationLoc = sysBiz.LoadByPK(DataDefine.eSYSTEM_CONFIG.TRN320.SYS_GROUP_ID, (NZString)DataDefine.eSYSTEM_CONFIG.TRN320.SYS_KEY.DEST_LOC.ToString()); InventoryTransactionDTO Source = new InventoryTransactionDTO(); List <InventoryTransactionDTO> DestinationList = new List <InventoryTransactionDTO>(); #region Destination foreach (DataRow dr in data.DATA_VIEW.Rows) { InventoryTransactionDTO dto = new InventoryTransactionDTO(); dto.CRT_BY = Common.CurrentUserInfomation.UserCD; //dto.CRT_DATE dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine; dto.UPD_BY = Common.CurrentUserInfomation.UserCD; //dto.UPD_DATE dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine; //dto.TRANS_ID dto.ITEM_CD = data.MASTER_NO; dto.LOC_CD = defaultDestinationLoc.CHAR_DATA; dto.LOT_NO = new NZString(null, dr[(int)PackingEntryUIDM.eColView.LOT_NO]); dto.FG_NO = data.FG_NO; dto.PACK_NO = data.PACK_NO; dto.EXTERNAL_LOT_NO = new NZString(null, dr[(int)PackingEntryUIDM.eColView.EXTERNAL_LOT_NO]); dto.TRANS_DATE = data.PACKING_DATE; dto.TRANS_CLS = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Packing).ToNZString(); dto.IN_OUT_CLS = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In).ToNZString(); dto.FG_NO = data.FG_NO; if (dr[(int)PackingEntryUIDM.eColView.QTY] == null || dr[(int)PackingEntryUIDM.eColView.QTY] == (object)DBNull.Value) { dto.QTY = new NZDecimal(null, 0); } else { dto.QTY = new NZDecimal(null, dr[(int)PackingEntryUIDM.eColView.QTY]); } //dto.WEIGHT //dto.OBJ_ITEM_CD //dto.OBJ_ORDER_QTY //dto.REF_NO //dto.REF_SLIP_NO //dto.REF_SLIP_CLS //dto.OTHER_DL_NO //dto.SLIP_NO dto.REMARK = data.REMARK; //dto.DEALING_NO //dto.PRICE //dto.AMOUNT //dto.FOR_CUSTOMER //dto.FOR_MACHINE dto.SHIFT_CLS = data.SHIFT_CLS; //dto.REF_SLIP_NO2 //dto.NG_QTY //dto.NG_WEIGHT //dto.TRAN_SUB_CLS = dto.SCREEN_TYPE = DataDefine.ScreenType.PackingEntry.ToNZString(); //dto.GROUP_TRANS_ID //dto.RESERVE_QTY //dto.RETURN_QTY //dto.NG_REASON dto.EFFECT_STOCK = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.In); //dto.LOT_REMARK dto.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE; //dto.CURRENCY //dto.REWORK_FLAG dto.OLD_DATA = new NZInt(null, 0); //dto.TIME_STAMP DestinationList.Add(dto); } #endregion #region Pack Source.CRT_BY = Common.CurrentUserInfomation.UserCD; //Source.CRT_DATE Source.CRT_MACHINE = Common.CurrentUserInfomation.Machine; Source.UPD_BY = Common.CurrentUserInfomation.UserCD; //Source.UPD_DATE Source.UPD_MACHINE = Common.CurrentUserInfomation.Machine; //Source.TRANS_ID Source.ITEM_CD = data.MASTER_NO; Source.LOC_CD = defaultSourceLoc.CHAR_DATA; //Source.LOT_NO Source.FG_NO = data.FG_NO; Source.PACK_NO = data.PACK_NO; //Source.EXTERNAL_LOT_NO Source.TRANS_DATE = data.PACKING_DATE; Source.TRANS_CLS = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Packing_Consumption).ToNZString(); Source.IN_OUT_CLS = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out).ToNZString(); Source.QTY = data.TOTAL_QTY; //Source.WEIGHT //Source.OBJ_ITEM_CD //Source.OBJ_ORDER_QTY //Source.REF_NO //Source.REF_SLIP_NO //Source.REF_SLIP_CLS //Source.OTHER_DL_NO //Source.SLIP_NO Source.REMARK = data.REMARK; //Source.DEALING_NO //Source.PRICE //Source.AMOUNT //Source.FOR_CUSTOMER //Source.FOR_MACHINE Source.SHIFT_CLS = data.SHIFT_CLS; //Source.REF_SLIP_NO2 //Source.NG_QTY //Source.NG_WEIGHT //Source.TRAN_SUB_CLS = Source.SCREEN_TYPE = DataDefine.ScreenType.PackingEntry.ToNZString(); //Source.GROUP_TRANS_ID //Source.RESERVE_QTY //Source.RETURN_QTY //Source.NG_REASON Source.EFFECT_STOCK = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.Out); //Source.LOT_REMARK Source.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE; //Source.CURRENCY //Source.REWORK_FLAG Source.OLD_DATA = new NZInt(null, 0); //Source.TIME_STAMP #endregion biz.AddPacking(DestinationList, Source, NumberOfBox); } catch (Exception) { throw; } }
public void SaveUpdatePacking(PackingEntryUIDM data) { try { #region Validate ItemValidator itemValidator = new ItemValidator(); ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(data.MASTER_NO)); BusinessException businessException = itemValidator.CheckItemNotExist(data.MASTER_NO); if (businessException != null) { ValidateException.ThrowErrorItem(businessException.Error); } #endregion InventoryBIZ biz = new InventoryBIZ(); InventoryTransBIZ bizInvTrans = new InventoryTransBIZ(); //SysConfigBIZ sysBiz = new SysConfigBIZ(); //SysConfigDTO defaultSourceLoc = sysBiz.LoadByPK(DataDefine.eSYSTEM_CONFIG.TRN320.SYS_GROUP_ID, (NZString)DataDefine.eSYSTEM_CONFIG.TRN320.SYS_KEY.SOURCE_LOC.ToString()); //SysConfigDTO defaultDestinationLoc = sysBiz.LoadByPK(DataDefine.eSYSTEM_CONFIG.TRN320.SYS_GROUP_ID, (NZString)DataDefine.eSYSTEM_CONFIG.TRN320.SYS_KEY.DEST_LOC.ToString()); InventoryTransactionDTO Source = null; List <InventoryTransactionDTO> NewLotList = null; List <InventoryTransactionDTO> ModifyLotList = null; List <InventoryTransactionDTO> DeleteLotList = null; DataTable dt = data.DATA_VIEW; DataTable dtNew = dt.GetChanges(DataRowState.Added); DataTable dtDelete = dt.GetChanges(DataRowState.Deleted); DataTable dtModify = dt.GetChanges(DataRowState.Modified); ModifyLotList = new List <InventoryTransactionDTO>(); #region Pack Source = bizInvTrans.LoadByTransactionID(data.TRANS_ID); //Source.CRT_BY = Common.CurrentUserInfomation.UserCD; //Source.CRT_DATE //Source.CRT_MACHINE = Common.CurrentUserInfomation.Machine; Source.UPD_BY = Common.CurrentUserInfomation.UserCD; //Source.UPD_DATE Source.UPD_MACHINE = Common.CurrentUserInfomation.Machine; //Source.TRANS_ID //Source.ITEM_CD = data.MASTER_NO; //Source.LOC_CD = data.SOURCE_LOC; //Source.LOT_NO Source.FG_NO = data.FG_NO; //Source.PACK_NO = data.PACK_NO; //Source.EXTERNAL_LOT_NO //Source.TRANS_DATE = data.PACKING_DATE; //Source.TRANS_CLS = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Packing_Consumption).ToNZString(); //Source.IN_OUT_CLS = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out).ToNZString(); Source.QTY = data.TOTAL_QTY; //Source.WEIGHT //Source.OBJ_ITEM_CD //Source.OBJ_ORDER_QTY //Source.REF_NO //Source.REF_SLIP_NO //Source.REF_SLIP_CLS //Source.OTHER_DL_NO //Source.SLIP_NO Source.REMARK = data.REMARK; //Source.DEALING_NO //Source.PRICE //Source.AMOUNT //Source.FOR_CUSTOMER //Source.FOR_MACHINE Source.SHIFT_CLS = data.SHIFT_CLS; //Source.REF_SLIP_NO2 //Source.NG_QTY //Source.NG_WEIGHT //Source.TRAN_SUB_CLS = Source.SCREEN_TYPE = DataDefine.ScreenType.PackingEntry.ToNZString(); //Source.GROUP_TRANS_ID //Source.RESERVE_QTY //Source.RETURN_QTY //Source.NG_REASON Source.EFFECT_STOCK = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.Out); //Source.LOT_REMARK Source.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE; //Source.CURRENCY //Source.REWORK_FLAG Source.OLD_DATA = new NZInt(null, 0); //Source.TIME_STAMP ModifyLotList.Add(Source); #endregion #region Destination : Modify Record if (dtModify != null) { foreach (DataRow dr in dtModify.Rows) { InventoryTransactionDTO dto = bizInvTrans.LoadByTransactionID(new NZString(null, dr[(int)PackingEntryUIDM.eColView.TRANS_ID])); //dto.CRT_BY = Common.CurrentUserInfomation.UserCD; //dto.CRT_DATE //dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine; dto.UPD_BY = Common.CurrentUserInfomation.UserCD; //dto.UPD_DATE dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine; //dto.TRANS_ID //dto.ITEM_CD = data.MASTER_NO; //dto.LOC_CD = defaultDestinationLoc.CHAR_DATA; //dto.LOT_NO = new NZString(null, dr[(int)PackingEntryUIDM.eColView.LOT_NO]); dto.FG_NO = data.FG_NO; //dto.PACK_NO = data.PACK_NO; dto.EXTERNAL_LOT_NO = new NZString(null, dr[(int)PackingEntryUIDM.eColView.EXTERNAL_LOT_NO]); //dto.TRANS_DATE = data.PACKING_DATE; //dto.TRANS_CLS = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Packing).ToNZString(); //dto.IN_OUT_CLS = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In).ToNZString(); if (dr[(int)PackingEntryUIDM.eColView.QTY] == null || dr[(int)PackingEntryUIDM.eColView.QTY] == (object)DBNull.Value) { dto.QTY = new NZDecimal(null, 0); } else { dto.QTY = new NZDecimal(null, dr[(int)PackingEntryUIDM.eColView.QTY]); } //dto.WEIGHT //dto.OBJ_ITEM_CD //dto.OBJ_ORDER_QTY //dto.REF_NO //dto.REF_SLIP_NO //dto.REF_SLIP_CLS //dto.OTHER_DL_NO //dto.SLIP_NO dto.REMARK = data.REMARK; //dto.DEALING_NO //dto.PRICE //dto.AMOUNT //dto.FOR_CUSTOMER //dto.FOR_MACHINE dto.SHIFT_CLS = data.SHIFT_CLS; //dto.REF_SLIP_NO2 //dto.NG_QTY //dto.NG_WEIGHT //dto.TRAN_SUB_CLS = dto.SCREEN_TYPE = DataDefine.ScreenType.PackingEntry.ToNZString(); //dto.GROUP_TRANS_ID //dto.RESERVE_QTY //dto.RETURN_QTY //dto.NG_REASON dto.EFFECT_STOCK = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.In); //dto.LOT_REMARK dto.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE; //dto.CURRENCY //dto.REWORK_FLAG dto.OLD_DATA = new NZInt(null, 0); //dto.TIME_STAMP ModifyLotList.Add(dto); } } #endregion #region Destination : New Record if (dtNew != null) { NewLotList = new List <InventoryTransactionDTO>(); foreach (DataRow dr in dtNew.Rows) { InventoryTransactionDTO dto = new InventoryTransactionDTO(); dto.CRT_BY = Common.CurrentUserInfomation.UserCD; //dto.CRT_DATE dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine; dto.UPD_BY = Common.CurrentUserInfomation.UserCD; //dto.UPD_DATE dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine; //dto.TRANS_ID dto.ITEM_CD = data.MASTER_NO; dto.LOC_CD = data.DEST_LOC; dto.LOT_NO = new NZString(null, dr[(int)PackingEntryUIDM.eColView.LOT_NO]); dto.FG_NO = data.FG_NO; dto.PACK_NO = data.PACK_NO; dto.EXTERNAL_LOT_NO = new NZString(null, dr[(int)PackingEntryUIDM.eColView.EXTERNAL_LOT_NO]); dto.TRANS_DATE = data.PACKING_DATE; dto.TRANS_CLS = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Packing).ToNZString(); dto.IN_OUT_CLS = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In).ToNZString(); if (dr[(int)PackingEntryUIDM.eColView.QTY] == null || dr[(int)PackingEntryUIDM.eColView.QTY] == (object)DBNull.Value) { dto.QTY = new NZDecimal(null, 0); } else { dto.QTY = new NZDecimal(null, dr[(int)PackingEntryUIDM.eColView.QTY]); } //dto.WEIGHT //dto.OBJ_ITEM_CD //dto.OBJ_ORDER_QTY //dto.REF_NO //dto.REF_SLIP_NO //dto.REF_SLIP_CLS //dto.OTHER_DL_NO dto.SLIP_NO = data.PACKING_NO; dto.REMARK = data.REMARK; //dto.DEALING_NO //dto.PRICE //dto.AMOUNT //dto.FOR_CUSTOMER //dto.FOR_MACHINE dto.SHIFT_CLS = data.SHIFT_CLS; //dto.REF_SLIP_NO2 //dto.NG_QTY //dto.NG_WEIGHT //dto.TRAN_SUB_CLS = dto.SCREEN_TYPE = DataDefine.ScreenType.PackingEntry.ToNZString(); dto.GROUP_TRANS_ID = Source.GROUP_TRANS_ID; //dto.RESERVE_QTY //dto.RETURN_QTY //dto.NG_REASON dto.EFFECT_STOCK = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.In); //dto.LOT_REMARK dto.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE; //dto.CURRENCY //dto.REWORK_FLAG dto.OLD_DATA = new NZInt(null, 0); //dto.TIME_STAMP NewLotList.Add(dto); } } #endregion #region Destination : Delete Record if (dtDelete != null) { DeleteLotList = new List <InventoryTransactionDTO>(); List <InventoryTransactionDTO> listDelete = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtDelete); foreach (InventoryTransactionDTO dtoDelete in listDelete) { if (dtoDelete.TRANS_ID == null || dtoDelete.TRANS_ID == (object)DBNull.Value) { continue; } InventoryTransactionDTO dto = bizInvTrans.LoadByTransactionID(new NZString(null, dtoDelete.TRANS_ID)); DeleteLotList.Add(dto); } } #endregion biz.UpdatePacking(NewLotList, ModifyLotList, DeleteLotList); } catch (Exception) { throw; } }