Пример #1
0
        public dynamic Get(RequestWrapper query)
        {
            query.LoadSettingXmlString(@"
            <settings defaultOrderBy='ID'>
                <select>*</select>
                <from>minimes_uph</from>
                <where defaultForAll='true' defaultCp='equal' defaultIgnoreEmpty='true' >
                <field name='WorkShopId'		cp='equal'></field>
                <field name='ProductCode'		cp='equal'></field>
                <field name='CreatePerson'		cp='equal'></field>
                </where>
            </settings>");
            var service = new minimes_uphService();
            var pQuery  = query.ToParamQuery();
            var result  = service.GetDynamicListWithPaging(pQuery);

            return(result);
        }
Пример #2
0
        public ActionResult EditImport(string controllers)
        {
            string info    = string.Empty;
            object objJson = "";

            try
            {
                //获取客户端上传的文件集合
                HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
                //判断是否存在文件
                if (files.Count > 0)
                {
                    //获取文件集合中的第一个文件(每次只上传一个文件)
                    HttpPostedFile file   = files[0];
                    string[]       column = new string[] { "WorkShopName", "ProductCode", "StandardUPH", "Ratio", "PackCount", "BoxCount", "SingleWeight" };
                    DataTable      dt     = ExcelHelper.ImportDataTableFromExcel(file.InputStream, file.FileName, column, 0, 0);

                    int    successCount = 0;
                    string ErrMsg       = "";

                    using (var db = Db.Context("MiniMES"))
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            string WorkShopName = dt.Rows[i]["WorkShopName"].ToString();
                            string ProductCode  = dt.Rows[i]["ProductCode"].ToString();
                            string StandardUPH  = dt.Rows[i]["StandardUPH"].ToString();
                            string Ratio        = dt.Rows[i]["Ratio"].ToString();
                            string PackCount    = dt.Rows[i]["PackCount"].ToString();
                            string BoxCount     = dt.Rows[i]["BoxCount"].ToString();
                            string SingleWeight = dt.Rows[i]["SingleWeight"].ToString();


                            int iStandardUPH = 0;
                            int iRatio       = 0;
                            int.TryParse(StandardUPH, out iStandardUPH);
                            int.TryParse(Ratio, out iRatio);



                            string WorkShopId = "";
                            if (WorkShopName == "注塑车间")
                            {
                                WorkShopId = "08ff98d5-aaa4-4a58-8bdc-244b1ddaef20";
                            }
                            else if (WorkShopName == "冲压车间")
                            {
                                WorkShopId = "c3b621ea-29a0-4d7b-b8cc-87f72aee5612";
                            }

                            if (!string.IsNullOrEmpty(ProductCode))
                            {
                                try
                                {
                                    int iResult = 0;

                                    minimes_uph minimes_uph = new minimes_uphService().GetModel(ParamQuery.Instance().Select("ProductCode").AndWhere("ProductCode", ProductCode));
                                    if (minimes_uph == null)
                                    {
                                        iResult = db.Insert("minimes_uph")
                                                  .Column("ID", Guid.NewGuid().ToString())
                                                  .Column("WorkShopId", WorkShopId)
                                                  .Column("WorkShopName", WorkShopName)
                                                  .Column("ProductCode", ProductCode)
                                                  .Column("StandardUPH", iStandardUPH)
                                                  .Column("Ratio", iRatio)
                                                  .Column("PackCount", PackCount)
                                                  .Column("BoxCount", BoxCount)
                                                  .Column("SingleWeight", SingleWeight)

                                                  .Column("CreateDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
                                                  .Column("CreatePerson", SysHelper.GetUserName())
                                                  .Column("TenantID", SysHelper.GetTenantId())
                                                  .Execute();
                                    }
                                    else
                                    {
                                        iResult = db.Update("minimes_uph")
                                                  .Column("WorkShopId", WorkShopId)
                                                  .Column("WorkShopName", WorkShopName)
                                                  .Column("StandardUPH", iStandardUPH)
                                                  .Column("Ratio", iRatio)
                                                  .Column("PackCount", PackCount)
                                                  .Column("BoxCount", BoxCount)
                                                  .Column("SingleWeight", SingleWeight)
                                                  .Column("CreateDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
                                                  .Column("CreatePerson", SysHelper.GetUserName())
                                                  .Where("ProductCode", ProductCode)
                                                  .Column("TenantID", SysHelper.GetTenantId())
                                                  .Execute();
                                    }
                                    if (iResult > 0)
                                    {
                                        successCount++;
                                    }
                                    else
                                    {
                                        ErrMsg += "物料编码[" + ProductCode + "]保存失败!\r\n";
                                    }
                                }
                                catch (Exception ex)
                                {
                                    return(Json(new { status = false, message = "上传失败:" + ex.Message }, JsonRequestBehavior.AllowGet));
                                }
                            }
                        }
                    }
                    return(Json(new { status = true, message = ("导入完成,共导入" + successCount + "条记录。" + (ErrMsg == "" ? "" : "但存在以下错误:\r\n " + ErrMsg)) }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { status = false, message = "请选择文件!" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { status = false, message = "上传失败:" + ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #3
0
        public dynamic Edit(dynamic data)
        {
            var listWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
            <settings>
                <table>
                    minimes_uph
                </table>
                <where>
                    <field name='ID' cp='equal'></field>
                </where>
            </settings>");

            try
            {
                if (data.list.inserted.Count > 0)
                {
                    foreach (var item in data.list.inserted)
                    {
                        item.CreatePerson = SysHelper.GetUserName();
                        if (item.WorkShopId == "08ff98d5-aaa4-4a58-8bdc-244b1ddaef20")
                        {
                            item.WorkShopName = "注塑车间";
                        }
                        else if (item.WorkShopId == "c3b621ea-29a0-4d7b-b8cc-87f72aee5612")
                        {
                            item.WorkShopName = "冲压车间";
                        }
                        item.TenantID = SysHelper.GetTenantId();
                    }
                }

                if (data.list.updated.Count > 0)
                {
                    foreach (var item in data.list.updated)
                    {
                        item.CreateDate   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        item.CreatePerson = SysHelper.GetUserName();

                        if (item.WorkShopId == "08ff98d5-aaa4-4a58-8bdc-244b1ddaef20")
                        {
                            item.WorkShopName = "注塑车间";
                        }
                        else if (item.WorkShopId == "c3b621ea-29a0-4d7b-b8cc-87f72aee5612")
                        {
                            item.WorkShopName = "冲压车间";
                        }
                        item.TenantID = SysHelper.GetTenantId();
                    }
                }
                var service = new minimes_uphService();
                var result  = service.Edit(null, listWrapper, data);
                if (result > 0)
                {
                    return new { status = true, message = "保存成功" }
                }
                ;
                else
                {
                    return new { status = false, message = "保存失败" }
                };
            }
            catch (Exception ex)
            {
                return(new { status = false, message = ex.Message });
            }
        }
Пример #4
0
        /// <summary>
        /// 下拉框改变
        /// </summary>
        /// <param name="ProductCode">产品型号</param>
        /// <param name="TenantID">企业ID</param>
        /// <returns></returns>
        public ActionResult SelectChange(string ProductCode, string TenantID, string OrderNo)
        {
            int    Ratio         = 1;
            int    UPH           = 1;
            int    StandardMould = 1;
            int    Person        = 1;
            string ActualMould   = "";

            try
            {
                //minimes_productService reportService = new minimes_productService();
                //List<minimes_product> reportList = reportService.GetModelList(
                //ParamQuery.Instance()
                //.AndWhere("InventoryCode", ProductCode)
                //.AndWhere("TenantId", TenantID)
                //);
                //if (reportList.Count > 0)
                //    Ratio = reportList[0].TallyRatio.Value;
                //List<dynamic> worksheetlist = ApiDataSource.GetInventoryList(TenantID, ProductCode, null, null, null, null).ToObject<List<dynamic>>();
                //if (worksheetlist.Count > 0)
                //    UPH = worksheetlist[0].StandardUPH;
                minimes_uphService uphService = new minimes_uphService();
                List <minimes_uph> uphList    = uphService.GetModelList(ParamQuery.Instance().AndWhere("ProductCode", ProductCode).AndWhere("TenantID", TenantID));
                if (uphList.Count != 0)
                {
                    int iStandardUPH = 0;
                    if (uphList[0].StandardUPH != null)
                    {
                        if (int.TryParse(Convert.ToString(uphList[0].StandardUPH), out iStandardUPH))
                        {
                            UPH = iStandardUPH;
                        }
                    }
                    int iRatio = 0;
                    if (uphList[0].Ratio != null)
                    {
                        if (int.TryParse(Convert.ToString(uphList[0].Ratio), out iRatio))
                        {
                            StandardMould = iRatio;;
                        }
                    }
                }


                minimes_order_recordService orderrecordService = new minimes_order_recordService();
                List <minimes_order_record> orderrecordList    = orderrecordService.GetModelList(ParamQuery.Instance().AndWhere("OrderNo", OrderNo));
                if (orderrecordList.Count != 0)
                {
                    Ratio         = orderrecordList[0].Ratio;
                    UPH           = orderrecordList[0].UPH;
                    StandardMould = orderrecordList[0].StandardMould;
                    Person        = orderrecordList[0].Person;
                    ActualMould   = orderrecordList[0].ActualMould.ToString();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            var result = new
            {
                Ratio         = Ratio,
                UPH           = UPH,
                StandardMould = StandardMould,
                Person        = Person,
                ActualMould   = ActualMould
            };
            string js = JsonConvert.SerializeObject(result);

            return(Json(js, "application/json", JsonRequestBehavior.AllowGet));;
        }