コード例 #1
0
ファイル: DangNhap.cs プロジェクト: ducanh99vp/QuanLyKho_TTN
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            string username = txtUser.Text;
            string pas      = txtPas.Text;

            TaoCSDL tempConnec = new TaoCSDL();

            //tempConnec.PutSql("connec.txt",@"Server=" + KetNoiCSDL.server + ";Initial Catalog=KhoHangHoa;Integrated Security=SSPI;");

            try
            {
                //MessageBox.Show(KetNoiCSDL.server + pas);


                string temp = con.GetValue("select Password from PhanQuyen where Username = '******'", 0).Trim();


                if (pas == temp)
                {
                    con.ThucThiCauLenhSQL("update tblLuuMK set name='" + username + "', pas='******' where num='1'");
                    if (checkLuuMK.Checked)
                    {
                        con.ThucThiCauLenhSQL("update tblLuuMK set checked='True' where num='1'");
                    }
                    else
                    {
                        con.ThucThiCauLenhSQL("update tblLuuMK set checked='False' where num='1'");
                    }
                    this.Hide();

                    lbNameUser += username;
                    DateTime currentTime = DateTime.Now;

                    con.ThucThiCauLenhSQL("insert into tblNhatKi (NKTen,NKTacVu,NKNgay,NKUser) values (N'',N'Đăng Nhập','" +
                                          string.Format("{0:yyyy/MM/dd HH:mm:ss}", currentTime) + "',N'" + lbNameUser + "')");

                    FormMain formmain = new FormMain();
                    formmain.ShowDialog();


                    if (formmain.DangXuat() == true)
                    {
                        try
                        {
                            formmain.Close();

                            lbNameUser = "******";
                            this.Show();
                        }
                        catch (Exception ex)
                        {
                            XtraMessageBox.Show("Error: " + ex.Message + "\n     Vui lòng tạo CSDL");
                        }
                    }
                    else if (formmain.DangXuat() == false)
                    {
                        this.Dispose();
                    }
                }
                else
                {
                    XtraMessageBox.Show("Mật khẩu sai hoặc tài khoản đã bị xóa");
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("Không thể kết nối" + ex.Message);
            }
        }
コード例 #2
0
ファイル: DangNhap.cs プロジェクト: ducanh99vp/QuanLyKho_TTN
        private void btnTaoCSDL_Click(object sender, EventArgs e)
        {
            TaoCSDL temp = new TaoCSDL();

            temp.ShowDialog();
        }