private void btn_luu_Click(object sender, EventArgs e) { //mở kế nối Unity.OpenConnection(); // MessageBox.Show("Biến thêm: " + them.ToString(), "Cảnh báo", MessageBoxButtons.OK); if (them) { try { string sql = "Insert into Chitiethoadon values(" + "N'" + this.cbx_MaHD.Text.ToString() + "',N'" + this.cbx_maSP.Text.ToString() + "',N'" + this.txt_soluong.Text.ToString() + "')"; //MessageBox.Show("sql thêm: " + sql, "Cảnh báo", MessageBoxButtons.OK); Unity.Excute(sql); String sqlload = "select * from Chitiethoadon"; LoadDB(sqlload); MessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", MessageBoxButtons.OK); Unity.Close(); } catch (SqlException) { MessageBox.Show("Lỗi!", "Cảnh báo", MessageBoxButtons.OK); } } else { //lấy thứ tự record hiện hành int r = dataGridViewQLDMCTHD.CurrentCell.RowIndex; //lấy thanhpho của record hiện hành string strMaHD = dataGridViewQLDMCTHD.Rows[r].Cells[0].Value.ToString(); string sql = "Update Chitiethoadon set MaHD = N'" + this.cbx_MaHD.Text.ToString() + "'," + "MaSP = N'" + this.cbx_maSP.Text.ToString() + "'," + "Soluong = N'" + this.txt_soluong.Text.ToString() + "'where MaHD=N'" + dataGridViewQLDMCTHD.Rows[r].Cells[0].Value.ToString() + "' AND MaSP =N'" + dataGridViewQLDMCTHD.Rows[r].Cells[1].Value.ToString() + "' AND Soluong =N'" + dataGridViewQLDMCTHD.Rows[r].Cells[2].Value.ToString() + "'"; MessageBox.Show("sql sửa: " + sql, "Cảnh báo", MessageBoxButtons.OK); Unity.Excute(sql); String sqlload = "select * from Chitiethoadon"; LoadDB(sqlload); MessageBox.Show("Cập nhật dữ liệu thành công!", "Thông báo", MessageBoxButtons.OK); Unity.Close(); } }
private void btn_luu_Click(object sender, EventArgs e) { //mở kế nối Unity.OpenConnection(); // MessageBox.Show("Biến thêm: " + them.ToString(), "Cảnh báo", MessageBoxButtons.OK); if (them) { try { string sql = "Insert into KhachHang values(" + "N'" + this.txt_maKH.Text.ToString() + "',N'" + this.txt_tencongty.Text.ToString() + "',N'" + this.txt_diachi.Text.ToString() + "',N'" + this.cbx_thanhpho.Text.ToString() + "',N'" + this.txt_dienthoai.Text.ToString() + "')"; //MessageBox.Show("sql thêm: " + sql, "Cảnh báo", MessageBoxButtons.OK); Unity.Excute(sql); String sqlload = "select * from Khachhang"; LoadDB(sqlload); MessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", MessageBoxButtons.OK); Unity.Close(); } catch (SqlException) { MessageBox.Show("Lỗi!", "Cảnh báo", MessageBoxButtons.OK); } } else { //lấy thứ tự record hiện hành int r = dataGridViewQLDMKH.CurrentCell.RowIndex; //lấy thanhpho của record hiện hành string strMaKH = dataGridViewQLDMKH.Rows[r].Cells[0].Value.ToString(); string sql = "Update KhachHang set MaKH = N'" + this.txt_maKH.Text.ToString() + "'," + "TenCty = N'" + this.txt_tencongty.Text.ToString() + "'," + "Diachi = N'" + this.txt_diachi.Text.ToString() + "'," + "ThanhPho = N'" + this.cbx_thanhpho.Text.ToString() + "'," + "Dienthoai = N'" + this.txt_dienthoai.Text.ToString() + "'where MaKH='" + strMaKH + "'"; Unity.Excute(sql); String sqlload = "select * from Khachhang"; LoadDB(sqlload); MessageBox.Show("Cập nhật dữ liệu thành công!", "Thông báo", MessageBoxButtons.OK); Unity.Close(); } }
private void Formdanhmucthanhpho_FormClosing(object sender, FormClosingEventArgs e) { Unity.Close(); }
private void FormQLDMTP_FormClosing(object sender, FormClosingEventArgs e) { Unity.Close(); }
private void Formdanhmucchitiethoadon_FormClosing(object sender, FormClosingEventArgs e) { Unity.Close(); }
private void Formdanhmuckhachhang_FormClosing(object sender, FormClosingEventArgs e) { Unity.Close(); }
private void Formdanhmucsanpham_FormClosing(object sender, FormClosingEventArgs e) { Unity.Close(); }