Exemple #1
0
        public ActionResult SupplierInfoDetail(int supplierid)
        {
            string strJson = "";
            List <t_CM_SupplierInfo> list = bll.t_CM_SupplierInfo.Where(d => d.SupplierID == supplierid).ToList();

            if (list.Count > 0)
            {
                t_CM_SupplierInfo info = list[0];
                strJson = JsonConvert.SerializeObject(info);
            }
            return(Content(strJson));
        }
Exemple #2
0
        public ActionResult SaveSupplierInfo(t_CM_SupplierInfo supplier)
        {
            string result = "0";

            try
            {
                List <t_CM_SupplierInfo> list = bll.t_CM_SupplierInfo.Where(d => (d.SupplierCode == supplier.SupplierCode || d.SupplierName == supplier.SupplierName) && d.SupplierID != supplier.SupplierID).ToList();
                if (list.Count > 0)
                {
                    result = "此供应商名称或编码已存在,请重新录入!";
                }
                else
                {
                    //编辑
                    if (supplier.SupplierID > 0)
                    {
                        t_CM_SupplierInfo info = bll.t_CM_SupplierInfo.Where(d => d.SupplierID == supplier.SupplierID).First();
                        info.SupplierID      = supplier.SupplierID;
                        info.SupplierCode    = supplier.SupplierCode;
                        info.SupplierName    = supplier.SupplierName;
                        info.Contacter       = supplier.Contacter;
                        info.MobilePhone     = supplier.MobilePhone;
                        info.Telephone       = supplier.Telephone;
                        info.SupplierAddress = supplier.SupplierAddress;
                        info.PID             = supplier.PID;
                        info.UseState        = supplier.UseState;
                        if (supplier.Remarks != null)
                        {
                            info.Remarks = supplier.Remarks.Replace("\n", "<br>");
                        }
                        else
                        {
                            info.Remarks = supplier.Remarks;
                        }

                        bll.ObjectStateManager.ChangeObjectState(info, EntityState.Modified);
                        bll.SaveChanges();
                        result = "ok1";
                        Common.InsertLog("供应商管理", CurrentUser.UserName, "编辑供应商信息[" + info.SupplierName + "(" + info.SupplierCode + ")_" + info.SupplierID + "]");
                    }
                    else
                    {
                        //新增
                        if (supplier.Remarks != null)
                        {
                            supplier.Remarks = supplier.Remarks.Replace("\n", "<br>");
                        }
                        else
                        {
                            supplier.Remarks = supplier.Remarks;
                        }

                        bll.t_CM_SupplierInfo.AddObject(supplier);
                        bll.SaveChanges();

                        result = "ok2";
                        Common.InsertLog("供应商管理", CurrentUser.UserName, "新增供应商信息[" + supplier.SupplierName + "(" + supplier.SupplierCode + ")]");
                    }
                }

                return(Content(result));
            }
            catch (Exception ex)
            {
                return(Content(ex.ToString()));
            }
        }