Example #1
0
        private void btn_login2_Click(object sender, EventArgs e)
        {
            Hide();
            string c = CheckAth();

            if (c == "OK")
            {
                ds_BranchesAndStores = login.SelectAllowedBranchesAndStores(user_id, com_company.SelectedValue.ToString());

                frm_main.com_companies.DataSource    = ds_CompaniesAndFyears.Tables["tbl_companies"];
                frm_main.com_companies.ValueMember   = "id";
                frm_main.com_companies.DisplayMember = "aname";
                frm_main.com_companies.SelectedValue = com_company.SelectedValue;

                frm_main.com_fyear.DataSource    = ds_CompaniesAndFyears.Tables["tbl_fyears"];
                frm_main.com_fyear.ValueMember   = "id";
                frm_main.com_fyear.DisplayMember = "aname";
                frm_main.com_fyear.SelectedValue = com_fyear.SelectedValue;

                frm_main.com_branches.DataSource    = ds_BranchesAndStores.Tables["tbl_branches"];
                frm_main.com_branches.ValueMember   = "id";
                frm_main.com_branches.DisplayMember = "aname";
                frm_main.com_branches.SelectedIndex = 0;

                frm_main.com_users.DataSource    = dt;
                frm_main.com_users.ValueMember   = "id";
                frm_main.com_users.DisplayMember = "aname";
                frm_main.com_users.SelectedValue = user_id;

                frm_main.frm_login = this;

                login.UpdateDatabase();

                frm_main.Show();
                Properties.Settings.Default.LoginUser = txt_Name.Text;
                Properties.Settings.Default.Save();
                return;
            }
            else
            {
                pro_view.fld_PL.fld_Login.frm_preventnu p = new frm_preventnu();
                p.UserID   = user_id;
                p.Case     = c;
                p.frm_main = frm_main;
                p.ShowDialog();
                return;
            }
        }
Example #2
0
        private void btn_Login_Click(object sender, EventArgs e)
        {
            model.aname    = txt_Name.Text.Trim();
            model.ename    = txt_Name.Text;
            model.password = txt_Password.Text.Trim();

            DataTable dt = new DataTable();

            dt = model.Select().Tables[0];

            foreach (DataRow r in dt.Rows)
            {
                if ((r["aname"].ToString() == model.aname || r["ename"].ToString() == model.ename) && r["password"].ToString() == model.password)
                {
                    Hide();
                    string c = CheckAth();
                    if (c == "OK")
                    {
                        user_id = r["id"].ToString();
                        frm_main.com_users.SelectedValue = user_id;
                        frm_main.Show();
                        Properties.Settings.Default.LoginUser = txt_Name.Text;
                        Properties.Settings.Default.Save();
                        return;
                    }
                    else
                    {
                        pro_view.fld_PL.fld_Login.frm_preventnu p = new frm_preventnu();
                        p.UserID   = r["id"].ToString();
                        p.Case     = c;
                        p.frm_main = frm_main;
                        p.ShowDialog();
                        return;
                    }
                }
            }
            MessageBox.Show("أسم المستخدم أو كلمة المرور غير صحيحة", "خطأ في بيانات الدخول", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }