コード例 #1
0
 private void AssignHeaderToDTO(InvoiceEntryUIDM model, InvoiceDTO dto, Common.eScreenMode Mode)
 {
     //dto.TRANS_ID = model.TRANS_ID;
     dto.BILL_NO = model.BILL_NO;
     //dto.DELIVERY_NO = model.DELIVERY_NO;
     //dto.ADDRESS_NO = model.ADDRESS_NO;
     //dto.ADDRESS = model.ADDRESS;
     //dto.INVOICE_NO = model.INVOICE_NO;
     //dto.INVOICE_DATE = model.INVOICE_DATE;
     //dto.TERM_OF_PAYMENT = model.TERM_OF_PAYMENT;
     //dto.PAYMENT_DUE_DATE = model.PAYMENT_DUE_DATE;
     //dto.REFER_TEM_NO = model.REFER_TEM_NO;
     //dto.REMARK = model.REMARK;
     //dto.SUB_TOTAL = model.SUB_TOTAL;
     //dto.VAT = model.VAT;
     //dto.VAT_AMOUNT = model.VAT_AMOUNT;
     //dto.TOTAL = model.TOTAL;
     //dto.CANCEL_FLAG = model.CANCEL_FLAG;
     dto.PO_NO           = model.PO_NO;
     dto.ORDER_NO        = model.ORDER_NO;
     dto.ORDER_DETAIL_NO = model.ORDER_DETAIL_NO;
     dto.ITEM_CD         = model.ITEM_CD;
     dto.SHORT_NAME      = model.SHORT_NAME;
     dto.ITEM_DESC       = model.ITEM_DESC;
     dto.UNIT            = model.UNIT;
     dto.QTY             = model.QTY;
     dto.PRICE           = model.PRICE;
     dto.AMOUNT          = model.AMOUNT;
     //dto.OLD_DATA = model.OLD_DATA;
     if (Mode == Common.eScreenMode.ADD)
     {
         dto.OLD_DATA.Value = 0;
     }
 }
コード例 #2
0
 public void SaveCustomerOrder(Database db
                               , List <CustomerOrderViewDTO> addItems
                               , List <CustomerOrderViewDTO> updateItems
                               , List <CustomerOrderViewDTO> deleteItems
                               , Common.eScreenMode Mode)
 {
     // For new order
     if (addItems != null && addItems.Count > 0)
     {
         AddNewCustomerOrder(db, addItems);
     }
     if (updateItems != null && updateItems.Count > 0)
     {
         UpdateCustomerOrder(db, updateItems);
     }
     if (deleteItems != null && deleteItems.Count > 0)
     {
         DeleteCustomerOrder(db, deleteItems);
     }
 }
コード例 #3
0
        private void SetScreenMode(Common.eScreenMode mode)
        {
            switch (mode)
            {
            case Common.eScreenMode.VIEW:
                CtrlUtil.EnabledControl(false, txtInvoiceNo, txtPONo, txtRemark, fpView);
                CtrlUtil.EnabledControl(false, dtReceiveDate, rdoReceive, rdoReceiveReturn);
                CtrlUtil.EnabledControl(false, txtInvoiceNo, txtPONo, txtRemark, cboStoredLoc, cboSupplierCode);

                tsbSaveAndNew.Enabled   = false;
                tsbSaveAndClose.Enabled = false;
                shtView.OperationMode   = OperationMode.ReadOnly;

                CtrlUtil.SpreadSetColumnsLocked(shtView, true, (int)eColView.ORDER_QTY);
                CtrlUtil.SpreadSetColumnsLocked(shtView, true, (int)eColView.SUPP_LOT_NO);
                CtrlUtil.SpreadSetColumnsLocked(shtView, true, (int)eColView.PRICE);
                fpView.ContextMenuStrip = null;
                break;

            case Common.eScreenMode.ADD:
                CtrlUtil.EnabledControl(true, dtReceiveDate, txtInvoiceNo, txtPONo
                                        , txtRemark, fpView, rdoReceiveReturn, rdoReceive, cboSupplierCode, cboStoredLoc);
                //m_keyboardSpread.StartBind();
                break;

            case Common.eScreenMode.EDIT:
                CtrlUtil.EnabledControl(true, fpView);
                CtrlUtil.EnabledControl(false, dtReceiveDate, rdoReceive, rdoReceiveReturn, cboStoredLoc, cboSupplierCode);
                CtrlUtil.EnabledControl(true, txtInvoiceNo, txtPONo, txtRemark);
                CtrlUtil.SpreadSetColumnsLocked(shtView, false, (int)eColView.ORDER_QTY);
                CtrlUtil.SpreadSetColumnsLocked(shtView, false, (int)eColView.SUPP_LOT_NO);
                CtrlUtil.SpreadSetColumnsLocked(shtView, false, (int)eColView.PRICE);
                //m_keyboardSpread.StartBind();
                break;
            }

            m_screenMode = mode;
        }
