Beispiel #1
0
 /// <summary>
 /// 审核并通过订单,即订单状态置1,且库存减1
 /// </summary>
 /// <param name="no">订单号</param>
 /// <param name="id">销售人员id</param>
 /// <returns></returns>未测试
 public bool CheckMarket(int no, string id)
 {
     #region
     using (var dbcontext = new asimsContext())
     {
         var market = dbcontext.Market
                      .Single(m => m.Mno == no);
         try
         {
             market.Pflag  = 1;
             market.Sphone = id;
             VehicleManagement vehicle = new VehicleManagement();
             bool isSuccess            = vehicle.InventoryReduction((int)market.Vno, (int)market.Number);
             if (isSuccess)
             {
                 dbcontext.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception)
         {
             return(false);
         }
     }
     #endregion
 }
Beispiel #2
0
 /// <summary>
 /// 车辆库存减num
 /// </summary>
 /// <param name="vno">车辆号</param>
 /// <param name="num">数量</param>
 /// <returns></returns>已测试
 public bool InventoryReduction(int vno, int num)
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             var query = dbcontext.Cashlist
                         .FirstOrDefault(c => c.Vno == vno);
             if (query.Vnumber > num)
             {
                 query.Vnumber = query.Vnumber - num;
                 dbcontext.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch
     {
         return(false);
     }
     #endregion
 }
Beispiel #3
0
 /// <summary>
 /// 查看所有用户
 /// </summary>
 /// <returns>所有用户</returns>已测试
 public List <User> ListAllUser()
 {
     #region
     using (var dbcontext = new asimsContext())
     {
         var query = dbcontext.User.FromSql("select * from asims.User").ToList();
         return(query);
     }
     #endregion
 }
Beispiel #4
0
 /// <summary>
 /// 查看账号为id用户的详细信息
 /// </summary>
 /// <param name="id">用户id</param>
 /// <returns>账号为id的用户</returns>
 public User GetUserDetail(string id)
 {
     #region
     using (var dbcontext = new asimsContext())
     {
         var user = dbcontext.User
                    .Single(users => users.Uphone == id);
         return(user);
     }
     #endregion
 }
Beispiel #5
0
 /// <summary>
 /// 通过id查询汽车
 /// </summary>
 /// <param name="id">汽车id</param>
 /// <returns>汽车</returns>
 public Vehicle CheckVehicleThoughId(int id)
 {
     #region
     using (var dbcontext = new asimsContext())
     {
         var vehicle = dbcontext.Vehicle
                       .Single(vehicles => vehicles.Vno == id);
         return(vehicle);
     }
     #endregion
 }
Beispiel #6
0
 /// <summary>
 /// 查询用户的订单
 /// </summary>
 /// <param name="id">用户id</param>
 /// <returns>订单列表</returns>
 public List <Market> GetSomeUserMarket(string id)
 {
     #region
     using (var dbcontext = new asimsContext())
     {
         var markets = dbcontext.Market
                       .FromSql("select * from asims.Market")
                       .Where(m => m.Uphone == id)
                       .ToList();
         return(markets);
     }
     #endregion
 }
Beispiel #7
0
        /// <summary>
        /// 查看所有用户
        /// </summary>
        /// <returns>所有用户</returns>
        public List <User> ListAllUser()
        {
            List <User> users = new List <User>();

            #region
            using (var dbcontext = new asimsContext())
            {
                foreach (var user in dbcontext.User)
                {
                    users.Add(user);
                }
            }
            #endregion
            return(users);
        }
Beispiel #8
0
 /// <summary>
 /// 处理员工的登录请求
 /// </summary>
 /// <param name="id">员工id</param>
 /// <param name="password">员工密码</param>
 /// <returns>成功返回true</returns>
 public bool Login(string id, string password)
 {
     #region
     using (var dbcontext = new asimsContext())
     {
         var staff = dbcontext.Staff
                     .FirstOrDefault(s => s.Sphone == id && s.Spassword == password);
         if (staff != null)
         {
             return(true);
         }
     }
     #endregion
     return(false);
 }
Beispiel #9
0
 /// <summary>
 /// 处理员工的登录请求
 /// </summary>
 /// <param name="id">员工id</param>
 /// <param name="password">员工密码</param>
 /// <returns>成功返回true</returns>
 public bool Login(string id, string password)
 {
     #region
     using (var dbcontext = new asimsContext())
     {
         foreach (var staff in dbcontext.Staff)
         {
             if (staff.Sphone == id && staff.Spassword == password)
             {
                 return(true);
             }
         }
     }
     #endregion
     return(false);
 }
Beispiel #10
0
 /// <summary>
 //根据地址号获取地址
 /// </summary>
 /// <param name="no">地址号</param>
 /// <returns>地址</returns>未测试
 public Address GetOneAddress(int no)
 {
     #region
     try
     {
         using (var db = new asimsContext())
         {
             return(db.Find <Address>(no));
         }
     }
     catch
     {
         return(null);
     }
     #endregion
 }
Beispiel #11
0
 /// <summary>
 /// 根据地址号来删除地址
 /// </summary>
 /// <param name="no">地址号</param>
 /// <returns>成功返回true</returns>未测试
 public bool DeleteAddress(int no)
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             dbcontext.Remove <Address>(this.GetOneAddress(no));
             return(true);
         }
     }
     catch
     {
         return(false);
     }
     #endregion
 }
