Пример #1
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();
     }
 }
Пример #2
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();
     }
 }
Пример #3
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();
            }
        }
Пример #4
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();
     }
 }
Пример #5
0
 public RoleModel FindRole(int roleId)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         return((from x in context.Roles
                 where x.RoleID == roleId
                 select new RoleModel()
         {
             AccessList = x.AccessList,
             RoleID = x.RoleID,
             RoleName = x.RoleName,
             Menus = (from menu in x.MenuAccess
                      orderby menu.MenuItem.OrderIndex
                      select new MenuItemModel()
             {
                 Link = menu.MenuItem.Link,
                 MenuCode = menu.MenuItem.MenuCode,
                 MenuText = menu.MenuItem.MenuText,
                 OrderIndex = menu.MenuItem.OrderIndex
             }).ToList()
         }).FirstOrDefault());
     }
 }
Пример #6
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();
     }
 }
Пример #7
0
 public RoleListModel GetRoleList()
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         RoleListModel result = new RoleListModel();
         result.ItemList = (from x in context.Roles
                            select new RoleModel()
         {
             RoleID = x.RoleID,
             RoleName = x.RoleName,
             Menus = (from menu in x.MenuAccess
                      orderby menu.MenuItem.OrderIndex
                      select new MenuItemModel()
             {
                 Link = menu.MenuItem.Link,
                 MenuCode = menu.MenuItem.MenuCode,
                 MenuText = menu.MenuItem.MenuText,
                 OrderIndex = menu.MenuItem.OrderIndex
             }).ToList(),
             AccessList = x.AccessList
         }).ToList();
         return(result);
     }
 }
Пример #8
0
 public TransportRecordModel GetTransportRecordModel(int id)
 {
     using (SQLDBDataContext context = new SQLDBDataContext())
     {
         return((from x in context.TransportRecords
                 where x.ID == id
                 select new TransportRecordModel()
         {
             ID = x.ID,
             AccountPayble = x.AccountPayble,
             CarLicense = x.CarLicense,
             ClientName = x.ClientName,
             Comment = x.Comment,
             Deductions = x.Deductions,
             DeliverDate = x.DeliverDate,
             DeliverPrice = x.DeliverPrice,
             DeliverType = x.DeliverType,
             Driver = x.Driver,
             FromLocation = x.FromLocation,
             HandlingFee = x.HandlingFee,
             PackageName = x.PackageName,
             PayDate = x.PayDate,
             PrePay = x.PrePay,
             Quantity = x.Quantity,
             Reparations = x.Reparations,
             ShortBargeFee = x.ShortBargeFee,
             Status = x.Status,
             ToLocation = x.ToLocation,
             Volume = x.Volume,
             TrayNo = x.TrayNo,
             OilCard = x.OilCard,
             BusinessArea = x.BusinessArea,
             Error = x.Error,
             ErrorMessage = x.ErrorMessage,
             Paid = x.Paid,
             Received = x.Received,
             ReceivedDate = x.ReceivedDate,
             HistoryItem = (from y in x.TransportRecordsOptionHistory
                            orderby y.LogDateTime
                            select new TransportRecordsHistoryModel()
             {
                 Description = y.Description,
                 LogDateTime = y.LogDateTime,
                 Operation = y.Operation,
                 TransportRecordID = y.TransportRecordID,
                 UserID = y.UserID,
                 User = new UserModel()
                 {
                     Comment = y.Users.Comment,
                     CreateDateTime = y.Users.CreateDateTime,
                     LastLoginIP = y.Users.LastLoginIP,
                     LastLoginTime = y.Users.LastLoginTime,
                     AreaID = y.Users.AreaID,
                     Area = new BusinessAreaModel()
                     {
                         AreaName = y.Users.BusinessArea.AreaName,
                         ID = y.Users.BusinessArea.ID
                     },
                     Name = y.Users.Name,
                     Password = y.Users.Password,
                     RoleID = y.Users.RoleId,
                     UserID = y.Users.UserID,
                     Role = new RoleModel()
                     {
                         RoleID = y.Users.Roles.RoleID,
                         RoleName = y.Users.Roles.RoleName
                     }
                 }
             }).ToList(),
             DetailItem = (from y in x.TransportRecordDetail
                           select new TransportRecordDetailModel()
             {
                 DetailNo = y.DetailNo,
                 ID = y.ID,
                 PackageName = y.PackageName,
                 Quantity = y.Quantity,
                 TransportRecordID = y.TransportRecordID,
                 Volume = y.Volume,
                 ReceiptCount = y.ReceiptCount,
                 Comment = y.Comment
             }).ToList()
         }).FirstOrDefault());
     }
 }
