示例#1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            CultureInfo c = new CultureInfo("ar-EG");
            NumberFormatInfo n = new NumberFormatInfo();
            n.DigitSubstitution = DigitShapes.NativeNational;
            c.NumberFormat = n;
            System.Threading.Thread.CurrentThread.CurrentCulture = c;
            DB.ConnectionString = ConfigurationManager.ConnectionStrings["POS.Properties.Settings.Con"];
            try
            {
                DB.OpenConnection();
                //if(System.DateTime.Now < new System.DateTime(2013, 9, 15))
                //{
                //   
                //   
                //}
                //else
                //{
                //    Application.Current.Shutdown();
                //}
                Window w = new Managent();
                w.ShowDialog();
            }
            catch
            {

            }

        }
示例#2
0
        private void Check_Login()
        {
            try
            {
                //select the user information giving the username 
                DB db = new DB("users");
                db.AddCondition("user_name", User_name_TB.Text.Trim());
                DataRow User = db.SelectRow("select * from users");

                //check if user is exist
                if(User != null)
                {
                    //check if password hashcode match
                    if(Password_TB.Password.GetHashCode().ToString() == User["user_pass"].ToString())
                    {
                        //set global variables
                        App.User_Id = User["User_Id"];
                        App.Group_ID = User["user_grp_id"];
                        //start application
                        Window m = new Window();
                        //check privileges
                        switch(int.Parse(User["user_grp_id"].ToString()))
                        {
                            case 1:
                                m = new Managent();
                                break;
                            case 2:
                                m = new Cashier_Window();
                                break;
                            case 3:
                                m = new Managent();
                                break;
                        }
                        //hide Login window and show the selected window
                        this.Hide();
                        m.ShowDialog();
                        //close application on windwos close
                        Application.Current.Shutdown();

                    }
                    else
                    {
                        Message.Show("كلمة المرور غير صحيحة", MessageBoxButton.OK, 10);
                    }
                }
                else
                {
                    Message.Show("إسم المستخدم غير صحيح", MessageBoxButton.OK, 10);
                }
            }
            catch
            {

            }
        }