private void btnAGREGAR_Click(object sender, EventArgs e) { if (dgvOCM.Rows.Count == 0) { MessageBox.Show("La orden de Compra se encuentra vacia, por favor ingrese un material"); return; } if (string.IsNullOrEmpty(txtNROFACTURA.Text)) { MessageBox.Show("Debe ingresar un numero de orden"); return; } if (string.IsNullOrEmpty(txtCLIENTE.Text)) { MessageBox.Show("Debe seleccionar un cliente"); return; } if (string.IsNullOrEmpty(dtpFECHA.Text)) { MessageBox.Show("Debe ingresar una fecha"); return; } oORDEN.nroFactura = txtNROFACTURA.Text; //oORDEN.Proveedor = oPROVEEDOR.razonSocial; oORDEN.Cliente = clientesovicj; //oORDEN.Proveedor =; //oORDEN.Proveedor = (MODELO.Proveedor)ToString(); //oORDEN.Proveedor = txtPROVEEDOR.Text; ///////////////////////////////////////////////////////////////////////////////// oORDEN.Fecha = dtpFECHA.Value; oORDEN.IvaTotal = Convert.ToDecimal(txtIVATOTAL.Text); oORDEN.Importe = Convert.ToDecimal(totalivadesc); oORDEN.DescuentoTotal = Convert.ToDecimal(totaldescuento); // oORDEN.CantidadesMat.Add(oCANTMAT); //foreach (MODELO.CantidadMat item in listaCantMateriales.ToList()) //{ // MODELO.CantidadMat mat = new MODELO.CantidadMat(); // mat.Material = item.Material; // mat.Cantidad_mat = item.Cantidad_mat; // cCantMat.agregarCantMat(mat); // listaCantMateriales.Add(mat); // //oORDEN.CantidadesMat.Add(mat); // // item.OrdenCompra.Add(oORDEN); // // cCantMat.modificarCantMat(item); // //oORDEN.CantidadesMat.Add(item); // // cOrden.modificarOrden(oORDEN); //} oORDEN.visibily = true; MODELO.oCanmatVenta Occantmat = new MODELO.oCanmatVenta(); foreach (MODELO.CantidadMat item in listaCantMateriales) { //int cantidadd = Convert.ToInt32(txtCANTIDAD.Text); oMATERIAL = item.Material; Occantmat.cantidadmat = item; Occantmat.venta = oORDEN; Occantmat.material = item.Material.DESCRIPCION_CORTA; Occantmat.cantidadmat.cantidad_base_venta = item.cantidad_base_venta; oMATERIAL = (MODELO.Materiales)cMateriales.obtenerMaterialNombree(item.Material.DESCRIPCION_CORTA)[0]; oMATERIAL.STOCK -= item.Cantidad_mat; cMateriales.modificarMateriales(oMATERIAL); cOccantmat.agregarOccantmatVenta(Occantmat); } //oMATERIAL.STOCK = oMATERIAL.STOCK - Convert.ToInt32(txtCANTIDAD.Text); this.DialogResult = DialogResult.OK; AGREGAR_AUDITORIA("Alta", oORDEN); }
private void btnGUARDAR_Click_1(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtCODIGO.Text)) { MessageBox.Show("Debe ingresar un codigo"); return; } if (string.IsNullOrEmpty(cmbMEDIDA.Text)) { MessageBox.Show("Debe ingresar una medida"); return; } if (string.IsNullOrEmpty(txtDESCRIPCION_CORTA.Text)) { MessageBox.Show("Debe ingresar una descripcion corta"); return; } if (string.IsNullOrEmpty(txtPROVEEDOR.Text)) { MessageBox.Show("Debe ingresar un proveedor"); return; } if (string.IsNullOrEmpty(txtDESCRIPCION_LARGA.Text)) { MessageBox.Show("Debe ingresar una descripcion larga"); return; } if (string.IsNullOrEmpty(txtPUC.Text)) { MessageBox.Show("Debe ingresar un PUC valido"); return; } if (string.IsNullOrEmpty(txtSTOCK.Text)) { MessageBox.Show("Debe ingresar un stock valido"); return; } if (string.IsNullOrEmpty(txtMAXIMO.Text)) { MessageBox.Show("Debe ingresar un maximo"); return; } if (string.IsNullOrEmpty(txtMINIMO.Text)) { MessageBox.Show("Debe ingresar un minimo"); return; } if (string.IsNullOrEmpty(txtGANANCIA.Text)) { MessageBox.Show("Debe ingresar una ganancia valida"); return; } if (string.IsNullOrEmpty(txtCLASE.Text)) { MessageBox.Show("Debe elegir una clase"); return; } if (string.IsNullOrEmpty(txtSUBCLASE.Text)) { MessageBox.Show("Debe elegir una subclase"); return; } if (Convert.ToInt32(txtGANANCIA.Text) > 100 || Convert.ToInt32(txtGANANCIA.Text) < 0) { MessageBox.Show("El numero de porcentaje ingresado es incorrecto"); return; } if (Convert.ToInt32(txtMINIMO.Text) >= Convert.ToInt32(txtMAXIMO.Text)) { MessageBox.Show("El stock minimo debe ser mayor o igual que el stock maximo"); return; } if (string.IsNullOrEmpty(cmbIVA.Text)) { MessageBox.Show("Debe elegir un iva"); return; } oMateriales.COD_MATERIAL = txtCODIGO.Text; oMateriales.DESCRIPCION_CORTA = txtDESCRIPCION_CORTA.Text; oMateriales.DESCRIPCION_LARGA = txtDESCRIPCION_LARGA.Text; oMateriales.MAXIMO = Convert.ToInt32(txtMAXIMO.Text); oMateriales.MINIMO = Convert.ToInt32(txtMINIMO.Text); oMateriales.STOCK = Convert.ToInt32(txtSTOCK.Text); oMateriales.PUC = Convert.ToInt32(txtPUC.Text); oMateriales.IVA = double.Parse(cmbIVA.Text); //oMateriales.PROVEEDOR = (MODELO.Proveedor)txtPROVEEDOR.Text; oMateriales.PROVEEDOR = txtPROVEEDOR.Text; oMateriales.MEDIDA = cmbMEDIDA.Text; oMateriales.CLASE = txtCLASE.Text; oMateriales.SUBCLASE = txtSUBCLASE.Text; //oMateriales.PROVEEDOR = (MODELO.Proveedor)cmbPROVEEDOR.SelectedItem; //oMateriales.SUBCLASE = (MODELO.Subclase)cmbSUBCLASE.SelectedItem; //oMateriales.CLASE = (MODELO.Clase)cmbCLASE.SelectedItem; oMateriales.GANANCIA = Convert.ToInt32(txtGANANCIA.Text); oMateriales.ULTIMA_MODIFICACION = dateTimePicker1.Value; //oAuditoria.Permiso = ((MODELO.PERMISO)item).Descripcion; if (accion == "A") { cMateriales.agregarMateriales(oMateriales); AGREGAR_AUDITORIA("Alta", oMateriales); } else { cMateriales.modificarMateriales(oMateriales); AGREGAR_AUDITORIA("Modificacion", oMateriales); } this.DialogResult = DialogResult.OK; }
public void button2_Click(object sender, EventArgs e) // boton + { if (txtCANTIDAD.Text == "" || Convert.ToInt32(txtCANTIDAD.Text) < 0) { MessageBox.Show("Debe ingresar una cantidad correcta"); return; } try { Int32.Parse(txtPUC.Text); } catch { MessageBox.Show("El PUC es invalido"); return; } if (txtPUC.Text == "" || Convert.ToInt32(txtPUC.Text) < 0) { MessageBox.Show("Debe ingresar un puc correcto"); return; } if (txtDESCUENTO.Text == "" || Convert.ToInt32(txtDESCUENTO.Text) < 0 || Convert.ToInt32(txtDESCUENTO.Text) >= 100) { MessageBox.Show("Debe ingresar un descuento correcto"); return; } Int32 cantidad; cantidad = (Convert.ToInt32(txtCANTIDAD.Text)); totalivadesc = 0; puc = double.Parse(txtPUC.Text); cantidad = Convert.ToInt16(txtCANTIDAD.Text); double total = (puc * cantidad); double ivaParcial = (oMATERIAL.IVA * total) / 100; ///descuento /// if (Convert.ToInt32(txtDESCUENTO.Text) < 0 || (Convert.ToInt32(txtDESCUENTO.Text) > 100)) { MessageBox.Show("El numero de descuento ingresado es incorrecto"); return; } if (DateTime.Now > dtpFECHARECEPCION.Value) { MessageBox.Show("La fecha de entrega no puede ser anterior a la fecha de hoy. Pongase en contacto con soporte"); return; } double descuentoparcial = (Convert.ToDouble(txtDESCUENTO.Text) * total) / 100; /*if ((cantidad + oMATERIAL.STOCK) > oMATERIAL.MAXIMO) * { * MessageBox.Show("La cantidad ingresada supera el MAXIMO de ese material, ponganse en contacto con el soporte"); * return; * }*/ if (string.IsNullOrEmpty(txtCANTIDAD.Text)) { MessageBox.Show("Debe ingresar una cantidad mayor a 0"); return; } if (string.IsNullOrEmpty(txtPUC.Text)) { MessageBox.Show("Debe ingresar un PUC valido"); return; } if (string.IsNullOrEmpty(txtDESCUENTO.Text)) { MessageBox.Show("Debe ingresar un descuento valido"); return; } int count = 0; //oORDEN = new MODELO.OrdenCompra(); //oCANTMAT = new MODELO.CantidadMat(); //oMATERIAL = (MODELO.Materiales)dgvMATERIALES.CurrentRow.DataBoundItem; //oCANTMAT.Material = oMATERIAL; //oCANTMAT.Cantidad_mat = Convert.ToInt32(txtCANTIDAD.Text); //cCantMat.agregarCantMat(oCANTMAT); for (int i = 0; i < listaMateriales.LongCount(); i++) { if (listaMateriales[i] == oMATERIAL) { MessageBox.Show("El material ya existe"); return; } count++; } if (count == listaMateriales.LongCount()) { listaMateriales.Add(oMATERIAL); ////listaCantMateriales.Add(oCANTMAT); listaImportes.Add(total); listaIva.Add(ivaParcial); listaDescuentos.Add(descuentoparcial); } for (int i = 0; i < listaImportes.LongCount(); i++) { totalfinal += total; totaliva += ivaParcial; totaldescuento += descuentoparcial; } /////total + iva con el desc double totalivadescparcial = ((total + ivaParcial) - descuentoparcial); if (count == listaPrecioTotal.LongCount()) { listaPrecioTotal.Add(totalivadescparcial); } totalivadesc = 0; for (int i = 0; i < listaPrecioTotal.LongCount(); i++) { totalivadesc += totalivadescparcial; } MODELO.CantidadMat mat = new MODELO.CantidadMat(); mat.Material = oMATERIAL; mat.Cantidad_mat = Convert.ToInt32(txtCANTIDAD.Text); mat.cantidad_base = mat.Cantidad_mat; cCantMat.agregarCantMat(mat); listaCantMateriales.Add(mat); oMATERIAL.PUC = Convert.ToInt32(txtPUC.Text); cMateriales.modificarMateriales(oMATERIAL); dgvOCM.DataSource = null; dgvOCM.DataSource = listaCantMateriales; txtCANTIDAD.Enabled = false; txtPUC.Enabled = false; txtDESCUENTO.Enabled = false; txtCANTIDAD.Text = ""; txtPUC.Text = ""; txtDESCUENTO.Text = ""; txtIMPORTE_TOTAL.Text = totalivadesc.ToString(); txtDTOTOTAL.Text = totaldescuento.ToString(); txtIMPORTE.Text = totalfinal.ToString(); txtIVATOTAL.Text = totaliva.ToString(); //double total = myList.Sum(item => item.Amount); //txtIMPORTE.Text = Convert.ToInt32(txtCANTIDAD.Text * txtPUC.Text); }
private void btnAGREGAR_Click(object sender, EventArgs e) { if (listaMaterialesUpdated.Count == 0) { MessageBox.Show("Debe agregar por lo menos un material"); return; } listanuevax2 = new List <MODELO.Materiales>(); listanuevax3 = new List <Int32>(); listanuevax2 = cOccantmat.obtenerNuevax2(oOrden); listanuevax3 = cOccantmat.obtenerCantidadxD(oOrden); oRemito.NroRemito = txtNROREMITO.Text; oRemito.Proveedor = oProvedorNew; oRemito.OrdenDeCompra = orderC; oRemito.Fecha = DateTime.Now; oRemito.Localidad = oOrden.Localidad; #region eval. prov //A = FECHA Y CANTIDAD OK, B = CANTIDAD OK Y FECHA MAL, C = CANTIDAD MAL O CANTIDAD Y FECHA MAL for (int i = 0; i < ocantmat.LongCount(); i++) { cantidadRequerida += ocantmat[i].cantidadmat.Cantidad_mat; } if (cantidadRequerida == cantidadIngresada) { if (oOrden.Fecha_Recepcion.Date >= dtpFECHARECEPCION.Value.Date) { oProvedorNew.tipo = "A"; } else if (oOrden.Fecha_Recepcion.Date < dtpFECHARECEPCION.Value.Date) { oProvedorNew.tipo = "B"; } } else if (cantidadRequerida > cantidadIngresada) { if (oOrden.Fecha_Recepcion.Date >= dtpFECHARECEPCION.Value.Date || oOrden.Fecha_Recepcion.Date <= dtpFECHARECEPCION.Value.Date) { oProvedorNew.tipo = "C"; } } #endregion foreach (var item in listaMaterialesUpdated) { oUpdated = item; for (int i = 0; i < ocantmat.LongCount(); i++) { if (ocantmat[i].cantidadmat.Cantidad_mat == oUpdated.Cantidad_Ingresada) { oRemito.CalifCantidad = "A"; if (oOrden.Fecha_Recepcion.Date == dtpFECHARECEPCION.Value.Date) { oRemito.CalifTiempo = "A tiempo"; } } else if (ocantmat[i].cantidadmat.Cantidad_mat != oUpdated.Cantidad_Ingresada) { oRemito.CalifCantidad = "B"; if (oOrden.Fecha_Recepcion.Date == dtpFECHARECEPCION.Value.Date) { oRemito.CalifTiempo = "A tiempo"; } else if (oOrden.Fecha_Recepcion.Date < dtpFECHARECEPCION.Value.Date) { oRemito.CalifTiempo = "Tarde"; } } } } //oMaterial int count = 0; foreach (var item in listaMaterialesUpdated) { oUpdated = item; cRemitoUpdated.agregarRemitoUpdated(oUpdated); for (int i = 0; i < ocantmat.LongCount(); i++) { if (ocantmat[i].material == oUpdated.material) { ocantmat[i].cantidadmat.Cantidad_mat -= oUpdated.Cantidad_Ingresada; cCANTMAT.modificarCantMat(ocantmat[i].cantidadmat); oMaterial = (MODELO.Materiales)cMateriales.obtenerMaterialNombree(ocantmat[i].material)[0]; oMaterial.STOCK += oUpdated.Cantidad_Ingresada; cMateriales.modificarMateriales(oMaterial); } } } for (int i = 0; i < ocantmat.LongCount(); i++) { if (ocantmat[i].cantidadmat.Cantidad_mat == 0) { count++; } } if (count == ocantmat.LongCount()) { oOrden.visibily = false; } cREMITO.agregarRemito(oRemito); AGREGAR_AUDITORIA("Alta", oRemito); this.DialogResult = DialogResult.OK; }