Beispiel #1
0
 private void btlogin_Click(object sender, EventArgs e)
 {
     if (txtmk.Text != textEdit2.Text || txtmk.Text == "")
     {
         XtraMessageBox.Show("Mật khẩu mới chưa khớp hoặc bạn chưa nhập mật khẩu mới.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         textEdit2.Text = "";
         txtmk.Text     = "";
         txtmk.Focus();
     }
     else
     {
         try
         {
             SplashScreenManager.ShowForm(typeof(Frm_wait));
             string userid = gen.GetString("select Userid from MSC_User where UserName='******' and Password='******'");
             gen.ExcuteNonquery("update MSC_User set Password='******' where UserID='" + userid + "'");
             XtraMessageBox.Show("Mật khẩu của bạn đã được thay đổi.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Information);
             textEdit1.Text = "";
             textEdit2.Text = "";
             txtmk.Text     = "";
             textEdit1.Focus();
             SplashScreenManager.CloseForm();
         }
         catch
         {
             XtraMessageBox.Show("Mật khẩu hiện tại không đúng.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             textEdit1.Text = "";
             textEdit1.Focus();
             SplashScreenManager.CloseForm();
         }
     }
 }
Beispiel #2
0
 private void btlogin_Click(object sender, EventArgs e)
 {
     if (txtmk.Text != txtmk2.Text || txtmk.Text == "")
     {
         XtraMessageBox.Show("Mật khẩu mới chưa khớp hoặc bạn chưa nhập mật khẩu mới.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtmk2.Text = "";
         txtmk.Text  = "";
         txtmk.Focus();
     }
     else
     {
         SQLString = "update MSC_User set Password='******' where Username='******' AND CompanyCode='" + Globals.companycode + "'";
         try
         {
             gen.ExcuteNonquery(SQLString);
             XtraMessageBox.Show("Mật khẩu của bạn đã được thay đổi.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtmk2.Text = "";
             txtmk.Text  = "";
             txtmk.Text  = "";
             txtmk2.Focus();
         }
         catch
         {
             XtraMessageBox.Show(SQLString, "btlogin_Click", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txtmk2.Text = "";
             txtmk2.Focus();
         }
     }
 }
Beispiel #3
0
        private void login_user()
        {
            if (txtten.Text == "Tên đăng nhập" || txtten.Text == "")
            {
                XtraMessageBox.Show("Bạn chưa nhập tên đăng nhập.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtten.Focus();
            }
            else if (txtmk.Text == "Mật khẩu" || txtmk.Text == "")
            {
                XtraMessageBox.Show("Bạn chưa nhập mật khẩu.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtmk.Focus();
            }//
            else
            {
                try
                {
                    //trong luc cho xu lý thì load frm_wait lên
                    //SplashScreenManager.ShowForm(typeof(Frm_wait));
                    gencon gen = new gencon();
                    //XtraMessageBox.Show(Globals.constring, "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    string userid = "";
                    try
                    {
                        userid = gen.GetString("select Userid from MSC_User where UserName='******' and Password='******'");


                        if (userid != "")
                        {
                            this.Text      = gen.GetString("select Top 1 CompanyName from Center");
                            Globals.userid = userid;
                            //Globals.clientid = Int32.Parse(txtClient.Text);
                            Globals.companycode = gen.GetString2("MSC_User", "CompanyCode", "Userid", userid);
                            Globals.version     = gen.GetString("select Version from Center where CompanyCode='" + Globals.companycode + "'");
                            Globals.username    = txtten.Text.Replace("-", "").ToUpper();
                            Globals.companyname = this.Text;
                            Globals.ngaychungtu = DateTime.Now.ToString();

                            //MainForm F = new MainForm();
                            Frm_Main F = new Frm_Main();
                            F.Show();
                        }
                        else
                        {
                            XtraMessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng hay tk bị block", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    catch (Exception ex)
                    {
                        //XtraMessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtmk.Text = "";
                        txtmk.Focus();
                        XtraMessageBox.Show(ex.Message, "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //SplashScreenManager.CloseForm();
                    }
                }
                catch
                {
                    XtraMessageBox.Show("Kết nối DB không thành công", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Beispiel #4
0
        private void btlogin_Click(object sender, EventArgs e)
        {
            if (txtten.Text == "Tên đăng nhập" || txtten.Text == "")
            {
                XtraMessageBox.Show("Bạn chưa nhập tên đăng nhập.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtten.Focus();
            }
            else if (txtmk.Text == "Mật khẩu" || txtmk.Text == "")
            {
                XtraMessageBox.Show("Bạn chưa nhập mật khẩu.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtmk.Focus();
            }
            else
            {
                try
                {
                    // gencon gen = new gencon();
                    //trong luc cho xu lý thì load frm_wait lên
                    SplashScreenManager.ShowForm(typeof(Frm_wait));
                    string userid = "";
                    try {
                        userid = gen.GetString("select Userid from Users where UserName='******' and Password='******' AND "
                                               + " ClientID =" + txtClient.Text);
                    }
                    catch (Exception ex)
                    {
                        XtraMessageBox.Show(ex.Message, "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    SplashScreenManager.CloseForm();
                    //int clientid = Int16.Parse(txtClientID.Text);

                    Globals.userid      = userid;
                    Globals.clientid    = Int32.Parse(txtClient.Text);
                    Globals.username    = txtten.Text.Replace("-", "");
                    Globals.companycode = gen.GetString2("Users", "companycode", "Username", Globals.username, Globals.clientid);
                    Globals.ngaychungtu = DateTime.Now.ToString();
                    //DataTable dtinfo = gen.GetTable("select FullName,BranchName,a.BranchID from MSC_User a with (NOLOCK), Branch b with (NOLOCK) where UserID='" + userid + "' and a.BranchID=b.BranchID ");
                    //Globals.branchid = dtinfo.Rows[0][2].ToString();
                    //Globals.khach = gen.GetTable("select AccountingObjectID as 'ID',AccountingObjectCode as 'Mã khách hàng',AccountingObjectName as 'Tên khách',Address as 'Địa chỉ', CompanyTaxCode as 'Mã số thuế', ContactHomeTel as 'Đội' from AccountingObject with (NOLOCK) order by AccountingObjectCode");
                    //Globals.hang = gen.GetTable("select InventoryItemID as 'ID',InventoryItemCode as 'Mã hàng hóa',InventoryItemName as 'Tên hàng',Unit as 'Đơn vị tính', ConvertUnit as 'Đơn vị quy đổi',convert(decimal(22,2),ConvertRate) as 'Tỷ lệ quy đổi',SalePrice as 'Đơn giá tham khảo',GuarantyPeriod as 'Công ty' from InventoryItem with (NOLOCK) order by InventoryItemCode");
                    //Globals.roleid = gen.GetString("select RoleID from MSC_UserJoinRole with (NOLOCK) where UserID='" + userid + "'");
                    //Form1 F = new Form1();// mo Form 1 báo cáo ghi nợ
                    MainForm F = new MainForm();

                    //F.getform(this); //-- cua Form1
                    //F.getuserid(userid); //-- cua Form1

                    F.Show();
                }
                catch
                {
                    XtraMessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtmk.Text = "";
                    txtmk.Focus();
                    SplashScreenManager.CloseForm();
                }
            }
        }