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 ActionResult Edit(string id = "")
        {
            var data = new MES_MaterialReturnDetailApiController().GetPageData(id);

            var dpartment  = new SYS_BN_UserService().GetDepartmentInfo(MmsHelper.GetUserCode());
            var departid   = "";
            var departname = "";

            if (dpartment.DepartmentCode != null)
            {
                departid   = dpartment.DepartmentCode.ToString();
                departname = dpartment.DepartmentName;
            }
            string dtNow = DateTime.Now.ToString("yyyy-MM-dd");

            var model = new
            {
                urls = new
                {
                    getdata     = "/api/Mms/MES_MaterialReturnDetail/GetPageData/",    //获取主表数据及数据滚动数据api
                    edit        = "/api/Mms/MES_MaterialReturnDetail/edit/",           //数据保存api
                    audit       = "/api/Mms/MES_MaterialReturnDetail/audit/",          //审核api
                    newkey      = "/api/Mms/MES_MaterialReturnDetail/GetNewRowId/",    //获取新的明细数据的主键(日语叫采番)
                    storageSave = "/api/Mms/MES_MaterialReturnDetail/PostStorage/"
                },
                resx = new
                {
                    rejected    = "已撤消修改!",
                    editSuccess = "保存成功!",
                    auditPassed = "单据已通过审核!",
                    auditReject = "单据已取消审核!"
                },
                dataSource = new
                {
                    pageData = data
                               //payKinds = codeService.GetValueTextListByType("PayType")
                },
                form = new
                {
                    defaults = new MES_MaterialReturnMain().Extend(new
                    {
                        ID             = id,
                        BillCode       = data.form == null ? "系统生成" : data.form.BillCode,
                        PickBillCode   = "",
                        DepartmentID   = dpartment.DepartmentCode ?? "",
                        DepartmentName = dpartment.DepartmentName ?? "",
                        ReturnDate     = dtNow,
                        ContractCode   = "",
                        ProjectName    = "",
                        WarehouseCode  = "",
                        WarehouseName  = "",
                        Billstate      = 1,
                        IsEnable       = 1
                    }),
                    primaryKeys = new string[] { "ID" }
                },
                tabs = new object[] {
                    new{
                        type       = "grid",
                        rowId      = "ID",
                        relationId = "ID",

                        /*
                         * Unit VARCHAR(20) NULL
                         * Model VARCHAR(20) NULL
                         * Material VARCHAR(20) NUL
                         */
                        postFields = new string[] { "ID", "MainID", "ContractCode", "ProjectName", "InventoryCode", "InventoryName", "ReturnQuantity", "IsEnable", "Unit", "Model", "Material" },
                        defaults   = new { ID = "", MainID = id, ContractCode = "", ProjectName = "", InventoryCode = "", InventoryName = "", ReturnQuantity = "", IsEnable = 1, Unit = "", Model = "", Material = "" }
                    }
                }
            };

            return(View(model));
        }
        public dynamic GetEditMaster(string id)
        {
            var service = new mms_drainagehouseholdsService();

            return(new
            {
                form = service.GetModel(ParamQuery.Instance().AndWhere("BillNo", id)),
                scrollKeys = service.ScrollKeys("BillNo", id, ParamQuery.Instance().AndWhere("ProjectCode", MmsHelper.GetCurrentProject()))
            });
        }
Esempio n. 4
0
        // 删除 DELETE api/mms/send
        public virtual void Delete(string id)
        {
            var result = masterService.Delete(ParamDelete.Instance().Where("BillNo", id));

            MmsHelper.ThrowHttpExceptionWhen(result <= 0, "单据删除失败[BillNo={0}],请重试或联系管理员!", id);
        }
Esempio n. 5
0
 protected override bool OnBeforeEditForm(EditEventArgs arg)
 {
     arg.dataNew["ProjectCode"] = MmsHelper.GetCurrentProject();
     return(base.OnBeforeEditForm(arg));
 }
        public string GetCode()
        {
            string billcode = MmsHelper.GetOrderNumber("WMS_BN_TakeStockMain", "BillCode", "PDDH", "", "");

            return(billcode);
        }
        //自动生成出入库单
        public int PostBuild(string billCode, out string msg)
        {
            msg = string.Empty;
            var    rowsAffected = 0;
            string sql          = String.Format(@"    select MAX(t1.BillState) as BillState,t2.WarehouseCode,max(t2.WarehouseName) as WarehouseName,t2.InventoryCode,max(t2.InventoryName) as InventoryName,sum(t2.DValue) as DValue from WMS_BN_TakeStockMain as t1
inner join WMS_BN_TakeStockDetail as t2 on t1.BillCode=t2.BillCode where t1.BillCode='{0}' 
group by t2.WarehouseCode,t2.Inventorycode", billCode);
            var    list         = db.Sql(sql).QueryMany <dynamic>();
            var    res          = list[1].DValue;

            if (list[0].BillState == 2)
            {
                msg = "已锁定的数据不能重复提交!";
                return(0);
            }
            db.UseTransaction(true);
            foreach (var item in list)
            {
                res = item.DValue;
                WMS_BN_BillMain master = new WMS_BN_BillMain();
                if (item.DValue > 0)
                {
                    master.BillType      = 6;
                    master.WarehouseCode = item.WarehouseCode;
                    master.WarehouseName = item.WarehouseName;
                    master.Remark        = "盘盈入库";
                }
                else if (item.DValue < 0)
                {
                    master.BillType      = 7;
                    master.WarehouseCode = item.WarehouseCode;
                    master.WarehouseName = item.WarehouseName;
                    master.Remark        = "盘亏出库";
                }
                else
                {
                    continue;
                }
                var sc = new sys_codeService().Getsys_codeByTypeAndID("BillType", Convert.ToInt16(master.BillType));
                master.BillCode     = MmsHelper.GetOrderNumber("WMS_BN_BillMain", "BillCode", sc.Description, "", "");
                master.CreateTime   = DateTime.Now;
                master.CreatePerson = MmsHelper.GetUserName();

                rowsAffected = db.Sql(@"insert into WMS_BN_BillMain (BillCode,BillType,WarehouseCode,WarehouseName,Remark,
CreatePerson,CreateTime) values(@0,@1,@2,@3,@4,@5,@6)", master.BillCode, master.BillType,
                                      master.WarehouseCode, master.WarehouseName, master.Remark, master.CreatePerson, master.CreateTime).Execute();
                if (rowsAffected < 0)
                {
                    db.Rollback();
                    return(rowsAffected);
                }

                var detailList = (from p in list where p.WarehouseCode == item.WarehouseCode select p).ToList();
                foreach (var it in detailList)
                {
                    WMS_BN_BillDetail detail = new WMS_BN_BillDetail();
                    detail.PBillCode     = billCode;
                    detail.BillCode      = master.BillCode;
                    detail.InventoryCode = it.InventoryCode;
                    detail.InventoryName = it.InventoryName;

                    detail.MateNum    = Math.Abs(item.DValue);
                    detail.ConfirmNum = Math.Abs(item.DValue);

                    rowsAffected = db.Insert <WMS_BN_BillDetail>("WMS_BN_BillDetail", detail)
                                   .AutoMap(x => x.ID)
                                   .Execute();
                    if (rowsAffected < 0)
                    {
                        db.Rollback();
                        return(rowsAffected);
                    }
                }
            }
            sql          = string.Format(@"update WMS_BN_TakeStockMain set BillState='2' where BillCode='{0}'", billCode);
            rowsAffected = db.Sql(sql).Execute();

            if (rowsAffected < 0)
            {
                db.Rollback();
                return(rowsAffected);
            }
            msg = "操作成功!";
            db.Commit();

            return(rowsAffected);
        }
        public string GetCode()
        {
            string documentNo = MmsHelper.GetOrderNumber("SYS_BN_Supplier", "SupplierCode", "GYBH", "", "");

            return(documentNo);
        }
        public void Edit(dynamic data)
        {
            var service = new MES_MaterialPickMainService();

            if (data.form["BillCode"] != "系统生成")
            {
                var pQuery = ParamQuery.Instance().Select("*").AndWhere("ID", data.form["ID"]);
                MES_MaterialPickMain model = service.GetModel(pQuery);
                if (model.BillState != null && model.BillState == 2)
                {
                    MmsHelper.ThrowHttpExceptionWhen(true, "已发布的不能修改!");
                    return;
                }
            }
            var ids = "(";

            foreach (JToken tab in data["tabs"].Children())
            {
                foreach (JProperty item in tab.Children())
                {
                    if (item.Name == "deleted")
                    {
                        foreach (var row in item.Value.Children())
                        {
                            ids += "'" + row["ID"] + "',";
                        }
                        item.Value = "[]";
                    }
                }
            }
            if (ids != "(")
            {
                ids  = ids.Remove(ids.Length - 1, 1);
                ids += ")";
                using (var db = Db.Context("Mms"))
                {
                    string sql1 = string.Format("update MES_MaterialPickDetail set IsEnable=0 where ID in {0} ", ids);
                    db.Sql(sql1).Execute();
                }
            }

            var formWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>
        MES_MaterialPickMain
    </table>
    <where>
        <field name='ID' cp='equal'></field>
    </where>
</settings>
");



            var tabsWrapper = new List <RequestWrapper>();

            tabsWrapper.Add(RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>MES_MaterialPickDetail</table>
    <where>
        <field name='ID' cp='equal'></field>      
    </where>
</settings>"));

            if (data.form["BillCode"] == "系统生成")
            {
                string documentNo = MmsHelper.GetOrderNumber("MES_MaterialPickMain", "BillCode", "CJLL", "", "");
                data.form["BillCode"] = documentNo;
            }
            var result = service.EditPage(data, formWrapper, tabsWrapper);
        }
Esempio n. 10
0
        public string GetWarehouseCode()
        {
            string documentNo = MmsHelper.GetOrderNumber("SYS_BN_Warehouse", "WarehouseCode", "CKBH", "", "");

            return(documentNo);
        }
Esempio n. 11
0
        public string GetBillCode()
        {
            string documentNo = MmsHelper.GetOrderNumber("PRS_DesignChangeRequest", "RequestCode", "GGSQ", "", "");

            return(documentNo);
        }
Esempio n. 12
0
        public void Edit(dynamic data)
        {
            dynamic depart = new SYS_BN_UserService().GetDepartment(MmsHelper.GetUserCode());
            string  code   = string.Empty;
            string  name   = string.Empty;

            if (depart != null)
            {
                code = depart.DepartmentCode;
                name = depart.DepartmentName;
            }

            if (data.form["TeamCode"] == "系统生成")
            {
                if (data.form["TeamName"] == "")
                {
                    MmsHelper.ThrowHttpExceptionWhen(true, "班组名称不能为空!", 0);
                    return;
                }
                string documentNo = MmsHelper.GetOrderNumber("SYS_WorkGroup", "BillCode", code, "", "");
                data.form["BillCode"] = documentNo;
                documentNo            = documentNo.Replace(DateTime.Now.ToString("yyMMdd") + "0", "");
                data.form["TeamCode"] = documentNo;
            }
            foreach (JToken tab in data["tabs"].Children())
            {
                foreach (JProperty item in tab.Children())
                {
                    if (item.Name == "deleted")
                    {
                        continue;
                    }
                    foreach (var row in item.Value.Children())
                    {
                        var pQuery = ParamQuery.Instance().Select("ID").AndWhere("UserCode", row["UserCode"]).AndWhere("IsEnable", 1);
                        var re     = new SYS_WorkGroupDetailService().GetModel(pQuery);
                        if (re != null)
                        {
                            if (re.ID > 0)
                            {
                                MmsHelper.ThrowHttpExceptionWhen(true, "员工" + row["UserName"] + "已在别的班组!", 0);
                                return;
                            }
                        }
                    }
                }
            }
            var formWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>
        SYS_WorkGroup
    </table>
    <where>
        <field name='ID' cp='equal'></field>
    </where>
</settings>
");

            var tabsWrapper = new List <RequestWrapper>();

            tabsWrapper.Add(RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>SYS_WorkGroupDetail</table>
    <where>
        <field name='ID' cp='equal'></field>      
    </where>
</settings>"));

            var service = new SYS_WorkGroupService();
            var result  = service.EditPage(data, formWrapper, tabsWrapper);
        }
Esempio n. 13
0
        public ActionResult Edit(string id)
        {
            var userName       = MmsHelper.GetUserName();
            var currentProject = MmsHelper.GetCurrentProject();
            var data           = new RealdataApiController().GetEditMaster(id);
            var codeService    = new sys_codeService();

            var model = new
            {
                form       = data.form,
                scrollKeys = data.scrollKeys,
                urls       = new
                {
                    getdetail = "/api/mms/realdata/getdetail/",
                    getmaster = "/api/mms/realdata/geteditmaster/",
                    edit      = "/api/mms/realdata/edit/",
                    audit     = "/api/mms/realdata/audit/",
                    getrowid  = "/mms/realdata/getnewrowid/",
                    report    = "realdata"
                },
                resx = new
                {
                    rejected    = "已撤消修改!",
                    editSuccess = "保存成功!",
                    auditReject = "信息已取消审核!",
                    auditPassed = "信息已通过审核"
                },
                dataSource = new
                {
                    AdministrativeArea = codeService.Decode("AdministrativeArea"),
                    FacilityStatus     = codeService.Decode("FacilityStatus"),
                    warehouseItems     = new mms_warehouseService().GetWarehouseItems(currentProject)
                },

                defaultForm = new mms_realdata().Extend(new
                {
                    BillNo               = id,
                    OrgX                 = "",
                    OrgY                 = "",
                    IdentificationCode   = "",
                    DrainageCode         = "",
                    RiversName           = "",
                    Category             = "",
                    Name                 = "",
                    GateOpening1         = "",
                    GateOpening2         = "",
                    GateOpening3         = "",
                    GateOpening4         = "",
                    GateOpening5         = "",
                    GateOpening6         = "",
                    GateOpening7         = "",
                    GateOpening8         = "",
                    UpstreamWaterLevel   = "",
                    DownstreamWaterLevel = "",
                    ControlIP            = "",
                    VideoIP              = "",
                    Rainfall             = "",
                    RiverWaterLevel      = "",
                    FacilityStatus       = codeService.GetDefaultCodeNew("FacilityStatus"),
                    DataSources          = codeService.GetDefaultCodeNew("DataSources"),
                    ReportingUnit        = "",
                    Remark               = "",
                    AdministrativeArea   = codeService.GetDefaultCodeNew("AdministrativeArea")
                }),

                setting = new
                {
                    postFormKeys = new string[] { "BillNo" }
                }
            };

            return(View(model));
        }
Esempio n. 14
0
        public string GetApsCode()
        {
            string documentNo = MmsHelper.GetOrderNumber("APS_ProjectProduceDetial", "ApsCode", "SCJH", "", "");

            return(documentNo);
        }
Esempio n. 15
0
        public ActionResult Edit(string id)
        {
            var userName       = MmsHelper.GetUserName();
            var currentProject = MmsHelper.GetCurrentProject();
            var data           = new DrainpipeApiController().GetEditMaster(id);
            var codeService    = new sys_codeService();

            var model = new
            {
                form       = data.form,
                scrollKeys = data.scrollKeys,
                urls       = new
                {
                    getdetail = "/api/mms/drainpipe/getdetail/",
                    getmaster = "/api/mms/drainpipe/geteditmaster/",
                    edit      = "/api/mms/drainpipe/edit/",
                    audit     = "/api/mms/drainpipe/audit/",
                    getrowid  = "/mms/drainpipe/getnewrowid/"
                },
                resx = new
                {
                    rejected    = "已撤消修改!",
                    editSuccess = "保存成功!",
                    auditReject = "信息已取消审核!",
                    auditPassed = "信息已通过审核"
                },
                dataSource = new
                {
                    Category           = codeService.Decode("InspectionWellCategory"),
                    AdministrativeArea = codeService.Decode("AdministrativeArea"),
                    LiningMaterial     = codeService.Decode("PipeLiningMaterial"),
                    Material           = codeService.Decode("PipeMaterial"),
                    PressureType       = codeService.Decode("PipePressureType"),
                    FacilityStatus     = codeService.Decode("FacilityStatus"),
                    warehouseItems     = new mms_warehouseService().GetWarehouseItems(currentProject)
                },

                defaultForm = new mms_drainpipe().Extend(new
                {
                    BillNo             = id,
                    IdentificationCode = "",
                    DrainageCode       = "",
                    Address            = "",
                    Start_stopPoint    = "",
                    Category           = codeService.GetDefaultCodeNew("InspectionWellCategory"),
                    Length             = "",
                    StartCode          = "",
                    StopCode           = "",
                    StartElevation     = "",
                    StopElevation      = "",
                    Diameter           = "",
                    Material           = codeService.GetDefaultCodeNew("PipeMaterial"),
                    PressureType       = codeService.GetDefaultCodeNew("PipePressureType"),
                    LiningMaterial     = codeService.GetDefaultCodeNew("PipeLiningMaterial"),
                    LiningThick        = "",
                    Slope              = "",
                    Siphon             = "",
                    OwnershipUnit      = "",
                    FacilityStatus     = codeService.GetDefaultCodeNew("FacilityStatus"),
                    DataSources        = codeService.GetDefaultCodeNew("DataSources"),
                    ReportingUnit      = "",
                    Remark             = "",
                    AdministrativeArea = codeService.GetDefaultCodeNew("AdministrativeArea")
                }),

                setting = new
                {
                    postFormKeys = new string[] { "BillNo" }
                }
            };

            return(View(model));
        }
Esempio n. 16
0
        public ActionResult Edit(string id)
        {
            var userName       = MmsHelper.GetUserName();
            var currentProject = MmsHelper.GetCurrentProject();
            var data           = new FloodareaApiController().GetEditMaster(id);
            var codeService    = new sys_codeService();

            var model = new
            {
                form       = data.form,
                scrollKeys = data.scrollKeys,
                urls       = new
                {
                    getdetail = "/api/mms/floodarea/getdetail/",
                    getmaster = "/api/mms/floodarea/geteditmaster/",
                    edit      = "/api/mms/floodarea/edit/",
                    audit     = "/api/mms/floodarea/audit/",
                    getrowid  = "/mms/floodarea/getnewrowid/"
                },
                resx = new
                {
                    rejected    = "已撤消修改!",
                    editSuccess = "保存成功!",
                    auditReject = "信息已取消审核!",
                    auditPassed = "信息已通过审核"
                },
                dataSource = new
                {
                    AdministrativeArea = codeService.Decode("AdministrativeArea"),
                    FacilityStatus     = codeService.Decode("FacilityStatus"),
                    warehouseItems     = new mms_warehouseService().GetWarehouseItems(currentProject)
                },

                defaultForm = new mms_drainpipe().Extend(new
                {
                    BillNo             = id,
                    IdentificationCode = "",
                    Region             = "",
                    Address            = "",
                    Type                  = "",
                    ReportedArea          = "",
                    ActualArea            = "",
                    MaximumWaterDepth     = "",
                    Watertime             = "",
                    WaterLong             = "",
                    WaterCause            = "",
                    InfluenceDegree       = "",
                    RemediationMeasures   = "",
                    PlannedCompletionTime = "",
                    PlanInvestment        = "",
                    OwnershipUnit         = "",
                    FacilityStatus        = codeService.GetDefaultCodeNew("FacilityStatus"),
                    DataSources           = codeService.GetDefaultCodeNew("DataSources"),
                    ReportingUnit         = "",
                    Remark                = "",
                    AdministrativeArea    = codeService.GetDefaultCodeNew("AdministrativeArea")
                }),

                setting = new
                {
                    postFormKeys = new string[] { "BillNo" }
                }
            };

            return(View(model));
        }
        public void Edit(dynamic data)
        {
            var serviceMain     = new WMS_BN_TakeStockMainService();
            var formWrapperMain = RequestWrapper.Instance().LoadSettingXmlString(@"
            <settings>
                <table>
                    WMS_BN_TakeStockMain
                </table>
                <where>
                    <field name='ID' cp='equal'></field>
                </where>
            </settings>
            ");

            var formWrapperDetail = RequestWrapper.Instance().LoadSettingXmlString(@"
                <settings>
                    <table>
                        WMS_BN_TakeStockDetail
                    </table>
                    <where>
                        <field name='ID' cp='equal'></field>
                    </where>
                </settings>
                ");

            //.GetNewKey("ID", "maxplus");
            //判断当前是否首次保存首次保存产生单号
            //var currentID = data["form"]["ID"];
            //var pQuery = ParamQuery.Instance().AndWhere("ID", currentID);
            //var currentInfo = serviceMain.GetModel(pQuery);

            //dynamic qm = new
            //{
            //    month = data["form"]["TakeStockYear"],
            //    year = data["form"]["TakeStockYear"]
            //};
            //if (currentInfo == null)
            //{

            //    var code = serviceMain.GetMaxBillCode(qm);
            //    data["form"]["BillCode"] = code;
            //}

            //判断是否是新增,是的话就判断一个月只能保存一条盘点数据
            dynamic qm = new
            {
                month = data["form"]["TakeStockMonth"],
                year  = data["form"]["TakeStockYear"]
            };

            if (qm.month != null || qm.year != null)
            {
                if (serviceMain.GetTakeStock(Convert.ToInt32(qm.year), Convert.ToInt32(qm.month)) > 0)
                {
                    MmsHelper.ThrowHttpExceptionWhen(true, "一个月只能生成一次盘点!", "");
                }
            }
            var tabsWrapper = new List <RequestWrapper>();

            tabsWrapper.Add(formWrapperDetail);
            var service = new WMS_BN_TakeStockDetailService();
            var result  = service.EditPage(data, formWrapperMain, tabsWrapper);
        }
Esempio n. 18
0
        public int AuditBillCode(string mainID, out string msg)
        {
            msg = string.Empty;
            var    rowsAffected = 0;
            string insertSql    = string.Empty;
            string sql          = String.Format(@"  SELECT t1.*,
       t2.MainID,
       t2.InventoryCode,
       t2.InventoryName,
	   t2.ArrivalQuatity,
       t2.Model,
       t2.Unit,
       t2.Material
FROM MES_GoodsInspection t1
    LEFT JOIN MES_GoodsInspectionDetail t2
        ON t1.ID = t2.MainID
           AND t1.IsEnable = 1
           AND t2.IsEnable = 1 where t1.ID='{0}'", mainID);
            var    resList      = db.Sql(sql).QueryMany <dynamic>();

            if (resList.Count == 0)
            {
                msg = "请先保存单据后再审核";
                return(0);
            }
            if (resList[0].BillState == 2)
            {
                msg = "单据已审核";
                return(0);
            }
            else
            {
                db.UseTransaction(true);
                sql          = string.Format(@"update MES_GoodsInspection set BillState=2 where ID='{0}'", mainID);
                rowsAffected = db.Sql(sql).Execute();
                if (rowsAffected > 0)
                {
                    sql = string.Format(@"select ID from MES_PurchaseOrderMain where BillCode='{0}'", resList[0].PurchaseOrderCode);
                    int mID = db.Sql(sql).QuerySingle <int>();
                    sql = string.Empty;
                    var           dno = MmsHelper.GetOrderNumber("QMS_GoodsCheck", "BillCode", "LLJY", "", "");
                    var           fno = dno.Substring(0, 10);
                    var           con = dno.Substring(10, 3);
                    StringBuilder sb  = new StringBuilder();
                    foreach (var item in resList)
                    {
                        dno = fno + con;
                        int intCon = Convert.ToInt32(con);
                        intCon++;
                        var zeros = 3 - intCon.ToString().Length;
                        con = "";
                        for (int i = 1; i <= zeros; i++)
                        {
                            con += "0";
                        }
                        con += intCon.ToString();
                        sql  = sql + string.Format(@" update MES_PurchaseOrderDetail set GoodsQuantity=ISNULL(GoodsQuantity,0)+ abs({0}) where MainID='{1}' and InventoryCode='{2}' ", item.ArrivalQuatity, mID, item.InventoryCode);
                        sb.Append(string.Format(@"INSERT INTO dbo.QMS_GoodsCheck
(
    ID,
    PBillCode,
    BillCode,
    ContractCode,
    ProjectName,
    SupplierCode,
    SupplierName,
    DepartmentID,
    DepartmentName,
    WarehouseID,
    WarehouseName,
    ProductionUnits,
    InventoryCode,
    InventoryName,
    Model,
    ArrivalDate,
    CheckQuantity,
    QualifiedQuantity,
    Unit,
    SalesmanCode,
    Salesman,
    BatchCode,
    BillState,
    IsEnable,
    CreatePerson,
    CreateTime,
    ModifyPerson,
    ModifyTime,
    Material,
    InspectionQuantity
)
VALUES
(   (select MAX(id)+1 from QMS_GoodsCheck),         -- ID - int
    '{0}',        -- PBillCode - varchar(50)
    '{1}',        -- BillCode - varchar(50)
    '{2}',        -- ContractCode - varchar(50)
    '{3}',        -- ProjectName - varchar(50)
    '{4}',        -- SupplierCode - varchar(50)
    '{5}',        -- SupplierName - varchar(50)
    '{6}',        -- DepartmentID - varchar(50)
    '{7}',        -- DepartmentName - varchar(50)
    '{8}',        -- WarehouseID - varchar(50)
    '{9}',        -- WarehouseName - varchar(50)
    '{10}',        -- ProductionUnits - varchar(50)
    '{11}',        -- InventoryCode - varchar(50)
    '{12}',        -- InventoryName - varchar(50)
    '{13}',        -- Model - varchar(50)
    '{14}', -- ArrivalDate - datetime
    '{15}',         -- CheckQuantity - int
    '{16}',         -- QualifiedQuantity - int
    '{17}',        -- Unit - varchar(50)
    '{18}',        -- SalesmanCode - varchar(50)
    '{19}',        -- Salesman - varchar(50)
    '',        -- BatchCode - varchar(50)
    1,         -- BillState - int
    1,         -- IsEnable - int
    '{20}',        -- CreatePerson - varchar(50)
    GETDATE(), -- CreateTime - datetime
    '{21}',        -- ModifyPerson - varchar(50)
    GETDATE(), -- ModifyTime - datetime
    '{22}',        -- Material - varchar(50)
    '{23}'          -- InspectionQuantity - int
    )", item.BillCode, dno, item.ContractCode, item.ProjectName, item.SupplierCode, item.SupplierName, item.DepartmentID, item.DepartmentName,
                                                item.WarehouseID, item.WarehouseName, "", item.InventoryCode, item.InventoryName, item.Model, item.ArrivalDate, item.ArrivalQuatity, item.ArrivalQuatity,
                                                item.Unit, item.SaleMan, item.UserCode, MmsHelper.GetUserName(), MmsHelper.GetUserName(), item.Material, item.ArrivalQuatity));
                    }
                    int res = db.Sql(sb.ToString()).Execute();
                    rowsAffected = db.Sql(sql).Execute();
                    if (rowsAffected > 0 && res == resList.Count)
                    {
                        msg = "操作成功";
                        db.Commit();
                        return(rowsAffected);
                    }
                    else
                    {
                        msg = "操作失败";
                        db.Rollback();
                        return(0);
                    }
                    //return rowsAffected;
                }
                else
                {
                    msg = "采购订单审核失败";
                    db.Rollback();
                    return(0);
                }

                //sql = string.Format(@"update APS_ProductPurchaseMain set BillState=2 where PurchaseDocumentCode='{0}'", res.ProductPurchaseCode);
            }
        }
        //自动生成盘点单
        public int PostBuildPD(int year, int month, int tackStockType, out string msg)
        {
            msg = string.Empty;
            var    rowsAffected = 0;
            string sql          = String.Format(@"select * from WMS_BN_TakeStockMain where TakeStockYear='{0}' and TakeStockMonth='{1}'", year, month);
            var    isExit       = db.Sql(sql).QuerySingle <int>();

            if (isExit > 0)
            {
                msg = "一个月只能生成一次盘点!";
                return(0);
            }
            var list = db.Sql(@"select t1.InventoryCode,MAX( t1.InventoryName) InventoryName,t2.WarehouseCode,MAX( t2.WarehouseName) WarehouseName,isnull( SUM( t2.RealStock),0) TakeStockNum from SYS_Part as t1
  inner join  WMS_BN_RealStock as t2 on t1.InventoryCode=t2.InventoryCode
  group by t1.InventoryCode,t2.WarehouseCode
  ").QueryMany <dynamic>();

            if (list.Count <= 0)
            {
                msg = "没有数据!";
                return(0);
            }

            db.UseTransaction(true);
            WMS_BN_TakeStockMain master = new WMS_BN_TakeStockMain();

            master.BillCode       = MmsHelper.GetOrderNumber("WMS_BN_TakeStockMain", "BillCode", "PDDH", "", "");
            master.TakeStockYear  = year;
            master.TakeStockMonth = month;
            master.BillState      = 1;
            master.TakeStockType  = tackStockType;
            master.CreateTime     = DateTime.Now;
            master.CreatePerson   = MmsHelper.GetUserName();

            rowsAffected = db.Sql(@"insert into WMS_BN_TakeStockMain (BillCode,TakeStockYear,TakeStockMonth,TakeStockType,BillState,CreateTime,CreatePerson) 
values(@0,@1,@2,@3,@4,@5,@6)", master.BillCode, master.TakeStockYear,
                                  master.TakeStockMonth, master.TakeStockType, master.BillState, master.CreateTime, master.CreatePerson).Execute();

            if (rowsAffected < 0)
            {
                db.Rollback();
                return(rowsAffected);
            }
            sql = String.Format(@"select * from WMS_BN_TakeStockMain where BillCode = '{0}'", master.BillCode);
            dynamic next = db.Sql(sql).QuerySingle <dynamic>();//

            foreach (var item in list)
            {
                WMS_BN_TakeStockDetail detail = new WMS_BN_TakeStockDetail();
                detail.BillCode      = next.BillCode;
                detail.InventoryCode = item.InventoryCode;
                detail.InventoryName = item.InventoryName;
                detail.WarehouseCode = item.WarehouseCode;
                detail.WarehouseName = item.WarehouseName;
                detail.TakeStockNum  = item.TakeStockNum;


                rowsAffected = db.Insert <WMS_BN_TakeStockDetail>("WMS_BN_TakeStockDetail", detail)
                               .AutoMap(x => x.ID)
                               .Execute();
                if (rowsAffected < 0)
                {
                    db.Rollback();
                    return(rowsAffected);
                }
            }

            msg = "操作成功!";
            db.Commit();
            return(rowsAffected);
        }
Esempio n. 20
0
        public int AuditBillCode(string BillCode, out string msg)
        {
            msg = string.Empty;

            var     rowsAffected = 0;
            string  sql          = String.Format(@"SELECT t1.*,
       t2.InventoryCode,
       t2.InventoryName,
       t2.RequiredQuantity,
       t2.Model,
       t2.Unit,
       t2.Material
      
FROM dbo.MES_MaterialPickMain t1
    INNER JOIN dbo.MES_MaterialPickDetail t2
        ON t1.ID = t2.MainID
           AND t1.IsEnable = 1
           AND t2.IsEnable = 1
 where t1.BillCode='{0}'", BillCode);
            string  insertSql    = "";
            dynamic MaterialPick = db.Sql(sql).QueryMany <dynamic>();

            if (MaterialPick.Count == 0)
            {
                msg = "请保存数据后审核";
                return(0);
            }
            if (MaterialPick[0].BillState == 2)
            {
                msg = "单据已审核";
                return(0);
            }
            else
            {
                using (var trans = db.UseTransaction(true))
                {
                    sql          = string.Format(@"update MES_MaterialPickMain set BillState=2 where BillCode='{0}'", BillCode);
                    rowsAffected = db.Sql(sql).Execute();
                    var dno = MmsHelper.GetOrderNumber("WMS_BN_BillMain", "BillCode", "LLCK", "", "");
                    insertSql = string.Format(@" INSERT dbo.WMS_BN_BillMain
	(
	    ID,
	    BillCode,
	    BillType,
	    ContractCode,
	    ProjectName,
	    DepartmentID,
	    DepartmentName,
	    WarehouseCode,
	    WarehouseName,
	    ApproveState,
	    Remark,
	    CreatePerson,
	    CreateTime,
	    ModifyPerson,
	    ModifyTime,
	    IsEnable,
        PickPerson,
        PickPersonCode
	)
	VALUES
	(   (select MAX(id)+1 from WMS_BN_BillMain),         -- ID - int                                         ID,
	    '{0}',        -- BillCode - varchar(50)                                                             BillCode,
	    ( SELECT Value FROM HBHC_Sys.dbo.sys_code WHERE Text='领料出库' ),                                  --BillType,
	   '{1}','{2}','{3}','{4}','{5}','{6}',1,'','{7}','{8}','{9}','{10}',1,'{11}','{12}'           
	    )"    , dno, MaterialPick[0].ContractCode, MaterialPick[0].ProjectName, MaterialPick[0].DepartmentID, MaterialPick[0].DepartmentName,
                                              MaterialPick[0].WarehouseCode, MaterialPick[0].WarehouseName, MmsHelper.GetUserName(), DateTime.Now, MmsHelper.GetUserName(), DateTime.Now, MmsHelper.GetUserName(), MmsHelper.GetUserCode());
                    foreach (var item in MaterialPick)
                    {
                        insertSql += string.Format(@"INSERT INTO dbo.WMS_BN_BillDetail
(
    BillCode,
    InventoryCode,
    InventoryName,
    Specs,
    Unit,
    MateNum,
    ConfirmNum,
    PBillCode,
    Remark,
    CreatePerson,
    CreateTime,
    ModifyPerson,
    ModifyTime,
    IsEnable
)
VALUES
(   '{0}',        -- BillCode - varchar(50)
    N'{1}',       -- InventoryCode - nvarchar(50)
    N'{2}',       -- InventoryName - nvarchar(50)
    '{3}',        -- Specs - varchar(50)
    N'{4}',       -- Unit - nvarchar(10)
    '{5}',       -- MateNum - float
    '{6}',       -- ConfirmNum - float
    '{7}',        -- PBillCode - varchar(50)
    N'',       -- Remark - nvarchar(500)
    N'{8}',       -- CreatePerson - nvarchar(50)
    GETDATE(), -- CreateTime - datetime
    N'{9}',       -- ModifyPerson - nvarchar(50)
    GETDATE(), -- ModifyTime - datetime
    1          -- IsEnable - int
    )", dno, item.InventoryCode, item.InventoryName, item.Model, item.Unit, item.RequiredQuantity,
                                                   item.RequiredQuantity, item.BillCode, MmsHelper.GetUserName(), MmsHelper.GetUserName());
                    }

                    var res = db.Sql(insertSql).Execute();
                    if (rowsAffected > 0 && res == MaterialPick.Count + 1)
                    {
                        msg = "检验记录审核成功";
                        trans.Commit();
                        return(rowsAffected);
                    }
                    else
                    {
                        trans.Rollback();
                        msg = "检验记录审核失败";
                        return(0);
                    }
                }
            }
        }
        public string GetCode()
        {
            string documentNo = MmsHelper.GetOrderNumber("SYS_BN_User", "UserCode", "YGBH", "", "");

            return(documentNo);
        }
        public ActionResult Edit(string id)
        {
            var userName       = MmsHelper.GetUserName();
            var currentProject = MmsHelper.GetCurrentProject();
            var data           = new InspectionwellApiController().GetEditMaster(id);
            var codeService    = new sys_codeService();

            var model = new
            {
                form       = data.form,
                scrollKeys = data.scrollKeys,
                urls       = new
                {
                    getdetail = "/api/mms/inspectionwell/getdetail/",
                    getmaster = "/api/mms/inspectionwell/geteditmaster/",
                    edit      = "/api/mms/inspectionwell/edit/",
                    audit     = "/api/mms/inspectionwell/audit/",
                    getrowid  = "/mms/inspectionwell/getnewrowid/",
                    report    = "inspectionwell"
                },
                resx = new
                {
                    rejected    = "已撤消修改!",
                    editSuccess = "保存成功!",
                    auditReject = "信息已取消审核!",
                    auditPassed = "信息已通过审核"
                },
                dataSource = new
                {
                    Category           = codeService.Decode("InspectionWellCategory"),
                    Type               = codeService.Decode("InspectionWellType"),
                    Form               = codeService.Decode("InspectionWellForm"),
                    AdministrativeArea = codeService.Decode("AdministrativeArea"),
                    CoverMaterial      = codeService.Decode("InspectionWellCoverMaterial"),
                    CoverSharp         = codeService.Decode("InspectionWellCoverSharp"),
                    WellType           = codeService.Decode("InspectionWellwelltype"),
                    BottomType         = codeService.Decode("InspectionWellBottomType"),
                    AntifallNet        = codeService.Decode("AdditionalFacilities"),
                    AntifallNetStatus  = codeService.Decode("AdditionalFacilitiesStatus"),
                    WellLevel          = codeService.Decode("InspectionWellLevel"),
                    FacilityStatus     = codeService.Decode("FacilityStatus"),
                    warehouseItems     = new mms_warehouseService().GetWarehouseItems(currentProject)
                },

                defaultForm = new mms_inspectionwell().Extend(new
                {
                    BillNo             = id,
                    OrgX               = "",
                    OrgY               = "",
                    IdentificationCode = "",
                    DrainageCode       = "",
                    Address            = "",
                    Category           = codeService.GetDefaultCodeNew("InspectionWellCategory"),
                    Type               = codeService.GetDefaultCodeNew("InspectionWellType"),
                    Form               = codeService.GetDefaultCodeNew("InspectionWellForm"),
                    Depth              = "",
                    GroundElevation    = "",
                    CoverMaterial      = codeService.GetDefaultCodeNew("InspectionWellCoverMaterial"),
                    CoverSharp         = codeService.GetDefaultCodeNew("InspectionWellCoverSharp"),
                    CoverSize          = "",
                    WellType           = codeService.GetDefaultCodeNew("InspectionWellwelltype"),
                    WellLength         = "",
                    WellWidth          = "",
                    WellDiameter       = "",
                    WellHeight         = "",
                    OrgWaterDepth      = "",
                    OrgDirtDepth       = "",
                    BottomType         = codeService.GetDefaultCodeNew("InspectionWellBottomType"),
                    AntifallNet        = codeService.GetDefaultCodeNew("AdditionalFacilities"),
                    AntifallNetStatus  = codeService.GetDefaultCodeNew("AdditionalFacilitiesStatus"),
                    WellLevel          = codeService.GetDefaultCodeNew("InspectionWellLevel"),
                    FacilityStatus     = codeService.GetDefaultCodeNew("FacilityStatus"),
                    DataSources        = codeService.GetDefaultCodeNew("DataSources"),
                    ReportingUnit      = "",
                    Remark             = "",
                    AdministrativeArea = codeService.GetDefaultCodeNew("AdministrativeArea")
                }),

                setting = new
                {
                    postFormKeys = new string[] { "BillNo" }
                }
            };

            return(View(model));
        }
Esempio n. 23
0
        public string GetFailureReportCode( )
        {
            string documentNo = MmsHelper.GetOrderNumber("EQP_FailureReport", "FailureReportCode", "GZBG", "", "");

            return(documentNo);
        }
        public ActionResult Edit(string id)
        {
            var userName       = MmsHelper.GetUserName();
            var currentProject = MmsHelper.GetCurrentProject();
            var data           = new SewagetreatmentApiController().GetEditMaster(id);
            var codeService    = new sys_codeService();

            var model = new
            {
                form       = data.form,
                scrollKeys = data.scrollKeys,
                urls       = new
                {
                    getdetail = "/api/mms/sewagetreatment/getdetail/",
                    getmaster = "/api/mms/sewagetreatment/geteditmaster/",
                    edit      = "/api/mms/sewagetreatment/edit/",
                    audit     = "/api/mms/sewagetreatment/audit/",
                    getrowid  = "/mms/sewagetreatment/getnewrowid/"
                },
                resx = new
                {
                    rejected    = "已撤消修改!",
                    editSuccess = "保存成功!",
                    auditReject = "信息已取消审核!",
                    auditPassed = "信息已通过审核"
                },
                dataSource = new
                {
                    AdministrativeArea = codeService.Decode("AdministrativeArea"),
                    FacilityStatus     = codeService.Decode("FacilityStatus"),
                    warehouseItems     = new mms_warehouseService().GetWarehouseItems(currentProject)
                },

                defaultForm = new mms_sewagetreatment().Extend(new
                {
                    BillNo             = id,
                    OrgX               = "",
                    OrgY               = "",
                    IdentificationCode = "",
                    Name               = "",
                    Sequence           = "",
                    AreaCovered        = "",
                    ServiceScope       = "",
                    PlanningCapacity   = "",
                    ActualCapacity     = "",
                    WaterQuality       = "",
                    DischargeWater     = "",
                    DischargeNumber    = "",
                    DischargeLoacation = "",
                    OperatingCondition = "",
                    TreatmentCost      = "",
                    FundsSources       = "",
                    OwnershipUnit      = "",
                    FacilityStatus     = codeService.GetDefaultCodeNew("FacilityStatus"),
                    DataSources        = codeService.GetDefaultCodeNew("DataSources"),
                    ReportingUnit      = "",
                    Remark             = "",
                    AdministrativeArea = codeService.GetDefaultCodeNew("AdministrativeArea")
                }),

                setting = new
                {
                    postFormKeys = new string[] { "BillNo" }
                }
            };

            return(View(model));
        }
        public ActionResult Index()
        {
            var loginer = FormsAuth.GetUserData <LoginerBase>();
            SYS_BN_Department department = new SYS_BN_Department();

            var user = new SYS_BN_UserService().GetModel(ParamQuery.Instance().AndWhere("IsEnable", 1).AndWhere("UserCode", MmsHelper.GetUserCode()));

            department = new SYS_BN_DepartmentService().GetModel(ParamQuery.Instance().AndWhere("IsEnable", 1).AndWhere("DepartmentCode", user.DepartmentCode));

            var model = new
            {
                urls = new
                {
                    query  = "/api/Mms/MES_MaterialReturnMain",
                    remove = "/api/Mms/MES_MaterialReturnMain/",
                    billno = "/api/Mms/MES_MaterialReturnMain/getnewbillno",
                    audit  = "/api/Mms/MES_MaterialReturnMain/audit/",
                    edit1  = "/Mms/MES_MaterialReturnMain/edit/"
                },
                resx = new
                {
                    detailTitle   = "车间退料明细",
                    noneSelect    = "请先选择一条单据!",
                    deleteConfirm = "确定要删除选中的单据吗?",
                    deleteSuccess = "删除成功!",
                    auditSuccess  = "单据已审核!"
                },
                dataSource = new
                {
                    //dsPurpose = new sys_codeService().GetValueTextListByType("Purpose")
                },
                form = new
                {
                    BillCode       = "",
                    DepartmentID   = department.DepartmentCode ?? "",
                    DepartmentName = department.DepartmentName ?? ""
                },
                idField = "ID"
            };

            return(View(model));
        }
Esempio n. 26
0
        public dynamic GetProcessRouteModel(string code, string ContractCode, string PartCode, string ProjectName, string fcode, string type)
        {
            string sql  = String.Format(@"select t1.*,t2.ProcessType from PRS_ProcessRouteModelDetail t1
left join PRS_BD_StandardProcess t2  on t1.processCode=t2.processCode
where t1.IsEnable=1 and MainID in (
select ID from PRS_ProcessRouteModelMain where ProcessRouteCode='{0}'
)   order by ProcessLineCode", code);
            var    list = db.Sql(sql).QueryMany <dynamic>();

            if (list.Count > 0)
            {
                //string sql2 = string.Format(@"select * from MES_BN_ProductProcessRoute where ContractCode='{0}' and PartCode='{1}'", ContractCode, PartCode);
                //var pclist = db.Sql(sql).QueryMany<MES_BN_ProductProcessRoute>();
                //foreach (var item in pclist)
                //{

                //}

                string sql2 = string.Format(@"delete MES_BN_ProductProcessRoute where ContractCode='{0}' and PartCode='{1}'", ContractCode, PartCode);
                db.Sql(sql2).Execute();
                var rowsAffected = 0;
                db.UseTransaction(true);
                foreach (var item in list)
                {
                    MES_BN_ProductProcessRoute detail = new MES_BN_ProductProcessRoute();
                    detail.ContractCode       = ContractCode;
                    detail.ProjectName        = ProjectName;
                    detail.PartCode           = PartCode;
                    detail.FigureCode         = fcode;
                    detail.ProcessCode        = item.ProcessCode;
                    detail.ProcessLineCode    = item.ProcessLineCode;
                    detail.ProcessName        = item.ProcessName;
                    detail.WorkshopID         = item.DepartmentCode;
                    detail.Unit               = 1;
                    detail.IsInspectionReport = 2;
                    detail.IsEnable           = 1;
                    detail.CreatePerson       = MmsHelper.GetUserName();
                    detail.CreateTime         = DateTime.Now;
                    detail.ProcessModelType   = type;

                    var detailID = db.Insert <MES_BN_ProductProcessRoute>("MES_BN_ProductProcessRoute", detail)
                                   .AutoMap(x => x.ID).ExecuteReturnLastId <int>();
                    if (detailID < 0)
                    {
                        db.Rollback();
                        return(detailID);
                    }

                    sql = String.Format(@"select * from PRS_ProcessRouteModelEquipment where MainID = '{0}'", item.ID);
                    var eqpList = db.Sql(sql).QueryMany <PRS_ProcessRouteModelEquipment>();//
                    foreach (var eqp in eqpList)
                    {
                        MES_BN_ProductProcessRouteEquipment detail1 = new MES_BN_ProductProcessRouteEquipment();
                        detail1.ProcessRouteID = detailID;
                        detail1.EquipmentCode  = eqp.EquipmentCode;
                        detail1.EquipmentName  = eqp.EquipmentName;
                        detail1.epqID          = eqp.epqID;
                        rowsAffected           = db.Insert <MES_BN_ProductProcessRouteEquipment>("MES_BN_ProductProcessRouteEquipment", detail1)
                                                 .AutoMap(x => x.ID)
                                                 .Execute();
                        if (rowsAffected < 0)
                        {
                            db.Rollback();
                            return(rowsAffected);
                        }
                    }

                    sql = String.Format(@"select * from PRS_ProcessModelWorkSteps where MainID = '{0}'", item.ID);
                    var stepList = db.Sql(sql).QueryMany <PRS_ProcessModelWorkSteps>();//
                    foreach (var step in stepList)
                    {
                        PRS_ProcessWorkSteps detail2 = new PRS_ProcessWorkSteps();
                        detail2.ProcessRouteID    = detailID;
                        detail2.WorkStepsLineCode = step.WorkStepsLineCode;
                        detail2.WorkStepsName     = step.WorkStepsName;
                        detail2.WorkStepsContent  = step.WorkStepsContent;
                        detail2.ManHours          = step.ManHours;
                        detail2.Unit         = step.Unit;
                        detail2.IsEnable     = 1;
                        detail2.CreatePerson = MmsHelper.GetUserName();
                        detail2.CreateTime   = DateTime.Now;
                        detail2.ModifyPerson = MmsHelper.GetUserName();
                        detail2.ModifyTime   = DateTime.Now;
                        rowsAffected         = db.Insert <PRS_ProcessWorkSteps>("PRS_ProcessWorkSteps", detail2)
                                               .AutoMap(x => x.ID)
                                               .Execute();
                        if (rowsAffected < 0)
                        {
                            db.Rollback();
                            return(rowsAffected);
                        }
                    }
                }

                db.Commit();
            }
            return(list);
        }
Esempio n. 27
0
 //插入ProjectCode
 protected override bool OnBeforEditMaster(EditEventArgs arg)
 {
     arg.form["ProjectCode"] = MmsHelper.GetCurrentProject();
     return(base.OnBeforEditMaster(arg));
 }
Esempio n. 28
0
        public int SaveProcessRouteModel(dynamic data)
        {
            var pQuery = ParamQuery.Instance()
                         .Select("*")
                         .AndWhere("ContractCode", data["ContractCode"].ToString())
                         .AndWhere("PartCode", data["PartCode"].ToString())
                         .AndWhere("ProcessModelType", data["ProcessModelType"].ToString());

            var    mainID  = "";
            string cPerson = MmsHelper.GetUserName();
            var    list    = new PRS_ProcessRouteModelMainService().GetModelList(pQuery);

            if (list.Count > 0)
            {
                mainID = list[0].ID.ToString();
            }
            PRS_ProcessRouteModelMain master = new PRS_ProcessRouteModelMain();
            int rowsAffected = 0;

            if (string.IsNullOrEmpty(mainID))
            {
                master.ProcessRouteCode = MmsHelper.GetLSNumber("PRS_ProcessRouteModelMain", "ProcessRouteCode", "GYMX", "", "");
                master.ProcessRouteName = data["PartName"].ToString();
                master.BillState        = 0;
                master.IsEnable         = 1;
                master.ContractCode     = data["ContractCode"].ToString();
                master.PartCode         = data["PartCode"].ToString();
                master.PartFigure       = data["PartFigureCode"].ToString();
                master.CraetePerson     = MmsHelper.GetUserName();
                master.CreateTime       = DateTime.Now;
                master.ModifyPerson     = master.CraetePerson;
                master.ModifyTime       = master.CreateTime;
                master.ProcessModelType = data["ProcessModelType"].ToString();
                db.UseTransaction(true);
                rowsAffected = db.Sql(@"insert into PRS_ProcessRouteModelMain (ID,ProcessRouteCode,ProcessRouteName,BillState,IsEnable,ContractCode,PartCode,PartFigure,
CraetePerson,CreateTime,ModifyPerson,ModifyTime,ProcessModelType) values(((select isnull( MAX(id),0)+1 from PRS_ProcessRouteModelMain)),@0,@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11)",
                                      master.ProcessRouteCode, master.ProcessRouteName, master.BillState, master.IsEnable, master.ContractCode, master.PartCode, master.PartFigure, master.CraetePerson,
                                      master.CreateTime, master.ModifyPerson, master.ModifyTime, master.ProcessModelType).Execute();
                if (rowsAffected < 0)
                {
                    db.Rollback();
                    return(rowsAffected);
                }
            }
            else
            {
                master = list[0];
            }
            var sql = String.Format(@"update PRS_ProcessRouteModelMain set BillState=0,ModifyPerson='{1}',ModifyTime='{2}' where ID = '{0}'", master.ID, MmsHelper.GetUserName(), DateTime.Now);

            db.Sql(sql).Execute();
            sql = String.Format(@"select * from PRS_ProcessRouteModelMain where ProcessRouteCode = '{0}'", master.ProcessRouteCode);
            dynamic next   = db.Sql(sql).QuerySingle <dynamic>();//
            string  delSql = "";

            sql = String.Format(@"select * from PRS_ProcessRouteModelDetail where MainID = '{0}'", next.ID);
            var detalList = db.Sql(sql).QueryMany <PRS_ProcessRouteModelDetail>();

            foreach (var item in detalList)
            {
                delSql = String.Format(@"delete PRS_ProcessRouteModelEquipment where MainID = '{0}'", item.ID);
                db.Sql(delSql).Execute();
                delSql = String.Format(@"delete PRS_ProcessModelWorkSteps where MainID = '{0}'", item.ID);
                db.Sql(delSql).Execute();
            }

            delSql = String.Format(@"delete PRS_ProcessRouteModelDetail where MainID = '{0}'", next.ID);
            db.Sql(delSql).Execute();

            foreach (var item in data.model)
            {
                PRS_ProcessRouteModelDetail detail = new PRS_ProcessRouteModelDetail();
                detail.MainID          = next.ID;
                detail.ProcessCode     = item.ProcessCode;
                detail.ProcessName     = item.ProcessName;
                detail.ProcessLineCode = item.ProcessLineCode;
                detail.DepartmentCode  = item.WorkshopID;
                detail.IsEnable        = 1;
                detail.CraetePerson    = MmsHelper.GetUserName();
                detail.CreateTime      = DateTime.Now;
                detail.ModifyPerson    = detail.CraetePerson;
                detail.ModifyTime      = detail.CreateTime;
                var detailID = db.Insert <PRS_ProcessRouteModelDetail>("PRS_ProcessRouteModelDetail", detail)
                               .AutoMap(x => x.ID).ExecuteReturnLastId <int>();
                if (detailID < 0)
                {
                    db.Rollback();
                    return(detailID);
                }

                sql = String.Format(@"select * from MES_BN_ProductProcessRouteEquipment where ProcessRouteID = '{0}'", item.ID);
                var eqpList = db.Sql(sql).QueryMany <MES_BN_ProductProcessRouteEquipment>();//
                foreach (var eqp in eqpList)
                {
                    PRS_ProcessRouteModelEquipment detail1 = new PRS_ProcessRouteModelEquipment();
                    detail1.MainID        = detailID;
                    detail1.EquipmentCode = eqp.EquipmentCode;
                    detail1.EquipmentName = eqp.EquipmentName;
                    detail1.epqID         = eqp.epqID;
                    detail1.IsEnable      = 1;
                    detail1.CreatePerson  = MmsHelper.GetUserName();
                    detail1.CreateTime    = DateTime.Now;
                    detail1.ModifyPerson  = detail1.CreatePerson;
                    detail1.ModifyTime    = detail1.CreateTime;
                    rowsAffected          = db.Insert <PRS_ProcessRouteModelEquipment>("PRS_ProcessRouteModelEquipment", detail1)
                                            .AutoMap(x => x.ID)
                                            .Execute();
                    if (rowsAffected < 0)
                    {
                        db.Rollback();
                        return(rowsAffected);
                    }
                }
                sql = String.Format(@"select * from PRS_ProcessWorkSteps where ProcessRouteID = '{0}'", item.ID);
                var stepList = db.Sql(sql).QueryMany <PRS_ProcessWorkSteps>();//
                foreach (var step in stepList)
                {
                    PRS_ProcessModelWorkSteps detail2 = new PRS_ProcessModelWorkSteps();
                    detail2.MainID            = detailID;
                    detail2.WorkStepsLineCode = step.WorkStepsLineCode;
                    detail2.WorkStepsName     = step.WorkStepsName;
                    detail2.WorkStepsContent  = step.WorkStepsContent;
                    //detail2.ManHours = step.ManHours;
                    detail2.Unit         = step.Unit;
                    detail2.IsEnable     = 1;
                    detail2.CreatePerson = MmsHelper.GetUserName();
                    detail2.CreateTime   = DateTime.Now;
                    detail2.ModifyPerson = detail2.CreatePerson;
                    detail2.ModifyTime   = detail2.CreateTime;
                    rowsAffected         = db.Insert <PRS_ProcessModelWorkSteps>("PRS_ProcessModelWorkSteps", detail2)
                                           .AutoMap(x => x.ID)
                                           .Execute();
                    if (rowsAffected < 0)
                    {
                        db.Rollback();
                        return(rowsAffected);
                    }
                }
            }

            db.Commit();
            return(1);
        }
        public ActionResult Edit(string id)
        {
            var userName       = MmsHelper.GetUserName();
            var currentProject = MmsHelper.GetCurrentProject();
            var data           = new DrainagehouseholdsApiController().GetEditMaster(id);
            var codeService    = new sys_codeService();

            var model = new
            {
                form       = data.form,
                scrollKeys = data.scrollKeys,
                urls       = new
                {
                    getdetail = "/api/mms/drainagehouseholds/getdetail/",
                    getmaster = "/api/mms/drainagehouseholds/geteditmaster/",
                    edit      = "/api/mms/drainagehouseholds/edit/",
                    audit     = "/api/mms/drainagehouseholds/audit/",
                    getrowid  = "/mms/drainagehouseholds/getnewrowid/",
                    report    = "drainagehouseholds"
                },
                resx = new
                {
                    rejected    = "已撤消修改!",
                    editSuccess = "保存成功!",
                    auditReject = "信息已取消审核!",
                    auditPassed = "信息已通过审核"
                },
                dataSource = new
                {
                    Certificate        = codeService.Decode("AdditionalFacilities"),
                    AdministrativeArea = codeService.Decode("AdministrativeArea"),
                    FacilityStatus     = codeService.Decode("FacilityStatus"),
                    warehouseItems     = new mms_warehouseService().GetWarehouseItems(currentProject)
                },

                defaultForm = new mms_drainagehouseholds().Extend(new
                {
                    BillNo             = id,
                    OrgX               = "",
                    OrgY               = "",
                    IdentificationCode = "",
                    Address            = "",
                    Name               = "",
                    Displacement       = "",
                    Type               = "",
                    Certificate        = codeService.GetDefaultCodeNew("AdditionalFacilities"),
                    CertificateyTime   = "",
                    FacilityStatus     = codeService.GetDefaultCodeNew("FacilityStatus"),
                    DataSources        = codeService.GetDefaultCodeNew("DataSources"),
                    ReportingUnit      = "",
                    Remark             = "",
                    AdministrativeArea = codeService.GetDefaultCodeNew("AdministrativeArea")
                }),

                setting = new
                {
                    postFormKeys = new string[] { "BillNo" }
                }
            };

            return(View(model));
        }
        public ActionResult Edit(string id)
        {
            var userName       = MmsHelper.GetUserName();
            var currentProject = MmsHelper.GetCurrentProject();
            var data           = new RainwaterportApiController().GetEditMaster(id);
            var codeService    = new sys_codeService();

            var model = new
            {
                form       = data.form,
                scrollKeys = data.scrollKeys,
                urls       = new
                {
                    getdetail = "/api/mms/rainwaterport/getdetail/",
                    getmaster = "/api/mms/rainwaterport/geteditmaster/",
                    edit      = "/api/mms/rainwaterport/edit/",
                    audit     = "/api/mms/rainwaterport/audit/",
                    getrowid  = "/mms/rainwaterport/getnewrowid/"
                },
                resx = new
                {
                    rejected    = "已撤消修改!",
                    editSuccess = "保存成功!",
                    auditReject = "信息已取消审核!",
                    auditPassed = "信息已通过审核"
                },
                dataSource = new
                {
                    Form = codeService.Decode("RainWaterPortForm"),
                    AdministrativeArea          = codeService.Decode("AdministrativeArea"),
                    GarbageInterceptionDevice   = codeService.Decode("AdditionalFacilities"),
                    DeodorizationDevice         = codeService.Decode("AdditionalFacilities"),
                    RainwaterInterceptionDevice = codeService.Decode("AdditionalFacilities"),
                    RainGrateMaterial           = codeService.Decode("RainGrateMaterial"),
                    FacilityStatus = codeService.Decode("FacilityStatus"),
                    warehouseItems = new mms_warehouseService().GetWarehouseItems(currentProject)
                },

                defaultForm = new mms_rainwaterport().Extend(new
                {
                    BillNo                      = id,
                    OrgX                        = "",
                    OrgY                        = "",
                    IdentificationCode          = "",
                    DrainageCode                = "",
                    Address                     = "",
                    Form                        = codeService.GetDefaultCodeNew("RainWaterPortForm"),
                    MaximumDepth                = "",
                    GroundElevation             = "",
                    MaximumFlowCapacity         = "",
                    Width                       = "",
                    Length                      = "",
                    RainGrateMaterial           = codeService.GetDefaultCodeNew("RainGrateMaterial"),
                    RainGrateLength             = "",
                    RainGrateWidth              = "",
                    GarbageInterceptionDevice   = codeService.GetDefaultCodeNew("AdditionalFacilitiesStatus"),
                    DeodorizationDevice         = codeService.GetDefaultCodeNew("AdditionalFacilitiesStatus"),
                    RainwaterInterceptionDevice = codeService.GetDefaultCodeNew("AdditionalFacilitiesStatus"),
                    RetentionCapacity           = "",
                    FacilityStatus              = codeService.GetDefaultCodeNew("FacilityStatus"),
                    DataSources                 = codeService.GetDefaultCodeNew("DataSources"),
                    ReportingUnit               = "",
                    Remark                      = "",
                    AdministrativeArea          = codeService.GetDefaultCodeNew("AdministrativeArea")
                }),

                setting = new
                {
                    postFormKeys = new string[] { "BillNo" }
                }
            };

            return(View(model));
        }