/// <summary>
        /// 添加批量追溯信息
        /// </summary>
        private void GetBatchInfoToModel()
        {
            #region 添加批量追溯信息
            if (RemoteMaterialHT != null && RemoteMaterialHT.Count > 0)
            {
                LocalMaterialHT.Clear();
                foreach (DictionaryEntry item in RemoteMaterialHT)        // 遍历哈希表
                {
                    //从数据库获取当前批次材料信息
                    BatchNoMDL model = batchDAL.GetModel(string.Format("MaterialCode='{0}'", item.Key.ToString()));
                    LocalMaterialHT.Add(item.Key.ToString(), model);
                    //获取更新的字段
                    materialFieldModel = materialFieldDAL.GetModel(string.Format("materialcode='{0}'", item.Key.ToString()));
                    //更新对应字段
                    #region 更新对应字段
                    if (materialFieldModel != null)
                    {
                        switch (materialFieldModel.FieldName)
                        {
                        //制动泵编码
                        case "brakepumpcode":
                            resultModel.brakepumpcode = model.BatchNo;
                            break;

                        //密封垫批次号
                        case "gasketbatchno":
                            resultModel.gasketbatchno = model.BatchNo;
                            break;

                        //六角(法兰面)螺母
                        case "hexagonalnutbatchno":
                            resultModel.hexagonalnutbatchno = model.BatchNo;
                            break;

                        //压力传感器批次号
                        case "pressuresensorbatchno":
                            resultModel.pressuresensorbatchno = model.BatchNo;
                            break;

                        //消音器(制动泵隔音垫)
                        case "silencerbatchno":
                            resultModel.silencerbatchno = model.BatchNo;
                            break;

                        //结合管(制动连接管)
                        case "connectingpipe":
                            resultModel.connectingpipe = model.BatchNo;
                            break;

                        //助力器制动泵支架
                        case "boosterbrakepumpbracket":
                            resultModel.boosterbrakepumpbracket = model.BatchNo;
                            break;
                        }
                    }
                    #endregion
                }
            }
            #endregion
        }
Esempio n. 2
0
        /// <summary>
        /// 添加批量追溯信息
        /// </summary>
        private void GetBatchInfoToModel()
        {
            #region 添加批量追溯信息
            if (RemoteMaterialHT != null && RemoteMaterialHT.Count > 0)
            {
                LocalMaterialHT.Clear();
                foreach (DictionaryEntry item in RemoteMaterialHT)        // 遍历哈希表
                {
                    //从数据库获取当前批次材料信息
                    BatchNoMDL model = batchDAL.GetModel(string.Format("MaterialCode='{0}'", item.Key.ToString()));
                    LocalMaterialHT.Add(item.Key.ToString(), model);
                    //获取更新的字段
                    materialFieldModel = materialFieldDAL.GetModel(string.Format("materialcode='{0}'", item.Key.ToString()));
                    //更新对应字段
                    #region 更新对应字段
                    if (materialFieldModel != null)
                    {
                        switch (materialFieldModel.FieldName)
                        {
                        //踏板总成
                        case "pedalassycode":
                            resultModel.pedalassycode = model.BatchNo;
                            break;

                        //油门踏板
                        case "accelpedalcode":
                            resultModel.accelpedalcode = model.BatchNo;
                            break;

                        //离合器把手批次号
                        case "cluthhandlebatchno":
                            resultModel.cluthhandlebatchno = model.BatchNo;
                            break;

                        //螺栓批次号
                        case "boltbatchno":
                            resultModel.boltbatchno = model.BatchNo;
                            break;

                        //螺母批次号
                        case "nutbatchno":
                            resultModel.nutbatchno = model.BatchNo;
                            break;
                        }
                    }
                    #endregion
                }
            }
            #endregion
        }
Esempio n. 3
0
        /// <summary>
        /// 添加批次信息
        /// </summary>
        private void Insert()
        {
            try
            {
                //string ProductCode = context.Request.Params["ProductCode"].ToString();
                string ProductType  = context.Request.Params["ProductType"].ToString();
                string MaterialCode = context.Request.Params["MaterialCode"].ToString();
                string BatchNo      = context.Request.Params["BatchNo"].ToString();
                string BatchNumStr  = context.Request.Params["BatchNum"].ToString();
                string Supplier     = context.Request.Params["Supplier"].ToString();
                int    BatchNum     = 0;
                bool   b            = int.TryParse(BatchNumStr, out BatchNum);

                BatchNoMDL Model = null;
                string     sql   = string.Format("materialcode='{0}'", MaterialCode);
                Model = DataDAL.GetModel(sql);
                if (Model != null)
                {
                    Model.BatchNo  = BatchNo;
                    Model.BatchNum = (b && BatchNum > 0) ? BatchNum : Model.BatchNum;
                    Model.StockNum = Model.BatchNum;
                    Model.Supplier = Supplier;

                    this.Update(Model);
                    return;
                }
                else
                {
                    Model = new BatchNoMDL();
                    sql   = string.Format("producttype='{0}' AND materialcode='{1}'", ProductType, MaterialCode);
                    ProductBomInfoDAL pb   = new ProductBomInfoDAL();
                    ProductBomInfoMDL info = pb.GetModel(sql);

                    if (b && BatchNum > 0)
                    {
                        Model.BatchNum = BatchNum;
                    }
                    else
                    {
                        if (info != null || info.BatchNum.ToString().Trim() != "")
                        {
                            Model.BatchNum = int.Parse(info.BatchNum.ToString());
                        }
                        else
                        {
                            Model.BatchNum = 1;
                        }
                    }
                    Model.StockNum     = Model.BatchNum;
                    Model.MaterialCode = MaterialCode;
                    Model.MaterialName = info.MaterialName;
                    Model.BatchNo      = BatchNo;
                    Model.Supplier     = Supplier;

                    bool flag = DataDAL.Add(Model);
                    if (flag)
                    {
                        ReturnData.Code = "1";
                        ReturnData.Msg  = "OK";
                    }

                    BatchNoHisDAL HisDAL   = new BatchNoHisDAL();
                    BatchNoHisMDL HisModel = new BatchNoHisMDL();
                    HisModel.MaterialCode = Model.MaterialCode;
                    HisModel.BatchNo      = BatchNo;
                    HisModel.BatchNum     = Model.BatchNum;
                    HisModel.Supplier     = Model.Supplier;
                    HisModel.CreateTime   = DateTime.Now;
                    flag = HisDAL.Add(HisModel);
                }
            }
            catch (Exception ex)
            {
                CLog.WriteErrLog(ex.Message + ex.StackTrace);
            }
        }