コード例 #1
0
 public PackingViewModel()
 {
     Packing          = new PackingInfo();
     Packings         = new List <PackingInfo>();
     Friendly_Message = new List <FriendlyMessageInfo>();
     Pager            = new PaginationInfo();
     Filter           = new PackingFilter();
 }
コード例 #2
0
        private PackingInfo Get_Packing_Values(DataRow dr)
        {
            PackingInfo packing = new PackingInfo();

            packing.Packing_Id   = Convert.ToInt32(dr["Packing_Id"]);
            packing.Packing_Name = Convert.ToString(dr["Packing_Name"]);
            packing.Is_Active    = Convert.ToBoolean(dr["Is_Active"]);
            packing.CreatedOn    = Convert.ToDateTime(dr["CreatedOn"]);
            packing.CreatedBy    = Convert.ToInt32(dr["CreatedBy"]);
            packing.UpdatedOn    = Convert.ToDateTime(dr["UpdatedOn"]);
            packing.UpdatedBy    = Convert.ToInt32(dr["UpdatedBy"]);
            return(packing);
        }
コード例 #3
0
        public async Task UpdatePackinInfo(PackingInfo updateItem)
        {
            var packInfos  = _SalesProducts.Select(d => d.PackingInfo).Distinct().ToList();
            var targetItem = packInfos.FirstOrDefault(d => d.SalesProductId == updateItem.SalesProductId);

            if (targetItem == null)
            {
                return;
            }

            targetItem.PackingWeight = updateItem.PackingWeight;

            await _PackingRepo.Save(packInfos);
        }
コード例 #4
0
        private List <SqlParameter> Set_Values_In_Packing(PackingInfo PackingInfo)
        {
            List <SqlParameter> sqlParams = new List <SqlParameter>();

            if (PackingInfo.Packing_Id != 0)
            {
                sqlParams.Add(new SqlParameter("@Packing_Id", PackingInfo.Packing_Id));
            }
            sqlParams.Add(new SqlParameter("@Packing_Name", PackingInfo.Packing_Name));
            sqlParams.Add(new SqlParameter("@Is_Active", PackingInfo.Is_Active));
            if (PackingInfo.Packing_Id == 0)
            {
                sqlParams.Add(new SqlParameter("@CreatedBy", PackingInfo.CreatedBy));
                sqlParams.Add(new SqlParameter("@CreatedOn", PackingInfo.CreatedOn));
            }
            sqlParams.Add(new SqlParameter("@UpdatedBy", PackingInfo.UpdatedBy));
            sqlParams.Add(new SqlParameter("@UpdatedOn", PackingInfo.UpdatedOn));
            return(sqlParams);
        }
コード例 #5
0
        public async Task UpdatePackResources(PackingInfo updatedItem)
        {
            using (await _AsyncLock.LockAsync())
            {
                var salesProduct = _SalesProducts.FirstOrDefault(d => d.Id == updatedItem.SalesProductId);
                if (salesProduct == null)
                {
                    return;
                }

                salesProduct.PackingInfo.Resources.Clear();
                salesProduct.PackingInfo.Resources.AddRange(updatedItem.Resources);

                var packResources = _SalesProducts.SelectMany(d => d.PackingInfo.Resources).Distinct().ToList();
                var packInfos     = _SalesProducts.Select(d => d.PackingInfo).Distinct().ToList();

                await _ResourceRepo.SavePackResources(packResources);

                await _PackingRepo.Save(packInfos);
            }
        }
コード例 #6
0
        public PackingInfo Get_Packing_By_Packing_Id(int packing_Id)
        {
            PackingInfo         packing   = new PackingInfo();
            List <SqlParameter> sqlParams = new List <SqlParameter>();

            sqlParams.Add(new SqlParameter("@Packing_Id", packing_Id));
            DataTable dt = _sqlRepo.ExecuteDataTable(sqlParams, StoredProcedures.Get_Packing_By_Id_Sp.ToString(), CommandType.StoredProcedure);

            if (dt != null && dt.Rows.Count > 0)
            {
                int            count  = 0;
                List <DataRow> drList = new List <DataRow>();

                drList = dt.AsEnumerable().ToList();

                count = drList.Count();

                foreach (DataRow dr in drList)
                {
                    packing = Get_Packing_Values(dr);
                }
            }
            return(packing);
        }
コード例 #7
0
 public void Update_Packing(PackingInfo PackingInfo)
 {
     _sqlRepo.ExecuteNonQuery(Set_Values_In_Packing(PackingInfo), StoredProcedures.Update_Packing_Sp.ToString(), CommandType.StoredProcedure);
 }
