Beispiel #1
0
        public IQueryable getDataCity()
        {
            UserManagerDataClassesDataContext db = new UserManagerDataClassesDataContext(cn);
            var q = from c in db.CityTables select new { c.CityName, c.Id };

            return(q);
        }
Beispiel #2
0
        public IQueryable getDataLogin()
        {
            UserManagerDataClassesDataContext db = new UserManagerDataClassesDataContext(cn);
            var q = from c in db.UserTables
                    join d in db.CityTables on c.City equals d.Id
                    select new
            {
                c.Id, c.Name, c.Family, c.User, c.Password, c.Permission, c.AdminVersion, c.Messages, d.CityName
            };

            return(q);
        }
Beispiel #3
0
 public IQueryable <CityTable> queryCities()
 {
     try
     {
         UserManagerDataClassesDataContext db = new UserManagerDataClassesDataContext(cn);
         var q = from c in db.CityTables select c;
         return(q);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         throw;
     }
 }
Beispiel #4
0
        public string getCityName(long cityID)
        {
            UserManagerDataClassesDataContext db = new UserManagerDataClassesDataContext(cn);
            var q = from c in db.CityTables select new { c.CityName, c.Id };

            foreach (var a in q)
            {
                if (a.Id == cityID)
                {
                    return(a.CityName);
                }
            }
            return("not found");
        }
Beispiel #5
0
 public Boolean addCity(CityTable newCity)
 {
     try
     {
         UserManagerDataClassesDataContext db = new UserManagerDataClassesDataContext(cn);
         db.CityTables.InsertOnSubmit(newCity);
         db.SubmitChanges();
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
Beispiel #6
0
 public bool sendUpdateNotify(int newVersion)
 {
     try {
         var logindata = getDataLogin();
         UserManagerDataClassesDataContext db = new UserManagerDataClassesDataContext(cn);
         var data = from a in db.UserTables select a;
         foreach (var d in data)
         {
             d.Version = newVersion;
         }
         db.SubmitChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #7
0
 public Boolean removeCity(CityTable newCity)
 {
     try
     {
         UserManagerDataClassesDataContext db = new UserManagerDataClassesDataContext(cn);
         var q = from a in db.CityTables where a.Id == newCity.Id select a;
         foreach (var a in q)
         {
             db.CityTables.DeleteOnSubmit(a);
         }
         db.SubmitChanges();
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
Beispiel #8
0
 public List <string> addUser(UserTable newLogin)
 {
     try
     {
         UserManagerDataClassesDataContext db = new UserManagerDataClassesDataContext(cn);
         db.UserTables.InsertOnSubmit(newLogin);
         db.SubmitChanges();
         List <string> report = new List <string>();
         report.Add(newLogin.User + "" + "  با موفقیت اضافه گردید");
         return(report);
     }
     catch (System.Data.SqlClient.SqlException)
     {
         // DaftarModelDataContext db = new DaftarModelDataContext(cn);
         List <string> report = new List <string>();
         report.Add(newLogin.User + "" + " نام کاربری تکراری است");
         return(report);
     }
 }
Beispiel #9
0
        public bool sendMessages(string messages)
        {
            try {
                // var logindata = getDataLogin();
                UserManagerDataClassesDataContext db = new UserManagerDataClassesDataContext(cn);
                var data = from a in db.UserTables select a;


                foreach (var d in data)
                {
                    d.Messages = messages;
                    d.Update   = true;
                }
                db.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(false);
            }
        }
Beispiel #10
0
        public bool MessagesSeenStatus(bool status, LoginInfo login)
        {
            try
            {
                var logindata = getDataLogin();
                UserManagerDataClassesDataContext db = new UserManagerDataClassesDataContext(cn);
                var data = from a in db.UserTables select a;

                foreach (var d in data)
                {
                    if (d.Id == login.Id)
                    {
                        d.Update = status;
                    }
                }
                db.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(false);
            }
        }
Beispiel #11
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            try
            {
                var cn = Properties.Settings.Default.MainConnectionString;
                if (IsServerConnected(cn))
                {
                    UserManagerDataClassesDataContext db = new UserManagerDataClassesDataContext(cn);
                    foreach (var q in db.UserTables)
                    {
                        if (q.User == this.UserNametextBox.Text && q.Password == this.PasswordTextBox.Text)
                        {
                            this.Hide();
                            LoginInfo login = new LoginInfo();
                            login.cityID       = q.City;
                            login.Name         = q.Name;
                            login.Id           = q.Id;
                            login.family       = q.Family;
                            login.permission   = q.Permission.Value;
                            login.user         = q.User;
                            login.update       = q.Update.Value;
                            login.messages     = q.Messages;
                            login.version      = q.Version ?? default(int);
                            login.adminVersion = q.AdminVersion ?? default(bool);
                            if (login.version > currentVersion && !login.adminVersion)
                            {
                                MessageBox.Show("نسخه شما بروز نیست . آخرین نسخه بروز شده را نصب کنید ", "پیغام",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Stop);
                                this.Close();
                                return;
                            }


                            SqlManipulator sql = new SqlManipulator();
                            if (!login.adminVersion)
                            {
                                if (login.update)
                                {
                                    MessageBox.Show(login.messages, "پیغام ",
                                                    MessageBoxButtons.OK,
                                                    MessageBoxIcon.Information);
                                    try {
                                        sql.MessagesSeenStatus(false, login);
                                    }
                                    catch (Exception)
                                    { MessageBox.Show("خطا در  پیغام"); }
                                }
                            }
                            string cityName = sql.getCityName(login.cityID);
                            login.cityName = cityName;
                            form.setLoginData(login);

                            Properties.Settings.Default.LastUser = this.UserNametextBox.Text;

                            tmr = new Timer();

                            //set time interval 3 sec

                            tmr.Interval = 3500;

                            //starts the timer
                            formwait = new SplashScreenForm();
                            formwait.Show();
                            tmr.Start();

                            tmr.Tick  += tmr_Tick;
                            permission = q.Permission.Value;
                            Properties.Settings.Default.Save();
                            return;
                        }
                    }
                    MessageBox.Show("نام کاربری و گذر واژه فاقد اعتبار است", "خطا",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    MessageBox.Show("ارتباط با سرور قطع است ، تنظیمات سرور را بررسی کنید", "خطا",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);

                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }