Example #1
0
 public ActionResult deleterece(int id)
 {
     var row = ServiceDB.Instance.ExecuteSqlCommand("update MsgRece set isDelete=1 where receId=" + id);
     ReturnValue r = new ReturnValue();
     r.status = row == 1;
     return Json(r, JsonRequestBehavior.AllowGet);
 }
Example #2
0
 public ActionResult deletesend(Guid id)
 {
     var row = ServiceDB.Instance.ExecuteSqlCommand("update MsgSend set isDelete=1 where msgId='" + id + "'");
     ReturnValue r = new ReturnValue();
     r.status = row == 1;
     return Json(r, JsonRequestBehavior.AllowGet);
 }
Example #3
0
 public ActionResult autopost()
 {
     ReturnValue r = new ReturnValue();
     r.status = true;
     r.message = SessionHelper.SessionId;
     Session["autopostsession"] = r.message;
     return Json(r, JsonRequestBehavior.AllowGet);
 }
Example #4
0
 public ActionResult checksupplierprice(int? priceid,int to)
 {
     try
     {
         if (!priceid.HasValue || !Masterpage.CheckRight("manage_supplier_pricecheck")) return Json(new ReturnValue { status = false, message = "非法权限" }, JsonRequestBehavior.AllowGet);
         var row = ServiceDB.Instance.ExecuteSqlCommand("update MaterialPrice set status=" + to + ",endDate="+(to==2?"'"+DateTime.Now.ToString("yyyy-MM-dd")+"'":"NULL")+" where priceid=" + priceid.Value);
         ReturnValue r = new ReturnValue() { status = (row == 1), message = "删除" + (row == 1 ? "成功" : "失败") };
         return Json(r, JsonRequestBehavior.AllowGet);
     }
     catch (Exception ex) { return Json(new ReturnValue { status = false, message = "删除失败" + ex.Message }, JsonRequestBehavior.AllowGet); }
 }
Example #5
0
 public ActionResult savebomcost()
 {
     ReturnValue back = new ReturnValue { status = false };
     if (!Masterpage.CheckRight("bomcost_update"))
     {
         back.message = "非法权限!";
     }
     else
     {
         var id = WebRequest.GetInt("costsn", 0);
         var bomId = WebRequest.GetInt("bom", 0);
         var mybom = WebRequest.GetInt("mybom", 0);
         var price = WebRequest.GetFloat("price", 0);
         var amount = WebRequest.GetFloat("amount", 0);
         var oldprice = WebRequest.GetFloat("oldprice", 0);
         var remark = WebRequest.GetString("remark", true);
         int row = 0;
         if (id == 0)
             row = ServiceDB.Instance.ExecuteSqlCommand("insert into BomCost values(" + mybom + "," + price + ",getdate(),'" + remark + "')");
         else
             row = ServiceDB.Instance.ExecuteSqlCommand("update BomCost set price=" + price + ",remark='remark' where costId=" + id);
         if (row != 1) back.message = "价格更新失败!";
         else
         {
             var egx = amount * price - amount * oldprice;
             var row2 = ServiceDB.Instance.ExecuteSqlCommand("update BomMain set rootCost=rootCost+" + egx + " where bomId=" + bomId);
             if (row != 1) back.message = "总成本更新失败!";
             else back.status = true;
         }
     }
     return Json(back, JsonRequestBehavior.AllowGet);
 }
Example #6
0
 public ActionResult bomoptdelete(string type, string no, int sn)
 {
     ReturnValue r = new ReturnValue();
     switch (type)
     {
         case "requrie":
             r = bomService.DeletePurcharseRequire(no, sn, Masterpage.CurrUser.staffid, Masterpage.CurrUser.depId);
             break;
         case "delegate":
             r = bomService.DeleteDelegate(no, sn, Masterpage.CurrUser.staffid, Masterpage.CurrUser.depId);
             break;
         case "produce":
             r = bomService.DeleteProduce(no, sn, Masterpage.CurrUser.staffid, Masterpage.CurrUser.depId);
             break;
         default:
             r.status = false;
             r.message = "操作类别有误";
             break;
     }
     return Json(r, JsonRequestBehavior.AllowGet);
 }
Example #7
0
 public ActionResult bomvalid()
 {
     int id = WebRequest.GetInt("id", 0);
     int valid = WebRequest.GetInt("valid", 0);
     string sql = "";
     if (valid == 0) sql = "update BomMain set status=" + valid + ",endDate='" + DateTime.Now.ToString() + "' where bomId=" + id;
     else sql = "update BomMain set status=" + valid + ",startDate='" + DateTime.Now.ToString() + "',endDate=null where bomId=" + id;
     var row = ServiceDB.Instance.ExecuteSqlCommand(sql);
     ReturnValue rv = new ReturnValue();
     rv.status = row == 1;
     return Json(rv, JsonRequestBehavior.AllowGet);
 }