コード例 #4
0
        public void Save(ReturnEntryUIDM model, Common.eScreenMode Mode)
        {
            NZString  m_EditSlipNo;
            DataTable m_OldReturn = new DataTable();
            DataTable m_NewReturn = new DataTable();

            ReturnBIZ bizReturn = new ReturnBIZ();

            Database db = Common.CurrentDatabase.CreateNewDatabase();

            try
            {
                db.KeepConnection = true;
                db.BeginTransaction(IsolationLevel.Serializable);
                ShipmentBIZ bizShipment = new ShipmentBIZ();
                //bizShipment.AddShipmentEntry(dtoInvTrnsList);
                if (Mode != Common.eScreenMode.ADD)
                {
                    m_EditSlipNo = model.SLIP_NO;
                    m_OldReturn  = bizReturn.Load_ReturnListEntry(m_EditSlipNo, false);
                }

                IssueEntryValidator val       = new IssueEntryValidator();
                CommonBizValidator  commonVal = new CommonBizValidator();


                //== If data not has to processing.
                if (model.DATA_VIEW == null || model.DATA_VIEW.Rows.Count == 0)
                {
                    ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0055.ToString()));
                }

                DataTable dtData     = model.DATA_VIEW;
                DataTable dtUnChange = new DataTable();
                DataTable dtAdd      = new DataTable();
                DataTable dtModify   = new DataTable();
                DataTable dtDelete   = new DataTable();

                //if (Mode == Common.eScreenMode.ADD || m_OldReturn.Rows.Count <= 0)
                //{
                dtUnChange = dtData.GetChanges(DataRowState.Unchanged);
                dtAdd      = dtData.GetChanges(DataRowState.Added);
                dtModify   = dtData.GetChanges(DataRowState.Modified);
                dtDelete   = dtData.GetChanges(DataRowState.Deleted);

                /*}
                 * else
                 * {
                 *  dtAdd = dtData.Clone();
                 *  dtModify = dtData.Clone();
                 *  dtDelete = dtData.Clone();
                 *
                 *  m_NewReturn = model.DATA_VIEW.Copy();
                 *  m_NewReturn.AcceptChanges();
                 *
                 *  // Manage for Update and Delete
                 *  for (int i = 0; i < m_OldReturn.Rows.Count; i++)
                 *  {
                 *      string OrderDetailNo = Convert.ToString(m_OldReturn.Rows[i]["REF_SLIP_NO"]);
                 *      string ItemCd = Convert.ToString(m_OldReturn.Rows[i]["ITEM_CD"]);
                 *
                 *      //decimal ShipQTY = Convert.ToDecimal(m_OldReturn.Rows[i]["SHIP_QTY"]);
                 *      //decimal RemainableQTY = Convert.ToDecimal(m_OldReturn.Rows[i]["RETURNABLE_QTY"]);
                 *      decimal ReturnQTY = Convert.ToDecimal(m_OldReturn.Rows[i]["RETURN_QTY"]);
                 *
                 *      bool found_order_detail = false;
                 *      for (int j = 0; j < m_NewReturn.Rows.Count; j++)
                 *      {
                 *
                 *          if (Convert.ToString(m_NewReturn.Rows[j]["REF_SLIP_NO"]) == OrderDetailNo
                 *              && Convert.ToString(m_NewReturn.Rows[j]["ITEM_CD"]) == ItemCd
                 *              && Convert.ToDecimal(m_NewReturn.Rows[j]["RETURN_QTY"]) != ReturnQTY)
                 *          {
                 *              found_order_detail = true;
                 *
                 *              // Delete Old
                 *              DataRow row = dtDelete.NewRow();
                 *              row["TRANS_ID"] = m_OldReturn.Rows[i]["TRANS_ID"];
                 *              row["ITEM_CD"] = m_OldReturn.Rows[i]["ITEM_CD"];
                 *              row["LOC_CD"] = m_OldReturn.Rows[i]["LOC_CD"];
                 *              row["TRANS_DATE"] = m_OldReturn.Rows[i]["TRANS_DATE"];
                 *              row["TRANS_CLS"] = m_OldReturn.Rows[i]["TRANS_CLS"];
                 *              row["IN_OUT_CLS"] = m_OldReturn.Rows[i]["IN_OUT_CLS"];
                 *              row["RETURN_QTY"] = m_OldReturn.Rows[i]["RETURN_QTY"];
                 *              row["REF_SLIP_NO"] = OrderDetailNo;
                 *              dtDelete.Rows.Add(row);
                 *
                 *
                 *              if (Convert.ToString(m_NewReturn.Rows[j]["REF_SLIP_NO"]) == OrderDetailNo
                 *                  && Convert.ToString(m_NewReturn.Rows[j]["ITEM_CD"]) == ItemCd)
                 *              {
                 *                  dtAdd.ImportRow(m_NewReturn.Rows[j]);
                 *              }
                 *
                 *          }
                 *          else if (Convert.ToString(m_NewReturn.Rows[j]["REF_SLIP_NO"]) == OrderDetailNo
                 *              && Convert.ToString(m_NewReturn.Rows[j]["ITEM_CD"]) == ItemCd
                 *              && Convert.ToDecimal(m_NewReturn.Rows[j]["RETURN_QTY"]) == ReturnQTY)
                 *          {
                 *              found_order_detail = true;
                 *          }
                 *
                 *          // In  update have remove order
                 *          if (j == m_NewReturn.Rows.Count - 1 && !found_order_detail)
                 *          {
                 *              // Delete Old
                 *              DataRow row = dtDelete.NewRow();
                 *              row["TRANS_ID"] = m_OldReturn.Rows[i]["TRANS_ID"];
                 *              row["ITEM_CD"] = m_OldReturn.Rows[i]["ITEM_CD"];
                 *              row["LOC_CD"] = m_OldReturn.Rows[i]["LOC_CD"];
                 *              row["TRANS_DATE"] = m_OldReturn.Rows[i]["TRANS_DATE"];
                 *              row["TRANS_CLS"] = m_OldReturn.Rows[i]["TRANS_CLS"];
                 *              row["IN_OUT_CLS"] = m_OldReturn.Rows[i]["IN_OUT_CLS"];
                 *              row["RETURN_QTY"] = m_OldReturn.Rows[i]["RETURN_QTY"];
                 *              row["REF_SLIP_NO"] = OrderDetailNo;
                 *              dtDelete.Rows.Add(row);
                 *          }
                 *      }
                 *  }
                 *
                 *  // Manage for check add new order on update mode
                 *  for (int i = 0; i < m_NewReturn.Rows.Count; i++)
                 *  {
                 *      string OrderDetailNo = Convert.ToString(m_NewReturn.Rows[i]["REF_SLIP_NO"]);
                 *      string ItemCd = Convert.ToString(m_NewReturn.Rows[i]["ITEM_CD"]);
                 *
                 *      //decimal ShipQTY = Convert.ToDecimal(m_NewReturn.Rows[i]["SHIP_QTY"]);
                 *      //decimal RemainableQTY = Convert.ToDecimal(m_NewReturn.Rows[i]["RETURNABLE_QTY"]);
                 *      decimal ReturnQTY = Convert.ToDecimal(m_NewReturn.Rows[i]["RETURN_QTY"]);
                 *      bool found_order_detail = false;
                 *      for (int j = 0; j < m_OldReturn.Rows.Count; j++)
                 *      {
                 *
                 *          if (Convert.ToString(m_OldReturn.Rows[j]["REF_SLIP_NO"]) == OrderDetailNo
                 *              && Convert.ToString(m_OldReturn.Rows[j]["ITEM_CD"]) == ItemCd
                 *              && Convert.ToDecimal(m_OldReturn.Rows[j]["RETURN_QTY"]) != ReturnQTY)
                 *          {
                 *              found_order_detail = true;
                 *          }
                 *
                 *
                 *          // Not found old order in new order then add new order
                 *          if (j == m_OldReturn.Rows.Count - 1 && !found_order_detail)
                 *          {
                 *              if (Convert.ToString(m_NewReturn.Rows[i]["REF_SLIP_NO"]) == OrderDetailNo
                 *                      && Convert.ToString(m_NewReturn.Rows[i]["ITEM_CD"]) == ItemCd)
                 *              {
                 *                  dtAdd.ImportRow(m_NewReturn.Rows[i]);
                 *              }
                 *          }
                 *      }
                 *  }
                 * }*/

                InventoryBIZ biz = new InventoryBIZ();

                List <InventoryTransactionDTO> listAdd      = null;
                List <InventoryTransactionDTO> listUpdate   = null;
                List <InventoryTransactionDTO> listDelete   = null;
                List <InventoryTransactionDTO> listUnChange = null;

                //== Insert process.
                if (dtAdd != null && dtAdd.Rows.Count > 0)
                {
                    listAdd = new List <InventoryTransactionDTO>();
                    listAdd = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtAdd);
                    RunningNumberBIZ runningNumberBIZ         = new RunningNumberBIZ();
                    NZString         runningNo_SLIP_NO        = null;
                    NZString         runningNo_GROUP_TRANS_ID = null;

                    if (model.SLIP_NO.IsNull || model.SLIP_NO.Value == "")
                    {
                        runningNo_SLIP_NO = runningNumberBIZ.GetCompleteRunningNo((NZString)"RETURN_NO", (NZString)"TB_INV_TRANS_TR");
                    }
                    else
                    {
                        runningNo_SLIP_NO = model.SLIP_NO;
                    }

                    if (model.GROUP_TRANS_ID.IsNull)
                    {
                        runningNo_GROUP_TRANS_ID = runningNumberBIZ.GetCompleteRunningNo(new NZString(null, "TRAN_GROUP_ID"), new NZString(null, "TB_INV_TRANS_TR"));
                    }
                    else
                    {
                        runningNo_GROUP_TRANS_ID = model.SLIP_NO;
                    }

                    for (int i = 0; i < listAdd.Count; i++)
                    {
                        InventoryTransactionDTO dto = listAdd[i];

                        // มีการ Gen Running Number ของ NO_LOT_TRANS_ID ไว้แล้วใน InventoryBIZ FN: AddInventoryTransaction
                        //NZString runningNo_LOT_TRANS_ID = runningNumberBIZ.GetCompleteRunningNo(new NZString(null, "TRAN_ID"), new NZString(null, "TB_INV_TRANS_TR"));
                        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                        AssignHeaderToDTO(model, dto, Mode);

                        dto.SLIP_NO        = runningNo_SLIP_NO;
                        dto.GROUP_TRANS_ID = runningNo_GROUP_TRANS_ID;

                        //dto.TRANS_ID = runningNo_LOT_TRANS_ID;

                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                        listAdd[i] = dto;
                        // check for lot no if ship type is SHIP
                        //if (model.TRANS_CLS.StrongValue != DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Shipment_Return))
                        //    ValidateException.ThrowErrorItem(commonVal.CheckInputLot(dto.ITEM_CD, dto.LOC_CD, dto.LOT_NO, true));
                    }
                }

                //== Update process.
                if (dtModify != null && dtModify.Rows.Count > 0)
                {
                    listUpdate = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtModify);

                    for (int i = 0; i < listUpdate.Count; i++)
                    {
                        InventoryTransactionDTO dto = listUpdate[i];

                        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                        AssignHeaderToDTO(model, dto, Mode);

                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                        listUpdate[i] = dto;
                    }
                }

                //== Update for Unchage กรณีที่ header เปลี่ยนแต่ส่วนของ Spread ไม่มีการเปลี่ยนแปลงต้องใช้ UnChanged ช่วย Update
                if (dtUnChange != null && dtUnChange.Rows.Count > 0)
                {
                    listUnChange = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtUnChange);
                    if (listUpdate == null)
                    {
                        listUpdate = new List <InventoryTransactionDTO>();
                    }
                    for (int i = 0; i < listUnChange.Count; i++)
                    {
                        InventoryTransactionDTO dto = listUnChange[i];

                        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                        AssignHeaderToDTO(model, dto, Mode);

                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                        //dto.QTY.Value = 0;

                        listUpdate.Add(dto);
                    }
                }


                //== Delete process.
                if (dtDelete != null && dtDelete.Rows.Count > 0)
                {
                    listDelete = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtDelete);
                }

                bizReturn.SaveShipmentEntry(db, listAdd, listUpdate, listDelete);

                //if (Mode == Common.eScreenMode.EDIT)
                //{
                //    if (dtData != null && dtData.Rows.Count > 0)
                //    {
                //        listUpdate = DTOUtility.ConvertDataTableToList<InventoryTransactionDTO>(dtData);

                //        for (int i = 0; i < listUpdate.Count; i++)
                //        {
                //            InventoryTransactionDTO dto = listUpdate[i];

                //            // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                //            AssignHeaderToDTO(model, dto,Mode);

                //            dto.CRT_BY = Common.CurrentUserInfomation.UserCD;
                //            dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                //            dto.UPD_BY = Common.CurrentUserInfomation.UserCD;
                //            dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                //            DeliveryBIZ bizDelivery = new DeliveryBIZ();
                //            bizDelivery.UpdateReceiveHeader(db, listUpdate[i]);
                //        }
                //    }

                //    //if (dtDelete != null && dtDelete.Rows.Count > 0)
                //    //{
                //    //    ShipmentEntryController ctlShip = new ShipmentEntryController();

                //    //    for (int i = 0; i < dtDelete.Rows.Count; i++)
                //    //    {
                //    //        NZString strOrderDetailNo = dtDelete.Rows[i]["REF_SLIP_NO"].ToString().ToNZString();
                //    //        decimal dQTY = Convert.ToDecimal(dtDelete.Rows[i]["QTY"]);
                //    //        if (dQTY == null || dQTY <= 0) continue;
                //    //        ctlShip.UpdateShipQTY(strOrderDetailNo, dQTY * -1);
                //    //    }
                //    //}

                //    //if (dtAdd != null && dtAdd.Rows.Count > 0)
                //    //{
                //    //    ShipmentEntryController ctlShip = new ShipmentEntryController();

                //    //    for (int i = 0; i < dtAdd.Rows.Count; i++)
                //    //    {
                //    //        NZString strOrderDetailNo = dtAdd.Rows[i]["REF_SLIP_NO"].ToString().ToNZString();
                //    //        decimal dQTY = Convert.ToDecimal(dtAdd.Rows[i]["QTY"]);
                //    //        if (dQTY == null || dQTY <= 0) continue;
                //    //        ctlShip.UpdateShipQTY(strOrderDetailNo, dQTY);
                //    //    }
                //    //}

                //}

                //if (Mode == Common.eScreenMode.EDIT)
                //{
                //    if (dtAdd != null && dtAdd.Rows.Count > 0)
                //    {
                //        listUpdate = DTOUtility.ConvertDataTableToList<InventoryTransactionDTO>(dtAdd);

                //        for (int i = 0; i < listUpdate.Count; i++)
                //        {
                //            InventoryTransactionDTO dto = listUpdate[i];

                //            // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                //            AssignHeaderToDTO(model, dto);

                //            dto.CRT_BY = Common.CurrentUserInfomation.UserCD;
                //            dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                //            dto.UPD_BY = Common.CurrentUserInfomation.UserCD;
                //            dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                //            //biz.UpdateReceiveHeader(db, dto);

                //            biz.UpdateInventoryOnhand(db, dto, DataDefine.eOperationClass.Add);
                //        }
                //    }
                //}
                db.Commit();
            }
            catch
            {
                db.Rollback();
                throw;
            }
            finally
            {
                if (db.DBConnectionState == ConnectionState.Open)
                {
                    db.Close();
                }
            }
        }