Beispiel #12
0
 /// <summary>
 /// 插入地址
 /// </summary>
 /// <param name="address">地址</param>
 /// <returns>地址编号</returns>未测试
 public int InsertAddress(Address address)
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             dbcontext.Add(address);
             return(address.Ano);
         }
     }
     catch
     {
         return(-1);
     }
     #endregion
 }
Beispiel #13
0
 /// <summary>
 /// 通过id查询汽车
 /// </summary>
 /// <param name="id">汽车id</param>
 /// <returns>汽车</returns>未测试
 public Vehicle CheckVehicleThoughId(int id)
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             var query = dbcontext.Vehicle
                         .FirstOrDefault(v => v.Vno == id);
             return(query);
         }
     }
     catch
     {
         return(null);
     }
     #endregion
 }
Beispiel #14
0
 /// <summary>
 /// 获取员工经手的订单号为no的详细信息
 /// </summary>
 /// <param name="id">员工id</param>
 /// <param name="no">订单号</param>
 /// <returns></returns>
 public Market GetOneStaffMarket(string id, int no)
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             var query = dbcontext.Market
                         .FirstOrDefault(m => m.Sphone == id && m.Mno == no);
             return(query);
         }
     }
     catch
     {
         return(null);
     }
     #endregion
 }
Beispiel #15
0
 /// <summary>
 /// 通过id获取员工
 /// </summary>
 /// <param name="id">员工id</param>
 /// <returns></returns>未测试
 public Staff GetStaffThoughID(string id)
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             var query = dbcontext.Staff
                         .FirstOrDefault(s => s.Sphone == id);
             return(query);
         }
     }
     catch
     {
         return(null);
     }
     #endregion
 }
Beispiel #16
0
 /// <summary>
 /// 添加员工
 /// </summary>
 /// <param name="staff">员工</param>
 /// <returns></returns>未测试
 public bool AddStaff(Staff staff)
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             dbcontext.Add(staff);
             dbcontext.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
     #endregion
 }
Beispiel #17
0
 /// <summary>
 //更新员工密码
 /// </summary>
 /// <param name="id">员工id</param>
 /// <param name="oldPassword">旧密码</param>
 /// <param name="newPassword">新密码</param>
 /// <returns>成功返回true</returns>
 public bool NewPassword(string id, string oldPassword, string newPassword)
 {
     #region
     using (var dbcontext = new asimsContext())
     {
         foreach (var staff in dbcontext.Staff)
         {
             if (staff.Sphone == id && staff.Spassword == oldPassword)
             {
                 staff.Spassword = newPassword;
                 dbcontext.SaveChanges();
                 break;
             }
         }
     }
     #endregion
     return(false);
 }
Beispiel #18
0
 /// <summary>
 /// 获取用户的订单号为no的详细信息
 /// </summary>
 /// <param name="id">用户id</param>
 /// <param name="no">订单号</param>
 /// <returns></returns>
 public Market GetOneUserMarket(string id, int no)
 {
     #region
     using (var dbcontext = new asimsContext())
     {
         var market = dbcontext.Market
                      .Single(m => m.Uphone == id && m.Mno == no);
         try
         {
             return(market);
         }
         catch (Exception)
         {
             return(null);
         }
     }
     #endregion
 }
