public static DetailApartModel SelectDetailApartById(DetailApartModel detailApart) { using (IDbConnection cnn = new MySqlConnection(LoadConnectionString())) { var output = cnn.Query <DetailApartModel>("SELECT * FROM detailinvoice WHERE idDetailApart = @idDetailApart", detailApart); return(output.Single()); } }
public static bool InsertDetailApart(DetailApartModel detailApart) { try { using (IDbConnection cnn = new MySqlConnection(LoadConnectionString())) { cnn.Execute("INSERT INTO detailapart (idEmployee, idClient, idBusiness, endDate, Discount, subTotal, Total, paymentType, currentPayment, Ivi, Residue)" + " VALUES(@idEmployee, @idClient, @idBusiness, @endDate, @discount, @subTotal, @total, @paymentType, @currentPayment, @ivi, @residue)", detailApart); } return(true); } catch (Exception ex) { throw; } }
private void btnAddApart_Click(object sender, EventArgs e) { EmployeeModel employee = (EmployeeModel)employeeComboBox.SelectedItem; ClientModel client = (ClientModel)clientComboBox.SelectedItem; BusinessModel businness = (BusinessModel)StoreComboBox.SelectedItem; string endDate = endDateTime.Text; string paymentType = typePayComboBox.Text; string discount = DiscountTextBox.Text; string subtotal = SubtotalTextBox.Text; string total = totalTextBox.Text; string currentPay = currentPayTextBox.Text; string ivi = TaxesTextBox.Text; string residue = ResidueTextBox.Text; try { if (DetailApartManagement.InsertDetailApart(employee.IdEmployee.ToString(), client.IdClient.ToString(), businness.IdBusiness.ToString(), endDate, discount, subtotal, total, paymentType, currentPay, ivi, residue)) { DetailApartModel id = DetailApartManagement.SelectDetailsApartID(); for (int i = 0; i < dgvAparts.RowCount; i++) { string idProduct = dgvAparts.Rows[i].Cells[0].Value.ToString(); int quantity = int.Parse(dgvAparts.Rows[i].Cells[4].Value.ToString()); if (ApartInvoiceManagement.InsertApartInvoice(id.idDetailApart.ToString(), idProduct, quantity.ToString())) { FrmMain.Instance.ToolStripLabel.Text = "Apartado agregado correctamente"; } else { FrmMain.Instance.ToolStripLabel.Text = "Error al agregar la factura de entrada"; } } } } catch (Exception) { throw; } }
public static bool InsertDetailApart(string idEmployee, string idClient, string idBusiness, string endDate, string discount, string subtotal, string total, string paymentType, string currentPayment, string ivi, string residue) { try { string[] inputInvoice = new string[] { idEmployee, idClient, idBusiness, endDate, discount, subtotal, total, paymentType, currentPayment, ivi, residue }; if (ValidateData.VerifyFields(inputInvoice)) { DetailApartModel detailApart = new DetailApartModel() { idEmployee = int.Parse(idEmployee), IdClient = int.Parse(idClient), IdBusiness = int.Parse(idBusiness), currentDate = DateTime.Parse(endDate), discount = decimal.Parse(discount), SubTotal = decimal.Parse(subtotal), Total = decimal.Parse(total), PaymentType = paymentType, CurrentPayment = decimal.Parse(currentPayment), Ivi = decimal.Parse(ivi), Residue = decimal.Parse(residue) }; return(DBDetailsApart.InsertDetailApart(detailApart)); } else { return(false); } } catch (Exception ex) { //Log4Net return(false); } }