コード例 #5
0
        private void AssignHeaderToDTO(ReturnEntryUIDM model, InventoryTransactionDTO dto, Common.eScreenMode Mode)
        {
            //dto.TRANS_DATE = model.TRANS_DATE;
            //dto.SLIP_NO = model.SLIP_NO;
            dto.TRANS_CLS          = DataDefine.eTRANS_TYPE_string.Shipment_Return.ToNZString();
            dto.IN_OUT_CLS         = DataDefine.eIN_OUT_CLASS.In.ToString().ToNZString();
            dto.EFFECT_STOCK.Value = (int)DataDefine.eEFFECT_STOCK.In;
            dto.REMARK             = model.REMARK;
            dto.LOC_CD             = model.LOC_CD;
            dto.REF_SLIP_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eREF_SLIP_CLS.Shipment);
            dto.SCREEN_TYPE        = DataDefine.ScreenType.ReturnEntry.ToNZString();
            dto.DEALING_NO         = model.DEALING_NO;
            if (Mode == Common.eScreenMode.ADD)
            {
                dto.OLD_DATA.Value = 0;
            }
            //dto.CURRENCY = model.CURRENCY;
            dto.TRANS_DATE = model.TRANS_DATE;


            if (dto.TRANS_CLS.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Shipment))
            {
                dto.IN_OUT_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out);
            }
            else
            {
                dto.IN_OUT_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In);
            }
        }
コード例 #6
0
 private void AssignHeaderToDTO(CustomerOrderEntryUIDM model, CustomerOrderViewDTO dto, Common.eScreenMode Mode)
 {
     dto.ORDER_NO      = model.ORDER_NO;
     dto.RECEIVE_DATE  = model.RECEIVE_DATE;
     dto.CUSTOMER_CD   = model.CUSTOMER_CD;
     dto.LOC_CD        = model.LOC_CD;
     dto.LOC_DESC      = model.LOC_DESC;
     dto.ORDER_TYPE    = model.ORDER_TYPE;
     dto.PO_NO         = model.PO_NO;
     dto.PO_DATE       = model.PO_DATE;
     dto.CURRENCY      = model.CURRENCY;
     dto.EXCHANGE_RATE = model.EXCHANGE_RATE;
     dto.REMARK        = model.REMARK;
     //dto.ITEM_CD = model.ITEM_CD;
     dto.SHORT_NAME = model.SHORT_NAME;
     //dto.ITEM_DELIVERY_DATE = model.ITEM_DELIVERY_DATE;
     //dto.QTY = model.QTY;
     //dto.PRICE = model.PRICE;
     //dto.AMOUNT = model.AMOUNT;
     //dto.AMOUNT_THB = model.AMOUNT_THB;
     dto.TOTAL_QTY        = model.TOTAL_QTY;
     dto.TOTAL_AMOUNT     = model.TOTAL_AMOUNT;
     dto.TOTAL_AMOUNT_THB = model.TOTAL_AMOUNT_THB;
     if (Mode == Common.eScreenMode.ADD)
     {
         dto.OLD_DATA.Value = 0;
     }
 }
コード例 #7
0
        //public CustomerOrderEntryUIDM LoadData(NZString orderNo)
        //{

        //    CustomerOrderBIZ biz = new CustomerOrderBIZ();
        //    List<CustomerOrderViewDTO> listViewDTO = DTOUtility.ConvertDataTableToList<CustomerOrderViewDTO>(biz.LoadCustomerOrderEntry(orderNo, false));
        //    if (listViewDTO != null)
        //    {
        //        if (listViewDTO.Count > 0)
        //        {
        //            CustomerOrderEntryUIDM model = MapDTOToUIDM(listViewDTO[0]);
        //            model.DATA_VIEW = DTOUtility.ConvertListToDataTable(listViewDTO);

        //            //== Ensure that data has not modified.
        //            model.DATA_VIEW.AcceptChanges();

        //            return model;
        //        }
        //    }
        //    return new CustomerOrderEntryUIDM();
        //}

        #region SaveData
        public void Save(CustomerOrderEntryUIDM model, Common.eScreenMode Mode)
        {
            try
            {
                Common.CurrentDatabase.KeepConnection = true;
                Common.CurrentDatabase.BeginTransaction(IsolationLevel.Serializable);

                CustomerOrderBIZ biz = new CustomerOrderBIZ();

                #region Validate Data
                //== If data not has to processing.
                if (model.DATA_VIEW == null || model.DATA_VIEW.Rows.Count == 0)
                {
                    ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0055.ToString()));
                }

                DataTable dtNonDelete = model.DATA_VIEW.GetChanges(DataRowState.Unchanged | DataRowState.Added | DataRowState.Modified);
                List <CustomerOrderViewDTO> listData = DTOUtility.ConvertDataTableToList <CustomerOrderViewDTO>(dtNonDelete);

                #endregion


                DataTable dtData   = model.DATA_VIEW.Copy();
                DataTable dtAdd    = dtData.GetChanges(DataRowState.Added);
                DataTable dtModify = dtData.GetChanges(DataRowState.Modified);
                DataTable dtDelete = dtData.GetChanges(DataRowState.Deleted);

                //ORDER_DETAIL_NO,
                //ITEM_CD,
                //ITEM_CD_BTN,
                //PART_NO,
                //ITEM_DELIVERY_DATE,
                //OLD_ITEM_DELIVERY_DATE,
                //QTY,
                //OLD_QTY,
                //PRICE,
                //AMOUNT,
                //PRICE_THB,
                //AMOUNT_THB

                // แก้บั๊ก GetChange แล้ว Data ไม่ถูกต้อง
                dtData.AcceptChanges();
                if (dtModify != null && dtModify.Rows.Count > 0)
                {
                    for (int i = 0; i < dtModify.Rows.Count; i++)
                    {
                        for (int j = 0; j < dtData.Rows.Count; j++)
                        {
                            if (Convert.ToString(dtModify.Rows[i]["ORDER_DETAIL_NO"]) == Convert.ToString(dtData.Rows[j]["ORDER_DETAIL_NO"]))
                            {
                                dtModify.Rows[i]["ITEM_CD"]            = dtData.Rows[j]["ITEM_CD"];
                                dtModify.Rows[i]["PART_NO"]            = dtData.Rows[j]["PART_NO"];
                                dtModify.Rows[i]["ITEM_DELIVERY_DATE"] = dtData.Rows[j]["ITEM_DELIVERY_DATE"];
                                dtModify.Rows[i]["QTY"]        = dtData.Rows[j]["QTY"];
                                dtModify.Rows[i]["PRICE"]      = dtData.Rows[j]["PRICE"];
                                dtModify.Rows[i]["AMOUNT"]     = dtData.Rows[j]["AMOUNT"];
                                dtModify.Rows[i]["PRICE_THB"]  = dtData.Rows[j]["PRICE_THB"];
                                dtModify.Rows[i]["AMOUNT_THB"] = dtData.Rows[j]["AMOUNT_THB"];
                            }
                        }
                    }
                }
                List <CustomerOrderViewDTO> listAdd    = new List <CustomerOrderViewDTO>();
                List <CustomerOrderViewDTO> listUpdate = new List <CustomerOrderViewDTO>();
                List <CustomerOrderViewDTO> listDelete = new List <CustomerOrderViewDTO>();


                //มีการปรับให้ทำคำสั่งทีละ set ของ add , update , delete เลย
                //ที่เริ่มจาก delete ก่อนเพราะ consumption จะได้มีการเอาไปใช้สำหรับตัวที่ add ได้เลย ไม่ต้องค้างไว้ lot หน้า
                //== Delete process.
                if (dtDelete != null && dtDelete.Rows.Count > 0)
                {
                    listDelete = DTOUtility.ConvertDataTableToList <CustomerOrderViewDTO>(dtDelete);
                    for (int i = 0; i < listDelete.Count; i++)
                    {
                        AssignHeaderToDTO(model, listDelete[i], Mode);
                    }

                    biz.SaveCustomerOrder(Common.CurrentDatabase, null, null, listDelete, Mode);

                    // When detail row <= 0 then delete header row

                    if ((dtAdd == null || dtAdd.Rows.Count == 0) &&
                        (dtModify == null || dtModify.Rows.Count == 0) &&
                        biz.LoadCustomerOrderEntry(listDelete[0].ORDER_NO, false).Count <= 0)
                    {
                        biz.DeleteCustomerOrderHeader(Common.CurrentDatabase, listDelete);
                    }
                }

                //== Insert process.
                if (dtAdd != null && dtAdd.Rows.Count > 0)
                {
                    listAdd = DTOUtility.ConvertDataTableToList <CustomerOrderViewDTO>(dtAdd);

                    List <CustomerOrderViewDTO> listAddEachDetail = null;

                    NZString         runningNo        = null;
                    RunningNumberBIZ runningNumberBIZ = new RunningNumberBIZ();

                    if (model.ORDER_NO.IsNull)
                    {
                        runningNo      = runningNumberBIZ.GetCompleteRunningNo((NZString)"CUSTOMER_ORDER_NO", (NZString)"TB_CUSTOMER_ORDERH_TR");
                        model.ORDER_NO = runningNo;
                        // Insert Header
                        AssignHeaderToDTO(model, listAdd[0], Mode);
                        biz.AddCustomerOrderHeader(Common.CurrentDatabase, listAdd[0]);
                    }
                    else
                    {
                        runningNo = model.ORDER_NO;
                    }


                    listAddEachDetail = new List <CustomerOrderViewDTO>();

                    for (int i = 0; i < listAdd.Count; i++)
                    {
                        CustomerOrderViewDTO dto = listAdd[i];

                        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                        AssignHeaderToDTO(model, dto, Mode);

                        //dto.TRANS_ID = runningNumberBIZ.GetCompleteRunningNo(DataDefine.TRANS_ID.ToNZString(), DataDefine.TRANSACTION_TABLE_NAME.ToNZString());

                        //add header ใส่ list
                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                        // Check all lines.


                        listAddEachDetail.Add(dto);
                    }

                    biz.SaveCustomerOrder(Common.CurrentDatabase, listAddEachDetail, null, null, Mode);
                }

                //== Update process.
                if (dtModify != null && dtModify.Rows.Count > 0)
                {
                    listUpdate = DTOUtility.ConvertDataTableToList <CustomerOrderViewDTO>(dtModify);


                    List <CustomerOrderViewDTO> listUpdateDetail = new List <CustomerOrderViewDTO>();


                    for (int i = 0; i < listUpdate.Count; i++)
                    {
                        CustomerOrderViewDTO dto = listUpdate[i];

                        CustomerOrderBIZ bizCustomer = new CustomerOrderBIZ();

                        CustomerOrderDDTO dtoDDTO = bizCustomer.LoadCustomerOrderDetail(dto.ORDER_NO.StrongValue, dto.ORDER_DETAIL_NO);

                        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                        AssignHeaderToDTO(model, dto, Mode);

                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                        //add header ใส่ list
                        listUpdateDetail.Add(dto);
                    }

                    biz.SaveCustomerOrder(Common.CurrentDatabase, null, listUpdateDetail, null, Mode);
                }


                //Update Header for Edit Case
                //if (Mode == Common.eScreenMode.EDIT && dtData != null && dtData.Rows.Count > 0)
                //{
                //    listUpdate = DTOUtility.ConvertDataTableToList<CustomerOrderViewDTO>(dtData);

                //    for (int i = 0; i < listUpdate.Count; i++)
                //    {
                //        CustomerOrderViewDTO dto = listUpdate[i];

                //        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                //        AssignHeaderToDTO(model, dto);

                //        dto.CRT_BY = Common.CurrentUserInfomation.UserCD;
                //        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                //        dto.UPD_BY = Common.CurrentUserInfomation.UserCD;
                //        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                //        biz.UpdateCustomerOrderHeader(Common.CurrentDatabase, dto);
                //    }
                //}

                Common.CurrentDatabase.Commit();
            }
            catch (Exception)
            {
                Common.CurrentDatabase.Rollback();
                throw;
            }
        }
