예제 #1
0
        private void loadData()
        {
            try
            {
                //LotMaintenanceController ctlsys = new LotMaintenanceController();
                //LotMaintenanceUIDM model = dmc.SaveData(new LotMaintenanceUIDM());
                //LotMaintenanceUIDM models = ctlsys.loaddata(model);
                DeliveryBIZ bizDelivery = new DeliveryBIZ();
                DataTable   dt          = bizDelivery.Load_DeliveryOrderListForReturn(dtPeriodBegin.NZValue, dtPeriodEnd.NZValue, txtMasterNo.Text.ToNZString(), txtItemDesc.Text.ToNZString(), m_Customer.ToNZString(), m_Return_Slip_No.ToNZString(), false);
                fpView.DataSource = dt;//models.DATA_VIEW;

                for (int i = 0; i < shtPreviousData.RowCount; i++)
                {
                    for (int j = shtView.RowCount - 1; j >= 0; j--)
                    {
                        if (Convert.ToDecimal(shtPreviousData.GetValue(i, (int)eColPreviousScreen.RETURNABLE_QTY)) <= 0)
                        {
                            shtView.RemoveRows(j, 1);
                            continue;
                        }
                        if (Convert.ToString(shtPreviousData.GetValue(i, (int)eColPreviousScreen.REF_SLIP_NO)) == Convert.ToString(shtView.GetValue(j, (int)eColumns.ORDER_DETAIL_NO)) &&
                            Convert.ToString(shtPreviousData.GetValue(i, (int)eColPreviousScreen.REF_NO)) == Convert.ToString(shtView.GetValue(j, (int)eColumns.TRANS_ID)))
                        {
                            shtView.RemoveRows(j, 1);
                        }
                    }
                }



                //for (int i = 0; i < shtView.Rows.Count; i++)
                //{
                //    if (Convert.ToInt32(shtView.Cells[i, (int)eColumns.EDIT_FLAG].Value) == 1)
                //        shtView.Cells[i, (int)eColumns.EDIT_FLAG].Value = true;
                //    else
                //        shtView.Cells[i, (int)eColumns.EDIT_FLAG].Value = false;
                //}
            }
            catch (Exception ex)
            {
                MessageDialog.ShowBusiness(this, ex.Message);
            }
        }
예제 #2
0
        private void Lot_Maintenance_Load(object sender, EventArgs e)
        {
            InitializeMenuButton();
            InitialFormat();
            InitialSpread();
            InitialDefaultValue();

            CtrlUtil.EnabledControl(false, txtItemNo, txtPartNo, txtRemainQty, txtQty);

            // Get all data
            DeliveryBIZ bizDelivery            = new DeliveryBIZ();
            List <ActualOnhandViewDTO> listDTO = bizDelivery.Load_LotMaintenance(SlipNo, LocCd, ItemCd, false);

            m_Data = DTOUtility.ConvertListToDataTable <ActualOnhandViewDTO>(listDTO);
            m_Data.Columns.Add(CONST_COLUMN_NAME_CHECK_FLAG, typeof(int));


            m_Data = OrderData(m_Data);

            // Filter
            loadData();
        }
예제 #3
0
        public List <ActualOnhandViewDTO> Load_LotMaintenance(NZString SlipNo, NZString LocCd, NZString ItemCd, bool IncludeOldData)
        {
            DeliveryBIZ biz = new DeliveryBIZ();

            return(biz.Load_LotMaintenance(SlipNo, LocCd, ItemCd, IncludeOldData));
        }
예제 #4
0
        public DataTable Load_Invoice(NZString SlipNo)
        {
            DeliveryBIZ biz = new DeliveryBIZ();

            return(biz.Load_Invoice(SlipNo, false));
        }
예제 #5
0
        public DataTable Load_LotList(NZString SlipNo)
        {
            DeliveryBIZ biz = new DeliveryBIZ();

            return(biz.Load_LotList(SlipNo, false));
        }
예제 #6
0
        public DataTable Load_DeliveryOrderListForReturn(NZDateTime DateBegin, NZDateTime DateEnd, NZString ItemCd, NZString ShortName, NZString CustomerCd, NZString Return_Slip_No)
        {
            DeliveryBIZ biz = new DeliveryBIZ();

            return(biz.Load_DeliveryOrderListForReturn(DateBegin, DateEnd, ItemCd, ShortName, CustomerCd, Return_Slip_No, false));
        }
예제 #7
0
        public DataTable Load_DeliveryList(NZDateTime beginPeriod, NZDateTime endPeriod)
        {
            DeliveryBIZ biz = new DeliveryBIZ();

            return(biz.Load_DeliveryList(beginPeriod, endPeriod, false));
        }
예제 #8
0
        public List <DeliveryViewDTO> Load_OrderMaintenance(NZDateTime beginPeriod, NZDateTime endPeriod, NZString CustomerCd, NZString Currency, NZString SlipNo)
        {
            DeliveryBIZ biz = new DeliveryBIZ();

            return(biz.Load_OrderMaintenance(beginPeriod, endPeriod, CustomerCd, Currency, SlipNo, false));
        }
예제 #9
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();
                }
            }
        }