コード例 #8
0
 public void Update_Packing(PackingInfo PackingInfo)
 {
     _packingRepo.Update_Packing(PackingInfo);
 }
コード例 #9
0
 public void Insert_Packing(PackingInfo PackingInfo)
 {
     _packingRepo.Insert_Packing(PackingInfo);
 }
コード例 #10
0
ファイル: W014.aspx.cs プロジェクト: N97031206/CustomizeRule
        protected void ttbWorkpiece_TextChanged(object sender, EventArgs e)
        {
            try
            {
                // 若卡控需輸入料號
                if (ttbDeviceName.Text.Trim().IsNullOrEmpty() && !ckbNoControl.Checked)
                {
                    throw new RuleCimesException(TextMessage.Error.T00043(lblDeviceName.Text));
                }
                // 取得輸入工件
                string inputObject = ttbWorkpiece.Text.Trim();
                if (inputObject.IsNullOrEmpty())
                {
                    return;
                }

                ComponentInfo componentInfo = null;
                LotInfo       lotInfo       = null;

                var lstDMCComponent = ComponentInfoEx.GetComponentByDMCCode(inputObject).OrderBy(p => p.ComponentID).ToList();
                if (lstDMCComponent.Count == 0)
                {
                    var compID = CustomizeFunction.ConvertDMCCode(inputObject);
                    lstDMCComponent = ComponentInfoEx.GetComponentListByComponentID(compID).OrderBy(p => p.ComponentID).ToList();
                }

                lstDMCComponent.ForEach(comp =>
                {
                    // 若DMC是唯一值可以檢查是否已經重複
                    if (_ProdType == "S" || _ProdType == "B")
                    {
                        // 取得批號資料
                        lotInfo = LotInfo.GetLotByLot(comp.CurrentLot);

                        // 自動線沒有DMCCode
                        if (lotInfo.UserDefineColumn08 == "Y" && comp["DMC"].ToString().IsNullOrEmpty())
                        {
                            var txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);
                            using (var cts = CimesTransactionScope.Create())
                            {
                                WIPTransaction.ModifyLotComponentSystemAttribute(lotInfo, comp, "DMC", inputObject, txnStamp);
                                cts.Complete();
                            }
                        }

                        #region 檢查子單元資料是否重複
                        if (lotInfo.DeviceName == _DeviceName)
                        {
                            _PackingList.ForEach(p =>
                            {
                                if (p.ComponentID == comp.ComponentID)
                                {
                                    throw new RuleCimesException(TextMessage.Error.T00033(lblWorkpiece.Text, comp.ComponentID));
                                }
                            });
                        }
                        else if (lotInfo.DeviceName == _RelativeDeviceName)
                        {
                            _RelativePackingList.ForEach(p =>
                            {
                                if (p.ComponentID == comp.ComponentID)
                                {
                                    throw new RuleCimesException(TextMessage.Error.T00033(lblWorkpiece.Text, comp.ComponentID));
                                }
                            });
                        }
                        #endregion
                        componentInfo = comp;
                    }
                    else
                    {
                        if (_PackingList.Find(p => p.ComponentID == comp.ComponentID) == null && _RelativePackingList.Find(p => p.ComponentID == comp.ComponentID) == null && componentInfo == null)
                        {
                            componentInfo = comp;
                            // 取得批號資料
                            lotInfo = LotInfo.GetLotByLot(componentInfo.CurrentLot);
                        }
                    }
                });

                // 找不到子單元需拋錯
                if (componentInfo == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Workpiece")));
                }
                // 找不到批號需拋錯
                if (lotInfo == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Lot")));
                }
                // 檢查CurrentRule是否正確
                if (lotInfo.CurrentRuleName != ProgramInformationBlock1.ProgramRight)
                {
                    throw new RuleCimesException(TextMessage.Error.T00384(lotInfo.CurrentRuleName, ProgramInformationBlock1.ProgramRight));
                }
                // 若需卡控
                if (!ckbNoControl.Checked)
                {
                    // 檢查批號型號與輸入的型號是否相同
                    if (_PackType == "Standard" && lotInfo.DeviceName != _DeviceName)
                    {
                        throw new RuleCimesException(RuleMessage.Error.C10041(_DeviceName));
                    }
                    // 如果為包裝方式為Mix(左右手),則對應料號與對應料號須符合
                    if (_PackType == "Mix" && lotInfo.DeviceName != _DeviceName && lotInfo.DeviceName != _RelativeDeviceName)
                    {
                        throw new RuleCimesException(RuleMessage.Error.C10042(_DeviceName, _RelativeDeviceName));
                    }
                }

                var packTempInfo = CSTWIPPackTempInfo.GetPackTempByComponentID(componentInfo.ComponentID);
                if (packTempInfo != null)
                {
                    ttbWorkpiece.Text = "";
                    throw new RuleCimesException(RuleMessage.Error.C10093());
                }

                // 新增PackingInfo物件
                var newPackItem = new PackingInfo();
                newPackItem.ComponentID   = componentInfo.ComponentID;
                newPackItem.ComponentInfo = componentInfo;
                newPackItem.LotInfo       = lotInfo;
                newPackItem.DMC           = componentInfo["DMC"].ToString();

                // 將PackingInfo物件加入包裝清單全域變數
                if (_PackType == "Standard" || (_PackType == "Mix" && lotInfo.DeviceName == _DeviceName) || ckbNoControl.Checked)
                {
                    // 工件數量({0})達到滿箱數量({1}) !
                    if (!ckbNoControl.Checked && _PackingList.Count >= ttbMaxPackSize.Text.ToDecimal())
                    {
                        throw new RuleCimesException(RuleMessage.Error.C10092(_PackingList.Count.ToString(), ttbMaxPackSize.Text));
                    }

                    newPackItem.Device = lotInfo.DeviceName;
                    newPackItem.Item   = (_PackingList.Count + 1).ToString();
                    _PackingList.Add(newPackItem);
                }
                // 將PackingInfo物件加入對應料號包裝清單全域變數
                else
                {
                    // 工件數量({0})達到滿箱數量({1}) !
                    if (!ckbNoControl.Checked && _RelativePackingList.Count >= ttbMaxPackSize.Text.ToDecimal())
                    {
                        throw new RuleCimesException(RuleMessage.Error.C10092(_RelativePackingList.Count.ToString(), ttbMaxPackSize.Text));
                    }

                    newPackItem.Device = lotInfo.DeviceName;
                    newPackItem.Item   = (_RelativePackingList.Count + 1).ToString();
                    _RelativePackingList.Add(newPackItem);
                }
                // 將目前已經輸入的物件顯示至畫面上
                _PackingList           = _PackingList.OrderByDescending(p => p.Item.ToDecimal()).ToList();
                gvWorkpiece.DataSource = _PackingList;
                gvWorkpiece.DataBind();
                // 將目前已經輸入的物件顯示至畫面上
                _RelativePackingList           = _RelativePackingList.OrderByDescending(p => p.Item.ToDecimal()).ToList();
                gvRelativeWorkpiece.DataSource = _RelativePackingList;
                gvRelativeWorkpiece.DataBind();
                // 清除工件欄位
                ttbWorkpiece.Text = "";
                // 將指標焦點放工件欄位輸入框
                AjaxFocus(ttbWorkpiece);

                if (_PackingList.Count != 0 || _RelativePackingList.Count != 0)
                {
                    ttbTempWorkpiece.ReadOnly = true;
                }
                else
                {
                    ttbTempWorkpiece.ReadOnly = false;
                }
                // 取得BatchID
                if (_BatchID == "")
                {
                    var cstWIPPackTempInfo = InfoCenter.GetBySQL <CSTWIPPackTempInfo>("SELECT * FROM CST_WIP_PACK_TEMP WHERE COMPONENTID = #[STRING]", inputObject);
                    _BatchID = (cstWIPPackTempInfo == null) ? "" : cstWIPPackTempInfo.BatchID;
                }

                #region ProcessWorkTime
                string sysTime     = DBCenter.GetSystemTime();
                var    usrWorkTime = InfoCenter.Create <CSTUserWorkTimeInfo>();
                usrWorkTime.WorkOrder    = lotInfo.WorkOrder;
                usrWorkTime.WorkUserID   = User.Identity.Name;
                usrWorkTime.StartTime    = _StartTime;
                usrWorkTime.EndTime      = DateTime.Parse(sysTime).AddSeconds(-1).ToString("yyyy/MM/dd HH:mm:ss");
                usrWorkTime.EXECUTEFLAG  = "N";
                usrWorkTime.SHIFTDATE    = _ShiftDate;
                usrWorkTime.SHIFT        = _Shift;
                usrWorkTime.Lot          = lotInfo.Lot;
                usrWorkTime["OPERATION"] = lotInfo.OperationName;
                _StartTime = sysTime;
                _UserWorkTimeList.Add(usrWorkTime);
                #endregion
            }
            catch (Exception ex)
            {
                HandleError(ex, ttbWorkpiece.ClientID);
            }
        }