Example #8
0
        public ActionResult saveouttsell_2( string pricelist, string remarklist, string materiallist, string amountlist)
        {
            string no = WebRequest.GetString("no", true);
            string type = WebRequest.GetString("type", true);
            string remark = WebRequest.GetString("remark", true);
            string deport = WebRequest.GetString("deport", true);
            int supplier = WebRequest.GetInt("supplier", 0);
            string express = WebRequest.GetString("express", true);
            string expresscode = WebRequest.GetString("expresscode", true);
            string date = WebRequest.GetString("date", true);
            ReturnValue r = new ReturnValue() { status = false };

            string[] remarkl = remarklist.Split(',');
            string[] materiall = materiallist.Split(',');
            string[] pricel = pricelist.Split(',');
            string[] amountl = amountlist.Split(',');
            if (amountl.Length < 1 || materiall.Length != pricel.Length)
            {
                r = new ReturnValue { status = false, message = "未提交任何明细" };
            }
            else
            {
                var head = 0;
                if (type == "add")
                {
                    string backno = stockoutService.GetStockOutNo();
                    if (backno != "")
                    {
                        head = ServiceDB.Instance.ExecuteSqlCommand(
                            "INSERT INTO [dbo].[StockOut] values('" + backno + "'," + Masterpage.CurrUser.staffid + "," + Masterpage.CurrUser.depId + "," + supplier
                            + ",'',null,4,'',0,0,0,getdate(),1,0,0,'','" + remark + "','" + deport+"','"+express+"','"+expresscode+"',"+(date==""?"null":"'"+date+"'")+",0)");
                        no = backno;
                    }
                }
                else if (type == "edit")
                {
                    head = ServiceDB.Instance.ExecuteSqlCommand("update [dbo].[StockOut] set deportStaff='" + deport + "',remark='" + remark + "',express='" + express + "',expresscode='" + expresscode + "',outDate= " + (date == "" ? "null" : "'" + date + "'") + " where stockoutNo='" + no + "'");

                }
                if (head > 0)
                {
                    #region 修改明细
                    if (type == "edit") ServiceDB.Instance.ExecuteSqlCommand("delete StockOutDetail where stockoutNo='" + no + "'");
                    head = 0;
                    List<string> delgno = new List<string>();
                    for (int i = 0; i < materiall.Length; i++)
                    {
                        if (materiall[i] == "" || pricel[i] == "" || pricel[i] == "0" || amountl[i] == ""|| amountl[i] == "0") continue;
                        var haddetail = ServiceDB.Instance.QueryOneModel<StockOutDetail>("select * from StockOutDetail where stockoutNo='" + no + "' and materialNo='" + materiall[i] + "'");
                        var addone = 0;
                        if (haddetail != null)
                        {
                            addone = ServiceDB.Instance.ExecuteSqlCommand("update INTO [dbo].[StockOutDetail] set outAmount+=" + amountl[i] + ", outPrice=" + pricel[i] + " where detailSn=" + haddetail.orderSn);
                        }
                        else
                        {
                            addone = ServiceDB.Instance.ExecuteSqlCommand("INSERT INTO [dbo].[StockOutDetail] VALUES('" + no + "','" + materiall[i] + "',2,null,null," + amountl[i] + ",0," + pricel[i] + ",'','" + remarkl[i] + "')");
                        }
                        head += addone;
                    }
                    if (head < 1)
                    {
                        ServiceDB.Instance.ExecuteSqlCommand("delete StockOut where stockoutNo='" + no + "'");
                    }
                    #endregion
                    r.status = true;
                }
            }

            return Json(r, JsonRequestBehavior.AllowGet);
        }
Example #9
0
        public ActionResult savepullone(string no)
        {
            string type = WebRequest.GetString("type", true);
            string backdate = WebRequest.GetString("backdate", true);
            string pulldate = WebRequest.GetString("pulldate", true);
            string remark = WebRequest.GetString("remark", true);
            string deport = WebRequest.GetString("deport", true);
            string productno = WebRequest.GetString("productno", true);
            string pullamount = WebRequest.GetString("pullamount", true);

            string material = WebRequest.GetString("material", true);
            string product = WebRequest.GetString("product", true);
            string amount = WebRequest.GetString("amount", true);
            string jsamount = WebRequest.GetString("jsamount", true);
            string remarks = WebRequest.GetString("remarks", true);
            string[] listmaterial = material.Split(',');
            string[] listproduct = product.Split(',');
            string[] listamount = amount.Split(',');
            string[] listremarks = remarks.Split(',');
            string[] listjsamount = jsamount.Split(',');
            ReturnValue r = new ReturnValue() { status = false };
            if (listmaterial.Length < 1 || listmaterial.Length != listamount.Length)
            {
                r = new ReturnValue { status = false, message = "未提交任何明细" };
            }
            else
            {
                var head = 0;
                if (type == "add")
                {
                    string backno = bomService.GetProductPullNo();
                    if (backno != "")
                    {
                        head = ServiceDB.Instance.ExecuteSqlCommand(
                            "INSERT INTO [dbo].[ProductPull] values('" + backno + "'," + Masterpage.CurrUser.staffid + "," + Masterpage.CurrUser.depId + ",'" + productno
                               + "'," + pullamount + ",'" + pulldate + "','" + backdate + "',0,1,1,0,0,'',null,'" + deport + "',getdate(),'" + remark + "')");
                        no = backno;
                    }
                }
                else if (type == "edit")
                {
                    head = ServiceDB.Instance.ExecuteSqlCommand("update [dbo].[ProductPull] set makeAmount=" + pullamount + ",backDate='" + backdate + "',pullDate='" + pulldate + "',remark='" + remark + "',deportStaff='" + deport + "' where pullNo='" + no + "'");

                }
                if (head > 0)
                {
                    #region 修改明细
                    if (type == "edit") ServiceDB.Instance.ExecuteSqlCommand("delete ProductPullDetail where pullNo='" + no + "'");
                    head = 0;
                    List<string> delgno = new List<string>();
                    for (int i = 0; i < listmaterial.Length; i++)
                    {
                        if (listmaterial[i] == "" || listamount[i] == "" || listamount[i] == "0") continue;
                        var addone = ServiceDB.Instance.ExecuteSqlCommand("INSERT INTO [dbo].[ProductPullDetail] VALUES('" + no + "'," + listproduct[i] + ",'" + listmaterial[i] + "'," + listjsamount[i] + "," + listamount[i] + ",'" + listremarks[i] + "')");
                        head += addone;
                    }
                    if (head < 1)
                    {
                        ServiceDB.Instance.ExecuteSqlCommand("delete ProductPull where pullNo='" + no + "'");
                    }
                    else
                    {
                        var hadd = ServiceDB.Instance.QueryOneModel<Production>("select * from Production where produceNo='" + productno + "' and  canfs=1");
                        if (hadd != null) ServiceDB.Instance.ExecuteSqlCommand("update Production set canfs=0 where produceNo='" + productno + "'");
                    }
                    #endregion
                    r.status = true;
                }
            }
            return Json(r, JsonRequestBehavior.AllowGet);
        }
Example #10
0
 public ActionResult uppwd(string oldpwd, string newpwd)
 {
     ReturnValue r = new ReturnValue();
     if (newpwd.Length < 6 || newpwd.Length > 20)
     {
         r = new ReturnValue { message = "新密码长度需为6到12位", status = false };
     }
     else
     {
         r = accountService.UpdatePwd(Masterpage.CurrUser.staffid, MD5Helper.MD5_32(oldpwd), MD5Helper.MD5_32(newpwd));
     }
     return Json(r);
 }
