Example #1
0
 public void UpdateTransportPaymentData(int id, DateTime?paymentDate, double?accountPayble, double?deductions, double?reparations, double?handlingfee, bool paid, string userID)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         TransportRecords record = context.TransportRecords.FirstOrDefault(x => x.ID == id);
         if (record == null)
         {
             throw new ApplicationException("要修改的记录不存在");
         }
         record.PayDate       = paymentDate;
         record.AccountPayble = accountPayble;
         record.Deductions    = deductions;
         record.Reparations   = reparations;
         record.HandlingFee   = handlingfee;
         record.Paid          = paid;
         record.TransportRecordsOptionHistory.Add(
             new TransportRecordsOptionHistory()
         {
             Description = string.Format("财务补充单据内容,新内容 赔款:{0} 扣款:{1} 付款日:{2} 应付金额: {3} ", reparations, deductions, paymentDate, accountPayble),
             LogDateTime = DateTime.Now,
             Operation   = "更新",
             UserID      = userID
         });
         context.SubmitChanges();
     }
 }
Example #2
0
 public void UpdateTransportModel(TransportRecordModel model, string userID)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         TransportRecords record = context.TransportRecords.FirstOrDefault(x => x.ID == model.ID);
         record.AccountPayble = model.AccountPayble;
         record.CarLicense    = model.CarLicense;
         record.ClientName    = model.ClientName;
         record.Comment       = model.Comment;
         record.Deductions    = model.Deductions;
         record.DeliverDate   = model.DeliverDate;
         record.DeliverPrice  = model.DeliverPrice;
         record.DeliverType   = model.DeliverType;
         record.Driver        = model.Driver;
         record.Error         = model.Error;
         record.ErrorMessage  = model.ErrorMessage;
         record.FromLocation  = model.FromLocation;
         record.HandlingFee   = model.HandlingFee;
         record.OilCard       = model.OilCard;
         record.PackageName   = model.PackageName;
         record.Paid          = model.Paid;
         record.PayDate       = model.PayDate;
         record.PrePay        = model.PrePay;
         record.Quantity      = model.Quantity;
         record.Received      = model.Received;
         record.ReceivedDate  = model.ReceivedDate;
         record.Reparations   = model.Reparations;
         record.ShortBargeFee = model.ShortBargeFee;
         record.Status        = model.Status;
         record.ToLocation    = model.ToLocation;
         record.TrayNo        = model.TrayNo;
         record.Volume        = model.Volume;
         context.SubmitChanges();
     }
 }
Example #3
0
        public void UpdateRoleModel(RoleModel role)
        {
            using (SQLDBDataContext context = new SQLDBDataContext())
            {
                Roles target = context.Roles.FirstOrDefault(x => x.RoleID == role.RoleID);
                if (target == null)
                {
                    throw new Exception("要编辑的角色不存在");
                }
                target.AccessList = role.AccessList;
                target.RoleName   = role.RoleName;
                string[] selectedMenuCode = (from x in role.Menus
                                             select x.MenuCode).ToArray();

                string[] newSelectedMenuCode = (from x in role.Menus
                                                where target.MenuAccess.Count(y => y.MenuCode == x.MenuCode) == 0
                                                select x.MenuCode).ToArray();

                string[] allMenuCode = (from x in context.MenuItem
                                        select x.MenuCode).ToArray();

                string[] unselectedMenuCode = allMenuCode.Where(x => !selectedMenuCode.Contains(x)).ToArray();
                context.MenuAccess.DeleteAllOnSubmit(context.MenuAccess.Where(x => x.RoleID == role.RoleID && unselectedMenuCode.Contains(x.MenuCode)));
                context.MenuAccess.InsertAllOnSubmit(from x in newSelectedMenuCode
                                                     select new MenuAccess()
                {
                    MenuCode = x,
                    RoleID   = role.RoleID
                });
                context.SubmitChanges();
            }
        }
