Ejemplo n.º 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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
        //get list of admin
        public static IList <ADMINMN> GetListOfAdmin()
        {
            IList <ADMINMN> rs;

            using (var httn = new TruckDataDataContext())
            {
                rs = httn.ADMINMNs.ToList();
            }
            return(rs);
        }
Ejemplo n.º 6
0
        //get list of driver
        public static IList <DRIVER> GetListOfDriver()
        {
            IList <DRIVER> rs;

            using (var httn = new TruckDataDataContext())
            {
                rs = httn.DRIVERs.ToList();
            }
            return(rs);
        }
Ejemplo n.º 7
0
        //get list of account
        public static IList <ACCOUNT> GetListOfAccount()
        {
            IList <ACCOUNT> rs;

            using (var httn = new TruckDataDataContext())
            {
                rs = httn.ACCOUNTs.ToList();
            }
            return(rs);
        }
Ejemplo n.º 8
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);
        }