コード例 #11
0
ファイル: W014.aspx.cs プロジェクト: N97031206/CustomizeRule
        protected void ttbTempWorkpiece_TextChanged(object sender, EventArgs e)
        {
            try
            {
                //必須輸入Device
                if (_DeviceName.IsNullOrEmpty())
                {
                    ttbTempWorkpiece.Text = "";
                    AjaxFocus(ttbDeviceName);
                    throw new RuleCimesException(TextMessage.Error.T00826(lblDeviceName.Text));
                }

                if (ttbTempWorkpiece.Text.Trim().IsNullOrEmpty())
                {
                    return;
                }

                string sTempWorkpiece = CustomizeFunction.ConvertDMCCode(ttbTempWorkpiece.Text.Trim());

                //取得BatchID
                var cstWIPPackTempInfo = InfoCenter.GetBySQL <CSTWIPPackTempInfo>("SELECT * FROM CST_WIP_PACK_TEMP WHERE COMPONENTID = #[STRING]", sTempWorkpiece);

                if (cstWIPPackTempInfo == null)
                {
                    throw new CimesException(RuleMessage.Error.C00054(ttbTempWorkpiece.Text.Trim()));
                }

                if (cstWIPPackTempInfo.SIDE == "R" && _DeviceName == cstWIPPackTempInfo.DeviceName)
                {
                    throw new RuleCimesException(RuleMessage.Error.C10168());
                }

                _BatchID = (cstWIPPackTempInfo == null) ? "" : cstWIPPackTempInfo.BatchID;

                if (_BatchID == "")
                {
                    AjaxFocus(ttbTempWorkpiece);
                    throw new RuleCimesException(TextMessage.Error.T00045(lblTempWorkpiece.Text));
                }

                var lstCSTWIPPackTempInfo = InfoCenter.GetList <CSTWIPPackTempInfo>("SELECT * FROM CST_WIP_PACK_TEMP WHERE BATCHID = #[STRING]", _BatchID);

                int idx = 1;
                lstCSTWIPPackTempInfo.FindAll(p => p.SIDE == "L").ForEach(p =>
                {
                    var packingInfo             = new PackingInfo();
                    packingInfo.Item            = idx.ToString();
                    packingInfo.Device          = _DeviceName;
                    packingInfo.ComponentID     = p.ComponentID;
                    ComponentInfo componentInfo = ComponentInfo.GetComponentByComponentID(p.ComponentID);
                    packingInfo.ComponentInfo   = componentInfo;
                    packingInfo.DMC             = componentInfo["DMC"].ToString();
                    LotInfo lotInfo             = LotInfo.GetLotByLot(componentInfo.CurrentLot);
                    packingInfo.LotInfo         = lotInfo;
                    idx++;
                    _PackingList.Add(packingInfo);
                });

                idx = 1;
                lstCSTWIPPackTempInfo.FindAll(p => p.SIDE == "R").ForEach(p =>
                {
                    var packingInfo             = new PackingInfo();
                    packingInfo.Item            = idx.ToString();
                    packingInfo.Device          = _RelativeDeviceName;
                    packingInfo.ComponentID     = p.ComponentID;
                    ComponentInfo componentInfo = ComponentInfo.GetComponentByComponentID(p.ComponentID);
                    packingInfo.ComponentInfo   = componentInfo;
                    packingInfo.DMC             = componentInfo["DMC"].ToString();
                    LotInfo lotInfo             = LotInfo.GetLotByLot(componentInfo.CurrentLot);
                    packingInfo.LotInfo         = lotInfo;
                    idx++;
                    _RelativePackingList.Add(packingInfo);
                });

                gvWorkpiece.DataSource = _PackingList;
                gvWorkpiece.DataBind();

                gvRelativeWorkpiece.DataSource = _RelativePackingList;
                gvRelativeWorkpiece.DataBind();

                ttbTempWorkpiece.Text = "";
                if (_PackingList.Count != 0 || _RelativePackingList.Count != 0)
                {
                    ttbTempWorkpiece.ReadOnly = true;
                }
                else
                {
                    ttbTempWorkpiece.ReadOnly = false;
                }
                AjaxFocus(ttbWorkpiece);
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }