Beispiel #1
0
        public void SaveDeliveryBill(System.Web.Mvc.FormCollection fc, UserInfo user)
        {
            Sale_eqm_ch_bill bill = new Sale_eqm_ch_bill();

            SomeUtils.SetFieldValueToModel(fc, bill);
            List <Sale_eqm_ch_bill_detail> details = JsonConvert.DeserializeObject <List <Sale_eqm_ch_bill_detail> >(fc.Get("ch_bill_details"));

            bill.FUserName = user.realName;
            bill.FSaveDate = DateTime.Now;
            bill.Sale_eqm_ch_bill_detail.AddRange(details);

            if (string.IsNullOrEmpty(bill.FSysNo))
            {
                bill.FSysNo = GetNextSysNo();
            }
            else
            {
                var existedBill = db.Sale_eqm_ch_bill.Where(s => s.FSysNo == bill.FSysNo && (s.FDeleted == null || s.FDeleted == false)).FirstOrDefault();
                if (existedBill != null)
                {
                    existedBill.FDeleted = true;
                }
            }

            db.Sale_eqm_ch_bill.InsertOnSubmit(bill);
            db.SubmitChanges();
        }
Beispiel #2
0
        public JsonResult GetK3StockBill(string account, string billNo)
        {
            var sv = new EqmSv();
            List <getK3EqmChDataResult> list;

            try {
                list = sv.GetK3StockBill(account, billNo);
            }
            catch (Exception ex) {
                return(Json(new { suc = false, msg = ex.Message }));
            }
            if (list.Count() < 1)
            {
                return(Json(new { suc = false, msg = "在K3找不到此销售出库单号" }));
            }

            var h    = list.First();
            var bill = new Sale_eqm_ch_bill();

            bill.FAccount        = account;
            bill.FBillNo         = billNo;
            bill.FDate           = h.FDate;
            bill.FCustomerName   = h.FCustomerName;
            bill.FCustomerNumber = h.FCustomerNumber;
            bill.FUserName       = currentUser.realName;

            var details = new List <Sale_eqm_ch_bill_detail>();

            foreach (var l in list)
            {
                var d = new Sale_eqm_ch_bill_detail();
                d.FAmount     = l.FConsignAmount;
                d.FIndex      = l.FEntryID;
                d.FItemModel  = l.FModel;
                d.FItemName   = l.FName;
                d.FItemNumber = l.FNumber;
                d.FPrice      = l.FConsignPrice;
                d.FQty        = (int)l.FAuxQty;
                d.FUnitName   = l.FUnitName;

                details.Add(d);
            }

            var deliveryInfo = sv.GetDeliveryInfo(bill.FCustomerNumber);

            Wlog(string.Format("获取出库单信息,account:{0},billNo:{1}", account, billNo));

            return(Json(new { suc = true, bill = bill, details = details, deliveryInfo = deliveryInfo }));
        }