private void btnLuu_Click(object sender, EventArgs e) { int maPsc = 1; int maPtt = 1; if (this.txtMaPSC.Text == "") { MessageBox.Show("Vui lòng điền đầy đủ thông tin!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { maPsc = Int32.Parse(this.txtMaPSC.Text); maPtt = Utility.Instance.autoKey(gwHoaDon); } catch { MessageBox.Show("Vui lòng kiểm tra lại thông tin!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Entity_PhieuThanhToan _ptt = new Entity_PhieuThanhToan(maPtt, maPsc); if (ptt.insertHoaDon(_ptt) == true) { MessageBox.Show("Lưu thành công!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.gwHoaDon.DataSource = ptt.getHoaDon(); this.btnLuu.Enabled = true; } else { MessageBox.Show("Có lỗi xảy ra, không thể lưu hóa đơn!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public bool insertHoaDon(Entity_PhieuThanhToan _ptt) { try { const string strSQL = "SP_INSERT_HOADON"; string[] pNames = { "@maPtt", "@maPsc" }; object[] pValues = { _ptt.MaPtt, _ptt.MaPsc }; int count = con.ExecuteStoredProcedure(strSQL, pNames, pValues); if (count >= 0) { return(true); } else { return(false); } } catch { return(false); } }
public bool insertHoaDon(Entity_PhieuThanhToan _ptt) { return(ptt.insertHoaDon(_ptt)); }