Example #4
0
 public void InsertNewTransportDetail(TransportRecordDetailModel detail, string userID)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         context.TransportRecordDetail.InsertOnSubmit(
             new TransportRecordDetail()
         {
             DetailNo          = detail.DetailNo,
             PackageName       = detail.PackageName,
             Quantity          = detail.Quantity,
             TransportRecordID = detail.TransportRecordID,
             Volume            = detail.Volume,
             ReceiptCount      = detail.ReceiptCount,
             Comment           = detail.Comment
         }
             );
         context.TransportRecordsOptionHistory.InsertOnSubmit(
             new TransportRecordsOptionHistory()
         {
             Description       = string.Format("插入新货物明细, 编号:{0},货物{1},数量:{2},体积:{3}", detail.DetailNo, detail.PackageName, detail.Quantity, detail.Volume),
             LogDateTime       = DateTime.Now,
             Operation         = "新货物明细",
             UserID            = userID,
             TransportRecordID = detail.TransportRecordID
         }
             );
         context.SubmitChanges();
     }
 }
Example #5
0
 public void DeleteTransportRecordDetail(long id)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         context.TransportRecordDetail.DeleteOnSubmit(context.TransportRecordDetail.FirstOrDefault(x => x.ID == id));
         context.SubmitChanges();
     }
 }
Example #6
0
 public void ChangePassword(string userID, string newPassword)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         Users target = context.Users.FirstOrDefault(x => x.UserID == userID);
         if (target == null)
         {
             throw new ApplicationException("用户不存在");
         }
         target.Password = newPassword;
         context.SubmitChanges();
     }
 }
Example #7
0
 public void UpdateLoginData(UserModel user)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         Users curuser = context.Users.FirstOrDefault(x => x.UserID == user.UserID);
         if (curuser == null)
         {
             return;
         }
         curuser.LastLoginIP   = user.LastLoginIP;
         curuser.LastLoginTime = user.LastLoginTime;
         context.SubmitChanges();
     }
 }
Example #8
0
 public void UpdateClientInformation(ClientModel client)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         Client update = context.Client.FirstOrDefault(x => x.ID == client.ID);
         if (update == null)
         {
             throw new ApplicationException("要修改的客户信息不存在");
         }
         update.ClientName = client.ClientName;
         update.ShortName  = client.ShortName;
         context.SubmitChanges();
     }
 }
Example #9
0
 public int InsertTransprotModel(TransportRecordModel model)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         TransportRecords newRecord = new TransportRecords()
         {
             AccountPayble = model.AccountPayble,
             CarLicense    = model.CarLicense,
             ClientName    = model.ClientName,
             Comment       = model.Comment,
             Deductions    = model.Deductions,
             DeliverDate   = model.DeliverDate,
             DeliverPrice  = model.DeliverPrice,
             DeliverType   = model.DeliverType,
             Driver        = model.Driver,
             FromLocation  = model.FromLocation,
             HandlingFee   = model.HandlingFee,
             PackageName   = model.PackageName,
             PayDate       = model.PayDate,
             PrePay        = model.PrePay,
             Quantity      = model.Quantity,
             Reparations   = model.Reparations,
             ShortBargeFee = model.ShortBargeFee,
             Status        = model.Status,
             ToLocation    = model.ToLocation,
             Volume        = model.Volume,
             TrayNo        = model.TrayNo,
             OilCard       = model.OilCard,
             BusinessArea  = model.BusinessArea,
             Error         = model.Error,
             Paid          = model.Paid,
             Received      = model.Received,
             ReceivedDate  = model.ReceivedDate
         };
         newRecord.TransportRecordsOptionHistory.AddRange(from x in model.HistoryItem
                                                          select new TransportRecordsOptionHistory()
         {
             Description       = x.Description,
             LogDateTime       = DateTime.Now,
             Operation         = x.Operation,
             TransportRecordID = newRecord.ID,
             UserID            = x.UserID
         });
         context.TransportRecords.InsertOnSubmit(newRecord);
         context.SubmitChanges();
         return(newRecord.ID);
     }
 }
