예제 #1
0
 public JsonResult ViewReceiptEditSave(T_Receipt model, string jsonStr)
 {
     using (TransactionScope sc = new TransactionScope())
     {
         try
         {
             List <T_ReceiptDetails> details = Com.Deserialize <T_ReceiptDetails>(jsonStr);
             var receipt = db.T_Receipt.Find(model.ID);
             receipt.Receivings = model.Receivings;
             receipt.Vip_Name   = model.Vip_Name;
             receipt.StorName   = model.StorName;
             receipt.Money      = model.Money;
             db.SaveChanges();
             if (details != null)
             {
                 foreach (var item in details)
                 {
                     var itemdetail = db.T_ReceiptDetails.Find(item.ID);
                     itemdetail.ProductName = item.ProductName;
                     itemdetail.Qty         = item.Qty;
                     itemdetail.Unit        = item.Unit;
                 }
                 db.SaveChanges();
             }
             sc.Complete();
             return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
         }
         catch (Exception ex)
         {
             return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet));
         }
     }
 }
예제 #2
0
 public JsonResult UpdateprintCountByID(int id)
 {
     try
     {
         T_Receipt model = db.T_Receipt.Find(id);
         model.PrintCount += 1;
         db.SaveChanges();
         return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { State = "Faile", Message = ex.Message }));
     }
 }
예제 #3
0
 public JsonResult RecieptDelete(int id)
 {
     try
     {
         T_Receipt model = db.T_Receipt.Find(id);
         model.IsDelete = 1;
         db.SaveChanges();
         return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #4
0
    protected void updateUser_Click(object sender, EventArgs e)
    {
        ReceiptAdapter da   = new ReceiptAdapter();
        T_Receipt      item = new T_Receipt();

        item.Code = this.txt_code.Text.Trim();
        item.Name = this.txt_name.Text.Trim();
        if (string.IsNullOrEmpty(item.Code))
        {
            Label1.Text = "部门代码不能为空";
            return;
        }
        if (string.IsNullOrEmpty(item.Name))
        {
            Label1.Text = "部门名称不能为空";
            return;
        }
        if (string.IsNullOrEmpty(HiddenField1.Value))
        {
            //新增
            try
            {
                da.addReceipt(item);
                Label1.Text = "新增成功";
                init();
                GridViewBand();
            }
            catch (Exception ex)
            {
                Label1.Text = ex.Message;
            }
        }
        else
        {
            //更新
            item.Id = Int32.Parse(HiddenField1.Value);
            try
            {
                da.updateReceipt(item);
                Label1.Text = "保存成功";
                init();
                GridViewBand();
            }
            catch (Exception ex)
            {
                Label1.Text = ex.Message;
            }
        }
    }
예제 #5
0
        /// <summary>
        /// 打印
        /// </summary>
        /// <param name="id"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public ActionResult ViewReceiptPrint(int id, int page = 1)
        {
            if (id == 0)
            {
                return(HttpNotFound());
            }
            T_Receipt model = db.T_Receipt.Find(id);
            IQueryable <T_ReceiptDetails> list = db.T_ReceiptDetails.Where(s => s.ReceiptOrderID == model.ID);
            int    totalRows = list.Count();
            int    total     = 0;
            string href      = "";

            if (totalRows % 10 != 0)
            {
                total = totalRows / 10 + 1;
            }
            else
            {
                total = totalRows / 6;
            }
            for (int i = 1; i <= total; i++)
            {
                href += "<a href=\"?page=" + i + "&id=" + id + "\">   " + i + "   </a>";
            }
            Recipts models = new Recipts
            {
                ID             = model.ID,
                StorName       = model.StorName,
                ShopDate       = model.ShopDate,
                Vip_Name       = model.Vip_Name,
                Receivings     = model.Receivings,
                Money          = model.Money,
                receiptDetails = list.OrderByDescending(s => s.ID).Skip((page - 1) * 10).Take(10).ToList()
            };

            ViewData["pager"] = href;
            ViewData["page"]  = page;
            ViewData["total"] = total;
            return(View(models));
        }
예제 #6
0
 public void updateReceipt(T_Receipt item)
 {
     Manager.updateReceipt(item);
 }
예제 #7
0
 public void addReceipt(T_Receipt item)
 {
     Manager.addReceipt(item);
 }
예제 #8
0
        public JsonResult ViewReceiptAddSave(T_Receipt model, string jsonStr)
        {
            using (TransactionScope sc = new TransactionScope())
            {
                try
                {
                    GY     gy  = new GY();
                    string cmd = "";

                    cmd = "{" +
                          "\"appkey\":\"171736\"," +
                          "\"method\":\"gy.erp.trade.get\"," +
                          "\"page_no\":1," +
                          "\"page_size\":10," +
                          "\"platform_code\":\"" + model.OrderCode + "\"," +
                          "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" +
                          "}";

                    string sign = gy.Sign(cmd);
                    cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}");
                    string   ret      = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd);
                    JsonData jsonData = null;
                    jsonData = JsonMapper.ToObject(ret);

                    if (jsonData.Count == 6 || jsonData["orders"].Count == 0)
                    {
                        cmd = "{" +
                              "\"appkey\":\"171736\"," +
                              "\"method\":\"gy.erp.trade.history.get\"," +
                              "\"page_no\":1," +
                              "\"page_size\":10," +
                              "\"platform_code\":\"" + model.OrderCode + "\"," +
                              "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" +
                              "}";
                        sign     = gy.Sign(cmd);
                        cmd      = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}");
                        ret      = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd);
                        jsonData = null;
                        jsonData = JsonMapper.ToObject(ret);
                        if (jsonData.Count == 6 || jsonData["orders"].Count == 0)
                        {
                            return(Json(new { State = "Faile", Message = "订单号不存在" }));
                        }
                    }
                    JsonData jsonOrders             = jsonData["orders"][0];
                    List <T_ReceiptDetails> details = Com.Deserialize <T_ReceiptDetails>(jsonStr);
                    //T_OrderList order = db.T_OrderList.Find(model.OrderId);
                    string           code = "SKSJ";
                    string           date = DateTime.Now.ToString("yyyyMMdd");
                    List <T_Receipt> list = db.T_Receipt.Where(s => s.Code.Contains(date)).OrderByDescending(s => s.ID).ToList();
                    if (list.Count == 0)
                    {
                        code += date + "0001";
                    }
                    else
                    {
                        string old     = list[0].Code.Substring(12);
                        int    newCode = int.Parse(old) + 1;
                        code += date + newCode.ToString().PadLeft(4, '0');
                    }
                    model.Code       = code;
                    model.Date       = DateTime.Now;
                    model.IsDelete   = 0;
                    model.ShopDate   = DateTime.Parse(jsonOrders["createtime"].ToString());
                    model.PostUser   = UserModel.Nickname;
                    model.PrintCount = 0;
                    db.T_Receipt.Add(model);
                    db.SaveChanges();
                    if (details != null)
                    {
                        foreach (var item in details)
                        {
                            item.ReceiptOrderID = model.ID;
                            db.T_ReceiptDetails.Add(item);
                        }
                        db.SaveChanges();
                    }
                    sc.Complete();
                    return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }
예제 #9
0
        /// <summary>
        /// 查询管易订单
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public JsonResult GetReceiptByGy(string code)
        {
            GY     gy  = new GY();
            string cmd = "";

            cmd = "{" +
                  "\"appkey\":\"171736\"," +
                  "\"method\":\"gy.erp.trade.get\"," +
                  "\"page_no\":1," +
                  "\"page_size\":10," +
                  "\"platform_code\":\"" + code + "\"," +
                  "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" +
                  "}";

            string sign = gy.Sign(cmd);

            cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}");
            string   ret      = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd);
            JsonData jsonData = null;

            jsonData = JsonMapper.ToObject(ret);

            if (jsonData.Count == 6 || jsonData["orders"].Count == 0)
            {
                cmd = "{" +
                      "\"appkey\":\"171736\"," +
                      "\"method\":\"gy.erp.trade.history.get\"," +
                      "\"page_no\":1," +
                      "\"page_size\":10," +
                      "\"platform_code\":\"" + code + "\"," +
                      "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" +
                      "}";
                sign     = gy.Sign(cmd);
                cmd      = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}");
                ret      = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd);
                jsonData = null;
                jsonData = JsonMapper.ToObject(ret);
                if (jsonData.Count == 6 || jsonData["orders"].Count == 0)
                {
                    return(Json(new { State = "Faile", Message = "订单号不存在" }));
                }
            }
            JsonData jsonOrders = jsonData["orders"][0];
            //订单信息
            string platform_code = isNULL(jsonOrders["platform_code"]).ToString();
            //店铺名称
            string shop_name = isNULL(jsonOrders["shop_name"]).ToString();
            //旺旺帐号
            string    vip_name      = isNULL(jsonOrders["vip_name"]).ToString();
            string    receiver_name = isNULL(jsonOrders["receiver_name"]).ToString();
            string    payment       = isNULL(jsonOrders["payment"]).ToString();
            T_Receipt model         = new T_Receipt();

            model.OrderCode  = code;
            model.Receivings = receiver_name;
            model.Money      = decimal.Parse(payment);
            model.Vip_Name   = receiver_name;
            model.StorName   = shop_name;
            List <T_ReceiptDetails> DetailsList = new List <T_ReceiptDetails>();

            JsonData jsonDetails = jsonOrders["details"];

            for (int i = 0; i < jsonDetails.Count; i++)
            {
                T_ReceiptDetails DetailsModel = new T_ReceiptDetails();
                DetailsModel.ProductName = jsonDetails[i]["item_name"] == null ? "" : jsonDetails[i]["item_name"].ToString();
                DetailsModel.Unit        = jsonDetails[i]["item_simple_name"] == null ? "" : jsonDetails[i]["item_simple_name"].ToString();
                DetailsModel.Qty         = jsonDetails[i]["qty"] == null ? 0 : int.Parse(jsonDetails[i]["qty"].ToString());
                DetailsList.Add(DetailsModel);
            }
            var json = new
            {
                rows = (from r in DetailsList
                        select new T_ReceiptDetails
                {
                    ProductName = r.ProductName,
                    Unit = r.Unit,
                    Qty = r.Qty
                }).ToArray()
            };

            return(Json(new { State = "Success", ModelList = model, Json = json }, JsonRequestBehavior.AllowGet));
        }