//insert public bool insertdoanhThuContract_Thue(doanhThuContract_ThueDTO doanhThuContract_ThueDTO) { try { this.openConnection(); SqlCommand cmd = new SqlCommand("INSERT INTO DOANHTHUCONTRACT_THUE(id, TotalCost, idEmployee)" + "VALUES (@id1, @TotalCost, @idEmployee)", this.getConnection); cmd.Parameters.Add("@id1", SqlDbType.NChar).Value = doanhThuContract_ThueDTO.id; cmd.Parameters.Add("@TotalCost", SqlDbType.Float).Value = doanhThuContract_ThueDTO.TotalCost; cmd.Parameters.Add("@idEmployee", SqlDbType.NChar).Value = doanhThuContract_ThueDTO.idEmployee; if (cmd.ExecuteNonQuery() == 1) { return(true); } } catch (Exception ex) { MessageBox.Show("Error: ", ex.Message); } finally { this.closeConnection(); } return(false); }
private void btnThanhToan_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Are you sure", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string idContract = this.txtIdContract.Text.Trim(); float totalCost = float.Parse(this.txtTien.Text.Trim()); string idEmployee = Global.GlobalEmployeeId.Trim(); doanhThuContract_ThueDTO doanhThuContract_ThueDTO = new doanhThuContract_ThueDTO(idContract, totalCost, idEmployee); if (this.doanhThuContract_ThuBUS.insertdoanhThuContract_Thue(doanhThuContract_ThueDTO)) { MessageBox.Show("Thêm vào danh sách thanh toán thành công", "Thanh Toán", MessageBoxButtons.OK, MessageBoxIcon.Information); if (this.contract_ThueBUS.RemoveContract(idContract)) { MessageBox.Show("Đã thanh toán thành công!", "Thanh Toán", MessageBoxButtons.OK, MessageBoxIcon.Information); this.fdoanhThuContract_Thue_Load(sender, e); this.ResetForm(); } else { MessageBox.Show("Thanh toán thất bại vui lòng thử lại sau", "Thanh Toán", MessageBoxButtons.OK, MessageBoxIcon.Error); this.doanhThuContract_ThuBUS.RemovedoanhThuContract_Thu(idContract); } } else { MessageBox.Show("Thêm vào danh sách thanh toán không thành công", "Thanh Toán", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Hủy thao tác", "Thanh Toán", MessageBoxButtons.OK, MessageBoxIcon.None); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }
//insert public bool insertdoanhThuContract_Thue(doanhThuContract_ThueDTO doanhThuContract_ThueDTO) { return(this.doanhThuContract_ThuDAL.insertdoanhThuContract_Thue(doanhThuContract_ThueDTO)); }