Example #10
0
 public void InsertNewArea(string newArea)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         if (context.BusinessArea.Count(x => x.AreaName == newArea) > 0)
         {
             throw new Exception("输入的地区名已经存在");
         }
         BusinessArea area = new BusinessArea()
         {
             AreaName = newArea
         };
         context.BusinessArea.InsertOnSubmit(area);
         context.SubmitChanges();
     }
 }
Example #11
0
 public void UpdateUser(UserModel user)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         Users target = context.Users.FirstOrDefault(x => x.UserID == user.UserID);
         if (target == null)
         {
             throw new ApplicationException("用户不存在");
         }
         target.Comment = string.IsNullOrEmpty(user.Comment)?string.Empty:user.Comment;
         target.AreaID  = user.AreaID;
         target.Name    = user.Name;
         //target.RoleId = user.RoleID;
         target.Disabled = user.Disabled;
         context.SubmitChanges();
     }
 }
Example #12
0
 public void UpdateTransportDetailModel(TransportRecordDetailModel model)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         TransportRecordDetail detail = context.TransportRecordDetail.FirstOrDefault(x => x.ID == model.ID);
         if (detail == null)
         {
             return;
         }
         detail.DetailNo     = model.DetailNo;
         detail.PackageName  = model.PackageName;
         detail.Quantity     = model.Quantity;
         detail.Volume       = model.Volume;
         detail.ReceiptCount = model.ReceiptCount;
         detail.Comment      = model.Comment;
         context.SubmitChanges();
     }
 }
Example #13
0
 public void InsertClient(ClientModel client)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         if (context.Client.Count(x => x.ClientName == client.ClientName) > 0)
         {
             throw new ApplicationException("同名客户已经存在");
         }
         Client newclient = new Client()
         {
             ClientName = client.ClientName,
             CreateTime = DateTime.Now,
             Index      = 0,
             IndexMonth = DateTime.Now.Month,
             ShortName  = client.ShortName
         };
         context.Client.InsertOnSubmit(newclient);
         context.SubmitChanges();
     }
 }
Example #14
0
 public void InsertUserModel(UserModel user)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         Users newUser = new Users()
         {
             Comment        = string.IsNullOrEmpty(user.Comment) ? " " : user.Comment,
             CreateDateTime = DateTime.Now,
             LastLoginIP    = string.Empty,
             LastLoginTime  = DateTime.Now,
             AreaID         = user.AreaID,
             Name           = user.Name,
             Password       = user.Password,
             RoleId         = user.RoleID,
             UserID         = user.UserID,
             Disabled       = user.Disabled
         };
         context.Users.InsertOnSubmit(newUser);
         context.SubmitChanges();
     }
 }
Example #15
0
 public void UpdateTransportModel(int id, string trayNo, double volume, int quantity, bool updateClientIndex, string userID)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         TransportRecords record = context.TransportRecords.FirstOrDefault(x => x.ID == id);
         if (record == null)
         {
             throw new ApplicationException("要修改的记录不存在");
         }
         record.TrayNo   = trayNo;
         record.Volume   = volume;
         record.Quantity = quantity;
         record.TransportRecordsOptionHistory.Add(
             new TransportRecordsOptionHistory()
         {
             Description = string.Format("更新单据内容,新内容 托编号:{0} 体积: {1} 数量:{2} ", trayNo, volume, quantity),
             LogDateTime = DateTime.Now,
             Operation   = "更新",
             UserID      = userID
         });
         if (updateClientIndex)
         {
             if (!string.IsNullOrEmpty(trayNo))
             {
                 Client client = context.Client.FirstOrDefault(x => x.ClientName == record.ClientName);
                 if (client != null)
                 {
                     client.Index = GetTrayNoIndex(trayNo);
                     if (client.IndexMonth != DateTime.Now.Month)
                     {
                         client.Index      = 0;
                         client.IndexMonth = DateTime.Now.Month;
                     }
                 }
             }
         }
         context.SubmitChanges();
     }
 }
