private void buttonAdd_Click(object sender, EventArgs e) { string values, order; if (CanInsert()) { if (comboBoxPaymentType.Text.Equals("Contado")) { values = string.Format("{0},{1},'{2}',{3},{4},{5},'{6}'", idClient, 1, labelSerialNumber.Text.Replace("Numero de serie: ", "") , textBoxFinalPrice.Text.Replace("$", ""), 1, 0, comboBoxPaymentType.Text); order = "idCliente,idAgente,NoSerie,MontoTotal,NoExhibiciones,Adeudo,TipoVenta"; connection.InsertInto("Venta", order, values); } else { values = string.Format("{0},{1},'{2}',{3},{4},{5},'{6}'", idClient, 1, labelSerialNumber.Text.Replace("Numero de serie: ", "") , textBoxFinalPrice.Text.Replace("$", ""), numericExhibitions.Value, float.Parse(textBoxFinalPrice.Text.Replace("$", "")) - (float)numericStartingAmount.Value , comboBoxPaymentType.Text); } MessageBox.Show("Se realizo la venta exitosamente"); this.Close(); } else { MessageBox.Show("No se pueden dejar espacios en blanco"); } }
public Form1() { InitializeComponent(); databaseconnection = new DatabaseConnection(@"DESKTOP-Q77ELOA\SQLEXPRESS", "databasecar"); //databaseconnection.InsertInto("Auto", "NoSerie, Nombre, Marca, Modelo, PrecioFabrica, PrecioVenta", "'hoolamundo','tsuru','niisan','hibrido',10.5,50.5"); databaseconnection.InsertInto("Cliente", "Nombre,Domicilio,Telefono,Ocupacion", "'Juan Perez','Himno Nacional', '4444954621','Estudiante'"); this.dataGridView1.DataSource = databaseconnection.Refresh("Cliente", "*"); }
/** * Enriquez Capetillo Gerardo Arturo * Cuando se presiona el boton "Aceptar" verifica que ningun campo quede vacio en caso contrario * muestra un mensaje al usuario. * */ private void buttonAccept_Click(object sender, EventArgs e) { string idCar = "-1"; if (textBoxCarBrand.Text.Equals("") || textBoxCarModel.Text.Equals("") || textBoxCarName.Text.Equals("") || textBoxCarSerialNumber.Text.Equals("") || numericUpDownCarPrice.Value == 0) { MessageBox.Show("No puedes dejar campos en blanco", "Error"); } else { if (connection.GetId("Auto", "*", string.Format("Modelo='{0}' AND Marca='{1}' AND Nombre = '{2}'", textBoxCarModel.Text, textBoxCarBrand.Text, textBoxCarName.Text)).Equals("-1")) { connection.InsertInto("Auto", "Modelo,Nombre,Marca,PrecioFabrica,Cantidad", string.Format("'{0}','{1}','{2}',{3},0", textBoxCarModel.Text, textBoxCarName.Text, textBoxCarBrand.Text, numericUpDownCarPrice.Value)); } idCar = connection.GetId("Auto", "*", string.Format("Modelo='{0}' AND Marca='{1}' AND Nombre = '{2}'", textBoxCarModel.Text, textBoxCarBrand.Text, textBoxCarName.Text)); connection.InsertInto("Instancia_Auto", "NoSerie,IdAuto,Bandera", string.Format("'{0}',{1},1", textBoxCarSerialNumber.Text, idCar)); connection.InsertInto("Compra", "idProveedor,idAgente,NoSerie", string.Format("{0},{1},'{2}'", idSupplier, 1, textBoxCarSerialNumber.Text)); MessageBox.Show("Se realizo la compra exitosamente"); this.Close(); } }
private void buttonAdd_Click(object sender, EventArgs e) { string order = "Nombre, Telefono, Domicilio, RazonSocial, Email"; try { if (verify_Fields()) { string value = String.Format("'{0}','{1}','{2}','{3}','{4}'", textBoxName.Text, textBoxPhone.Text, textBoxResidency.Text, textBoxBusinessName.Text, textBoxEmail.Text); connection.InsertInto(tableName, order, value); dataGridViewSuppliers.DataSource = connection.Refresh(tableName, "*"); } } catch (Exception ex) { MessageBox.Show("El E-mail,Telefono y Razon Social deben ser unicos \ny no se pueden repetir"); } }
private void buttonInsert_Click(object sender, EventArgs e) { try { if (existEmptyFields() != true) { connection.InsertInto(tableName, "Nombre,RFC,Salario,Domicilio,Celular,Email", generateStringValue("INSERT")); dataGridViewAgent.DataSource = connection.Refresh(tableName, "*"); cleanForm(); } else { MessageBox.Show("Es obligatorio llenar todos los campos"); } } catch (Exception ex) { MessageBox.Show("El RFC, E-mail y Telefono deben ser unicos \ny no se pueden repetir"); } }
private void buttonInsert_Click(object sender, EventArgs e) { try { if (existEmptyFields() != true) { connection.InsertInto(tableName, "Nombre,Domicilio,Telefono,Ocupacion", generateStringValue("INSERT")); dataGridViewClient.DataSource = connection.Refresh(tableName, "*"); cleanForm(); } else { MessageBox.Show("Es Obligatorio llenar todos los campos"); } } catch (Exception ex) { MessageBox.Show("El Celular tiene que ser unico\ny no se puede repetir."); } }