コード例 #1
0
ファイル: CHSv.cs プロジェクト: liyihan20/Ele_Sale
        public override string SaveBill(System.Web.Mvc.FormCollection fc, UserInfo user)
        {
            bill = new ChBill();
            SomeUtils.SetFieldValueToModel(fc, bill);
            List <ChBillDetail> details = JsonConvert.DeserializeObject <List <ChBillDetail> >(fc.Get("ch_bill_details"));

            bill.ChBillDetail.AddRange(details);

            try {
                //保存送货地址信息
                var dInfos = new OtherSv().GetDeliveryInfo(bill.customer_no)
                             .Where(d => d.deliveryUnit == bill.delivery_unit && d.attn == bill.delivery_attn &&
                                    d.addr == bill.delivery_addr && d.phone == bill.delivery_phone).Count();
                if (dInfos == 0)
                {
                    var info = new CustomerDeliveryInfo()
                    {
                        customer_name   = bill.customer_name,
                        customer_number = bill.customer_no,
                        delivery_unit   = bill.delivery_unit,
                        addr            = bill.delivery_addr,
                        attn            = bill.delivery_attn,
                        phone           = bill.delivery_phone,
                        op_date         = DateTime.Now,
                        op_name         = user.realName
                    };
                    db.CustomerDeliveryInfo.InsertOnSubmit(info);
                }

                var existsed = db.ChBill.Where(c => c.sys_no == bill.sys_no).ToList();
                if (existsed.Count() > 0)
                {
                    //备份旧单
                    BackupData bd = new BackupData();
                    bd.sys_no         = bill.sys_no;
                    bd.op_date        = DateTime.Now;
                    bd.user_id        = user.userId;
                    bd.main_data      = SomeUtils.ModelToString <ChBill>(existsed.First());
                    bd.secondary_data = SomeUtils.ModelsToString <ChBillDetail>(existsed.First().ChBillDetail.ToList());
                    db.BackupData.InsertOnSubmit(bd);

                    //删掉旧单
                    db.ChBillDetail.DeleteAllOnSubmit(existsed.First().ChBillDetail);
                    db.ChBill.DeleteAllOnSubmit(existsed);
                }
                bill.bill_date = DateTime.Now;
                bill.user_id   = user.userId;

                db.ChBill.InsertOnSubmit(bill);
                db.ChBillDetail.InsertAllOnSubmit(bill.ChBillDetail);
                db.SubmitChanges();
            }
            catch (Exception ex) {
                return(ex.Message);
            }

            return("");
        }
コード例 #2
0
 /// <summary>
 /// (有参构造)审批之前需要做的事
 /// </summary>
 /// <param name="step">步骤</param>
 /// <param name="stepName">步骤名称</param>
 /// <param name="isPass">是否通过</param>
 /// <param name="userId">用户ID</param>
 public override void DoWhenBeforeAudit(int step, string stepName, bool isPass, int userId)
 {
     if (isPass)
     {
         //审批ok之前再检查一次产品是否被禁用
         var otherSv = new OtherSv();
         foreach (var d in order.OrderDetail)
         {
             if (otherSv.GetProducts(d.item_no).Count() < 1)
             {
                 throw new Exception("以下产品编码已被禁用或变更为历史资料:[" + d.item_no + "],如有问题请联系工程部。");
             }
         }
     }
 }