Beispiel #19
0
 /// <summary>
 /// 处理用户的登录请求
 /// </summary>
 /// <param name="id">用户id</param>
 /// <param name="password">用户密码</param>
 /// <returns></returns>已测试
 public bool Login(string id, string password)
 {
     #region
     using (var dbcontext = new asimsContext())
     {
         var user = dbcontext.User
                    .FirstOrDefault(u => u.Uphone == id && u.Upassword == password);
         if (user != null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     #endregion
 }
Beispiel #20
0
 /// <summary>
 /// 删除员工
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>未测试
 public bool DeleteStaff(string id)
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             var query = GetStaffThoughID(id);
             dbcontext.Staff.Remove(query);
             dbcontext.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
     #endregion
 }
Beispiel #21
0
 /// <summary>
 /// 获取所有车辆
 /// </summary>
 /// <returns>车辆列表</returns>未测试
 public List <Vehicle> GetAllVehicle()
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             var query = dbcontext.Vehicle
                         .FromSql("select * from asims.Vehicle")
                         .ToList();
             return(query);
         }
     }
     catch
     {
         return(null);
     }
     #endregion
 }
Beispiel #22
0
 /// <summary>
 /// 通过姓名获取员工(模糊查找)
 /// </summary>
 /// <param name="name">员工姓名</param>
 /// <returns></returns>已测试
 public List <Staff> GetStaffThoughName(string name)
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             var query = dbcontext.Staff
                         .Where(s => s.Sname.Contains(name))
                         .ToList();
             return(query);
         }
     }
     catch
     {
         return(null);
     }
     #endregion
 }
Beispiel #23
0
 /// <summary>
 /// 处理用户的注册
 /// </summary>
 /// <param name="user">用户对象</param>
 /// <param name="address">地址号</param>
 /// <returns></returns>未测试
 public bool Register(User user, int address)
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             user.Uaddress = address;
             dbcontext.User.Add(user);
             dbcontext.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
     #endregion
 }
Beispiel #24
0
 /// <summary>
 /// 获取所有员工
 /// </summary>
 /// <returns></returns>未测试
 public List <Staff> GetAllStaff()
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             var query = dbcontext.Staff
                         .FromSql("select * from asims.Staff")
                         .ToList();
             return(query);
         }
     }
     catch
     {
         return(null);
     }
     #endregion
 }
Beispiel #25
0
 /// <summary>
 /// 提交订单
 /// </summary>
 /// <param name="id">用户id</param>
 /// <param name="market">订单</param>
 /// <returns></returns>未测试
 public bool SubmitOrder(string id, Market market)
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             market.Uphone = id;
             dbcontext.Add(market);
             dbcontext.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
     #endregion
 }
Beispiel #26
0
 /// <summary>
 /// 查询所有订单
 /// </summary>
 /// <returns>订单列表</returns>
 public List <Market> GetAllMarket()
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             var query = dbcontext.Market
                         .FromSql("select * from asims.Market")
                         .ToList();
             return(query);
         }
     }
     catch
     {
         return(null);
     }
     #endregion
 }
Beispiel #27
0
 /// <summary>
 /// 审核并通过订单,即订单状态置1
 /// </summary>
 /// <param name="no">订单号</param>
 /// <returns>是否成功</returns>
 public bool CheckMarket(int no)
 {
     #region
     using (var dbcontext = new asimsContext())
     {
         var market = dbcontext.Market
                      .Single(m => m.Mno == no);
         try
         {
             market.Pflag = 1;
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
     #endregion
 }
Beispiel #28
0
 /// <summary>
 /// 进货
 /// </summary>
 /// <param name="vno">车辆编号</param>
 /// <param name="num">车辆数目</param>
 /// <returns></returns>已测试
 public bool StockVehicle(int vno, int num)
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             var query = dbcontext.Cashlist
                         .FirstOrDefault(c => c.Vno == vno);
             query.Vnumber = query.Vnumber + num;
             dbcontext.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
     #endregion
 }
Beispiel #29
0
 /// <summary>
 /// 查询员工经手的订单
 /// </summary>
 /// <param name="id">员工id</param>
 /// <returns>订单列表</returns>
 public List <Market> GetSomeStaffMarket(string id)
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             var query = dbcontext.Market
                         .FromSql("select * from asims.Market")
                         .Where(m => m.Sphone == id)
                         .ToList();
             return(query);
         }
     }
     catch
     {
         return(null);
     }
     #endregion
 }
Beispiel #30
0
 /// <summary>
 /// 通过汽车类型查找汽车
 /// </summary>
 /// <param name="type">汽车类型</param>
 /// <returns>type类型的所有汽车</returns>未测试
 public List <Vehicle> CheckVehicleThoughType(string type)
 {
     #region
     try
     {
         using (var dbcontext = new asimsContext())
         {
             var query = dbcontext.Vehicle
                         .FromSql("select * from asims.Vehicle")
                         .Where(v => v.Vtype == type)
                         .ToList();
             return(query);
         }
     }
     catch
     {
         return(null);
     }
     #endregion
 }