Example #11
0
        public ActionResult saveoutsell()
        {
            string no = WebRequest.GetString("no", true);
            string type = WebRequest.GetString("type", true);
            string remark = WebRequest.GetString("remark", true);
            int supplier = WebRequest.GetInt("supplier", 0);
            string deport = WebRequest.GetString("deport", true);
            ReturnValue r = new ReturnValue() { status = false };
            List<StockDetailModel> temp = (List<StockDetailModel>)SessionHelper.GetSession("WO1" + no + Masterpage.CurrUser.staffid);
            if (temp == null || temp.Count < 1)
            {
                r.message = "不存在出库明细";
            }
            else if (supplier==0)
            {
                r.message = "未选择客户";
            }
            else
            {
                if (type == "add")
                {
                    string backno = stockoutService.AddStockOut(Masterpage.CurrUser.staffid, Masterpage.CurrUser.depId, supplier, 1, remark,deport);
                    if (backno == "")
                    {
                        r.message = "出库单生成失败";
                    }
                    else
                    {
                        r = stockoutService.SaveStockOutDetail(backno, temp, 0, remark, deport);
                    }
                }
                else if (type == "edit")
                {
                    r = stockoutService.SaveStockOutDetail(no, temp, 0, remark, deport);

                }
            }
            SessionHelper.Del("WO1" + no + Masterpage.CurrUser.staffid);
            return Json(r, JsonRequestBehavior.AllowGet);
        }
Example #12
0
        public ActionResult savemsg(string title, string cate, string forids, string fornames, string remark,string attrname,string attrguid)
        {
            Guid msg = Guid.NewGuid();
            MsgSend send = new MsgSend();
            send.createDate = DateTime.Now;
            send.isDelete = false;
            send.msgcate = cate;
            send.hadAttr = false;
            send.msgcontent = remark;
            send.msgId = msg;
            send.receIds = forids;
            send.receNames = fornames;
            send.staffId = Masterpage.CurrUser.staffid;
            send.title = title;
            if (attrname != null && attrname != "" && attrguid != null && attrguid != "")
            {
                send.hadAttr = true;
                ServiceDB.Instance.ExecuteSqlCommand("insert into Attachment values(newid(),'" + msg + "','" + attrguid + "','" + attrname + "','',getdate())");
            }

            bool exc = manageService.SaveSendMessage(send);
            int rececount = 0;
            if (exc)
            {
                string[] rece = forids.Split(',');
                foreach (var item in rece)
                {
                    if (item != "")
                    {
                        var row = ServiceDB.Instance.ExecuteSqlCommand("insert into MsgRece values('" + msg + "'," + item + ",0,null,0,null)");
                        rececount += row;
                    }
                }
            }
            ReturnValue r = new ReturnValue();
            r.status = rececount > 0;
            return Json(r, JsonRequestBehavior.AllowGet);
        }
Example #13
0
 public ActionResult deletebomselect()
 {
     string forids = WebRequest.GetString("forids");
     string[] ids = forids.Split(',');
     int count = 0;
     foreach (string item in ids)
     {
         if (item == "") continue;
         var bom = ServiceDB.Instance.QueryOneModel<BomMain>("select * from bommain where bomid=" + item);
         if (bom != null && bom.bomId > 0)
         {
             var del = bomService.DeleteBom(bom.bomId);
             if (del.status) count++;
         }
     }
     ReturnValue r = new ReturnValue();
     r.status = count > 0;
     r.message = r.status ? "" : "BOM节点删除失败,BOM已引用,禁止删除";
     return Json(r, JsonRequestBehavior.AllowGet);
 }
Example #14
0
        public ActionResult gosettle()
        {
            ReturnValue back = new ReturnValue { status = false };
            string no = WebRequest.GetString("no", true);
            string forids = WebRequest.GetString("forids", true);
            string costs = WebRequest.GetString("costs", true);
            string date = WebRequest.GetString("date", true);
            string remark = WebRequest.GetString("remark", true);
            float cost = WebRequest.GetFloat("cost", 0);
            var one = ServiceDB.Instance.QueryOneModel<Settlement>(" select * from Settlement  where settleNo='" + no + "'");
            if (one == null)
            {
                back.message = "不存在结算单";
                return Json(back, JsonRequestBehavior.AllowGet);
            }
            string[] snlist = forids.Split(',');
            string[] costlist = costs.Split(',');
            if (snlist.Length != costlist.Length || snlist.Length < 1)
            {
                back.message = "传入参数数组有误";
                return Json(back, JsonRequestBehavior.AllowGet);
            }
            string sql = "";
            #region sql集合
            sql += "insert into SettlementCapital values('" + one.settleNo + "'," + one.supplierId + ",'" + one.supplierName + "','" + date + "','" + Masterpage.CurrUser.name + "'," + cost + ",0,0,getdate(),'" + remark + "');";

            sql += "update Settlement set realCost+=" + cost + " where settleNo='" + no + "';";
            for (int i = 0; i < snlist.Length; i++)
            {
                sql += "update SettlementDetail set isSettle=1,realCost=" + costlist[i] + " where detailSn=" + snlist[i] + ";";
            }
            #endregion
            try
            {
                var insert3 = ServiceDB.Instance.ExecuteSqlCommand(sql);
                if (insert3 > 0)
                {
                    var list = ServiceDB.Instance.QueryModelList<SettlementDetail>(" select * from SettlementDetail  where settleNo='" + no + "' and isSettle=0").ToList();
                    if (list == null || list.Count < 1)
                    {
                        ServiceDB.Instance.ExecuteSqlCommand("update Settlement set isover=1, status=2  where settleNo='" + no + "';");
                    }
                }
                back.status = true;
                return Json(back, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                back.status = false;
                back.value = ex.Message;
                return Json(back, JsonRequestBehavior.AllowGet);
            }
        }
Example #15
0
        public ActionResult saveinproduct()
        {
            string no = WebRequest.GetString("no", true);
            string type = WebRequest.GetString("type", true);
            string remark = WebRequest.GetString("remark", true);
            string deport = WebRequest.GetString("deport", true);
            ReturnValue r = new ReturnValue() { status = false };
            List<StockDetailModel> temp = (List<StockDetailModel>)SessionHelper.GetSession("WE2" + no + Masterpage.CurrUser.staffid);
            if (temp == null || temp.Count < 1)
            {
                r.message = "不存在入库明细";
            }
            else
            {
                if (type == "add")
                {
                    string backno = stockinService.AddStockIn(Masterpage.CurrUser.staffid, Masterpage.CurrUser.depId, 0, 2, remark, deport);
                    if (backno == "")
                    {
                        r.message = "入库单生成失败";
                    }
                    else
                    {
                        r = stockinService.SaveStockInDetail(backno, temp, 0, remark, deport);
                    }
                }
                else if (type == "edit")
                {
                    r = stockinService.SaveStockInDetail(no, temp, 0, remark, deport);

                }
            }
            SessionHelper.Del("WE2" + no + Masterpage.CurrUser.staffid);
            return Json(r, JsonRequestBehavior.AllowGet);
        }
Example #16
0
        public ActionResult savesneedin(string no)
        {
            string type = WebRequest.GetString("type", true);
            string supplier = WebRequest.GetString("supplier", true);
            int i_supplier = Convert.ToInt32(supplier);
            string remark = WebRequest.GetString("remark", true);
            string deport = WebRequest.GetString("deport", true);
            ReturnValue r = new ReturnValue() { status = false };
            var list = new List<StockDetailModel>();
            list = (List<StockDetailModel>)SessionHelper.GetSession("WE1" + no + Masterpage.CurrUser.staffid);
            if (list.Count == 0)
            {
                r = new ReturnValue { status = false, message = "未提交任何订单明细" };
            }
            else
            {
                if (type == "add")
                {
                    string backno = stockinService.AddStockIn(Masterpage.CurrUser.staffid, Masterpage.CurrUser.depId, i_supplier, 1, remark, deport);
                    if (backno == "")
                    {
                        r.message = "入库单生成失败";
                    }
                    else
                    {
                        r = stockinService.SaveStockInDetail(backno, list, 0, remark, deport);
                    }
                }
                else if (type == "edit")
                {
                    r = stockinService.SaveStockInDetail(no, list, 0, remark, deport);

                }
            }
            SessionHelper.Del("WE1" + no + Masterpage.CurrUser.staffid);
            return Json(r, JsonRequestBehavior.AllowGet);
        }
Example #17
0
 public ActionResult savesemione()
 {
     string no = WebRequest.GetString("no", true);
     string type = WebRequest.GetString("type", true);
     string date = WebRequest.GetString("date", true);
     ReturnValue r = new ReturnValue() { status = false };
     List<ProductSemi> temp = (List<ProductSemi>)SessionHelper.GetSession("WE4" + no + Masterpage.CurrUser.staffid);
     if (temp == null || temp.Count < 1)
     {
         r.message = "不存在半成品明细";
     }
     else
     {
         string semino = no;
         int count = 0;
         if (type == "add")
         {
             semino = stockinService.GetStockSemiNo();
         }
         else if (type == "edit")
         {
             semino = no;
         }
         foreach (var item in temp)
         {
             string sql = "";
             if (item.semiId <= 0) { sql = "insert into ProductSemi values('" + semino + "','" + item.proName + "','" + item.proModel + "'," + item.amount + "," + item.price + ",'" + item.remark + "'," + Masterpage.CurrUser.staffid + ",'" + Masterpage.CurrUser.name + "',getdate(),'" + date + "','',null,0)"; }
             else { sql = "update ProductSemi set proName='" + item.proName + "',proModel='" + item.proModel + "',amount=" + item.amount + ",price=" + item.price + ",remark='" + item.remark + "',staffId=" + Masterpage.CurrUser.staffid + ",staffName='" + Masterpage.CurrUser.name + "',semiDate='" + date + "' where semiId=" + item.semiId; }
             ServiceDB.Instance.ExecuteSqlCommand(sql);
             count++;
         }
         r.status = count > 0;
     }
     SessionHelper.Del("WE4" + no + Masterpage.CurrUser.staffid);
     return Json(r, JsonRequestBehavior.AllowGet);
 }
Example #18
0
        public ActionResult saverolemenu(int id)
        {
            ReturnValue rv = new ReturnValue();
            try
            {
                string addstr = WebRequest.GetString("add", true);
                string delstr = WebRequest.GetString("del", true);
                if (addstr.EndsWith("#")) addstr = addstr.Substring(0, addstr.Length - 1);
                if (delstr.EndsWith("#")) delstr = delstr.Substring(0, delstr.Length - 1);
                string[] add = addstr.Split('#');
                string[] del = delstr.Split('#');
                bool b = systemService.SaveRoleMenu(id, add, del);
                if (b) rv = new ReturnValue { status = true, message = "" };
                else rv = new ReturnValue { status = false, message = "保存失败" };

            }
            catch (Exception ex)
            {
                rv = new ReturnValue { status = false, message = "程序异常:" + ex.Message };
            }
            return Json(rv, JsonRequestBehavior.AllowGet);
        }
Example #19
0
        public ActionResult fileuploadactin(string filetype)
        {
            ReturnValue r = new ReturnValue() { status = true };
            var res = ConfigurationManager.AppSettings["FilePath"].ToString();//c:\Res\
            var directory = "";
            var httpfile = Request.Files["myfile"];
            if (httpfile != null)
            {
                var fn = httpfile.FileName;
                var exn = fn.Substring(fn.LastIndexOf("."));
                var filename = "";
                if (fn.Contains("\\")) filename = fn.Substring(fn.LastIndexOf("\\")).Replace("\\", "");
                else filename = fn;

                if (filetype == "material")
                {
                    #region 物料图片
                    directory = res  + "\\material\\";
                    #region 上传
                    if (!Directory.Exists(directory)) Directory.CreateDirectory(directory);
                    if (exn.ToLower() != ".png" && exn.ToLower() != ".jpg" && exn.ToLower() != ".bmp" && exn.ToLower() != ".jpeg" && exn.ToLower() != ".gif")
                    {
                        r.status = false;
                        r.message= "请上传图片格式文件(jpg,jpeg,png,bmp,gif)";
                    }
                    else
                    {
                        var newname = Guid.NewGuid().ToString() + exn;
                        try
                        {
                            httpfile.SaveAs(directory + newname);
                        }
                        catch
                        {
                            r.status = false;
                            r.message = "上传失败";
                        }
                        r.status = true;
                        r.value = newname;
                        r.value2 = filename;
                    }
                    #endregion
                    #endregion
                }
                else if (filetype == "message")
                {
                    #region 站内消息附件
                    directory = res + "\\message\\";
                    #region 上传
                    if (!Directory.Exists(directory)) Directory.CreateDirectory(directory);
                    if (exn.ToLower() == ".exe" || exn.ToLower() == ".dll" || exn.ToLower() == ".js" || exn.ToLower() == ".ms" || exn.ToLower() == ".php")
                    {
                        r.status = false;
                        r.message = "请上传正确的文档文件";
                    }
                    else
                    {
                        var newname = Guid.NewGuid().ToString() + exn;
                        try
                        {
                            httpfile.SaveAs(directory + newname);
                        }
                        catch
                        {
                            r.status = false;
                            r.message = "上传失败";
                        }
                        r.status = true;
                        r.value = newname;
                        r.value2 = filename;
                    }
                    #endregion
                    #endregion
                }
                else
                {
                    var str2 = JsonHelper.ToJson(new { status = false, message = "文件上传类型错误" });
                    return Content(str2);
                }
            }
            else
            {
                r.status = false;
                r.message = "未上传文件";
            }
            var str = JsonHelper.ToJson(r);
            return Content(str);
        }
Example #20
0
        public ActionResult savepurchase()
        {
            //no: no, sn: sn, remark: bz, date: date, km: km, cost: cost
            string no = WebRequest.GetString("no", true);

            ReturnValue back = new ReturnValue { status = true };

            string remark = WebRequest.GetString("remark", true);
            var insert3 = ServiceDB.Instance.ExecuteSqlCommand("update BillCost set remark='" + remark + "' where billNo='" + no + "'");

            return Json(back, JsonRequestBehavior.AllowGet);
        }
Example #21
0
 public ActionResult checkdata(string key, string no, int status)
 {
     ReturnValue back = new ReturnValue { status = true };
     if (key == "require")
     {
         #region 采购申请
         back.status = purchaseService.ChangeRequireStatus(no, status, Masterpage.CurrUser.name);
         #endregion
     }
     else if (key == "purchase")
     {
         back.status = purchaseService.ChangePurchaseStatus(no, status, Masterpage.CurrUser.name);
     }
     else if (key == "stockin")
     {
         back.status = stockinService.ChangeStockInStatus(no, status, Masterpage.CurrUser.name);
     }
     else if (key == "stockout")
     {
         back = stockoutService.ChangeStockOutStatus(no, status, Masterpage.CurrUser.name);
     }
     else if (key == "stockchange")
     {
         back = stockoutService.ChangeChangeOtNStatus(no, status, Masterpage.CurrUser.name);
     }
     else if (key == "orderreturn")
     {
         back = stockinService.ChangeReturnStatus(no, status, Masterpage.CurrUser.name);
     }
     else if (key == "stockreturn")
     {
         back = stockoutService.ChangeStockReturnStatus(no, status, Masterpage.CurrUser.name);
     }
     else if (key == "bomorder")
     {
         back = bomService.ChangeBomOrderStatus(no, status, Masterpage.CurrUser.name);
     }
     else if (key == "bill")
     {
         back.status = manageService.ChangeBillStatus(no, status, Masterpage.CurrUser.staffid);
     }
     else if (key == "settle" || key == "pay")
     {
         back.status = manageService.ChangeSettleStatus(no, status, Masterpage.CurrUser.staffid);
     }
     else if (key == "delegate")
     {
         back = bomService.ChangeDelegateStatus(no, status, Masterpage.CurrUser.name);
     }
     else if (key == "produce")
     {
         back = bomService.ChangeProductionStatus(no, status, Masterpage.CurrUser.name);
     }
     else if (key == "delegatesend")
     {
         back = bomService.ChangeDelegateSendStatus(no, status, Masterpage.CurrUser.name);
     }
     else if (key == "delegateback")
     {
         back = bomService.ChangeDelegateBackStatus(no, status, Masterpage.CurrUser.name);
     }
     else if (key == "producepull")
     {
         back = bomService.ChangeProductPullStatus(no, status, Masterpage.CurrUser.name);
     }
     else if (key == "producegive")
     {
         back = bomService.ChangeProductGiveStatus(no, status, Masterpage.CurrUser.name);
     }
     return Json(back, JsonRequestBehavior.AllowGet);
 }
Example #22
0
        public ActionResult savepurchasedetail()
        {
            //no: no, sn: sn, remark: bz, date: date, km: km, cost: cost
            string no = WebRequest.GetString("no", true);
            string km = WebRequest.GetString("km", true);
            string bz = WebRequest.GetString("bz", true);
            string date = WebRequest.GetString("date", true);
            string cost = WebRequest.GetString("cost", true);
            string amount = WebRequest.GetString("amount", true);
            int sn = WebRequest.GetInt("sn", 0);

            ReturnValue back = new ReturnValue { status = false };

            string title = WebRequest.GetString("title", true);
            string remark = WebRequest.GetString("remark", true);

            string type = WebRequest.GetString("type", true);

            if (type == "add")
            {
                var newno = manageService.GetTCNo();
                var insert = ServiceDB.Instance.ExecuteSqlCommand("insert into BillCost (billno,title,staffmake,depid,status,valid,isover,billtype,remark,createdate) values('" + newno + "',''," + Masterpage.CurrUser.staffid + "," + Masterpage.CurrUser.depId + ",0,1,0,1,'" + remark + "',getdate())");
                if (insert != 1)
                {
                    back.message = "采购单创建失败,请刷新当前页重试";
                    return Json(back, JsonRequestBehavior.AllowGet);
                }
                no = newno;
            }
            #region 添加明细
            var had = ServiceDB.Instance.QueryOneModel<BillCostDetail>("select * from BillCostDetail where billNo='" + no + "' and billTitle='" + km + "' and remark=" + remark);
            if (sn == 0)
            {
                #region 添加
                if (had != null)
                {
                    back.message = "采购单明细已存在";
                    return Json(back, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    var insert2 = ServiceDB.Instance.ExecuteSqlCommand("insert into BillCostDetail values('" + no + "','" + km + "'," + amount + "," + cost + ",'" + date + "','" + bz + "')");
                    if (insert2 != 1)
                    {
                        back.message = "采购单明细创建失败,请刷新当前页重试";
                        return Json(back, JsonRequestBehavior.AllowGet);
                    }
                    var me = ServiceDB.Instance.QueryOneModel<BillCostDetail>("select * from BillCostDetail where billNo='" + no + "' and billTitle='" + km + "' and price=" + cost);
                    if (me == null)
                    {
                        back.message = "采购单明细创建失败";
                    }
                    else
                    {
                        back.status = true;
                        back.value2 = no;
                        back.value = me.detailSn.ToString();
                    }
                }
                #endregion
            }
            else
            {
                #region 修改
                if (had != null && sn != had.detailSn)
                {
                    back.message = "采购单明细已存在";
                    return Json(back, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    var insert3 = ServiceDB.Instance.ExecuteSqlCommand("update BillCostDetail set billTitle='" + km + "',amount=" + amount + ",price=" + cost + ",billDate='" + date + "',remark='" + bz + "' where detailSn=" + sn);
                    if (insert3 != 1)
                    {
                        back.message = "采购单明细修改失败,请刷新当前页重试";
                        return Json(back, JsonRequestBehavior.AllowGet);
                    }
                    back.status = true;
                    back.value2 = no;
                    back.value = sn.ToString();
                }
                #endregion
            }
            #endregion

            return Json(back, JsonRequestBehavior.AllowGet);
        }
Example #23
0
        public ActionResult saveoutold2new()
        {
            string no = WebRequest.GetString("no", true);
            string type = WebRequest.GetString("type", true);
            string remark = WebRequest.GetString("remark", true);
            string deport = WebRequest.GetString("deport", true);
            ReturnValue r = new ReturnValue() { status = false };
            List<StockDetailModel> temp = (List<StockDetailModel>)SessionHelper.GetSession("ON1" + no + Masterpage.CurrUser.staffid);
            if (temp == null || temp.Count < 1)
            {
                r.message = "不存在以旧换新明细";
            }
            else
            {
                var inlist = temp.Where(p => p.changeType == 0).ToList();

                var outlist = temp.Where(p => p.changeType == 1).ToList();
                if (inlist.Count < 1 || outlist.Count < 1)
                {
                    r.message = "旧物料入库、新物料出库均不能为空";
                }
                else
                {
                    if (type == "add")
                    {
                        string backno = stockoutService.AddChangeOtN(Masterpage.CurrUser.staffid, Masterpage.CurrUser.depId, remark, deport);
                        if (backno == "")
                        {
                            r.message = "以旧换新单生成失败";
                        }
                        else
                        {
                            r = stockoutService.SaveChangeOtNDetail(backno, inlist, outlist, remark, deport);
                        }
                    }
                    else if (type == "edit")
                    {
                        r = stockoutService.SaveChangeOtNDetail(no, inlist, outlist, remark, deport);

                    }
                    else
                    {
                        r.message = "操作类别错误";
                    }
                }

            }
            SessionHelper.Del("ON1" + no + Masterpage.CurrUser.staffid);
            return Json(r, JsonRequestBehavior.AllowGet);
        }
Example #24
0
 public ActionResult updatebomcost()
 {
     string forids = WebRequest.GetString("forids");
     string[] ids = forids.Split(',');
     int count = 0;
     foreach (string item in ids)
     {
         if (item == "") continue;
         System.Data.SqlClient.SqlParameter[] param = new System.Data.SqlClient.SqlParameter[1];
         System.Data.SqlClient.SqlParameter sp = new System.Data.SqlClient.SqlParameter("@bomid", item);
         param[0] = sp;// new System.Data.SqlClient.SqlParameter { Direction = System.Data.ParameterDirection.Input, Value = item, };
         var bom = ServiceDB.Instance.ExecuteSqlCommand("exec usp_update_bomcost @bomid ", param);
         count++;
     }
     ReturnValue r = new ReturnValue();
     r.status = count > 0;
     r.message = r.status ? "" : "BOM成本更新失败";
     return Json(r, JsonRequestBehavior.AllowGet);
 }
Example #25
0
        public ActionResult saveoutsell_2(string outsnlist, string ordersnlist, string remarklist, string materiallist, string depotlist, string amountlist)
        {
            string no = WebRequest.GetString("no", true);
            string type = WebRequest.GetString("type", true);
            string remark = WebRequest.GetString("remark", true);
            int supplier = WebRequest.GetInt("supplier", 0);
            string deport = WebRequest.GetString("deport", true);
            string order = WebRequest.GetString("order", true);
            string date = WebRequest.GetString("date", true);
            ReturnValue r = new ReturnValue() { status = false };

                        string[] outsnl = outsnlist.Split(',');
                        string[] ordersnl = ordersnlist.Split(',');
                        string[] remarkl = remarklist.Split(',');
                        string[] materiall = materiallist.Split(',');
                        string[] depotl = depotlist.Split(',');
                        string[] amountl = amountlist.Split(',');
                        if (type == "add")
                        {
                            string backno = stockoutService.AddStockOut(Masterpage.CurrUser.staffid, Masterpage.CurrUser.depId, supplier, 1, remark, deport);
                            if (backno == "")
                            {
                                r.message = "出库单生成失败";
                            }
                            else
                            {
                                try
                                {
                                    ServiceDB.Instance.ExecuteSqlCommand("update StockOut set  outDate='" + date + "',  bomOrderNo='" + order + "' where stockoutNo='" + backno + "'");
                                    for (int i = 0; i < ordersnl.Length; i++)
                                    {
                                        var od = ServiceDB.Instance.QueryOneModel<BomOrderDetail>("select * from BomOrderDetail where detailSn=" + ordersnl[i]);
                                        ServiceDB.Instance.ExecuteSqlCommand("insert into StockOutDetail values('" + backno + "','" + materiall[i] + "'," + depotl[i] + "," + ordersnl[i] + ",null," + amountl[i] + ",0," + od.Price + ",null,'" + remarkl[i] + "')");
                                    }
                                    r.status = true;
                                }
                                catch (Exception x)
                                { r.message = "添加明细失败:" + x.Message; }
                            }
                        }
                        else if (type == "edit")
                        {
                            try
                            {
                                for (int i = 0; i < ordersnl.Length; i++)
                                {

                                    if (outsnl[i] == "0")
                                        ServiceDB.Instance.ExecuteSqlCommand("insert into StockOutDetail values('" + no + "','" + materiall[i] + "'," + depotl[i] + "," + ordersnl[i] + ",null," + amountl[i] + ",0,0,null,'" + remarkl[i] + "')");
                                    else if (outsnlist[i] > 0 && amountlist[i] == 0) ServiceDB.Instance.ExecuteSqlCommand("delete StockOutDetail where detailSn=" + outsnlist[i]);
                                    else ServiceDB.Instance.ExecuteSqlCommand("update StockOutDetail set depotId=" + depotl[i] + ",outAmount=" + amountl[i] + ",remark='" + remarkl[i] + "', outDate='" + date + "' where detailSn=" + outsnl[i]);

                                }
                                r.status = true;
                            }
                            catch (Exception x)
                            { r.message = "修改明细失败:" + x.Message; }

                        }
                        else r.message = "操作类别有误";

            return Json(r, JsonRequestBehavior.AllowGet);
        }
Example #26
0
        public ActionResult updatebomnode()
        {
            //id: id,mybom: mybom, forbom: bomid, type: type,name:name,amount: amount, price: price, remark: rmk
            int id = WebRequest.GetInt("id", 0);
            int mybomid = WebRequest.GetInt("mybom", 0);
            int forbom = WebRequest.GetInt("forbom", 0);

            var type = WebRequest.GetString("type", true);
            var name = WebRequest.GetString("name", true);
            var remark = WebRequest.GetString("remark", true);
            var amount = WebRequest.GetFloat("amount", 0f);
            var price = WebRequest.GetFloat("price", 0f);
            var bom = ServiceDB.Instance.QueryOneModel<BomMain>("select * from BomMain where bomid=" + forbom);
            var row = 0; double newcost = 0f;
            ReturnValue r = new ReturnValue { status = false };
            #region 更新
            if (type == "addk")
            {
                row = ServiceDB.Instance.ExecuteSqlCommand("insert into BomVirtual values(" + forbom + ",'" + name + "'," + amount + "," + price + ",'" + remark + "')");
                if (row == 1)
                {
                    newcost = bom.rootCost + amount * price;
                    r.status = true; r.message = "新项目添加成功";
                }
            }
            else if (type == "addm")
            {
                var mybom = ServiceDB.Instance.QueryOneModel<BomMain>("select * from BomMain where bomid=" + mybomid);
                row = ServiceDB.Instance.ExecuteSqlCommand("insert into BomCost values(" + mybomid + "," + price + ",getdate(),'" + remark + "')");
                if (row == 1)
                {
                    newcost = bom.rootCost + amount * price;//
                    r.status = true; r.message = "新BOM单价添加成功";
                }
            }
            else if (type == "updk")
            {
                var old = ServiceDB.Instance.QueryOneModel<BomVirtual>("select * from BomVirtual where virtualId=" + id);
                row = ServiceDB.Instance.ExecuteSqlCommand("update BomVirtual set virtualName='" + name + "',vAmount=" + amount + ",vPrice=" + price + ",remark='" + remark + "' where virtualId=" + id);
                if (row == 1)
                {
                    newcost = bom.rootCost + (amount * price - old.vAmount * old.vPrice);
                    r.status = true; r.message = "项目修改成功";
                }
            }
            else if (type == "updm")
            {
                var mybom = ServiceDB.Instance.QueryOneModel<BomMain>("select * from BomMain where bomid=" + mybomid);
                var old = ServiceDB.Instance.QueryOneModel<BomCost>("select * from BomCost where costId=" + id);
                row = ServiceDB.Instance.ExecuteSqlCommand("update BomCost set price=" + price + ",remark='" + remark + "' where costId=" + id);
                if (row == 1)
                {
                    newcost = bom.rootCost + (amount * price - old.price * amount);
                    r.status = true; r.message = "BOM单价修改成功";
                }
            }
            else if (type == "delm")
            {
                var mybom = ServiceDB.Instance.QueryOneModel<BomMain>("select * from BomMain where bomid=" + mybomid);
                var old = ServiceDB.Instance.QueryOneModel<BomCost>("select * from BomCost where costId=" + id);
                row = ServiceDB.Instance.ExecuteSqlCommand("delete BomCost where costId=" + id);
                if (row == 1)
                {
                    newcost = bom.rootCost - (old.price * amount);
                    r.status = true; r.message = "BOM单价删除成功";
                }
            }
            else if (type == "delk")
            {
                var old = ServiceDB.Instance.QueryOneModel<BomVirtual>("select * from BomVirtual where virtualId=" + id);
                row = ServiceDB.Instance.ExecuteSqlCommand("delete BomVirtual where virtualId=" + id);
                if (row == 1)
                {
                    newcost = bom.rootCost - (old.vPrice * old.vAmount);
                    r.status = true; r.message = "BOM成本项目删除成功";
                }
            }
            else { r.status = false; r.message = type + "操作类别错误"; }
            if (r.status)
            {
                if (newcost < 0) newcost = 0;
                ServiceDB.Instance.ExecuteSqlCommand("update BomMain set rootCost=" + newcost + " where bomid=" + forbom);
                r.value = Math.Round(newcost, 4).ToString();

            }
            #endregion

            return Json(r, JsonRequestBehavior.AllowGet);
        }
Example #27
0
        public ActionResult savecanreturn(string no)
        {
            string type = WebRequest.GetString("type", true);
            string remark = WebRequest.GetString("remark", true);
            string deport = WebRequest.GetString("deport", true);
            var returntype = WebRequest.GetInt("returntype", 0);
            ReturnValue r = new ReturnValue() { status = false };
            var list = new List<StockReturnDetailModel>();
            list = (List<StockReturnDetailModel>)SessionHelper.GetSession("SR" + no + Masterpage.CurrUser.staffid);
            if (list.Count == 0)
            {
                r = new ReturnValue { status = false, message = "未提交任何退单明细" };
            }
            else
            {
                if (type == "add")
                {
                    string backno = stockoutService.AddStockReturn(Masterpage.CurrUser.staffid, Masterpage.CurrUser.depId, remark, deport, returntype);
                    if (backno == "")
                    {
                        r.message = "领料单生成失败";
                    }
                    else
                    {
                        r = stockoutService.SaveStockReturnDetail(backno, list, remark, deport);
                    }
                }
                else if (type == "edit")
                {
                    r = stockoutService.SaveStockReturnDetail(no, list, remark, deport);

                }
            }
            SessionHelper.Del("SR" + no + Masterpage.CurrUser.staffid);
            return Json(r, JsonRequestBehavior.AllowGet);
        }
Example #28
0
        public ActionResult showmsg(int id)
        {
            var msg = ServiceDB.Instance.QueryOneModel<MsgReceModel>("select * from MsgReceModel where receId=" + id + " and recestaffid=" + Masterpage.CurrUser.staffid);

            ReturnValue r = new ReturnValue();
            if (msg != null)
            {
                if (!msg.isRead) ServiceDB.Instance.QueryOneModel<MsgReceModel>("update msgrece set isread=1,readdate=getdate() where receId=" + id);
                r.status = true;
                r.message = msg.msgcontent;
                r.value = msg.title;
            }
            else { r.status = false; }
            return Json(r, JsonRequestBehavior.AllowGet);
        }
Example #29
0
        public ActionResult savesneedbuy(string no)
        {
            string type = WebRequest.GetString("type", true);
            string supplier = WebRequest.GetString("supplier", true);
            int i_supplier = Convert.ToInt32(supplier);
            string remark = WebRequest.GetString("remark", true);
            //deport, datesend: datesend, dateback
            string deport = WebRequest.GetString("deport", true);
            string datesend = WebRequest.GetString("datesend", true);
            string dateback = WebRequest.GetString("dateback", true);
            ReturnValue r = new ReturnValue() { status = false };
            var list = new List<V_DelegateSendDetailModel>();
            list = (List<V_DelegateSendDetailModel>)SessionHelper.GetSession("DS" + no + Masterpage.CurrUser.staffid);
            if (list.Count == 0)
            {
                r = new ReturnValue { status = false, message = "未提交任何发货明细" };
            }
            else
            {
                var head = 0;
                if (type == "add")
                {
                    string backno = bomService.GetDelegateSendNo();// purchaseService.AddPurchase("", Masterpage.CurrUser.staffid, Masterpage.CurrUser.depId, i_supplier, 1, 0, remark);
                    if (backno != "")
                    {
                        head = ServiceDB.Instance.ExecuteSqlCommand("INSERT INTO [dbo].[DelegateSend] values('" + backno + "'," + Masterpage.CurrUser.staffid + "," + Masterpage.CurrUser.depId + "," + i_supplier
                               + ",'" + datesend + "','" + dateback + "',getdate(),'" + remark + "',0,1,1,0,0,'','" + deport + "')");
                   no=backno;
                    }
                }
                else if (type == "edit")
                {
                    head = ServiceDB.Instance.ExecuteSqlCommand("update [dbo].[DelegateSend] set sendDate='" + datesend + "',needDate='" + dateback + "',remark='" + remark + "',deportStaff='" + deport + "' where sendNo='" + no + "'");

                }
                if (head>0)
                {
                    #region 修改明细
                    if (type == "edit") ServiceDB.Instance.ExecuteSqlCommand("delete DelegateSendDetail where sendNo='" + no + "'");
                    head = 0;
                    List<string> delgno = new List<string>();
                    foreach (var item in list)
                    {
                        var addone = ServiceDB.Instance.ExecuteSqlCommand("INSERT INTO [dbo].[DelegateSendDetail] VALUES('" + no + "','" + item.delegateNo + "'," + item.productAmount + "," + item.price + ",0,'" + item.materialNo + "'," + item.bomId + "," + item.delegateDetailSn + "," + item.theoryAmount + "," + item.realAmount + ",'" + item.remark + "')");
                        if (!delgno.Contains(item.delegateNo))
                        {
                            var hadd = ServiceDB.Instance.QueryOneModel<DelegateOrder>("select * from DelegateOrder where delegateNo='" + item.delegateNo + "' and canfs=1");
                            if (hadd != null) ServiceDB.Instance.ExecuteSqlCommand("update DelegateOrder set canfs=0 where delegateNo='" + item.delegateNo + "'");
                            delgno.Add(item.delegateNo);
                        }

                        head += addone;
                    }
                    #endregion
                    if (head == list.Count) r.status = true;
                    else r.message = "保存失败";
                }
            }
            SessionHelper.Del("DS" + no + Masterpage.CurrUser.staffid);
            return Json(r, JsonRequestBehavior.AllowGet);
        }
Example #30
0
        public ActionResult showmsg2(Guid id)
        {
            var msg = ServiceDB.Instance.QueryOneModel<MsgSendModel>("select * from MsgSendModel where msgId='" + id + "' and staffid=" + Masterpage.CurrUser.staffid);

            ReturnValue r = new ReturnValue();
            if (msg != null)
            {
                r.status = true;
                r.message = msg.msgcontent;
                r.value = msg.title;
                r.value2 = msg.receNames;
            }
            else { r.status = false; }
            return Json(r, JsonRequestBehavior.AllowGet);
        }