Пример #9
0
        public TransportRecordListModel QueryTransportModel(string clientName, DateTime?deliverDate, string received, string paid, string error, int pageIndex, BusinessAreaModel area)
        {
            TransportRecordListModel listModel = new TransportRecordListModel();

            if (pageIndex < 1)
            {
                pageIndex = 1;
            }

            using (SQLDBDataContext context = new SQLDBDataContext())
            {
                bool     checkDeliverDate = deliverDate.HasValue;
                DateTime dd = DateTime.MinValue;
                if (checkDeliverDate)
                {
                    dd = deliverDate.Value;
                }
                string areaName = string.Empty;
                if (area != null)
                {
                    areaName = area.AreaName;
                }

                int totalCount = context.TransportRecords.Count(x => (string.IsNullOrEmpty(clientName) || x.ClientName == clientName) &&
                                                                (!checkDeliverDate || x.DeliverDate.Date == dd) && (string.IsNullOrEmpty(areaName) || x.BusinessArea == areaName));
                listModel.TotalCount = totalCount;
                listModel.TotalPage  = totalCount / TransportRecordListModel.PageSize;
                listModel.PageIndex  = pageIndex;
                if (totalCount % TransportRecordListModel.PageSize > 0)
                {
                    listModel.TotalPage++;
                }
                if (listModel.TotalPage < 1)
                {
                    listModel.TotalPage = 1;
                }
                if (pageIndex > listModel.TotalPage)
                {
                    pageIndex = listModel.TotalPage;
                }
                int startIndex = (pageIndex - 1) * TransportRecordListModel.PageSize;
                listModel.ClientName  = clientName;
                listModel.DeliverDate = deliverDate;
                listModel.ItemList    = (from x in context.TransportRecords
                                         orderby x.ID descending
                                         where (string.IsNullOrEmpty(clientName) || x.ClientName == clientName) &&
                                         (!checkDeliverDate || x.DeliverDate.Date == dd) &&
                                         (string.IsNullOrEmpty(areaName) || x.BusinessArea == areaName) &&
                                         ((received == "Y" && x.Received) || (received == "N" && !x.Received) || (received != "Y" && received != "N")) &&
                                         ((paid == "Y" && x.Paid) || (paid == "N" && !x.Paid) || (paid != "Y" && paid != "N")) &&
                                         ((error == "Y" && x.Error) || (error == "N" && !x.Error) || (error != "Y" && error != "N"))
                                         select new TransportRecordModel()
                {
                    ID = x.ID,
                    AccountPayble = x.AccountPayble,
                    CarLicense = x.CarLicense,
                    ClientName = x.ClientName,
                    Comment = x.Comment,
                    Deductions = x.Deductions,
                    DeliverDate = x.DeliverDate,
                    DeliverPrice = x.DeliverPrice,
                    DeliverType = x.DeliverType,
                    Driver = x.Driver,
                    FromLocation = x.FromLocation,
                    HandlingFee = x.HandlingFee,
                    PackageName = x.PackageName,
                    PayDate = x.PayDate,
                    PrePay = x.PrePay,
                    Quantity = x.Quantity,
                    Reparations = x.Reparations,
                    ShortBargeFee = x.ShortBargeFee,
                    Status = x.Status,
                    ToLocation = x.ToLocation,
                    Volume = x.Volume,
                    TrayNo = x.TrayNo,
                    OilCard = x.OilCard,
                    BusinessArea = x.BusinessArea,
                    Error = x.Error,
                    Paid = x.Paid,
                    Received = x.Received,
                    ReceivedDate = x.ReceivedDate,
                    HistoryItem = (from y in x.TransportRecordsOptionHistory
                                   orderby y.LogDateTime
                                   select new TransportRecordsHistoryModel()
                    {
                        Description = y.Description,
                        LogDateTime = y.LogDateTime,
                        Operation = y.Operation,
                        TransportRecordID = y.TransportRecordID,
                        UserID = y.UserID,
                        User = new UserModel()
                        {
                            Comment = y.Users.Comment,
                            CreateDateTime = y.Users.CreateDateTime,
                            LastLoginIP = y.Users.LastLoginIP,
                            LastLoginTime = y.Users.LastLoginTime,
                            AreaID = y.Users.AreaID,
                            Area = new BusinessAreaModel()
                            {
                                AreaName = y.Users.BusinessArea.AreaName,
                                ID = y.Users.BusinessArea.ID
                            },
                            Name = y.Users.Name,
                            Password = y.Users.Password,
                            RoleID = y.Users.RoleId,
                            UserID = y.Users.UserID,
                            Role = new RoleModel()
                            {
                                RoleID = y.Users.Roles.RoleID,
                                RoleName = y.Users.Roles.RoleName
                            }
                        }
                    }).ToList()
                }).Skip(startIndex).Take(TransportRecordListModel.PageSize).ToList();
            }
            return(listModel);
        }