コード例 #8
0
        internal NZString SaveShipmentEntry(ShipmentEntryUIDM model, Common.eScreenMode Mode, DataTable OldOrder, DataTable NewOrder, DataTable OldLot, DataTable NewLot)
        {
            Database db     = Common.CurrentDatabase.CreateNewDatabase();
            NZString SlipNo = new NZString();


            try
            {
                db.KeepConnection = true;
                db.BeginTransaction(IsolationLevel.Serializable);

                //bizShipment.AddShipmentEntry(dtoInvTrnsList);
                ShipmentBIZ         bizShipment = new ShipmentBIZ();
                IssueEntryValidator val         = new IssueEntryValidator();
                CommonBizValidator  commonVal   = new CommonBizValidator();


                //== If data not has to processing.
                if (model.DATA_VIEW == null || model.DATA_VIEW.Rows.Count == 0)
                {
                    ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0055.ToString()));
                }

                DataTable dtData   = model.DATA_VIEW;
                DataTable dtAdd    = new DataTable();
                DataTable dtModify = new DataTable();
                DataTable dtDelete = new DataTable();

                if (Mode == Common.eScreenMode.ADD || OldOrder.Rows.Count <= 0)
                {
                    dtAdd    = dtData.GetChanges(DataRowState.Added);
                    dtModify = dtData.GetChanges(DataRowState.Modified);
                    dtDelete = dtData.GetChanges(DataRowState.Deleted);
                }
                else
                {
                    dtAdd    = dtData.Clone();
                    dtModify = dtData.Clone();
                    dtDelete = dtData.Clone();

                    // Manage for Update and Delete
                    for (int i = 0; i < OldOrder.Rows.Count; i++)
                    {
                        string  OrderDetailNo      = Convert.ToString(OldOrder.Rows[i]["ORDER_DETAIL_NO"]);
                        decimal ShipQTY            = Convert.ToDecimal(OldOrder.Rows[i]["SHIP_QTY"]);
                        string  ItemCd             = Convert.ToString(OldOrder.Rows[i]["ITEM_CD"]);
                        bool    found_order_detail = false;
                        for (int j = 0; j < NewOrder.Rows.Count; j++)
                        {
                            if (Convert.ToString(NewOrder.Rows[j]["ORDER_DETAIL_NO"]) == OrderDetailNo &&
                                Convert.ToString(NewOrder.Rows[j]["ITEM_CD"]) == ItemCd &&
                                Convert.ToDecimal(NewOrder.Rows[j]["SHIP_QTY"]) != ShipQTY)
                            {
                                found_order_detail = true;
                                // Delete Old
                                for (int k = 0; k < OldLot.Rows.Count; k++)
                                {
                                    if (Convert.ToString(OldLot.Rows[k]["REF_SLIP_NO"]) == OrderDetailNo &&
                                        Convert.ToString(OldLot.Rows[k]["ITEM_CD"]) == ItemCd)
                                    {
                                        DataRow row = dtDelete.NewRow();
                                        row["TRANS_ID"]    = OldLot.Rows[k]["TRANS_ID"];
                                        row["ITEM_CD"]     = OldLot.Rows[k]["ITEM_CD"];
                                        row["LOC_CD"]      = OldLot.Rows[k]["LOC_CD"];
                                        row["TRANS_DATE"]  = OldLot.Rows[k]["TRANS_DATE"];
                                        row["TRANS_CLS"]   = OldLot.Rows[k]["TRANS_CLS"];
                                        row["IN_OUT_CLS"]  = OldLot.Rows[k]["IN_OUT_CLS"];
                                        row["QTY"]         = OldLot.Rows[k]["QTY"];
                                        row["REF_SLIP_NO"] = OrderDetailNo;
                                        dtDelete.Rows.Add(row);
                                    }
                                }
                                //bizShipment.AddShipmentEntry(db, null, null, DTOUtility.ConvertDataTableToList<InventoryTransactionDTO>(dtDelete));

                                // Add New
                                for (int l = 0; l < NewLot.Rows.Count; l++)
                                {
                                    if (Convert.ToString(NewLot.Rows[l]["REF_SLIP_NO"]) == OrderDetailNo &&
                                        Convert.ToString(NewLot.Rows[l]["ITEM_CD"]) == ItemCd)
                                    {
                                        dtAdd.ImportRow(NewLot.Rows[l]);
                                    }
                                }
                            }
                            else if (Convert.ToString(NewOrder.Rows[j]["ORDER_DETAIL_NO"]) == OrderDetailNo &&
                                     Convert.ToString(NewOrder.Rows[j]["ITEM_CD"]) == ItemCd &&
                                     Convert.ToDecimal(NewOrder.Rows[j]["SHIP_QTY"]) == ShipQTY)
                            {
                                found_order_detail = true;
                                bool diff_pack = false;

                                for (int x = 0; x < NewLot.Rows.Count; x++)
                                {
                                    bool   check_same = false;
                                    string pack_no    = Convert.ToString(NewLot.Rows[x]["PACK_NO"]);
                                    string lot_no     = Convert.ToString(NewLot.Rows[x]["LOT_NO"]);

                                    for (int y = 0; y < OldLot.Rows.Count; y++)
                                    {
                                        if (Convert.ToString(OldLot.Rows[y]["REF_SLIP_NO"]) == OrderDetailNo &&
                                            Convert.ToString(OldLot.Rows[y]["ITEM_CD"]) == ItemCd &&
                                            Convert.ToString(OldLot.Rows[y]["PACK_NO"]) == pack_no &&
                                            Convert.ToString(OldLot.Rows[y]["LOT_NO"]) == lot_no)
                                        {
                                            check_same = true;
                                            continue;
                                        }
                                    }

                                    if (!check_same)
                                    {
                                        diff_pack = !check_same;
                                        continue;
                                    }
                                }

                                if (diff_pack)
                                {
                                    // Delete Old
                                    for (int k = 0; k < OldLot.Rows.Count; k++)
                                    {
                                        if (Convert.ToString(OldLot.Rows[k]["REF_SLIP_NO"]) == OrderDetailNo &&
                                            Convert.ToString(OldLot.Rows[k]["ITEM_CD"]) == ItemCd)
                                        {
                                            DataRow row = dtDelete.NewRow();
                                            row["TRANS_ID"]    = OldLot.Rows[k]["TRANS_ID"];
                                            row["ITEM_CD"]     = OldLot.Rows[k]["ITEM_CD"];
                                            row["LOC_CD"]      = OldLot.Rows[k]["LOC_CD"];
                                            row["TRANS_DATE"]  = OldLot.Rows[k]["TRANS_DATE"];
                                            row["TRANS_CLS"]   = OldLot.Rows[k]["TRANS_CLS"];
                                            row["IN_OUT_CLS"]  = OldLot.Rows[k]["IN_OUT_CLS"];
                                            row["QTY"]         = OldLot.Rows[k]["QTY"];
                                            row["REF_SLIP_NO"] = OrderDetailNo;
                                            dtDelete.Rows.Add(row);
                                        }
                                    }
                                    //bizShipment.AddShipmentEntry(db, null, null, DTOUtility.ConvertDataTableToList<InventoryTransactionDTO>(dtDelete));

                                    // Add New
                                    for (int l = 0; l < NewLot.Rows.Count; l++)
                                    {
                                        if (Convert.ToString(NewLot.Rows[l]["REF_SLIP_NO"]) == OrderDetailNo &&
                                            Convert.ToString(NewLot.Rows[l]["ITEM_CD"]) == ItemCd)
                                        {
                                            dtAdd.ImportRow(NewLot.Rows[l]);
                                        }
                                    }
                                }
                            }

                            // In  update have remove order
                            if (j == NewOrder.Rows.Count - 1 && !found_order_detail)
                            {
                                for (int k = 0; k < OldLot.Rows.Count; k++)
                                {
                                    if (Convert.ToString(OldLot.Rows[k]["REF_SLIP_NO"]) == OrderDetailNo &&
                                        Convert.ToString(OldLot.Rows[k]["ITEM_CD"]) == ItemCd)
                                    {
                                        DataRow row = dtDelete.NewRow();
                                        row["TRANS_ID"]    = OldLot.Rows[k]["TRANS_ID"];
                                        row["ITEM_CD"]     = OldLot.Rows[k]["ITEM_CD"];
                                        row["LOC_CD"]      = OldLot.Rows[k]["LOC_CD"];
                                        row["TRANS_DATE"]  = OldLot.Rows[k]["TRANS_DATE"];
                                        row["TRANS_CLS"]   = OldLot.Rows[k]["TRANS_CLS"];
                                        row["IN_OUT_CLS"]  = OldLot.Rows[k]["IN_OUT_CLS"];
                                        row["QTY"]         = OldLot.Rows[k]["QTY"];
                                        row["REF_SLIP_NO"] = OrderDetailNo;
                                        dtDelete.Rows.Add(row);
                                    }
                                }
                            }
                        }
                    }

                    // Manage for check add new order on update mode
                    for (int i = 0; i < NewOrder.Rows.Count; i++)
                    {
                        string OrderDetailNo      = Convert.ToString(NewOrder.Rows[i]["ORDER_DETAIL_NO"]);
                        string ItemCd             = Convert.ToString(NewOrder.Rows[i]["ITEM_CD"]);
                        bool   found_order_detail = false;
                        for (int j = 0; j < OldOrder.Rows.Count; j++)
                        {
                            if (Convert.ToString(OldOrder.Rows[j]["ORDER_DETAIL_NO"]) == OrderDetailNo &&
                                Convert.ToString(OldOrder.Rows[j]["ITEM_CD"]) == ItemCd)
                            {
                                found_order_detail = true;
                            }

                            // Not found old order in new order then add new order
                            if (j == OldOrder.Rows.Count - 1 && !found_order_detail)
                            {
                                for (int l = 0; l < NewLot.Rows.Count; l++)
                                {
                                    if (Convert.ToString(NewLot.Rows[l]["REF_SLIP_NO"]) == OrderDetailNo &&
                                        Convert.ToString(NewLot.Rows[l]["ITEM_CD"]) == ItemCd)
                                    {
                                        dtAdd.ImportRow(NewLot.Rows[l]);
                                    }
                                }
                            }
                        }
                    }
                }

                InventoryBIZ biz = new InventoryBIZ();

                List <InventoryTransactionDTO> listAdd    = null;
                List <InventoryTransactionDTO> listUpdate = null;
                List <InventoryTransactionDTO> listDelete = null;


                //== Insert process.
                if (dtAdd != null && dtAdd.Rows.Count > 0)
                {
                    listAdd = new List <InventoryTransactionDTO>();
                    listAdd = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtAdd);
                    RunningNumberBIZ runningNumberBIZ         = new RunningNumberBIZ();
                    NZString         runningNo_SLIP_NO        = null;
                    NZString         runningNo_GROUP_TRANS_ID = null;

                    if (model.SLIP_NO.IsNull || model.SLIP_NO.Value == "")
                    {
                        runningNo_SLIP_NO = runningNumberBIZ.GetCompleteRunningNo((NZString)"DELIVERY_SLIP_NO", (NZString)"TB_INV_TRANS_TR");
                    }
                    else
                    {
                        runningNo_SLIP_NO = model.SLIP_NO;
                    }

                    SlipNo = runningNo_SLIP_NO;

                    if (model.GROUP_TRANS_ID.IsNull)
                    {
                        runningNo_GROUP_TRANS_ID = runningNumberBIZ.GetCompleteRunningNo(new NZString(null, "TRAN_GROUP_ID"), new NZString(null, "TB_INV_TRANS_TR"));
                    }
                    else
                    {
                        runningNo_GROUP_TRANS_ID = model.SLIP_NO;
                    }

                    for (int i = 0; i < listAdd.Count; i++)
                    {
                        InventoryTransactionDTO dto = listAdd[i];

                        // มีการ Gen Running Number ของ NO_LOT_TRANS_ID ไว้แล้วใน InventoryBIZ FN: AddInventoryTransaction
                        //NZString runningNo_LOT_TRANS_ID = runningNumberBIZ.GetCompleteRunningNo(new NZString(null, "TRAN_ID"), new NZString(null, "TB_INV_TRANS_TR"));
                        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                        AssignHeaderToDTO(model, dto);

                        dto.SLIP_NO        = runningNo_SLIP_NO;
                        dto.GROUP_TRANS_ID = runningNo_GROUP_TRANS_ID;
                        //dto.TRANS_ID = runningNo_LOT_TRANS_ID;

                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                        listAdd[i] = dto;
                        // check for lot no if ship type is SHIP
                        //if (model.TRANS_CLS.StrongValue != DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Shipment_Return))
                        //    ValidateException.ThrowErrorItem(commonVal.CheckInputLot(dto.ITEM_CD, dto.LOC_CD, dto.LOT_NO, true));
                    }
                }

                //== Update process.
                if (dtModify != null && dtModify.Rows.Count > 0)
                {
                    listUpdate = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtModify);

                    for (int i = 0; i < listUpdate.Count; i++)
                    {
                        InventoryTransactionDTO dto = listUpdate[i];

                        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                        AssignHeaderToDTO(model, dto);

                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                        listUpdate[i] = dto;
                    }
                }


                //== Delete process.
                if (dtDelete != null && dtDelete.Rows.Count > 0)
                {
                    listDelete = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtDelete);
                }

                bizShipment.AddShipmentEntry(db, listAdd, listUpdate, listDelete);

                if (Mode == Common.eScreenMode.EDIT)
                {
                    if (dtData != null && dtData.Rows.Count > 0)
                    {
                        listUpdate = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtData);

                        for (int i = 0; i < listUpdate.Count; i++)
                        {
                            InventoryTransactionDTO dto = listUpdate[i];

                            // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                            AssignHeaderToDTO(model, dto);

                            dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                            dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                            dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                            dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                            DeliveryBIZ bizDelivery = new DeliveryBIZ();
                            bizDelivery.UpdateReceiveHeader(db, listUpdate[i]);
                        }

                        SlipNo = listUpdate[0].SLIP_NO;
                    }

                    //if (dtDelete != null && dtDelete.Rows.Count > 0)
                    //{
                    //    ShipmentEntryController ctlShip = new ShipmentEntryController();

                    //    for (int i = 0; i < dtDelete.Rows.Count; i++)
                    //    {
                    //        NZString strOrderDetailNo = dtDelete.Rows[i]["REF_SLIP_NO"].ToString().ToNZString();
                    //        decimal dQTY = Convert.ToDecimal(dtDelete.Rows[i]["QTY"]);
                    //        if (dQTY == null || dQTY <= 0) continue;
                    //        ctlShip.UpdateShipQTY(strOrderDetailNo, dQTY * -1);
                    //    }
                    //}

                    //if (dtAdd != null && dtAdd.Rows.Count > 0)
                    //{
                    //    ShipmentEntryController ctlShip = new ShipmentEntryController();

                    //    for (int i = 0; i < dtAdd.Rows.Count; i++)
                    //    {
                    //        NZString strOrderDetailNo = dtAdd.Rows[i]["REF_SLIP_NO"].ToString().ToNZString();
                    //        decimal dQTY = Convert.ToDecimal(dtAdd.Rows[i]["QTY"]);
                    //        if (dQTY == null || dQTY <= 0) continue;
                    //        ctlShip.UpdateShipQTY(strOrderDetailNo, dQTY);
                    //    }
                    //}
                }

                //if (Mode == Common.eScreenMode.EDIT)
                //{
                //    if (dtAdd != null && dtAdd.Rows.Count > 0)
                //    {
                //        listUpdate = DTOUtility.ConvertDataTableToList<InventoryTransactionDTO>(dtAdd);

                //        for (int i = 0; i < listUpdate.Count; i++)
                //        {
                //            InventoryTransactionDTO dto = listUpdate[i];

                //            // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                //            AssignHeaderToDTO(model, dto);

                //            dto.CRT_BY = Common.CurrentUserInfomation.UserCD;
                //            dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                //            dto.UPD_BY = Common.CurrentUserInfomation.UserCD;
                //            dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                //            //biz.UpdateReceiveHeader(db, dto);

                //            biz.UpdateInventoryOnhand(db, dto, DataDefine.eOperationClass.Add);
                //        }
                //    }
                //}
                db.Commit();

                return(SlipNo);
            }
            catch
            {
                db.Rollback();
                throw;
            }
            finally
            {
                if (db.DBConnectionState == ConnectionState.Open)
                {
                    db.Close();
                }
            }
        }
