예제 #1
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            try
            {
                if (chkGioitinh.CheckState == CheckState.Checked)
                {
                    gioitinh = "Nam";
                }
                else if (chkGioitinh.CheckState == CheckState.Unchecked)
                {
                    gioitinh = "Nữ";
                }

                if (MessageBox.Show("Bạn có muốn sửa không", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string sql = "UPDATE tblNhanvien " +
                                 "SET Tennhanvien = '" + txtTennhanvien.Text + "', Gioitinh = '" + gioitinh + "', " +
                                 "Diachi = '" + txtDiachi.Text + "', Dienthoai = '" + mskDienthoai.Text + "', " +
                                 "Ngaysinh = '" + mskNgaysinh.Value.ToString("yyyy/MM/dd") + "' " +
                                 "WHERE Manhanvien = '" + txtManhanvien.Text + "'";

                    FunctionConnect.runsql(sql);

                    Load_DataGridView();

                    MessageBox.Show("Sửa thành công !");
                }
                Disable_Entity();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi: ", ex.Message);
            }
        }
예제 #2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtMachatlieu.Text.Trim().Length == 0 || txtTenchatlieu.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn chưa nhập dữ liệu", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                // Kiểm tra key Mã Chất Liệu
                sql = "Select MaChatlieu From tblChatlieu where MaChatlieu='" + txtMachatlieu.Text.Trim() + "'";
                if (FunctionConnect.checkkey(sql))
                {
                    MessageBox.Show("Mã chất liệu hiện tại đang tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtMachatlieu.Focus();
                    return;
                }

                // Thêm dữ liệu
                if (MessageBox.Show("Bạn có muốn thêm không", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    sql = "INSERT INTO tblChatlieu (Machatlieu, Tenchatlieu) VALUES ('" + txtMachatlieu.Text + "','" + txtTenchatlieu.Text + "')";
                    FunctionConnect.runsql(sql);
                    Load_DataGridView();

                    MessageBox.Show("Thêm thành công !");

                    txtMachatlieu.Enabled = false;
                    btnLuu.Enabled        = false;
                    btnBoqua.Enabled      = false;
                }
            }
        }
예제 #3
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtMachatlieu.Text.Trim().Length == 0 || txtTenchatlieu.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn chưa nhập dữ liệu", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                sql = "SELECT Machatlieu From tblChatlieu where Machatlieu ='" + txtMachatlieu.Text.Trim() + "'";
                if (FunctionConnect.checkkey(sql))
                {
                    MessageBox.Show("Thông tin bạn cập nhập đã tồn tại !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtMachatlieu.Focus();
                    return;
                }
                if (MessageBox.Show("Bạn có muốn sửa không ?", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    sql = "UPDATE tblChatlieu Tenchatlieu = '" + txtTenchatlieu.Text + "' WHERE Machatlieu = '" + txtMachatlieu.Text + "'";
                    FunctionConnect.runsql(sql);
                    Load_DataGridView();

                    MessageBox.Show("Sửa thành công !");

                    //txtMachatlieu.Enabled = false;
                    btnLuu.Enabled   = false;
                    btnBoqua.Enabled = false;
                }
            }
        }
예제 #4
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn xoá không", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                string sql = "DELETE KHACHHANG WHERE KHACHHANG.MAKH = '" + txtMachatlieu.Text + "'";
                FunctionConnect.runsql(sql);
                Load_DataGridView();

                MessageBox.Show("Xoá thành công !");
            }
        }
예제 #5
0
파일: frmDMHang.cs 프로젝트: CuPhuc/QLBH
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn xoá: " + DataGridView.CurrentRow.Cells[1].Value.ToString() + " không ?", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                string sql = "DELETE tblHang WHERE MaHang = '" + txtMahang.Text + "'";
                FunctionConnect.runsql(sql);
                Load_DataGridView();

                MessageBox.Show("Xoá thành công !");
            }
        }
예제 #6
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (tblNhanvien.Rows.Count == 0)
            {
                MessageBox.Show("Không có dữ liệu !");
                return;
            }
            else if (MessageBox.Show("Bạn có muốn xoá \nNhân viên: " + txtTennhanvien.Text + " không ?", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                string sql = "DELETE tblNhanvien WHERE Manhanvien = '" + txtManhanvien.Text + "'";
                FunctionConnect.runsql(sql);
                Load_DataGridView();

                MessageBox.Show("Xoá thành công !");
            }
        }
예제 #7
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                if (chkGioitinh.CheckState == CheckState.Checked)
                {
                    gioitinh = "Nam";
                }
                else if (chkGioitinh.CheckState == CheckState.Unchecked)
                {
                    gioitinh = "Nữ";
                }

                string sql;
                if (txtManhanvien.Text.Trim().Length == 0 || txtTennhanvien.Text.Trim().Length == 0 ||
                    txtDiachi.Text.Trim().Length == 0 || mskDienthoai.Text.Trim().Length == 0)
                {
                    MessageBox.Show("Bạn cần điền đầy đủ thông tin \nĐể có thể lưu", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    sql = "SELECT Manhanvien FROM tblNhanvien WHERE Manhanvien ='" + txtManhanvien.Text.Trim() + "'";
                    if (FunctionConnect.checkkey(sql))
                    {
                        MessageBox.Show("Mã bạn muốn lưu đã tồn tại ! \nVui lòng chọn mã khácƯ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtManhanvien.Focus();
                        return;
                    }
                    if (MessageBox.Show("Bạn có muốn lưu không ?", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        sql = "INSERT INTO " +
                              "tblNhanvien (Manhanvien, Tennhanvien, Gioitinh, Diachi, Dienthoai, Ngaysinh) " +
                              "VALUES ('" + txtManhanvien.Text + "','" + txtTennhanvien.Text + "','" + gioitinh + "','" + txtDiachi.Text + "','" + mskDienthoai.Text + "','" + mskNgaysinh.Value.ToString("yyyy/MM/dd") + "')";
                        FunctionConnect.runsql(sql);
                        Load_DataGridView();
                        MessageBox.Show("Thêm thành công !");

                        Disable_Entity();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi: ", ex.Message);
            }
        }
예제 #8
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Bạn có muốn sửa không", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string sql = "UPDATE tblKhach " +
                                 "SET Tenkhach = '" + txtTenkhach.Text + "', Diachi = '" + txtDiachi.Text + "', Dienthoai = '" + mskDienthoai.Text + "'" +
                                 "WHERE Makhach = '" + txtMakhach.Text + "'";

                    FunctionConnect.runsql(sql);

                    Load_DataGridView();

                    MessageBox.Show("Sửa thành công !");
                }
                Disable_Button();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi: ", ex.Message);
            }
        }
예제 #9
0
파일: frmDMHang.cs 프로젝트: CuPhuc/QLBH
 private void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         string sql;
         if (txtMahang.Text.Trim().Length == 0 || txtTenhang.Text.Trim().Length == 0 ||
             txtDongianhap.Text.Trim().Length == 0 || txtDongiaban.Text.Trim().Length == 0)
         {
             MessageBox.Show("Bạn cần điền đầy đủ thông tin \nĐể có thể lưu", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             sql = "SELECT Mahang FROM tblHang WHERE Mahang ='" + txtMahang.Text.Trim() + "'";
             if (FunctionConnect.checkkey(sql))
             {
                 MessageBox.Show("Mã bạn muốn lưu đã tồn tại ! \nVui lòng chọn mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 txtMahang.Focus();
                 return;
             }
             if (MessageBox.Show("Bạn có muốn lưu không ?", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 sql = "INSERT INTO " +
                       "tblHang (Mahang, Tenhang, Machatlieu, Soluong, Dongianhap, Dongiaban, Anh, Ghichu) " +
                       "VALUES ('" + txtMahang.Text + "','" + txtTenhang.Text + "','" + cboMachatlieu.Text + "','" + txtSoluong.Text + "','" + txtDongianhap.Text + "','" + txtDongiaban.Text + "','" + txtAnh.Text + "','" + txtGhichu.Text + "')";
                 FunctionConnect.runsql(sql);
                 Load_DataGridView();
                 MessageBox.Show("Thêm thành công !");
             }
             Disable_Enitity();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đã xảy ra lỗi trong quá trình lưu lưu phát sinh lỗi ! \nError: " + ex.Message);
     }
 }
예제 #10
0
파일: frmDMHang.cs 프로젝트: CuPhuc/QLBH
        private void btnSua_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Bạn có muốn sửa dữ liều hàng này không ?", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string sql = "UPDATE tblHang " +
                                 "SET Tenhang = '" + txtTenhang.Text + "', Machatlieu = '" + cboMachatlieu.Text + "', Soluong = '" + txtSoluong.Text + "'," +
                                 "Dongianhap = '" + txtDongianhap.Text + "', Dongiaban = '" + txtDongiaban.Text + "', Anh = '" + txtAnh.Text + "', Ghichu = '" + txtGhichu.Text + "'" +
                                 "WHERE MaHang = '" + txtMahang.Text + "'";

                    FunctionConnect.runsql(sql);

                    Load_DataGridView();

                    MessageBox.Show("Sửa thành công !");
                }
                Disable_Enitity();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi trong quá trình sửa ! \nError: " + ex.Message);
            }
        }
예제 #11
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         string sql;
         if (txtMakhach.Text.Trim().Length == 0 || txtTenkhach.Text.Trim().Length == 0 ||
             txtDiachi.Text.Trim().Length == 0 || mskDienthoai.Text.Trim().Length == 0)
         {
             MessageBox.Show("Bạn cần điền đầy đủ thông tin \nĐể có thể lưu", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             sql = "SELECT Makhach FROM tblKhach WHERE Makhach ='" + txtMakhach.Text.Trim() + "'";
             if (FunctionConnect.checkkey(sql))
             {
                 MessageBox.Show("Mã khách bạn muốn lưu đã tồn tại ! \nVui lòng chọn mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 txtMakhach.Focus();
                 return;
             }
             if (MessageBox.Show("Bạn có muốn lưu không ?", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 sql = "INSERT INTO " +
                       "tblKhach (Makhach, Tenkhach, Diachi, Dienthoai) " +
                       "VALUES ('" + txtMakhach.Text + "','" + txtTenkhach.Text + "','" + txtDiachi.Text + "','" + mskDienthoai.Text + "')";
                 FunctionConnect.runsql(sql);
                 Load_DataGridView();
                 MessageBox.Show("Thêm thành công !");
             }
         }
         Disable_Button();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Có lỗi: ", ex.Message);
     }
 }