Exemple #1
0
        private void frmQuanLyTaiKhoan_Load(object sender, EventArgs e)
        {
            this.CenterToScreen();

            KetNoiSQL.LoadDLQLKH(dataViewQLKH);
            cbbTimKiemKH.Text = "Họ Tên";
        }
Exemple #2
0
        private void btThemTK_Click(object sender, EventArgs e)
        {
            frmQuanLyKhachHang_ThemKH frm = new frmQuanLyKhachHang_ThemKH();

            frm.ShowDialog();
            KetNoiSQL.LoadDLQLKH(dataViewQLKH);
        }
        private void btThemTK_Click(object sender, EventArgs e)
        {
            frmQuanLyTaiKhoan_ThemTK frm = new frmQuanLyTaiKhoan_ThemTK();

            frm.ShowDialog();
            KetNoiSQL.LoadDLQLTK(dataViewQLTK);
        }
        private void frmQuanLyTaiKhoan_Load(object sender, EventArgs e)
        {
            this.CenterToScreen();

            KetNoiSQL.LoadDLQLTK(dataViewQLTK);
            cbbTimKiemTK.Text = "Tài Khoản";
        }
        private void btnThanhToan_Click(object sender, EventArgs e)
        {
            if (grdHoaDon.Rows.Count == 0)
            {
                return;
            }
            try
            {
                DialogResult ok = new DialogResult();
                ok = MessageBox.Show("Tính tiền cho bàn " + btnBanDaChon.Text + " ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (ok == DialogResult.Yes)
                {
                    MessageBox.Show("Tổng tiền là " + lblTongTien.Text, "Thông báo",
                                    MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    Tien();
                    string s = "UPDATE HoaDon SET TrangThai = '1' WHERE MaBan = '" + MaBan_Luu + "'";
                    KetNoiSQL.ExecuteNonQuery(s);
                    DanhSachBan();
                    DanhSachHoaDon(MaBan_Luu);
                    Tien();
                }
                else
                {
                    return;
                }
            }
            catch { MessageBox.Show("Bạn chưa chọn bàn thanh toán", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); }
        }
Exemple #6
0
        private void frmQuanLyKho_Load(object sender, EventArgs e)
        {
            this.CenterToScreen();

            cbbTieuChiTimKiem.Text = "Tên Gạo";
            KetNoiSQL.LoadDLQLTTGao(dataViewQLTTG);
            Disable_TTGao();
        }
Exemple #7
0
        private void btXoa_Click(object sender, EventArgs e)
        {
            EmptyTTGao();
            SqlConnection conn = SQLDatabase.GetDBConnection();

            conn.Open();
            try
            {
                if (MessageBox.Show("Bạn chắc chắn muốn xóa Thông Tin Gạo đã chọn?", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    int dem = 0;
                    foreach (DataGridViewRow row in dataViewQLTTG.Rows)
                    {
                        if (row.Cells[0].Value != null)
                        {
                            if ((bool)row.Cells[0].Value == true)
                            {
                                dem++;
                                string     MaGao           = row.Cells[1].Value.ToString();
                                string     sqldelete_QLTTG = "DELETE FROM GAO WHERE MAGAO = @MaGao";
                                SqlCommand command1        = new SqlCommand(sqldelete_QLTTG, conn);
                                command1.Parameters.AddWithValue("@MaGao", MaGao);
                                command1.ExecuteNonQuery();
                            }
                        }
                    }
                    if (dem == 0)
                    {
                        MessageBox.Show("Bạn chưa chọn Thông Tin Gạo để xóa!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        string strThongBao = "Xóa " + dem + " Thông Tin Gạo thành công!";
                        MessageBox.Show(strThongBao, "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    KetNoiSQL.LoadDLQLTTGao(dataViewQLTTG);
                }
            }
            catch
            {
                MessageBox.Show("Xóa Thông Tin Gạo không thành công\nVui lòng kiểm tra lại", "LỖI", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                conn.Close();
            }
        }
        private void btXoaTK_Click(object sender, EventArgs e)
        {
            SqlConnection conn = SQLDatabase.GetDBConnection();

            conn.Open();
            try
            {
                if (MessageBox.Show("Bạn chắc chắn muốn xóa Tài Khoản đã chọn?", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    int dem = 0;
                    foreach (DataGridViewRow row in dataViewQLTK.Rows)
                    {
                        if (row.Cells[0].Value != null)
                        {
                            if ((bool)row.Cells[0].Value == true)
                            {
                                dem++;
                                string     MaTaiKhoan     = row.Cells[1].Value.ToString();
                                string     sqldelete_QLTK = "DELETE FROM TAIKHOAN WHERE MATAIKHOAN = @TaiKhoan";
                                SqlCommand command1       = new SqlCommand(sqldelete_QLTK, conn);
                                command1.Parameters.AddWithValue("@TaiKhoan", MaTaiKhoan);
                                command1.ExecuteNonQuery();
                            }
                        }
                    }

                    if (dem == 0)
                    {
                        MessageBox.Show("Bạn chưa chọn Tài Khoản để xóa!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        string strThongBao = "Xóa " + dem + " Tài Khoản thành công!";
                        MessageBox.Show(strThongBao, "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    KetNoiSQL.LoadDLQLTK(dataViewQLTK);
                }
            }
            catch
            {
                MessageBox.Show("Xóa không thành công\nBạn không thể xóa tài khoản của nhân viên đã có giao dịch", "CẢNH BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                conn.Close();
            }
        }
Exemple #9
0
        private void btDongY_Sua_Click(object sender, EventArgs e)
        {
            SqlConnection conn = SQLDatabase.GetDBConnection();

            conn.Open();
            if (txtMaGao.Text == "")
            {
                MessageBox.Show("Cập nhật Thông Tin Gạo không thành công\nVui lòng kiểm tra lại Mã Gạo", "CẢNH BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txtTenGao.Text == "" || cbbLoaiGao.Text == "" || txtTrongLuong.Text == "" || txtGiaNhap.Text == "" || txtGiaBan.Text == "" || txtXuatXu.Text == "")
            {
                MessageBox.Show("Vui lòng nhập đầy đủ thông tin", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                try
                {
                    Double     TrongLuong = Double.Parse(txtTrongLuong.Text);
                    string     sql1       = "UPDATE GAO SET TENGAO = @TenGao, LOAIGAO = @LoaiGao, TRONGLUONGGAO = @TrongLuongGao, GIANHAP = @GiaNhap, GIABAN = @GiaBan, XUATXU = @XuatXu WHERE MAGAO = @MaGao";
                    SqlCommand command1   = new SqlCommand(sql1, conn);
                    command1.Parameters.AddWithValue("@MaGao", txtMaGao.Text);
                    command1.Parameters.AddWithValue("@TenGao", txtTenGao.Text);
                    command1.Parameters.AddWithValue("@LoaiGao", cbbLoaiGao.Text);
                    command1.Parameters.AddWithValue("@TrongLuongGao", TrongLuong);
                    command1.Parameters.AddWithValue("@GiaNhap", txtGiaNhap.Text);
                    command1.Parameters.AddWithValue("@GiaBan", txtGiaBan.Text);
                    command1.Parameters.AddWithValue("@XuatXu", txtXuatXu.Text);
                    command1.ExecuteNonQuery();

                    MessageBox.Show("Cập nhật Thông Tin Gạo thành công!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    KetNoiSQL.LoadDLQLTTGao(dataViewQLTTG);
                }
                catch
                {
                    MessageBox.Show("Cập nhật Thông Tin Gạo không thành công..\nVui lòng kiểm tra lại.", "LỖI", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    conn.Close();
                }
            }
        }
Exemple #10
0
        private void btSuaTK_Click(object sender, EventArgs e)
        {
            frmQuanLyKhachHang_SuaKH frm = new frmQuanLyKhachHang_SuaKH();

            try
            {
                int      CurentIndex = dataViewQLKH.CurrentCell.RowIndex;
                string   MaKH        = Convert.ToString(dataViewQLKH.Rows[CurentIndex].Cells[1].Value.ToString());
                string   HoTen       = Convert.ToString(dataViewQLKH.Rows[CurentIndex].Cells[2].Value.ToString());
                string   NamSinh     = Convert.ToString(dataViewQLKH.Rows[CurentIndex].Cells[3].Value.ToString());
                string   GioiTinh    = Convert.ToString(dataViewQLKH.Rows[CurentIndex].Cells[4].Value.ToString());
                string   SoDienThoai = Convert.ToString(dataViewQLKH.Rows[CurentIndex].Cells[5].Value.ToString());
                string   DiaChi      = Convert.ToString(dataViewQLKH.Rows[CurentIndex].Cells[6].Value.ToString());
                string[] dt0         = NamSinh.Split(new char[] { ' ' });
                string   dt1         = dt0[0];

                frm.txtMaKH.Text        = MaKH;
                frm.txtHoTen.Text       = HoTen;
                frm.dtNamSinh.Text      = dt1;
                frm.txtDiaChi.Text      = DiaChi;
                frm.txtSoDienThoai.Text = SoDienThoai;
                if (GioiTinh == "Nam")
                {
                    frm.rbNam.Checked = true;
                    frm.rbNu.Checked  = false;
                }
                else
                {
                    frm.rbNu.Checked  = true;
                    frm.rbNam.Checked = false;
                }

                frm.ShowDialog();
                KetNoiSQL.LoadDLQLKH(dataViewQLKH);
            }
            catch
            {
                MessageBox.Show("Không có Thông Tin Khách Hàng nào được chọn", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #11
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtMatKhau_Cu.Text == "")
            {
                MessageBox.Show("Mật khẩu cũ không được trống", "Thông báo",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtMatKhau_Cu.Focus();
                return;
            }
            if (txtMatKhau_Moi.Text == "")
            {
                MessageBox.Show("Mật khẩu mới không được trống", "Thông báo",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtMatKhau_Moi.Focus();
                return;
            }
            if ((txtMatKhau_Moi.Text != txtMatKhau_NhapLai.Text))
            {
                MessageBox.Show("Nhập lại mật khẩu không trùng khớp", "Thông báo",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtMatKhau_Moi.Focus();
                return;
            }
            if (txtMatKhau_Cu.Text != frmDangNhap.MatKhau_Luu)
            {
                MessageBox.Show("Mật khẩu cũ không chính xác", "Thông báo",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtMatKhau_Cu.Focus();
                return;
            }
            string strSQL = string.Format(@"UPDATE TaiKhoan_NhanVien set MatKhau = '" + txtMatKhau_Moi.Text + "' where MaTK_NV = '" + txtMaTK_NV.Text + "'");

            KetNoiSQL.ExecuteNonQuery(strSQL);
            MessageBox.Show("Đổi mật khẩu thành công ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            this.Close();
        }
Exemple #12
0
        private void ThemMoiGao()
        {
            SqlConnection conn = SQLDatabase.GetDBConnection();

            conn.Open();

            if (txtMaGao.Text == "")
            {
                MessageBox.Show("Thêm mới Thông Tin Gạo không thành công\nVui lòng nhập thông tin Mã Gạo", "CẢNH BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                try
                {
                    int check = CheckExistence("MAGAO", txtMaGao.Text);

                    //Nhập mới;
                    if (check == 0)
                    {
                        if (txtTenGao.Text == "" || cbbLoaiGao.Text == "" || txtTrongLuong.Text == "" || txtGiaNhap.Text == "" || txtGiaBan.Text == "" || txtXuatXu.Text == "")
                        {
                            MessageBox.Show("Thêm mới Thông Tin Gạo không thành công\nVui lòng nhập đầy đủ thông tin", "CẢNH BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            string     sql2     = "INSERT INTO GAO(MAGAO,TENGAO,LOAIGAO,TRONGLUONGGAO,GIANHAP,GIABAN,XUATXU) VALUES(@MaGao,@TenGao,@LoaiGao,@TrongLuongGao,@GiaNhap,@GiaBan,@XuatXu)";
                            SqlCommand command2 = new SqlCommand(sql2, conn);
                            command2.Parameters.AddWithValue("@MaGao", txtMaGao.Text);
                            command2.Parameters.AddWithValue("@TenGao", txtTenGao.Text);
                            command2.Parameters.AddWithValue("@LoaiGao", cbbLoaiGao.Text);
                            command2.Parameters.AddWithValue("@TrongLuongGao", txtTrongLuong.Text);
                            command2.Parameters.AddWithValue("@GiaNhap", txtGiaNhap.Text);
                            command2.Parameters.AddWithValue("@GiaBan", txtGiaBan.Text);
                            command2.Parameters.AddWithValue("@XuatXu", txtXuatXu.Text);
                            command2.ExecuteNonQuery();
                            MessageBox.Show("Thêm Thông Tin Gạo mới thành công!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            KetNoiSQL.LoadDLQLTTGao(dataViewQLTTG);
                        }
                    }
                    //Cập nhật;
                    else
                    {
                        Double        tempTrongLuong = 0;
                        string        TenGao         = "";
                        string        sql3           = "SELECT * FROM GAO WHERE GAO.MAGAO = '" + txtMaGao.Text + "'";
                        SqlCommand    command3       = new SqlCommand(sql3, conn);
                        SqlDataReader reader         = command3.ExecuteReader();
                        while (reader.Read())
                        {
                            TenGao         = reader.GetString(1);
                            tempTrongLuong = reader.GetDouble(3);
                        }

                        reader.Close();

                        Double temp = Double.Parse(txtTrongLuong.Text);

                        Double TrongLuong = (tempTrongLuong + temp);

                        //txtXuatXu.Text = TrongLuong;

                        string     sql4     = "UPDATE GAO SET TRONGLUONGGAO = @TrongLuongGao WHERE MAGAO = @MaGao";
                        SqlCommand command4 = new SqlCommand(sql4, conn);
                        command4.Parameters.AddWithValue("@MaGao", txtMaGao.Text);
                        command4.Parameters.AddWithValue("@TrongLuongGao", TrongLuong);
                        command4.ExecuteNonQuery();
                        string str = "Gạo '" + TenGao + "' vừa được nhập thêm '" + txtTrongLuong.Text + "' KG";
                        MessageBox.Show(str, "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        KetNoiSQL.LoadDLQLTTGao(dataViewQLTTG);
                    }
                }
                catch
                {
                    MessageBox.Show("Không thành công\nVui lòng kiểm tra lại", "LỖI", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    conn.Close();
                }
            }
        }
        private void btSuaTK_Click(object sender, EventArgs e)
        {
            frmQuanLyTaiKhoan_SuaTK frm = new frmQuanLyTaiKhoan_SuaTK();

            try
            {
                int      CurentIndex = dataViewQLTK.CurrentCell.RowIndex;
                string   TaiKhoan    = Convert.ToString(dataViewQLTK.Rows[CurentIndex].Cells[1].Value.ToString());
                string   MatKhau     = Convert.ToString(dataViewQLTK.Rows[CurentIndex].Cells[2].Value.ToString());
                string   HoTen       = Convert.ToString(dataViewQLTK.Rows[CurentIndex].Cells[3].Value.ToString());
                string   NamSinh     = Convert.ToString(dataViewQLTK.Rows[CurentIndex].Cells[4].Value.ToString());
                string   SoDienThoai = Convert.ToString(dataViewQLTK.Rows[CurentIndex].Cells[5].Value.ToString());
                string   GioiTinh    = Convert.ToString(dataViewQLTK.Rows[CurentIndex].Cells[6].Value.ToString());
                string   DiaChi      = Convert.ToString(dataViewQLTK.Rows[CurentIndex].Cells[7].Value.ToString());
                string   LoaiTK      = Convert.ToString(dataViewQLTK.Rows[CurentIndex].Cells[8].Value.ToString());
                string   QuyenHan    = Convert.ToString(dataViewQLTK.Rows[CurentIndex].Cells[9].Value.ToString());
                string[] dt0         = NamSinh.Split(new char[] { ' ' });
                string   dt1         = dt0[0];

                frm.txtTaiKhoan.Text    = TaiKhoan;
                frm.txtMatKhau.Text     = MatKhau;
                frm.txtHoTen.Text       = HoTen;
                frm.dtNamSinh.Text      = dt1;
                frm.txtSoDienThoai.Text = SoDienThoai;
                frm.txtDiaChi.Text      = DiaChi;
                frm.cbbLoaiTK.Text      = LoaiTK;
                if (GioiTinh == "Nam")
                {
                    frm.rbNam.Checked = true;
                    frm.rbNu.Checked  = false;
                }
                else
                {
                    frm.rbNu.Checked  = true;
                    frm.rbNam.Checked = false;
                }

                foreach (char QH in QuyenHan)
                {
                    switch (QH)
                    {
                    case '1':
                        frm.cbQLTK.Checked = true;
                        break;

                    case '2':
                        frm.cbQLKH.Checked = true;
                        break;

                    case '3':
                        frm.cbQLTTG.Checked = true;
                        break;

                    case '4':
                        frm.cbQLBG.Checked = true;
                        break;

                    case '5':
                        frm.cbBCTK.Checked = true;
                        break;

                    default:
                        frm.cbQLTK.Checked  = false;
                        frm.cbQLKH.Checked  = false;
                        frm.cbQLTTG.Checked = false;
                        frm.cbQLBG.Checked  = false;
                        frm.cbBCTK.Checked  = false;
                        break;
                    }
                }



                frm.ShowDialog();
                KetNoiSQL.LoadDLQLTK(dataViewQLTK);
            }
            catch
            {
                MessageBox.Show("Không có Tài Khoản nào được chọn", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }