Example #1
0
        /// <summary>
        /// 修改材料
        /// </summary>
        /// <param name="context"></param>
        private void update(HttpContext context)
        {
            string       json  = "";
            TBL_MATERIAL model = new TBL_MATERIAL();

            model.materialid         = context.Request["materialid"];
            model.materialcategoryid = context.Request["materialcategoryid"];
            model.code           = context.Request["code"];
            model.name           = context.Request["name"];
            model.standard       = context.Request["standard"];
            model.unit           = context.Request["unit"];
            model.unitprice      = Convert.ToDecimal(context.Request["unitprice"]);
            model.retrievetype   = context.Request["retrievetype"];
            model.recovery       = Convert.ToDecimal(context.Request["recovery"]);
            model.organizationid = context.Request["organizationid"];
            try
            {
                Bll.Update(model);
                json = "{IsSuccess:'true',Message:'保存成功!'}";
            }
            catch
            {
                json = "{IsSuccess:'false',Message:'保存失败!'}";
            }
            // context.Response.ContentType = "application/json";
            //返回JSON结果
            context.Response.Write(json);
            context.Response.End();
        }
Example #2
0
        /// <summary>
        /// 新增材料
        /// </summary>
        /// <param name="context"></param>
        private void add(HttpContext context)
        {
            string       json  = "";
            TBL_MATERIAL model = new TBL_MATERIAL();

            model.materialid         = System.Guid.NewGuid().ToString().ToUpper();
            model.materialcategoryid = context.Request["materialcategoryid"];
            model.code           = context.Request["code"];
            model.name           = context.Request["name"];
            model.standard       = context.Request["standard"];
            model.unit           = context.Request["unit"];
            model.unitprice      = Convert.ToDecimal(context.Request["unitprice"]);
            model.retrievetype   = context.Request["retrievetype"];
            model.recovery       = Convert.ToDecimal(context.Request["recovery"]);
            model.organizationid = context.Request["organizationid"];
            try
            {
                Bll.Add(model);
                json = "{IsSuccess:'true',Message:'保存成功!'}";
            }
            catch
            {
                json = "{IsSuccess:'false',Message:'保存失败!'}";
            }
            context.Response.Write(json);
            context.Response.End();
        }
Example #3
0
        /// <summary>
        /// 判断材料编码是否存在
        /// </summary>
        /// <param name="context"></param>
        private void isExit(HttpContext context)
        {
            string json = string.Empty;
            string sql  = "  ";
            string code = context.Request["code"];
            string id   = context.Request["id"];

            if (!string.IsNullOrEmpty(code))
            {
                sql += "  and  t.code ='" + code + "'";
            }

            try
            {
                List <TBL_MATERIAL> lists = Bll.GetList(sql) as List <TBL_MATERIAL>;
                if (lists.Count > 0)
                {
                    if (lists.Count == 1)
                    {
                        TBL_MATERIAL model = lists[0];
                        if (model.materialid == id)
                        {
                            json = JsonConvert.SerializeObject("{IsSuccess:'false',Message:'不存在该材料编码!'}");
                        }
                        else
                        {
                            json = JsonConvert.SerializeObject("{IsSuccess:'true',Message:'存在该材料编码!'}");
                        }
                    }
                    else
                    {
                        json = JsonConvert.SerializeObject("{IsSuccess:'true',Message:'存在该材料编码!'}");
                    }
                }
                else
                {
                    json = JsonConvert.SerializeObject("{IsSuccess:'false',Message:'不存在该材料编码!'}");
                }
            }
            catch
            {
                json = JsonConvert.SerializeObject("{IsSuccess:'false',Message:'服务器交互失败!'}");
            }
            context.Response.ContentType = "application/json";
            //返回JSON结果
            context.Response.Write(json);
            context.Response.End();
        }
Example #4
0
 public JsonResult AddOrUpdateEntity(TBL_MATERIAL item, bool isEdit)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(item.MaterialName) && ((isEdit && item.MaterialID > 0) || !isEdit))
         {
             int result = isEdit ? DA_Material.Instance.Update(item) : DA_Material.Instance.Insert(item);
             return(Json(result > 0 ? 1 : 0));
         }
         return(Json(0));
     }
     catch (Exception ex)
     {
         return(Json(0));
     }
 }
Example #5
0
 public JsonResult GetUOMID()
 {
     try
     {
         //jQuery DataTables Param
         string id = (Request.Form.GetValues("id").FirstOrDefault() == null
             ? ""
             : Request.Form.GetValues("id").FirstOrDefault().ToString());
         if (id.All(Char.IsDigit))
         {
             TBL_MATERIAL item = DA_Material.Instance.GetById(Convert.ToInt32(id));
             return(Json(item == null ? 1 : item.UOMID));
         }
     }
     catch (Exception ex) { }
     return(Json(1));
 }
Example #6
0
 public JsonResult delete()
 {
     try
     {
         //jQuery DataTables Param
         string id = (Request.Form.GetValues("id").FirstOrDefault() == null
             ? ""
             : Request.Form.GetValues("id").FirstOrDefault().ToString());
         if (id.All(Char.IsDigit))
         {
             TBL_MATERIAL material = DA_Material.Instance.GetById(Convert.ToInt32(id));
             return(Json(material == null ? 0 : DA_Material.Instance.Delete(material)));
         }
         return(Json(0));
     }
     catch (Exception ex)
     {
         return(Json(0));
     }
 }
 public JsonResult deleteMany(List <int> lsIdItem)
 {
     try
     {
         using (var scope = new TransactionScope())
         {
             foreach (int id in lsIdItem)
             {
                 if (!DA_Material.Instance.UsingMaterial(Convert.ToInt32(id)))
                 {
                     DA_Material.Instance.Delete(Convert.ToInt32(id));
                 }
                 else
                 {
                     TBL_MATERIAL item = DA_Material.Instance.GetById(id);
                     throw new Exception("Nguyên liệu " + item.MaterialName + " đang sử dụng");
                 }
             }
             scope.Complete();
             return(Json(1));
         }
     }
     catch (Exception ex) { return(Json(ex.Message)); }
 }