コード例 #9
0
        public void SaveInvoiceEntry(InvoiceEntryUIDM model, Common.eScreenMode Mode)
        {
            try
            {
                Common.CurrentDatabase.KeepConnection = true;
                Common.CurrentDatabase.BeginTransaction(IsolationLevel.Serializable);

                InvoiceBIZ biz = new InvoiceBIZ();

                #region Validate Data
                //== If data not has to processing.
                if (model.DATA_VIEW == null || model.DATA_VIEW.Rows.Count == 0)
                {
                    ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0055.ToString()));
                }

                DataTable         dtNonDelete = model.DATA_VIEW.GetChanges(DataRowState.Unchanged | DataRowState.Added | DataRowState.Modified);
                List <InvoiceDTO> listData    = DTOUtility.ConvertDataTableToList <InvoiceDTO>(dtNonDelete);

                #endregion


                DataTable dtData   = model.DATA_VIEW;
                DataTable dtAdd    = dtData.GetChanges(DataRowState.Added);
                DataTable dtModify = dtData.GetChanges(DataRowState.Modified);
                DataTable dtDelete = dtData.GetChanges(DataRowState.Deleted);

                // แก้บั๊ก GetChange แล้ว Data ไม่ถูกต้อง
                if (dtModify != null && dtModify.Rows.Count > 0)
                {
                    for (int i = 0; i < dtModify.Rows.Count; i++)
                    {
                        for (int j = 0; j < dtData.Rows.Count; j++)
                        {
                            if (Convert.ToString(dtModify.Rows[i]["TRANS_ID"]) == Convert.ToString(dtData.Rows[j]["TRANS_ID"]))
                            {
                                dtModify.Rows[i]["PO_NO"]           = dtData.Rows[j]["PO_NO"];
                                dtModify.Rows[i]["ORDER_NO"]        = dtData.Rows[j]["ORDER_NO"];
                                dtModify.Rows[i]["ORDER_DETAIL_NO"] = dtData.Rows[j]["ORDER_DETAIL_NO"];
                                dtModify.Rows[i]["ITEM_CD"]         = dtData.Rows[j]["ITEM_CD"];
                                dtModify.Rows[i]["SHORT_NAME"]      = dtData.Rows[j]["SHORT_NAME"];
                                dtModify.Rows[i]["ITEM_DESC"]       = dtData.Rows[j]["ITEM_DESC"];
                                dtModify.Rows[i]["UNIT"]            = dtData.Rows[j]["UNIT"];
                                dtModify.Rows[i]["QTY"]             = dtData.Rows[j]["QTY"];
                                dtModify.Rows[i]["PRICE"]           = dtData.Rows[j]["PRICE"];
                                dtModify.Rows[i]["AMOUNT"]          = dtData.Rows[j]["AMOUNT"];
                            }
                        }
                    }
                }
                List <InvoiceDTO> listAdd    = new List <InvoiceDTO>();
                List <InvoiceDTO> listUpdate = new List <InvoiceDTO>();
                List <InvoiceDTO> listDelete = new List <InvoiceDTO>();


                //มีการปรับให้ทำคำสั่งทีละ set ของ add , update , delete เลย
                //ที่เริ่มจาก delete ก่อนเพราะ consumption จะได้มีการเอาไปใช้สำหรับตัวที่ add ได้เลย ไม่ต้องค้างไว้ lot หน้า
                //== Delete process.
                if (dtDelete != null && dtDelete.Rows.Count > 0)
                {
                    listDelete = DTOUtility.ConvertDataTableToList <InvoiceDTO>(dtDelete);
                    for (int i = 0; i < listDelete.Count; i++)
                    {
                        AssignHeaderToDTO(model, listDelete[i], Mode);
                    }

                    foreach (InvoiceDTO dto in listDelete)
                    {
                        biz.Delete(dto.TRANS_ID.StrongValue);
                    }
                }

                //== Insert process.
                if (dtAdd != null && dtAdd.Rows.Count > 0)
                {
                    NZString BillNo  = null;
                    NZString TransID = null;
                    listAdd = DTOUtility.ConvertDataTableToList <InvoiceDTO>(dtAdd);
                    if (!listAdd[0].TRANS_ID.IsNull && listAdd[0].TRANS_ID.StrongValue != "")
                    {
                        TransID = listAdd[0].TRANS_ID;
                    }

                    RunningNumberBIZ runningNumberBIZ = new RunningNumberBIZ();

                    if (model.BILL_NO.IsNull)
                    {
                        BillNo        = runningNumberBIZ.GetCompleteRunningNo((NZString)"BILL_NO", (NZString)"BILL_NO");
                        model.BILL_NO = BillNo;
                    }
                    else
                    {
                        BillNo = model.BILL_NO;
                    }

                    for (int i = 0; i < listAdd.Count; i++)
                    {
                        InvoiceDTO dto = listAdd[i];

                        if (dto.TRANS_ID.IsNull)
                        {
                            TransID      = runningNumberBIZ.GetCompleteRunningNo((NZString)"INVOICE_TRANS_ID", (NZString)"TRANS_ID");
                            dto.TRANS_ID = TransID;
                        }

                        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                        AssignHeaderToDTO(model, dto, Mode);

                        //dto.TRANS_ID = runningNumberBIZ.GetCompleteRunningNo(DataDefine.TRANS_ID.ToNZString(), DataDefine.TRANSACTION_TABLE_NAME.ToNZString());

                        //add header ใส่ list
                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                    }

                    foreach (InvoiceDTO dto in listAdd)
                    {
                        biz.Add_New(dto);
                    }
                }

                //== Update process.
                if (dtModify != null && dtModify.Rows.Count > 0)
                {
                    listUpdate = DTOUtility.ConvertDataTableToList <InvoiceDTO>(dtModify);

                    foreach (InvoiceDTO dto in listUpdate)
                    {
                        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                        AssignHeaderToDTO(model, dto, Mode);

                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                    }

                    foreach (InvoiceDTO dto in listUpdate)
                    {
                        biz.Update_WithOut_PK(dto);
                    }
                }

                Common.CurrentDatabase.Commit();
            }
            catch (Exception)
            {
                Common.CurrentDatabase.Rollback();
                throw;
            }
        }
