Пример #1
0
        //update a driver
        public static bool UpdateInfoDriver(int id, string name, string idcard, string address, string phone)
        {
            bool rt = true;

            using (var httn = new TruckDataDataContext())
            {
                var rs = httn.DRIVERs.Where(s => s.ID == id).Select(s => s).SingleOrDefault();
                if (rs != null)
                {
                    rs.NAME    = name;
                    rs.IDCARD  = idcard;
                    rs.ADDRESS = address;
                    rs.PHONE   = phone;
                    try
                    {
                        httn.SubmitChanges();
                    }
                    catch (Exception)
                    {
                        rt = false;
                    }
                }
                else
                {
                    rt = false;
                }
            }
            return(rt);
        }
Пример #2
0
        //add a driver
        public static bool AddDriver(int id, string name, string idcard, string address, string phone)
        {
            bool rt = true;

            using (var httn = new TruckDataDataContext())
            {
                DRIVER t = new DRIVER
                {
                    ID      = id,
                    NAME    = name,
                    IDCARD  = idcard,
                    ADDRESS = address,
                    PHONE   = phone
                };
                httn.DRIVERs.InsertOnSubmit(t);
                try
                {
                    httn.SubmitChanges();
                }
                catch
                {
                    rt = false;
                }
            }
            return(rt);
        }
Пример #3
0
        //update password account
        public static bool UpdatePasswordAccount(int id, string pass)
        {
            bool rt = true;

            using (var httn = new TruckDataDataContext())
            {
                var rs = httn.ACCOUNTs.Where(s => s.ID == id).Select(s => s).SingleOrDefault();
                if (rs != null)
                {
                    rs.PASSWORD = pass;
                    try
                    {
                        httn.SubmitChanges();
                    }
                    catch (Exception)
                    {
                        rt = false;
                    }
                }
                else
                {
                    rt = false;
                }
            }
            return(rt);
        }
Пример #4
0
        //add a account
        public static bool AddAccount(string username, string password, int typeid, int status)
        {
            bool rt = true;

            using (var httn = new TruckDataDataContext())
            {
                int     count = httn.ACCOUNTs.Count();
                ACCOUNT t     = new ACCOUNT
                {
                    ID       = count + 1,
                    USERNAME = username,
                    PASSWORD = password,
                    TYPEID   = typeid,
                    STATUS   = status
                };
                httn.ACCOUNTs.InsertOnSubmit(t);
                try
                {
                    httn.SubmitChanges();
                }
                catch
                {
                    rt = false;
                }
            }
            return(rt);
        }
Пример #5
0
        //delete a account
        public static bool DeleteAccount(int id)
        {
            bool rt = true;

            using (var httn = new TruckDataDataContext())
            {
                var rs = httn.ACCOUNTs.Where(s => s.ID == id);
                httn.ACCOUNTs.DeleteAllOnSubmit(rs);
                try
                {
                    httn.SubmitChanges();
                }
                catch (Exception)
                {
                    rt = false;
                }
            }
            return(rt);
        }