Beispiel #1
0
 public EOSv(string sysNo)
 {
     try {
         bill = db.Sale_eo_bill.Single(c => c.sys_no == sysNo);
     }
     catch {
         throw new Exception("流水号不存在");
     }
 }
Beispiel #2
0
        public override object GetNewBill(UserInfo currentUser)
        {
            bill              = new Sale_eo_bill();
            bill.sys_no       = GetNextSysNo(BILL_TYPE);
            bill.applier_name = currentUser.realName;
            bill.bill_date    = DateTime.Now;
            bill.account      = "";

            return(bill);
        }
Beispiel #3
0
        public override string SaveBill(System.Web.Mvc.FormCollection fc, UserInfo user)
        {
            bill = new Sale_eo_bill();
            SomeUtils.SetFieldValueToModel(fc, bill);
            bill.Sale_eo_bill_detail.AddRange(JsonConvert.DeserializeObject <List <Sale_eo_bill_detail> >(fc.Get("details")));

            if (string.IsNullOrEmpty(bill.clerk_no))
            {
                return("营业员请输入厂牌或姓名然后按回车键搜索后,在列表中选择");
            }

            try {
                var existedBill = db.Sale_eo_bill.Where(s => s.sys_no == bill.sys_no).FirstOrDefault();
                if (existedBill != null)
                {
                    bill.applier_id   = existedBill.applier_id;
                    bill.applier_name = existedBill.applier_name;
                    bill.apply_time   = existedBill.apply_time;

                    //备份
                    JsonSerializerSettings js = new JsonSerializerSettings()
                    {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                    };
                    BackupData bd = new BackupData();
                    bd.op_date        = DateTime.Now;
                    bd.sys_no         = existedBill.sys_no;
                    bd.user_id        = user.userId;
                    bd.main_data      = JsonConvert.SerializeObject(existedBill, js);
                    bd.secondary_data = JsonConvert.SerializeObject(existedBill.Sale_eo_bill_detail, js);
                    db.BackupData.InsertOnSubmit(bd);

                    //删除
                    db.Sale_eo_bill_detail.DeleteAllOnSubmit(existedBill.Sale_eo_bill_detail);
                    db.Sale_eo_bill.DeleteOnSubmit(existedBill);
                }
                else
                {
                    bill.applier_id   = user.userId;
                    bill.applier_name = user.realName;
                    bill.apply_time   = DateTime.Now;
                }

                db.Sale_eo_bill.InsertOnSubmit(bill);
                db.Sale_eo_bill_detail.InsertAllOnSubmit(bill.Sale_eo_bill_detail);
                db.SubmitChanges();
            }
            catch (Exception ex) {
                return(ex.Message);
            }
            return("");
        }