private void addData1(ChitietPhieuNhapObj ctpn) { ctpn.Ma = txtMaPN.Text.Trim(); ctpn.Masach = cbbMaSach.Text.Trim(); ctpn.Soluong = Convert.ToInt32(txtSoLuong.Text.Trim()); ctpn.Gianhap = Convert.ToInt32(txtGiaNhap.Text.Trim()); }
public bool AddData(ChitietPhieuNhapObj ctpnObj) { cmd.CommandText = "insert into ChiTietPhieuNhap(MaPN,MaSach,SoLuong,GiaNhap) values('" + ctpnObj.Ma + "','" + ctpnObj.Masach + "','" + ctpnObj.Soluong + "','" + ctpnObj.Gianhap + "')"; cmd.CommandType = CommandType.Text; cmd.Connection = con.Connection; try { con.OpenConn(); cmd.ExecuteNonQuery(); return(true); } catch (Exception ex) { string mex = ex.Message; cmd.Dispose(); con.CloseConn(); } return(false); }
private void btnLuu_Click(object sender, EventArgs e) { bool a = false; ChitietPhieuNhapObj ctpnObj = new ChitietPhieuNhapObj(); for (int k = 0; k < dtGRchitietHD.Rows.Count; k++) { ctpnObj.Ma = txtMaPN.Text; ctpnObj.Masach = dtGRchitietHD.Rows[k].Cells[0].Value.ToString(); ctpnObj.Soluong = int.Parse(dtGRchitietHD.Rows[k].Cells[4].Value.ToString()); ctpnObj.Gianhap = int.Parse(dtGRchitietHD.Rows[k].Cells[5].Value.ToString()); a = ctpnCtr.AddData(ctpnObj); } if (a == true) { MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool AddData(ChitietPhieuNhapObj ctpnObj) { return(ctpnMod.AddData(ctpnObj)); }