예제 #1
0
        public string GetPurchaseAdvanceTime(string PartCode, DateTime PlanedStartTime)
        {
            var part_list           = new SYS_PartService().GetModelList(ParamQuery.Instance().AndWhere("PartCode", PartCode));
            int PurchaseAdvanceTime = part_list.Count > 0 ? Convert.ToInt32(part_list.First().PurchaseAdvanceTime) : 0;
            var PlanedFinishTime    = PlanedStartTime.AddDays(PurchaseAdvanceTime);

            return(PlanedFinishTime.ToString("yyyy-MM-dd hh:mm:ss"));
        }
예제 #2
0
     public void Edit(dynamic data)
     {
         var listWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
 <settings>
     <table>
         SYS_Part
     </table>
     <where>
         <field name='ID' cp='equal'></field>
     </where>
 </settings>");
         var service     = new SYS_PartService();
         var result      = service.Edit(null, listWrapper, data);
     }
예제 #3
0
        public dynamic Get(RequestWrapper query)
        {
            query.LoadSettingXmlString(@"
    <settings defaultOrderBy='ID'>
        <select>t1.*,t2.TypeName</select>
        <from>SYS_Part as t1 left join SYS_PartType as t2 on t1.PartTypeID = t2.PartTypeCode</from>
        <where defaultForAll='true' defaultCp='equal' defaultIgnoreEmpty='true'>
                <field name='PartCode'       cp='equal'></field>
        </where>
    </settings>");
            var service = new SYS_PartService();
            var pQuery  = query.ToParamQuery();
            var result  = service.GetDynamicListWithPaging(pQuery);

            return(result);
        }
예제 #4
0
        public string PostStorage(dynamic data)
        {
            string msg      = "";
            string BillCode = data["BillCode"];
            var    result   = new QMS_GoodsInspectionItemService().AuditBillCode(BillCode, out msg);
            //生成物料条码:外购件
            var QMS_GoodsCheckModel = new QMS_GoodsCheckService().GetModel(ParamQuery.Instance().AndWhere("BillCode", BillCode));

            if (QMS_GoodsCheckModel != null)
            {
                string InnerFactoryBatch = QMS_GoodsCheckModel.BatchCode;         //厂内批次
                string OuterFactoryBatch = QMS_GoodsCheckModel.OuterFactoryBatch; //厂外批次
                string InventoryCode     = QMS_GoodsCheckModel.InventoryCode;     //存货编码
                var    SysPartModel      = new SYS_PartService().GetModel(ParamQuery.Instance().AndWhere("InventoryCode", InventoryCode));
                if (SysPartModel != null)
                {
                    string InventoryName  = SysPartModel.InventoryName;
                    string PartCode       = SysPartModel.PartCode;
                    string PartName       = SysPartModel.PartName;
                    string PartFigureCode = SysPartModel.FigureCode;
                    //string CorrespondingBarcode = SysPartModel.CorrespondingBarcode; //无用字段

                    var SYS_MaterialBatchModel = new SYS_MaterialBatchService().GetModel(ParamQuery.Instance()
                                                                                         .AndWhere("PartCode", PartCode)
                                                                                         .AndWhere("InnerFactoryBatch", InnerFactoryBatch)
                                                                                         .AndWhere("OuterFactoryBatch", OuterFactoryBatch));

                    if (SYS_MaterialBatchModel == null)
                    {
                        var    model       = new SYS_MaterialBatchService();
                        string MateBarCode = model.CreateMateBarCode(0);
                        model.Insert(ParamInsert.Instance()
                                     .Insert("SYS_MaterialBatch")
                                     .Column("MateBarCode", MateBarCode)
                                     .Column("InventoryCode", InventoryCode)
                                     .Column("InventoryName", InventoryName)
                                     .Column("PartCode", PartCode)
                                     .Column("PartFigureCode", PartFigureCode)
                                     .Column("PartName", PartName)
                                     .Column("InnerFactoryBatch", InnerFactoryBatch)
                                     .Column("OuterFactoryBatch", OuterFactoryBatch));
                    }
                }
            }
            return(msg);
        }
예제 #5
0
        public dynamic Get(RequestWrapper query)
        {
            query.LoadSettingXmlString(@"
    <settings defaultOrderBy='PartType'>
        <select>ID,text,case when InventoryCode=ReferenceCode then '' else InventoryCode end InventoryCode,InventoryName,Model,Spec,ReferenceCode,ReferenceName,ReferenceModel,PartType,WarehouseCode,WarehouseName,QuantityUnit</select>
        <from>(SELECT *, CASE WHEN PartType='PRS_BoardCreateMate' THEN  '板材报料'
 WHEN PartType='MES_WorkshopPurchaseDetail'  THEN  '车间请购'
  WHEN PartType='PRS_Process_BOM'  THEN  '工艺定料' END AS text
  FROM [V_CreateSysPart])  as tmp</from>
        <where defaultForAll='true' defaultCp='equal' defaultIgnoreEmpty='true'>
                <field name='InventoryName'          cp='like'></field>
                <field name='Model'          cp='like'></field>
                <field name='Spec'       cp='like'></field>
        </where>
    </settings>");
            var service = new SYS_PartService();
            var pQuery  = query.ToParamQuery();
            var result  = service.GetDynamicListWithPaging(pQuery);

            return(result);
        }
예제 #6
0
        public void Edit(dynamic data)
        {
            var listWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
    <settings>
        <table>
            PRS_Process_BOM_Blanking
        </table>
        <where>
            <field name='ID' cp='equal'></field>
        </where>
    </settings>");
            var service     = new PRS_Process_BOM_BlankingService();

            if (data.list.updated.ToString() != "[]")
            {
                foreach (JToken row in data["list"]["updated"].Children())
                {
                    string SetMateName = row["SetMateName"].ToString();

                    string New_PartName = row["New_PartName"].ToString();

                    string New_Model = row["New_Model"].ToString();


                    //处理同上

                    //row["New_PartName"] = row["MaterialInventoryName"];//MaterialInventoryName代替InventoryName
                    //row["New_Model"] = row["MaterialInventoryCode"];//MaterialInventoryCode代替Model
                    //string inventoryCode = row["New_InventoryCode"].ToString();
                    //var inventory = service.GetModel(ParamQuery.Instance().AndWhere("IsEnable", 1).AndWhere("ID", row["ID"].ToString()));
                    SYS_Part part    = new SYS_PartService().GetModel(ParamQuery.Instance().Select("*").AndWhere("InventoryCode", SetMateName));
                    bool     mEquals = New_Model.Equals(part.Model == null ? "" : part.Model);
                    bool     nEquals = New_PartName.Equals(part.InventoryName == null ? "" : part.InventoryName);
                    bool     res     = mEquals && nEquals;
                    row["MaterialInventoryName"] = part.InventoryName;
                    row["MaterialInventoryCode"] = part.Model;

                    row["New_InventoryCode"] = "";

                    if (res)
                    {
                        row["New_InventoryCode"] = row["SetMateName"];
                    }

                    /*else
                     * {
                     *  if (row["New_InventoryCode"].ToString().Equals(row["SetMateName"].ToString()))
                     *  {
                     *      row["New_InventoryCode"] = "";
                     *  }
                     *  else
                     *  {
                     *
                     *  }
                     * }*/

                    ////处理同上
                    //row["New_InventoryCode"] = row["SetMateName"];
                    //row["New_PartName"] = row["MaterialInventoryName"];//MaterialInventoryName代替InventoryName
                    //row["New_Model"] = row["MaterialInventoryCode"];//MaterialInventoryCode代替Model
                    //string inventoryCode = row["New_InventoryCode"].ToString();
                    //var inventory = service.GetModel(ParamQuery.Instance().AndWhere("IsEnable", 1).AndWhere("ID", row["ID"].ToString()));
                    //var pQuery = ParamQuery.Instance().Select("*").AndWhere("InventoryCode", inventory.SetMateName);
                    //SYS_Part part = new SYS_PartService().GetModel(pQuery);
                    //bool mEquals = row["MaterialInventoryCode"].ToString().Equals(part.Model == null ? "" : part.Model);
                    //bool nEquals = row["MaterialInventoryName"].ToString().Equals(part.InventoryName == null ? "" : part.InventoryName);
                    //bool res = mEquals && nEquals;
                    //row["MaterialInventoryName"] = part.InventoryName;
                    //row["MaterialInventoryCode"] = part.Model;
                    //if (!res)
                    //{
                    //    row["New_InventoryCode"] = "";
                    //}
                }
            }

            var result = service.Edit(null, listWrapper, data);
        }
        public void Edit(dynamic data)
        {
            var listWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
    <settings>
        <table>
            PRS_BoardCreateMate
        </table>
        <where>
            <field name='ID' cp='equal'></field>
        </where>
    </settings>");
            var service     = new PRS_BoardCreateMateService();

            //var result = service.Edit(null, listWrapper, data);
            if (data.list.inserted.ToString() != "[]")
            {
                foreach (JToken row in data["list"]["inserted"].Children())
                {
                    //首先页面中显示用户只能维护InventoryCode,InventoryName,Model,但是不能确定用户是否在选中完现有的材料信息后有没有进行修改型号规格。
                    //所以先默认存储的新存货编码,存货名称,型号规格数据都为页面传过来的数据
                    row["New_InventoryCode"] = row["InventoryCode"];
                    row["New_InventoryName"] = row["InventoryName"];
                    row["New_Model"]         = row["Model"];
                    row["IsEnable"]          = 1;
                    //row["New_Specs"] = row["Specs"];
                    //获取用户选中的存货编码,并以此为条件查询出原本次存货编码下物料的型号规格数据
                    string   inventoryCode = row["New_InventoryCode"].ToString();
                    var      pQuery        = ParamQuery.Instance().Select("*").AndWhere("InventoryCode", row["InventoryCode"].ToString());
                    SYS_Part part          = new SYS_PartService().GetModel(pQuery);
                    //判断数据库中原有的型号规格与页面传入的型号规格是否形同
                    bool mEquals = row["Model"].ToString().Equals(part.Model == null ? "" : part.Model);
                    //bool sEquals = row["Specs"].ToString().Equals(part.Spec==null?"": part.Spec);
                    //判断数据库中原有的存货名称与页面传入的存货名称是否形同
                    bool nEquals = row["InventoryName"].ToString().Equals(part.InventoryName == null ? "" : part.InventoryName);
                    bool res     = mEquals && nEquals;
                    //同时对页面中的InventoryName进行赋值,保存选中物料编码下物料原有的存货名称
                    row["InventoryName"] = part.InventoryName;
                    //row["ID"] = "";
                    //同时对页面中的Model进行赋值,保存选中物料编码下物料原有的型号规格
                    row["Model"]             = part.Model;
                    row["New_InventoryCode"] = part.InventoryCode;
                    //row["Specs"] = part.Spec;
                    //当页面传入的存货名称和型号规格有任何数据与数据库中的存货名称和型号规格不同时,即证明此物料的存货编码应该新增,所以清除掉新存货编码数据
                    if (!res)
                    {
                        row["New_InventoryCode"] = "";
                    }
                }
            }

            if (data.list.updated.ToString() != "[]")
            {
                foreach (JToken row in data["list"]["updated"].Children())
                {
                    //处理同上
                    row["New_InventoryCode"] = row["InventoryCode"];
                    row["New_InventoryName"] = row["InventoryName"];
                    row["New_Model"]         = row["Model"];
                    row["IsEnable"]          = 1;
                    //row["New_Specs"] = row["Specs"];
                    string inventoryCode = row["New_InventoryCode"].ToString();
                    var    inventory     = service.GetModel(ParamQuery.Instance().AndWhere("IsEnable", 1).AndWhere("ID", row["ID"].ToString()));

                    var pQuery = ParamQuery.Instance().Select("*").AndWhere("InventoryCode", inventory.InventoryCode);

                    SYS_Part part    = new SYS_PartService().GetModel(pQuery);
                    bool     mEquals = row["Model"].ToString().Equals(part.Model == null ? "" : part.Model);
                    //bool sEquals = row["Specs"].ToString().Equals(part.Spec == null ? "" : part.Spec);
                    bool nEquals = row["InventoryName"].ToString().Equals(part.InventoryName == null ? "" : part.InventoryName);
                    bool res     = mEquals && nEquals;
                    row["InventoryName"] = part.InventoryName;
                    row["Model"]         = part.Model;
                    //row["Specs"] = part.Spec;
                    if (!res)
                    {
                        row["New_InventoryCode"] = "";
                    }
                }
            }
            var result = service.Edit(null, listWrapper, data);
        }
        public void Edit(dynamic data)
        {
            var listWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
    <settings>
        <table>
            PRS_BlankingPlateDetail
        </table>
        <where>
            <field name='ID' cp='equal'></field>
        </where>
    </settings>");

            //data.list.inserted[0].MainID

            StringBuilder sb       = new StringBuilder();
            long          maxICode = new SYS_PartService().GetSysPartMaxICode("050203");
            string        newPName = PRS_BlankingPlateDetailController.NewPName;
            DateTime      newDT    = DateTime.Now;

            for (var i = 0; i < data.list.inserted.Count; i++)
            {
                string iCode = "050203" + (++maxICode).ToString().PadLeft(12, '0');

                data.list.inserted[i].InventoryCode = iCode;

                sb.Append(WinFormClientService.GetInsertSQL(new SYS_Part()
                {
                    InventoryCode = iCode,
                    InventoryName = newPName,
                    Model         = $"尺寸={data.list.inserted[i].PlateSize},重量={data.list.inserted[i].Weight},线长={data.list.inserted[i].LineLength}",
                    IsEnable      = 1,
                    CreatePerson  = MmsHelper.GetUserName(),
                    CreateTime    = newDT,
                    ModifyPerson  = MmsHelper.GetUserName(),
                    ModifyTime    = newDT
                }));
            }

            for (var i = 0; i < data.list.updated.Count; i++)
            {
                sb.Append(WinFormClientService.GetUpdateSQL(nameof(SYS_Part), new KeyValuePair <string, object>("InventoryCode", data.list.updated[i].InventoryCode), new
                {
                    Model = $"尺寸={data.list.updated[i].PlateSize},重量={data.list.updated[i].Weight},线长={data.list.updated[i].LineLength}"
                }));
            }

            string sql = sb.ToString();

            using (var db = Db.Context("Mms"))
            {
                db.Sql(sql).Execute();
            }

            //dynamic inserted_list= data.list.inserted;
            //dynamic deleted_list = data.list.deleted;
            //dynamic updated_list = data.list.updated;
            //var PRS_BlankingPlateDetail_IDList = new List<int>();
            //foreach (dynamic item in inserted_list)
            //{
            //    int ID = item.ID;
            //    PRS_BlankingPlateDetail_IDList.Add(ID);
            //}
            //foreach (dynamic item in deleted_list)
            //{
            //    int ID = item.ID;
            //    PRS_BlankingPlateDetail_IDList.Add(ID);
            //}
            //foreach (dynamic item in updated_list)
            //{
            //    int ID = item.ID;
            //    PRS_BlankingPlateDetail_IDList.Add(ID);
            //}
            //bool flag = true;
            //new Mes_BlankingResultService().PostCreateBoard(out flag, PRS_BlankingPlateDetail_IDList);

            var service = new PRS_BlankingPlateDetailService();
            var result  = service.Edit(null, listWrapper, data);
        }
        public int PostSavePartCode(dynamic data)
        {
            string PartCode       = data.PartCode;
            string SetMateName    = data.SetMateName;
            float  SetMateNum     = data.SetMateNum;
            string InPlanceSize   = data.InPlanceSize;
            string BlankingSize   = data.BlankingSize;
            string ContractCode   = data.ContractCode;
            string FigureCode     = data.FigureCode;
            string PartName       = data.PartName;
            int    Quantity       = data.Quantity == null ? 0 : data.Quantity;
            int    PartQuantity   = data.PartQuantity == null ? 0 : data.PartQuantity;
            string MaterialCode   = data.MaterialCode;
            string New_Specs      = data.New_Specs;
            string New_Model      = data.New_Model;
            string New_PartName   = data.New_PartName;
            int    MateType       = data.MateType;
            string MateParamValue = data.MateParamValue;
            bool   IsSetNewSMP    = data.IsSetNewSMP;

            //int BlankingType = data.BlankingType;
            using (var db = Db.Context("Mms"))
            {
                db.UseTransaction(true);
                try
                {
                    //int MainID = new APS_ProductPurchaseMainService().GetModelList().Count > 0 ?
                    //   new APS_ProductPurchaseMainService().GetModelList().Max(a => a.ID) + 1 : 1;
                    int res = 0;

                    if (IsSetNewSMP)
                    {
                        string newInventoryCode = SetMateName;
                        //先获取关联物料的存货名称,型号规格信息
                        SYS_Part part      = new SYS_PartService().GetModel(ParamQuery.Instance().AndWhere("IsEnable", 1).AndWhere("InventoryCode", SetMateName));
                        bool     modelTrue = New_Model.Equals(part.Model);
                        bool     nameTrue  = New_PartName.Equals(part.InventoryName);
                        //判断页面传入的零件的星海规格和名称是否与part表中存储的数据一致
                        if (!(modelTrue && nameTrue))
                        {
                            //不一致,就说明需要新增零件,此时需要保证订料材料的New_InventoryCode 为空,并保存前台用户维护后的型号规格和物料名称
                            res = db.Update("PRS_Process_BOM")
                                  .Column("SetMateName", SetMateName)
                                  .Column("SetMateNum", SetMateNum)
                                  .Column("InPlanceSize", InPlanceSize)
                                  .Column("BlankingSize", BlankingSize)
                                  .Column("New_Specs", New_Specs)
                                  .Column("New_Model", New_Model)
                                  .Column("New_PartName", New_PartName)
                                  //.Column("New_InventoryCode", newInventoryCode)
                                  .Column("MateType", MateType)
                                  .Column("MateParamValue", MateParamValue)
                                  //.Column("BlankingType", BlankingType)
                                  .Where("PartCode", PartCode).Execute();
                        }
                        else
                        {
                            //一致,就说明并不需要新增零件,所以New_InventoryCode就是订料材料的SetMateName
                            New_PartName = "";
                            res          = db.Update("PRS_Process_BOM")
                                           .Column("SetMateName", SetMateName)
                                           .Column("SetMateNum", SetMateNum)
                                           .Column("InPlanceSize", InPlanceSize)
                                           .Column("BlankingSize", BlankingSize)
                                           .Column("New_Specs", New_Specs)
                                           .Column("New_Model", New_Model)
                                           .Column("New_PartName", New_PartName)
                                           .Column("New_InventoryCode", newInventoryCode)
                                           .Column("MateType", MateType)
                                           .Column("MateParamValue", MateParamValue)
                                           //.Column("BlankingType", BlankingType)
                                           .Where("PartCode", PartCode).Execute();
                        }
                    }
                    else
                    {
                        res = db.Update("PRS_Process_BOM")
                              .Column("SetMateName", SetMateName)
                              .Column("SetMateNum", SetMateNum)
                              .Column("InPlanceSize", InPlanceSize)
                              .Column("BlankingSize", BlankingSize)
                              //当用户没有选择新增零件时,SetMateName及为新物料编码New_InventoryCode
                              .Column("New_InventoryCode", SetMateName)
                              .Column("MateType", MateType)
                              .Column("MateParamValue", MateParamValue)
                              //.Column("BlankingType", BlankingType)
                              .Where("PartCode", PartCode).Execute();
                    }

                    if (res <= 0)
                    {
                        db.Rollback();
                        return(0);
                    }
                    string CreateType = data.MateType;
                    int    total      = Quantity * PartQuantity;

                    if (CreateType == "1")
                    {
                        var PRS_BlankingRecord         = new PRS_BlankingRecordService();
                        PRS_BlankingRecord blankRecode = new PRS_BlankingRecord();
                        blankRecode = PRS_BlankingRecord.GetModel(ParamQuery.Instance().AndWhere("PartCode", PartCode).AndWhere("IsEnable", 1));

                        if (blankRecode == null)
                        {
                            res = db.Insert("PRS_BlankingRecord")
                                  .Column("ContractCode", ContractCode)
                                  .Column("InventoryCode", SetMateName)
                                  .Column("PartCode", PartCode)
                                  .Column("FigureCode", FigureCode)
                                  .Column("PartName", PartName)
                                  .Column("IsEnable", 1)
                                  .Column("SingleQuantity", PartQuantity)
                                  .Column("TotalQuantity", total)
                                  .Column("MaterialCode", MaterialCode)
                                  .Column("InPlanceSize", InPlanceSize)
                                  .Column("BlankingSize", BlankingSize)
                                  .Column("BlankedQuantity", 0)
                                  .Column("NoBlankingQuantity", total)
                                  .Column("CreateTime", DateTime.Now)
                                  .Column("CreatePerson", MmsHelper.GetUserName())
                                  .Column("ModifyTime", DateTime.Now)
                                  .Column("ModifyPerson", MmsHelper.GetUserName()).Execute();
                            if (res <= 0)
                            {
                                db.Rollback();
                                return(0);
                            }
                        }
                        else
                        {
                            res = db.Update("PRS_BlankingRecord")
                                  .Column("InventoryCode", SetMateName)
                                  .Column("SingleQuantity", PartQuantity)
                                  .Column("TotalQuantity", total)
                                  .Column("InPlanceSize", InPlanceSize)
                                  .Column("BlankingSize", BlankingSize)
                                  .Column("MaterialCode", MaterialCode)
                                  .Column("ModifyTime", DateTime.Now)
                                  .Column("ModifyPerson", MmsHelper.GetUserName())
                                  .Where("PartCode", PartCode).Execute();
                            if (res <= 0)
                            {
                                db.Rollback();
                                return(0);
                            }
                        }
                    }

                    //if (BlankingType == 1 || BlankingType == 2)
                    //{
                    //    DateTime newDT = DateTime.Now;
                    //    MES_BN_ProductProcessRoute oldPPR = db.Sql(string.Format(@"SELECT * FROM dbo.MES_BN_ProductProcessRoute WHERE IsEnable = 1 AND PartCode = '{0}' AND ProcessModelType = '1' AND ProcessLineCode =1", PartCode)).QuerySingle<MES_BN_ProductProcessRoute>();
                    //    PMS_BN_Project project = db.Sql(string.Format(@"SELECT * FROM dbo.PMS_BN_Project WHERE IsEnable = 1 AND ContractCode ='{0}'", ContractCode)).QuerySingle<PMS_BN_Project>();
                    //    PRS_BD_StandardProcess standardProcessXL = db.Sql(@"SELECT * FROM dbo.PRS_BD_StandardProcess WHERE IsEnable = 1 AND ProcessName LIKE '切割%'").QuerySingle<PRS_BD_StandardProcess>();
                    //    PRS_BD_StandardProcess standardProcessJ = db.Sql(@"SELECT * FROM dbo.PRS_BD_StandardProcess WHERE IsEnable = 1 AND ProcessName LIKE '锯%'").QuerySingle<PRS_BD_StandardProcess>();
                    //    SYS_BN_Department departmentXL = db.Sql(@"SELECT * FROM dbo.SYS_BN_Department WHERE IsEnable = 1 AND DepartmentName LIKE '%大阀下料车间%'").QuerySingle<SYS_BN_Department>();
                    //    SYS_BN_Department departmentJ = db.Sql(@"SELECT * FROM dbo.SYS_BN_Department WHERE IsEnable = 1 AND DepartmentName LIKE '%大阀棒材库%'").QuerySingle<SYS_BN_Department>();

                    //    MES_BN_ProductProcessRoute newPPR = new MES_BN_ProductProcessRoute()
                    //    {
                    //        ContractCode = ContractCode,
                    //        ProjectName = project.ProjectName,
                    //        PartCode = PartCode,
                    //        ProcessCode = BlankingType.Equals(1) ? standardProcessXL.ProcessCode : standardProcessJ.ProcessCode,
                    //        ProcessName = BlankingType.Equals(1) ? standardProcessXL.ProcessName : standardProcessJ.ProcessName,
                    //        ProcessLineCode = 1,
                    //        WorkshopID = BlankingType.Equals(1) ? departmentXL.DepartmentCode : departmentJ.DepartmentCode,
                    //        WorkshopName = BlankingType.Equals(1) ? departmentXL.DepartmentName : departmentJ.DepartmentName,
                    //        FigureCode = FigureCode,
                    //        IsEnable = 1,
                    //        Unit = 1,
                    //        IsInspectionReport = 2,
                    //        CreatePerson = MmsHelper.GetUserName(),
                    //        CreateTime = newDT,
                    //        ModifyPerson = MmsHelper.GetUserName(),
                    //        ModifyTime = newDT,
                    //        ProcessModelType = "1"
                    //    };
                    //    PRS_ProcessWorkSteps prsStep = new PRS_ProcessWorkSteps()
                    //    {
                    //        ProcessRouteID = new MES_BN_ProductProcessRouteService().GetModelList().Count > 0 ?
                    //    new MES_BN_ProductProcessRouteService().GetModelList().Max(a => a.ID) + 1 : 1,
                    //        WorkStepsLineCode = 1,
                    //        //WorkStepsName = newPPR.ProcessName,
                    //        IsEnable = 1,
                    //        Unit = 0,
                    //        CreatePerson = MmsHelper.GetUserName(),
                    //        CreateTime = newDT,
                    //        ModifyPerson = MmsHelper.GetUserName(),
                    //        ModifyTime = newDT
                    //    };


                    //    string sqlPPR = string.Empty;
                    //    string sqlStep = string.Empty;

                    //    if (oldPPR == null)
                    //    {
                    //        sqlStep = WinFormClientService.GetInsertSQL(prsStep);
                    //        sqlPPR = WinFormClientService.GetInsertSQL(newPPR);
                    //    }
                    //    else
                    //    {
                    //        sqlPPR = WinFormClientService.GetUpdateSQL(oldPPR, newPPR);

                    //    }

                    //    if (db.Sql(sqlPPR).Execute() <= 0)
                    //    {
                    //        db.Rollback();
                    //        return 0;
                    //    }

                    //    if (!string.IsNullOrEmpty(sqlStep))
                    //    {
                    //        if (db.Sql(sqlStep).Execute() <= 0)
                    //        {
                    //            db.Rollback();
                    //            return 0;
                    //        }
                    //    }

                    //    string sqlA = string.Format(@"SELECT ISNULL(COUNT(ID),0) FROM dbo.MES_BN_ProductProcessRoute WHERE IsEnable = 1 AND PartCode = '{0}' AND ProcessModelType = '{1}'", PartCode, 1);
                    //    string sqlB = string.Format(@"UPDATE dbo.PRS_Process_BOM SET {0} = {1} WHERE PartCode = '{2}'", "Blanking", db.Sql(sqlA).QuerySingle<int>(), PartCode);

                    //    if (db.Sql(sqlB).Execute() <= 0)
                    //    {
                    //        db.Rollback();
                    //        return 0;
                    //    }
                    //}

                    db.Commit();
                    return(1);
                }
                catch (Exception ex)
                {
                    var msg = ex.Message;
                    db.Rollback();
                    return(0);
                }
            }
        }