Example #16
0
 public void InsertRoleModel(RoleModel role)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         Roles r = new Roles()
         {
             RoleName   = role.RoleName,
             AccessList = role.AccessList
         };
         r.MenuAccess = new System.Data.Linq.EntitySet <MenuAccess>();
         r.MenuAccess.AddRange(
             from x in role.Menus
             select new MenuAccess()
         {
             MenuCode = x.MenuCode,
             RoleID   = r.RoleID
         }
             );
         context.Roles.InsertOnSubmit(r);
         context.SubmitChanges();
     }
 }
Example #17
0
        public void UpdateTransportComment(int id, String comment, String userID)
        {
            using (SQLDBDataContext context = new SQLDBDataContext())
            {
                TransportRecords record = context.TransportRecords.FirstOrDefault(x => x.ID == id);
                if (record == null)
                {
                    throw new ApplicationException("要修改的记录不存在");
                }
                record.Comment = comment;
                record.TransportRecordsOptionHistory.Add(
                    new TransportRecordsOptionHistory()
                {
                    Description = string.Format("修改备注信息为: {0} ", comment),
                    LogDateTime = DateTime.Now,
                    Operation   = "更新",
                    UserID      = userID
                });

                context.SubmitChanges();
            }
        }
Example #18
0
 public void UpdateTransportErrorStatus(int id, bool error, string errorMessage, string userID)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         TransportRecords record = context.TransportRecords.FirstOrDefault(x => x.ID == id);
         if (record == null)
         {
             throw new ApplicationException("要修改的记录不存在");
         }
         record.Error        = error;
         record.ErrorMessage = errorMessage;
         record.TransportRecordsOptionHistory.Add(
             new TransportRecordsOptionHistory()
         {
             Description = string.Format("修改异常状态为{0}, 异常信息:{1}", error?"异常":"正常", errorMessage),
             LogDateTime = DateTime.Now,
             Operation   = "修改异常状态",
             UserID      = userID
         });
         context.SubmitChanges();
     }
 }
Example #19
0
 public void UpdateTransportReceivedStatus(int id, bool received, DateTime?receivedDate, string userID)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         TransportRecords record = context.TransportRecords.FirstOrDefault(x => x.ID == id);
         if (record == null)
         {
             throw new ApplicationException("要修改的记录不存在");
         }
         record.Received     = received;
         record.ReceivedDate = receivedDate;
         record.TransportRecordsOptionHistory.Add(
             new TransportRecordsOptionHistory()
         {
             Description = string.Format("修改到货状态为{0},日期 {1}", received ? "到货" : "未到货", receivedDate),
             LogDateTime = DateTime.Now,
             Operation   = "修改到货状态",
             UserID      = userID
         });
         context.SubmitChanges();
     }
 }
Example #20
0
 public void UpdateTransportPrice(int id, double?deliverPrice, double?shortBargeFee, double?accoundPayable, string userID)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         TransportRecords record = context.TransportRecords.FirstOrDefault(x => x.ID == id);
         if (record == null)
         {
             throw new ApplicationException("要修改的记录不存在");
         }
         record.DeliverPrice  = deliverPrice;
         record.ShortBargeFee = shortBargeFee;
         record.AccountPayble = accoundPayable;
         record.TransportRecordsOptionHistory.Add(
             new TransportRecordsOptionHistory()
         {
             Description = string.Format("修改价格信息, 运费:{0},短驳费:{1},应付金额:{2}", deliverPrice, shortBargeFee, accoundPayable),
             LogDateTime = DateTime.Now,
             Operation   = "修改价格信息",
             UserID      = userID
         });
         context.SubmitChanges();
     }
 }