コード例 #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <exception cref="!:EVOFramework.ValidateException"><c>ValidateException</c>.</exception>
        public void Save(ReceivingEntryUIDM model, Common.eScreenMode Mode)
        {
            try
            {
                Common.CurrentDatabase.KeepConnection = true;
                Common.CurrentDatabase.BeginTransaction(IsolationLevel.Serializable);

                InventoryBIZ      biz      = new InventoryBIZ();
                InventoryTransBIZ bizTrans = new InventoryTransBIZ();

                #region Validate Data
                //== Validate Header, contain: Receive Date, Stored Loc.
                ReceivingValidator receivingValidator = new ReceivingValidator();
                DealingValidator   locationValidator  = new DealingValidator();
                ItemValidator      itemValidator      = new ItemValidator();
                CommonBizValidator commonVal          = new CommonBizValidator();

                ValidateException.ThrowErrorItem(receivingValidator.CheckReceiveDate(model.RECEIVE_DATE));
                ValidateException.ThrowErrorItem(locationValidator.CheckEmptyLocationCode(model.STORED_LOC));
                ValidateException.ThrowErrorItem(locationValidator.CheckNotExistsLocationCode(model.STORED_LOC));
                // Check for Supplier Type
                ValidateException.ThrowErrorItem(receivingValidator.CheckForSupplierType(model.DEALING_NO));

                //== If data not has to processing.
                if (model.DATA_VIEW == null || model.DATA_VIEW.Rows.Count == 0)
                {
                    ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0055.ToString()));
                }

                DataTable dtNonDelete = model.DATA_VIEW.GetChanges(DataRowState.Unchanged | DataRowState.Added | DataRowState.Modified);
                List <InventoryTransactionViewDTO> listData = DTOUtility.ConvertDataTableToList <InventoryTransactionViewDTO>(dtNonDelete);

                //== Validate Item cannot duplicate on ITEM_CD and LOT_NO
                List <string> listCheckKeyDuplicate = new List <string>();
                for (int i = 0; i < listData.Count; i++)
                {
                    BusinessException err = itemValidator.CheckItemNotExist(listData[i].ITEM_CD);
                    if (err != null)
                    {
                        ValidateException.ThrowErrorItem(err.Error);
                    }
                    string strKey = listData[i].ITEM_CD.NVL(String.Empty)
                                    + listData[i].LOT_NO.NVL(String.Empty)
                                    + listData[i].EXTERNAL_LOT_NO.NVL(String.Empty)
                    ;

                    if (listCheckKeyDuplicate.Contains(strKey))
                    {
                        ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0096.ToString(), new object[] { listData[i].ITEM_CD.NVL(String.Empty), listData[i].LOT_NO.NVL(String.Empty), listData[i].EXTERNAL_LOT_NO.NVL(String.Empty) }));
                    }

                    listCheckKeyDuplicate.Add(strKey);
                }



                for (int i = 0; i < listData.Count; i++)
                {
                    InventoryTransactionViewDTO viewDTO = listData[i];

                    //== Check LotNo If item use lot control class.
                    ValidateException.ThrowErrorItem(commonVal.CheckInputLot(viewDTO.ITEM_CD, new NZString(), viewDTO.LOT_NO, false));
                }
                #endregion


                DataTable dtData = model.DATA_VIEW;

                DataTable dtAdd    = dtData.GetChanges(DataRowState.Added);
                DataTable dtModify = dtData.GetChanges(DataRowState.Modified);
                DataTable dtDelete = dtData.GetChanges(DataRowState.Deleted);

                List <InventoryTransactionDTO> listAdd    = null;
                List <InventoryTransactionDTO> listUpdate = null;
                List <InventoryTransactionDTO> listDelete = null;


                //มีการปรับให้ทำคำสั่งทีละ set ของ add , update , delete เลย
                //ที่เริ่มจาก delete ก่อนเพราะ consumption จะได้มีการเอาไปใช้สำหรับตัวที่ add ได้เลย ไม่ต้องค้างไว้ lot หน้า
                //== Delete process.
                if (dtDelete != null && dtDelete.Rows.Count > 0)
                {
                    listDelete = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtDelete);

                    List <InventoryTransactionDTO> listDeleteConsumption = null;
                    for (int i = 0; i < listDelete.Count; i++)
                    {
                        InventoryTransactionDTO dto = listDelete[i];

                        listDeleteConsumption = bizTrans.LoadConsumptionItemByRefNo(dto.REF_NO);
                        biz.ReceivingItems(Common.CurrentDatabase, null, null, listDeleteConsumption);
                    }
                }
                biz.ReceivingItems(Common.CurrentDatabase, null, null, listDelete);



                //== Insert process.
                if (dtAdd != null && dtAdd.Rows.Count > 0)
                {
                    //listAdd = DTOUtility.ConvertDataTableToList<InventoryTransactionDTO>(dtAdd);

                    //ถ้ากรณี receiving ให้แตกเป็น lot ย่อยตาม lot size ให้
                    if (model.RECEIVE_TYPE.StrongValue.Equals(DataDefine.eTRANS_TYPE_string.Receiving))
                    {
                        listAdd = SplitBoxSize(model, DTOUtility.ConvertDataTableToList <InventoryTransactionViewDTO>(dtAdd));
                    }
                    else
                    {
                        listAdd = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtAdd);
                    }
                    NZString         runningNo        = null;
                    RunningNumberBIZ runningNumberBIZ = new RunningNumberBIZ();

                    if (model.RECEIVE_NO.IsNull)
                    {
                        runningNo = runningNumberBIZ.GetCompleteRunningNo(DataDefine.RECEIVE_SLIP_NO.ToNZString(), DataDefine.TRANSACTION_TABLE_NAME.ToNZString());
                    }
                    else
                    {
                        runningNo = model.RECEIVE_NO;
                    }

                    List <InventoryTransactionDTO> listAddEachDetail = null;

                    for (int i = 0; i < listAdd.Count; i++)
                    {
                        listAddEachDetail = new List <InventoryTransactionDTO>();

                        InventoryTransactionDTO dto = listAdd[i];

                        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                        AssignHeaderToDTO(model, dto);

                        //ถ้า Receive ต้อง check ว่า lot นั้นไม่เคยทำ receive มาก่อน
                        //if (model.RECEIVE_TYPE.StrongValue.Equals(DataDefine.eTRANS_TYPE_string.Receiving))
                        //{
                        //    ValidateException.ThrowErrorItem(receivingValidator.CheckExistReceiveItem(dto.ITEM_CD, dto.LOT_NO));
                        //}
                        //else
                        //{
                        //    ValidateException.ThrowErrorItem(receivingValidator.CheckNotExistReceiveItem(dto.ITEM_CD, dto.LOT_NO));
                        //}

                        //dto.TRANS_ID = runningNumberBIZ.GetCompleteRunningNo(DataDefine.TRANS_ID.ToNZString(), DataDefine.TRANSACTION_TABLE_NAME.ToNZString());
                        dto.SLIP_NO     = runningNo;
                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                        // Check all lines.
                        receivingValidator.ValidateBeforeSaveAdd(dto);

                        //add header ใส่ list
                        listAddEachDetail.Add(dto);
                        #region Do Consumption if Item Process Type is SP and Receive Type is Receiving
                        if (model.RECEIVE_TYPE.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Receiving))
                        {
                            // load for item process type
                            ItemBIZ        bizItem = new ItemBIZ();
                            ItemProcessDTO dtoItem = bizItem.LoadItemProcess(dto.ITEM_CD);
                            //if (dtoItem.ORDER_PROCESS_CLS.StrongValue == DataDefine.ORDER_PROCESS_CLS_SUBCONTACT)
                            //{
                            //    List<InventoryTransactionDTO> dtoConsumptionTr = CreateConsumptionDTO(dto);
                            //    if (dtoConsumptionTr != null && dtoConsumptionTr.Count > 0)
                            //    {
                            //        listAddEachDetail.AddRange(dtoConsumptionTr);

                            //        //for (int j = 0; j < dtoConsumptionTr.Count; j++)
                            //        //{
                            //        //    listAddEachDetail.Add(dtoConsumptionTr[j]);
                            //        //}
                            //    }

                            //}
                        }
                        #endregion

                        biz.ReceivingItems(Common.CurrentDatabase, listAddEachDetail, null, null);
                    }
                }

                //== Update process.
                if (dtModify != null && dtModify.Rows.Count > 0)
                {
                    listUpdate = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtModify);


                    List <InventoryTransactionDTO> listUpdateDetail      = null;
                    List <InventoryTransactionDTO> listAddConsumption    = null;
                    List <InventoryTransactionDTO> listDeleteConsumption = null;

                    for (int i = 0; i < listUpdate.Count; i++)
                    {
                        listUpdateDetail      = new List <InventoryTransactionDTO>();
                        listAddConsumption    = new List <InventoryTransactionDTO>();
                        listDeleteConsumption = new List <InventoryTransactionDTO>();

                        InventoryTransactionDTO dto = listUpdate[i];

                        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                        AssignHeaderToDTO(model, dto);

                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                        // Check all lines.
                        receivingValidator.ValidateBeforeSaveAdd(dto);


                        //Clear consumption เดิมก่อน
                        listDeleteConsumption = bizTrans.LoadConsumptionItemByRefNo(dto.REF_NO);
                        biz.ReceivingItems(Common.CurrentDatabase, null, null, listDeleteConsumption);

                        //add header ใส่ list
                        listUpdateDetail.Add(dto);

                        #region Do Consumption if Item Process Type is SP
                        if (model.RECEIVE_TYPE.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Receiving))
                        {
                            // load for item process type
                            ItemBIZ        bizItem = new ItemBIZ();
                            ItemProcessDTO dtoItem = bizItem.LoadItemProcess(dto.ITEM_CD);
                            //if (dtoItem.ORDER_PROCESS_CLS.StrongValue == DataDefine.ORDER_PROCESS_CLS_SUBCONTACT)
                            //{
                            //    List<InventoryTransactionDTO> dtoConsumptionTr = CreateConsumptionDTO(dto);
                            //    if (dtoConsumptionTr != null && dtoConsumptionTr.Count > 0)
                            //    {
                            //        listAddConsumption.AddRange(dtoConsumptionTr);
                            //        //for (int j = 0; j < dtoConsumptionTr.Count; j++)
                            //        //{
                            //        //    listConsumption.Add(dtoConsumptionTr[j]);
                            //        //}
                            //    }
                            //}
                        }
                        #endregion


                        biz.ReceivingItems(Common.CurrentDatabase, listAddConsumption, listUpdateDetail, null);
                    }
                }


                //ปรับให้ไปสั่ง add delete แต่ละตัวไป เพราะว่ากรณีที่ตัด consumption
                //จะมีโอกาสข้าม lot  ถ้าคำนวณ โดยไม่ตัด mat ก่อน มันจะตัด lot เดิมตลอด
                //biz.ReceivingItems(Common.CurrentDatabase, listAdd, listUpdate, listDelete, listConsumption);
                //biz.ReceivingItems(Common.CurrentDatabase, null, listUpdate, null, null);



                //Update Header for Edit Case
                if (Mode == Common.eScreenMode.EDIT && dtData != null && dtData.Rows.Count > 0)
                {
                    listUpdate = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtData);

                    for (int i = 0; i < listUpdate.Count; i++)
                    {
                        InventoryTransactionDTO dto = listUpdate[i];

                        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                        AssignHeaderToDTO(model, dto);

                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                        biz.UpdateReceiveHeader(Common.CurrentDatabase, dto);
                    }
                }

                Common.CurrentDatabase.Commit();
            }
            catch (Exception)
            {
                Common.CurrentDatabase.Rollback();
                throw;
            }
        }
