public static void Insert_CTPDH(ChiTietPDHDTO ctpdh) { try { cnn = DataProvider.ConnectData(); string insert = string.Format("insert into chi_tiet_pdh(ma_sp,ma_pdh,soluong,thanhtien) values('{0}','{1}','{2}','{3}');", ctpdh.ma_sp, ctpdh.ma_pdh, ctpdh.soluong, ctpdh.thanhtien); DataProvider.Execute(cnn, insert); cnn.Close(); } catch (Exception ex) { throw ex; } }
/// <summary> /// sửa chi tiết phiếu đặt hàng /// </summary> /// <param name="ctpdh"></param> public static void Update_CTPDH(ChiTietPDHDTO ctpdh) { try { cnn = DataProvider.ConnectData(); string update = string.Format("UPDATE chi_tiet_pdh SET ma_sp='{1}',soluong={2},thanhtien='{3}' WHERE id = '{0}'", ctpdh.id, ctpdh.ma_sp, ctpdh.soluong, ctpdh.thanhtien); DataProvider.Execute(cnn, update); cnn.Close(); } catch (Exception ex) { throw ex; } }
private void button3_Click(object sender, EventArgs e) { try { if (txtMa_PDH.Text == "") { MessageBox.Show("Bạn chưa nhập mã phiếu !", "Thông báo"); txtMa_PDH.Focus(); } else { pdh.ma_pdh = txtMa_PDH.Text; thanhtien += double.Parse(txtTT.Text); ChiTietPDHDTO ctpdh = new ChiTietPDHDTO(); ctpdh.ma_pdh = txtMa_PDH.Text; ctpdh.ma_sp = txtMaSanPham.Text; ctpdh.soluong = int.Parse(txtSoLuong.Text); ctpdh.thanhtien = double.Parse(txtTT.Text); PhieuDatHangBUS.insert_CTPDH(ctpdh); sp.soluong = soluong - int.Parse(txtSoLuong.Text); SanPhamBUS.Update_SP(sp); MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK); TongTien = TongTien + double.Parse(txtTT.Text.Trim()); txtTongthanhtoan.Text = "" + TongTien + ""; load_data(); txtMaSP.Clear(); txtTT.Clear(); txtTenSP_PDH.Clear(); txtSoLuong.Clear(); txtDG.Clear(); txtTenSP_PDH.Clear(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static void insert_CTPDH(ChiTietPDHDTO ctpdh) { ChiTietPhieuDatHangDAO.Insert_CTPDH(ctpdh); }
public static void Update_CTPDH(ChiTietPDHDTO ctpdh) { ChiTietPhieuDatHangDAO.Update_CTPDH(ctpdh); }