コード例 #11
0
        public override void OnSaveAndNew()
        {
            try
            {
                label7.Focus();

                this.fpCustomerOrder.StopCellEditing();
                //if (m_bRowHasModified)
                //{ // ถ้า Row กำลังแก้ไขอยู่
                //    if (!ValidateRowSpread(shtCustomerOrder.ActiveRowIndex, false))
                //    {
                //        return;
                //    }
                //}


                // ต้องเรียกก่อน Save เสมอ  เพื่อ Commit ข้อมูลการแก้ไขล่าสุดบน Grid
                // ใช้ได้เฉพาะกับ Sheet ที่ผูก DataSource
                CtrlUtil.SpreadSheetRowEndEdit(shtCustomerOrder, shtCustomerOrder.ActiveRowIndex);

                RemoveRowUnused(shtCustomerOrder);

                if (!ValidateMandatory())
                {
                    return;
                }

                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, new Message(SystemMaintenance.Messages.eConfirm.CFM9001.ToString()).MessageDescription);
                switch (dr)
                {
                case MessageDialogResult.Cancel:
                    return;

                case MessageDialogResult.No:
                    //Close();
                    return;

                case MessageDialogResult.Yes:
                    break;
                }
                if (SaveData())
                {
                    MessageDialog.ShowInformation(this, "Information", new Message(SystemMaintenance.Messages.eInformation.INF9003.ToString()).MessageDescription);
                    ClearAllControlExceptDefault();
                    m_Mode = Common.eScreenMode.ADD;
                    lblTransactionNo.Text = "";

                    SysConfigBIZ sysBiz        = new SysConfigBIZ();
                    SysConfigDTO argScreenInfo = new SysConfigDTO();
                    argScreenInfo.SYS_GROUP_ID = DataDefine.eSYSTEM_CONFIG.TRN100.SYS_GROUP_ID;
                    argScreenInfo.SYS_KEY      = (NZString)DataDefine.eSYSTEM_CONFIG.TRN100.SYS_KEY.DEFAULT_DATE.ToString();
                    dtInvoiceDate.Value        = sysBiz.GetDefaultDateForScreen(argScreenInfo);

                    CtrlUtil.EnabledControl(true, txtRemark, dtInvoiceDate, cboCustomerCode);
                    dtInvoiceDate.Focus();
                    dtInvoiceDate.Select();
                }
            }
            catch (ValidateException err)
            {
                for (int i = 0; i < err.ErrorResults.Count; i++)
                {
                    MessageDialog.ShowBusiness(this, err.ErrorResults[i].Message);
                    err.ErrorResults[i].FocusOnControl();
                }
            }
            catch (BusinessException err)
            {
                MessageDialog.ShowBusiness(this, err.Error.Message);
                err.Error.FocusOnControl();
            }
            catch (Exception ex)
            {
                MessageDialog.ShowBusiness(this, ex.Message);
            }
        }
コード例 #12
0
        private void SetScreenMode(Common.eScreenMode mode)
        {
            switch (mode)
            {
            case Common.eScreenMode.ADD:
                CtrlUtil.EnabledControl(true, txtDeliveryNo, cboAddress, txtInvoiceNo,
                                        dtInvoiceDate, cboTermOfPayment, dtPaymentDueDate,
                                        txtReferTemNo, txtRemark, txtVat, txtVatTotal);
                CtrlUtil.EnabledControl(false, cboCustomerCode, txtFullAddress, txtSubTotal, txtTotal);
                shtCustomerOrder.OperationMode = OperationMode.Normal;
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.PO_NO);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.ORDER_NO);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.ORDER_DETAIL_NO);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.ITEM_CD);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.SHORT_NAME);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, false, (int)eColView.ITEM_DESC);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, false, (int)eColView.UNIT);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, false, (int)eColView.QTY);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, false, (int)eColView.PRICE);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, false, (int)eColView.AMOUNT);


                break;

            case Common.eScreenMode.EDIT:
                CtrlUtil.EnabledControl(false, txtDeliveryNo, cboAddress, txtInvoiceNo,
                                        dtInvoiceDate, cboTermOfPayment, dtPaymentDueDate,
                                        txtVat, cboCustomerCode, txtFullAddress, txtSubTotal);
                CtrlUtil.EnabledControl(true, txtReferTemNo, txtRemark, txtVatTotal, txtTotal);
                shtCustomerOrder.OperationMode = OperationMode.Normal;
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.PO_NO);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.ORDER_NO);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.ORDER_DETAIL_NO);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.ITEM_CD);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.SHORT_NAME);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, false, (int)eColView.ITEM_DESC);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, false, (int)eColView.UNIT);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, false, (int)eColView.QTY);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, false, (int)eColView.PRICE);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, false, (int)eColView.AMOUNT);

                break;

            case Common.eScreenMode.VIEW:

                shtCustomerOrder.OperationMode = OperationMode.ReadOnly;
                CtrlUtil.EnabledControl(false, txtDeliveryNo, cboAddress, txtInvoiceNo,
                                        dtInvoiceDate, cboTermOfPayment, dtPaymentDueDate,
                                        txtVat, cboCustomerCode, txtFullAddress, txtSubTotal);
                CtrlUtil.EnabledControl(false, txtReferTemNo, txtRemark, txtVatTotal, txtTotal);
                shtCustomerOrder.OperationMode = OperationMode.ReadOnly;
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.PO_NO);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.ORDER_NO);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.ORDER_DETAIL_NO);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.ITEM_CD);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.SHORT_NAME);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.ITEM_DESC);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.UNIT);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.QTY);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.PRICE);
                CtrlUtil.SpreadSetColumnsLocked(shtCustomerOrder, true, (int)eColView.AMOUNT);


                fpCustomerOrder.ContextMenuStrip = null;
                tsbSaveAndClose.Enabled          = false;
                tsbSaveAndNew.Enabled            = false;
                break;
            }

            m_Mode = mode;
        }