private void ValidaTabladetallemovmov(String valproductid) { var xproductid = string.Empty; Decimal xprecio = 0, xprecunit = 0, xcantidad = 0, xcostoprom = 0, tipcamb = 0; var desct1 = 0; Decimal imporfac = 0; Decimal import = 0; Decimal totimpx = 0; xproductid = valproductid.Trim(); var BL_ = new tb_60movimientosBL(); var BE_ = new tb_60movimientoscab(); DataTable dt = new DataTable(); BE_.tip_op = "OP"; BE_.ser_op = ser_op.Text.Trim().PadLeft(4, '0'); BE_.num_op = num_op.Text.Trim().PadLeft(10, '0'); BE_.productoid = xproductid; BE_.moduloid = modulo.Trim().ToString(); BE_.idx = "ONE"; dt = BL_.GetvalidaMov(EmpresaID, BE_).Tables[0]; string arows = dt.Rows[0].Field<string>("Idx"); //if (arows == "0") //{ // MessageBox.Show("El Producto seleccionado no pertenece a la OP N°: " + ser_op.Text + "-" + num_op.Text + // ", \n Verificar OP ", "Confirmación", // MessageBoxButtons.OK, MessageBoxIcon.Exclamation); //} //else //{ #region griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["productname"].Value = string.Empty; txt_stock.Text = "0"; txt_valor.Text = "0"; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["precunit"].Value = "0"; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["importfac"].Value = "0"; if (xproductid.Trim().Length == 13) { var BL = new tb_60local_stockBL(); var BE = new tb_60local_stock(); var DT = new DataTable(); BE.moduloid = modulo.ToString(); BE.local = local.ToString(); BE.productid = xproductid; DT = BL.GetAll(EmpresaID, BE).Tables[0]; if (DT.Rows.Count > 0) { griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["productid"].Value = DT.Rows[0]["productid"].ToString().Trim(); griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["productname"].Value = DT.Rows[0]["productname"].ToString().Trim(); griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["unmed"].Value = DT.Rows[0]["unmed"].ToString().Trim(); griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["rollo"].Value = string.Empty; Decimal lsStock = 0, dtCantidad = 0, mvCantidad = 0, dtstock = 0; lsStock = Convert.ToDecimal(DT.Rows[0]["stock"].ToString().Trim().PadLeft(1, '0')); dtCantidad = Convert.ToDecimal(griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["cantidad"].Value); mvCantidad = Convert.ToDecimal(griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["cantidad_old"].Value); if (almacaccionid.Substring(0, 1) == "1") { dtstock = lsStock + dtCantidad - mvCantidad; } else { if (almacaccionid.Substring(0, 1) == "2") { dtstock = lsStock - dtCantidad + mvCantidad; } } griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["stock_old"].Value = lsStock; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["stock"].Value = dtstock; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["dalmacaccionid"].Value = almacaccionid.ToString().Trim(); txt_stock.Text = Convert.ToString(dtstock); if (almacaccionid.Substring(0, 1) == "2") { xprecventa = Convert.ToDecimal(Convert.ToDecimal(DT.Rows[0]["precventa"]).ToString("###,###,##0.000000")); // LO COMENTAMOS PORQUE AHORA EL PRECIO LO TRAEMOS DEL COSTO PROMEDIO = costopromed //xprecio = Convert.ToDecimal(Convert.ToDecimal(DT.Rows[0]["costoultimo"]).ToString("###,###,##0.000000")); xprecio = Convert.ToDecimal(Convert.ToDecimal(DT.Rows[0]["costopromed"]).ToString("###,###,##0.000000")); txt_valor.Text = Convert.ToDecimal(DT.Rows[0]["costopromed"].ToString().Trim().PadLeft(1, '0')).ToString("###,###,##0.0000"); xcostoprom = Convert.ToDecimal(DT.Rows[0]["costopromed"].ToString().Trim().PadLeft(1, '0')); } else { if (almacaccionid.Substring(0, 1) == "1") { // LO COMENTAMOS PORQUE AHORA EL PRECIO LO TRAEMOS DEL COSTO PROMEDIO = costopromed //xcostoultimo = Convert.ToDecimal(Convert.ToDecimal(DT.Rows[0]["costoultimo"]).ToString("###,###,##0.000000")); //xprecio = Convert.ToDecimal(Convert.ToDecimal(DT.Rows[0]["costoultimo"]).ToString("###,###,##0.000000")); //txt_valor.Text = Convert.ToDecimal(DT.Rows[0]["costoultimo"].ToString().Trim().PadLeft(1, '0')).ToString("###,###,##0.0000"); xcostoultimo = Convert.ToDecimal(Convert.ToDecimal(DT.Rows[0]["costopromed"]).ToString("###,###,##0.000000")); xprecio = Convert.ToDecimal(Convert.ToDecimal(DT.Rows[0]["costopromed"]).ToString("###,###,##0.000000")); txt_valor.Text = Convert.ToDecimal(DT.Rows[0]["costopromed"].ToString().Trim().PadLeft(1, '0')).ToString("###,###,##0.0000"); } } griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["precventa"].Value = xprecventa; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["costoultimo"].Value = xcostoultimo; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["costopromed"].Value = xcostoprom; xcantidad = Convert.ToDecimal(griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["cantidad"].Value); imporfac = Math.Round(xcantidad * Convert.ToDecimal(xprecio), 6); tipcamb = Convert.ToDecimal(tcamb.Text.Trim()); if (tipcamb <= 0) { tipcamb = 1; } if (moneda.SelectedValue.ToString() == "S") { xprecunit = xprecio; } else { xprecunit = xprecio / tipcamb; } _cal_Igv(); desct1 = 0; import = imporfac * (1 - (desct1 / 100)); if (incprec.Trim() == "S") { totimpx = Math.Round(import * (Convert.ToDecimal(igv) / (100 + Convert.ToDecimal(igv))), 6); } else { totimpx = Math.Round(import * (Convert.ToDecimal(igv) / 100), 6); } griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["valor"].Value = xprecunit; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["importe"].Value = Math.Round(xcantidad * xprecunit, 6); griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["dtotimpto"].Value = totimpx; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["cantidad"].Value = xcantidad; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["precunit"].Value = xprecunit; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["importfac"].Value = Math.Round(imporfac, 2); Tabladetallemov.AcceptChanges(); griddetallemov.CurrentCell = griddetallemov.Rows[griddetallemov.RowCount - 1].Cells["cantidad"]; } else { MessageBox.Show("Producto no existe en tabla LOCAL_STOCK !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Producto no existe !!! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endregion //} }
private void btn_grabar_Click(object sender, EventArgs e) { var sw_prosigue = false; if (ssModo == "NEW") { if (XNIVEL == "0" || XNIVEL == "1" || XNIVEL == "2") { sw_prosigue = (MessageBox.Show("¿Desea Guardar Documento actual ?", "Mensaje del Sistema", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes); } string prodid = ""; if (sw_prosigue) { DataTable dt = new DataTable(); dt.Columns.Add("productid", typeof(System.String)); foreach (DataGridViewRow rowGrid in griddetallemov.Rows) { DataRow row = dt.NewRow(); row["productid"] = Convert.ToString(rowGrid.Cells[1].Value); prodid = prodid+row["productid"].ToString(); dt.Rows.Add(row); } var BL_ = new tb_60movimientosBL(); var BE_ = new tb_60movimientoscab(); DataTable dt_ = new DataTable(); BE_.tip_op = "OP"; BE_.ser_op = ser_op.Text.Trim().PadLeft(4, '0'); BE_.num_op = num_op.Text.Trim().PadLeft(10, '0'); BE_.productoid = prodid.ToString(); BE_.moduloid = modulo.Trim().ToString(); BE_.idx = "ALL"; dt_ = BL_.GetvalidaMov(EmpresaID, BE_).Tables[0]; string arows = dt_.Rows[0].Field<string>("Idx"); //if (arows == "0") //{ // MessageBox.Show("Algunos Productos de la lista no corresponden\n a la OP N°: " + ser_op.Text + "-" + num_op.Text + // ", Verificar OP ", "Confirmación", // MessageBoxButtons.OK, MessageBoxIcon.Exclamation); //}else //{ Insert(); //} } } else { if (XNIVEL == "0" || XNIVEL == "1") { sw_prosigue = (MessageBox.Show("¿Desea Modificar Documento actual ?", "Mensaje del Sistema", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes); if (sw_prosigue) { Update(); } } } }
private void Delete() { try { if (ctacte.Text.Trim().Length == 0) { MessageBox.Show("Ingrese Proveedor/Cliente !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (Tabladetallemov.Rows.Count == 0) { MessageBox.Show("Documento no tiene Items !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (numdoc.Text.Trim().Length == 10) { var BL = new tb_60movimientosBL(); var BE = new tb_60movimientos(); BE.dominioid = dominio; BE.moduloid = modulo; BE.local = local; BE.tipodoc = tipodoc.SelectedValue.ToString(); BE.serdoc = serdoc.Text.Trim(); BE.numdoc = numdoc.Text.Trim(); BE.status = "9"; BE.usuar = VariablesPublicas.Usuar; BE.numref = numdococ1.Text.Trim() + numdococ.Text.Trim(); if (BL.Delete(EmpresaID, BE)) { SEGURIDAD_LOG("E"); NIVEL_FORMS(); MessageBox.Show("Datos eliminados correctamente !!!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); limpiar_documento(); form_bloqueado(false); tipodoc.Enabled = false; numdoc.Enabled = false; btn_nuevo.Enabled = true; btn_primero.Enabled = true; btn_anterior.Enabled = true; btn_siguiente.Enabled = true; btn_ultimo.Enabled = true; btn_salir.Enabled = true; } } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Update() { _cal_Igv(); try { if (ctacte.Text.Trim().Length == 0) { MessageBox.Show("Ingrese Proveedor/Cliente !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (Tabladetallemov.Rows.Count == 0) { MessageBox.Show("Documento no tiene Items !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (tcamb.Text.Trim() == "1") { MessageBox.Show("Actualize el Tipo de Cambio !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (numdoc.Text.Trim().Length == 10) { var BL = new tb_60movimientosBL(); var BE = new tb_60movimientos(); var Detalle = new tb_60movimientos.Item(); var ListaItems = new List<tb_60movimientos.Item>(); BE.dominioid = dominio; BE.moduloid = modulo; BE.local = local; BE.tipodoc = tipodoc.SelectedValue.ToString(); BE.serdoc = serdoc.Text.Trim(); BE.numdoc = numdoc.Text.Trim(); BE.fechdoc = Convert.ToDateTime(fechdoc.Text); BE.moneda = moneda.SelectedValue.ToString().Trim(); BE.tcamb = Convert.ToDecimal(tcamb.Text.Trim()); BE.almacaccionid = almacaccionid.Trim(); BE.tipoperacionid = tipoperacionid.SelectedValue.ToString(); BE.ctacteaccionid = string.Empty; BE.ctacte = ctacte.Text.Trim().ToUpper(); BE.nmruc = nmruc.Text.Trim(); BE.ctactename = ctactename.Text.Trim().ToUpper(); BE.direc = direc.Text.Trim().ToUpper(); BE.direcnume = direcnume.Trim().ToUpper(); BE.direcname = direcname.Text.Trim().ToUpper(); BE.direcdeta = direcdeta.Text.Trim().ToUpper(); if (tipref.SelectedValue != null && serref.Text.Trim().Length > 0) { if (tipref.SelectedValue.ToString() == "OC") { BE.tipref = tipref.SelectedValue.ToString(); BE.serref = serref.Text.Trim().PadLeft(4, '0'); BE.numref = numdococ1.Text.Trim() + numdococ.Text.Trim().PadLeft(6, '0'); try { BE.fechref = Convert.ToDateTime(fechref.Text.Trim()); } catch { BE.fechref = Convert.ToDateTime("01/01/1900"); } } else { if (tipref.SelectedValue.ToString() == "SO") { BE.tipref = string.Empty; BE.serref = string.Empty; BE.numref = string.Empty; try { BE.fechref = Convert.ToDateTime(fechref.Text.Trim()); } catch { BE.fechref = Convert.ToDateTime("01/01/1900"); } } } } if (ser_op.Text.Trim().Length > 0 && num_op.Text.Trim().Length > 0) { BE.tip_op = "OP"; BE.ser_op = ser_op.Text.Trim().PadLeft(4, '0'); BE.num_op = num_op.Text.Trim().PadLeft(10, '0'); } if (serfac.Text.Trim().Length > 0 && numfac.Text.Trim().Length > 0) { BE.tipfac = tipfac.SelectedItem.ToString(); BE.serfac = serfac.Text.Trim().ToString().PadLeft(4, '0'); BE.numfac = numfac.Text.Trim().ToString().PadLeft(10, '0'); try { BE.fechfac = Convert.ToDateTime(fechfac.Text.Trim()); } catch { BE.fechfac = Convert.ToDateTime("01/01/1900"); } } if (serguia.Text.Trim().Length > 0 && numguia.Text.Trim().Length > 0) { BE.tipguia = tipguia.Text.Trim(); BE.serguia = serguia.Text.Trim().ToString().PadLeft(4, '0'); BE.numguia = numguia.Text.Trim().ToString().PadLeft(10, '0'); try { BE.fechguia = Convert.ToDateTime(fechguia.Text.Trim()); } catch { BE.fechguia = Convert.ToDateTime("01/01/1900"); } } if (sernotac.Text.Trim().Length > 0 && numnotac.Text.Trim().Length > 0) { BE.tipnotac = tipnotac.Text.Trim(); BE.sernotac = sernotac.Text.Trim().ToString().PadLeft(4, '0'); BE.numnotac = numnotac.Text.Trim().ToString().PadLeft(10, '0'); try { BE.fechnotac = Convert.ToDateTime(fechnotac.Text.Trim()); } catch { BE.fechnotac = Convert.ToDateTime("01/01/1900"); } } if (vendperid.Text.Trim().Length > 0) { BE.perdni = vendperid.Text.Trim().ToString(); } ; BE.ubige = "000000"; BE.cencosid = cencosid.Text.Trim().ToString(); BE.estacion = estacion.Text.Trim().ToString(); try { BE.totdscto1 = Convert.ToDecimal(totdscto1.Text.Trim()); } catch { BE.totdscto1 = Convert.ToDecimal(0); } BE.tipimptoid = tipimptotasa.SelectedValue.ToString().Trim(); BE.incprec = incprec.Trim(); BE.items = Convert.ToDecimal(itemsT.Text.Trim()); BE.totpzas = Convert.ToDecimal(totpzas.Text.Trim()); BE.bruto = Convert.ToDecimal(bruto.Text.Trim()); BE.igv = igv; BE.totimpto = Convert.ToDecimal(totimpto.Text.Trim()); BE.valventa = Convert.ToDecimal(valventa.Text.Trim()); BE.totimporte = Convert.ToDecimal(totimporte.Text.Trim()); BE.codctadebe = string.Empty; BE.codctahaber = string.Empty; BE.glosa = glosa.Text.Trim().ToUpper().ToString(); try { BE.fechcancel = Convert.ToDateTime("01/01/1900"); } catch { BE.fechcancel = Convert.ToDateTime("01/01/1900"); } try { BE.fechentrega = Convert.ToDateTime(fechentrega.Text.Trim()); } catch { BE.fechentrega = Convert.ToDateTime("01/01/1900"); } try { BE.fechpago = Convert.ToDateTime(fechpago.Text.Trim()); } catch { BE.fechpago = Convert.ToDateTime("01/01/1900"); } BE.transpid = transpid.Text.Trim().ToString(); if (motivotrasladoid.SelectedValue != null) { BE.motivotrasladoid = motivotrasladoid.SelectedValue.ToString(); } if (mottrasladointid.SelectedValue != null) { BE.mottrasladointid = mottrasladointid.SelectedValue.ToString(); } BE.ddnni = ddnni.Text.Trim(); BE.tipdid = string.Empty; BE.statborrado = string.Empty; BE.clientetipo = string.Empty; BE.modofactu = string.Empty; BE.tipodocmanejaserie = tipodocmanejaserie; BE.perianio = fechdoc.Value.Year.ToString(); BE.perimes = fechdoc.Value.Month.ToString().PadLeft(2 , '0'); BE.status = "0"; BE.usuar = VariablesPublicas.Usuar; var item = 0; foreach (DataRow fila in Tabladetallemov.Rows) { Detalle = new tb_60movimientos.Item(); item++; Detalle.fechdoc = Convert.ToDateTime(fechdoc.Text); Detalle.moneda = moneda.SelectedValue.ToString().Trim(); Detalle.tcamb = Convert.ToDecimal(tcamb.Text.Trim()); Detalle.tipoperacionid = tipoperacionid.SelectedValue.ToString(); Detalle.ctacteaccionid = string.Empty; Detalle.ctacte = ctacte.Text.Trim().ToUpper(); Detalle.ctactename = ctactename.Text.Trim().ToUpper(); Detalle.direcnume = direcnume.Trim().ToUpper(); Detalle.direcname = direcname.Text.Trim().ToUpper(); if (tipref.SelectedValue != null && serref.Text.Trim().Length > 0) { Detalle.tipref = tipref.SelectedValue.ToString(); Detalle.serref = serref.Text.Trim().PadLeft(4, '0'); Detalle.numref = numdococ1.Text.Trim() + numdococ.Text.Trim().PadLeft(6, '0'); try { Detalle.fechref = Convert.ToDateTime(fechref.Text.Trim()); } catch { Detalle.fechref = Convert.ToDateTime("01/01/1900"); } } if (ser_op.Text.Trim().Length > 0 && num_op.Text.Trim().Length > 0) { Detalle.tip_op = "OP"; Detalle.ser_op = ser_op.Text.Trim().PadLeft(4, '0'); Detalle.num_op = num_op.Text.Trim().PadLeft(10, '0'); } if (serfac.Text.Trim().Length > 0 && numfac.Text.Trim().Length > 0) { Detalle.tipfac = tipfac.SelectedItem.ToString(); Detalle.serfac = serfac.Text.Trim().ToString().PadLeft(4, '0'); Detalle.numfac = numfac.Text.Trim().ToString().PadLeft(10, '0'); try { Detalle.fechfac = Convert.ToDateTime(fechfac.Text.Trim()); } catch { Detalle.fechfac = Convert.ToDateTime("01/01/1900"); } } if (serguia.Text.Trim().Length > 0 && numguia.Text.Trim().Length > 0) { Detalle.tipguia = tipguia.Text.Trim(); Detalle.serguia = serguia.Text.Trim().ToString().PadLeft(4, '0'); Detalle.numguia = numguia.Text.Trim().ToString().PadLeft(10, '0'); try { Detalle.fechguia = Convert.ToDateTime(fechguia.Text.Trim()); } catch { Detalle.fechguia = Convert.ToDateTime("01/01/1900"); } } if (sernotac.Text.Trim().Length > 0 && numnotac.Text.Trim().Length > 0) { Detalle.tipnotac = tipnotac.Text.Trim(); Detalle.sernotac = sernotac.Text.Trim().ToString().PadLeft(4, '0'); Detalle.numnotac = numnotac.Text.Trim().ToString().PadLeft(10, '0'); try { Detalle.fechnotac = Convert.ToDateTime(fechnotac.Text.Trim()); } catch { Detalle.fechnotac = Convert.ToDateTime("01/01/1900"); } } Detalle.cencosid = cencosid.Text.Trim(); if (vendperid.Text.Trim().Length > 0) { BE.vendorid = vendperid.Text.Trim().ToString(); } ; Detalle.itemref = fila["itemref"].ToString(); Detalle.itemsdet = item.ToString().PadLeft(5, '0'); Detalle.rollo = fila["rollo"].ToString(); Detalle.productid = fila["productid"].ToString(); Detalle.productname = fila["productname"].ToString(); Detalle.cantidad = Convert.ToDecimal(fila["cantidad"].ToString()); Detalle.valor = Convert.ToDecimal(fila["valor"].ToString()); Detalle.precunit = Convert.ToDecimal(fila["precunit"].ToString()); Detalle.importe = Convert.ToDecimal(fila["importe"].ToString()); Detalle.importfac = Convert.ToDecimal(fila["importfac"].ToString()); Detalle.totimpto = Convert.ToDecimal(fila["totimpto"].ToString()); Detalle.Ubicacion = fila["ubicacion"].ToString().ToUpper(); Detalle.unmed = fila["unmed"].ToString().Trim(); Detalle.nserie = fila["nserie"].ToString().Trim(); Detalle.almacaccionid = almacaccionid; if (motivotrasladoid.SelectedValue != null) { Detalle.motivotrasladoid = motivotrasladoid.SelectedValue.ToString(); } if (mottrasladointid.SelectedValue != null) { Detalle.mottrasladointid = mottrasladointid.SelectedValue.ToString(); } Detalle.statcostopromed = statcostopromed.Trim(); Detalle.tiptransac = tiptransac.Trim(); Detalle.incprec = incprec.Trim(); Detalle.igv = igv; Detalle.glosa = glosa.Text.Trim().ToUpper().ToString(); Detalle.codctadebe = string.Empty; Detalle.codctahaber = string.Empty; Detalle.perianio = fechdoc.Value.Year.ToString(); Detalle.perimes = fechdoc.Value.Month.ToString().PadLeft(2, '0'); Detalle.status = "0"; Detalle.usuar = VariablesPublicas.Usuar; if (ssModo != "EDIT") { fila["productid"].ToString(); fila["cantidad"].ToString(); fila["importfac"].ToString(); if (fila["productid"].ToString().Trim().Length == 13 && Convert.ToDecimal(fila["cantidad"]) > 0 && Convert.ToDecimal(fila["importfac"]) > 0) { ListaItems.Add(Detalle); } else { MessageBox.Show("Documento DETALLE EN FORMATO INCORRECTO !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { ListaItems.Add(Detalle); } } if (ListaItems.Count == 0) { MessageBox.Show("Documento SIN DETALLE Y/O DETALLE INCORRECTO !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } BE.ListaItems = ListaItems; if (BL.Update(EmpresaID, BE)) { SEGURIDAD_LOG("M"); NIVEL_FORMS(); MessageBox.Show("Datos Modificados Correctamente !!!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); form_bloqueado(false); Blanquear(); tipodoc.Enabled = false; btn_nuevo.Enabled = true; btn_imprimir.Enabled = true; btnImprimirNoval.Enabled = true; btn_primero.Enabled = true; btn_anterior.Enabled = true; btn_siguiente.Enabled = true; btn_ultimo.Enabled = true; btn_salir.Enabled = true; } } } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ValidaTabladetallemovmov(String valrollo) { var xrollo = string.Empty; var xproductid = string.Empty; Decimal xpreciorollo = 0, xprecunit = 0, xcantidad = 0, xcostoprom = 0, tipcamb = 0; Decimal desct1 = 0; Decimal imporfac = 0; Decimal import = 0; Decimal totimpx = 0; xrollo = valrollo.Trim(); var rowrollo = Tabladetallemov.Select("rollo='" + xrollo + "'"); if (rowrollo.Length > 0) { MessageBox.Show("Rollo ya existe !!!!!!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } txt_stock.Text = "0"; txt_valor.Text = "0"; var BLR = new tb_ta_prodrolloBL(); var DTR = new DataTable(); DTR = BLR.GetOne(EmpresaID, xrollo).Tables[0]; if (DTR.Rows.Count > 0) { xproductid = DTR.Rows[0]["productid"].ToString(); if (xproductid.Trim().Length == 13) { var BL = new tb_60local_stockBL(); var BE = new tb_60local_stock(); var DT = new DataTable(); BE.moduloid = modulo; BE.productid = xproductid; DT = BL.GetAll(EmpresaID, BE).Tables[0]; var nrow = griddetallemov.CurrentCell.RowIndex; if (DT.Rows.Count > 0) { griddetallemov.Rows[nrow].Cells["productid"].Value = DT.Rows[0]["productid"].ToString().Trim(); griddetallemov.Rows[nrow].Cells["productname"].Value = DT.Rows[0]["productname"].ToString().Trim(); griddetallemov.Rows[nrow].Cells["rollo"].Value = DTR.Rows[0]["rollo"].ToString().Trim(); griddetallemov.Rows[nrow].Cells["stock"].Value = Convert.ToDecimal(DTR.Rows[0]["rollostock"].ToString().Trim().PadLeft(1, '0')); griddetallemov.Rows[nrow].Cells["dalmacaccionid"].Value = almacaccionid.ToString().Trim(); txt_stock.Text = Math.Round(Convert.ToDecimal(DTR.Rows[0]["rollostock"].ToString().Trim().PadLeft(1, '0')), 2).ToString(); if (almacaccionid.Substring(0, 1) == "2") { xprecventa = Convert.ToDecimal(Convert.ToDecimal(DT.Rows[0]["precventa"]).ToString("###,###,##0.000000")); xpreciorollo = Convert.ToDecimal(Convert.ToDecimal(DT.Rows[0]["costoultimo"]).ToString("###,###,##0.000000")); txt_valor.Text = Convert.ToDecimal(DT.Rows[0]["costopromed"].ToString().Trim().PadLeft(1, '0')).ToString("###,###,##0.0000"); xcostoprom = Convert.ToDecimal(DT.Rows[0]["costopromed"].ToString().Trim().PadLeft(1, '0')); } else { if (almacaccionid.Substring(0, 1) == "1") { xcostoultimo = Convert.ToDecimal(Convert.ToDecimal(DT.Rows[0]["costoultimo"]).ToString("###,###,##0.000000")); xpreciorollo = Convert.ToDecimal(Convert.ToDecimal(DT.Rows[0]["costoultimo"]).ToString("###,###,##0.000000")); txt_valor.Text = Convert.ToDecimal(DT.Rows[0]["costoultimo"].ToString().Trim().PadLeft(1, '0')).ToString("###,###,##0.0000"); } } griddetallemov.Rows[nrow].Cells["precventa"].Value = xprecventa; griddetallemov.Rows[nrow].Cells["costoultimo"].Value = xcostoultimo; griddetallemov.Rows[nrow].Cells["costopromed"].Value = xcostoprom; var BL_ = new tb_60movimientosBL(); var BE_ = new tb_60movimientoscab(); DataTable dt = new DataTable(); BE_.tip_op = "OP"; BE_.ser_op = ser_op.Text.Trim().PadLeft(4, '0'); BE_.num_op = num_op.Text.Trim().PadLeft(10, '0'); BE_.productoid = DT.Rows[0]["productid"].ToString().Trim(); BE_.moduloid = modulo.Trim().ToString(); BE_.idx = "ONE"; dt = BL_.GetvalidaMov(EmpresaID, BE_).Tables[0]; string arows = dt.Rows[0].Field<string>("Idx"); //if (arows == "0") //{ // MessageBox.Show("El Producto seleccionado no pertenece a la OP N°: " + ser_op.Text + "-" + num_op.Text + // ", \n Verificar OP ", "Confirmación", // MessageBoxButtons.OK, MessageBoxIcon.Exclamation); //} if (tipoperacionid.SelectedValue.ToString() == "02") { xcantidad = Convert.ToDecimal(DTR.Rows[0]["rollomedcompra"].ToString().Trim().PadLeft(1, '0')); } else { xcantidad = Convert.ToDecimal(DTR.Rows[0]["rollostock"].ToString().Trim().PadLeft(1, '0')); } tipcamb = Convert.ToDecimal(tcamb.Text.Trim()); if (tipcamb <= 0) { tipcamb = 1; } if (moneda.SelectedValue.ToString() == "S") { xprecunit = xpreciorollo; } else { xprecunit = xpreciorollo / tipcamb; } if (tipoperacionid.SelectedValue.ToString() == "02" && Convert.ToDecimal(DTR.Rows[0]["rollovaloractual"].ToString().Trim().PadLeft(1, '0')) > 0) { xprecunit = Convert.ToDecimal(DTR.Rows[0]["rollovaloractual"].ToString().Trim().PadLeft(1, '0')); } imporfac = Math.Round(xcantidad * Convert.ToDecimal(xprecunit), 6); _cal_Igv(); desct1 = 0; import = imporfac * (1 - (desct1 / 100)); if (incprec.Trim() == "S") { totimpx = Math.Round(import * (Convert.ToDecimal(igv) / (100 + Convert.ToDecimal(igv))), 6); } else { totimpx = Math.Round(import * (Convert.ToDecimal(igv) / 100), 6); } griddetallemov.Rows[nrow].Cells["valor"].Value = xpreciorollo; griddetallemov.Rows[nrow].Cells["importe"].Value = Math.Round(xcantidad * xpreciorollo, 6); griddetallemov.Rows[nrow].Cells["dtotimpto"].Value = totimpx; griddetallemov.Rows[nrow].Cells["cantidad"].Value = xcantidad; griddetallemov.Rows[nrow].Cells["precunit"].Value = xprecunit; griddetallemov.Rows[nrow].Cells["importfac"].Value = Math.Round(imporfac, 2); Tabladetallemov.AcceptChanges(); griddetallemov.CurrentCell = griddetallemov.Rows[nrow].Cells["cantidad"]; } else { MessageBox.Show("Producto no existe en tabla LOCAL_STOCK !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Producto no existe !!! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Rollo no Existe !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void RecibeRollos(DataTable dtresultado) { string prodid = ""; try { if (dtresultado.Rows.Count > 0) { var cont = 0; foreach (DataRow fila in dtresultado.Rows) { cont = cont + 1; if (griddetallemov.Rows.Count > 0) { var nFilaAnt = griddetallemov.RowCount - 1; var xProductid = fila["productid"].ToString(); var xRollo = fila["rollo"].ToString(); var xProductname = fila["productname"].ToString(); var xActivo = Convert.ToBoolean(fila["check"].ToString()); Decimal xPrecio = 0; if (xActivo) { xPrecio = Convert.ToDecimal(fila["precio"].ToString()); } var xnserie = string.Empty; if (modulo == "0500") { xnserie = fila["nserie"].ToString(); } if (cont > 1) { Tabladetallemov.Rows.Add(VariablesPublicas.InsertIntoTable(Tabladetallemov)); Tabladetallemov.Rows[Tabladetallemov.Rows.Count - 1]["items"] = VariablesPublicas.CalcMaxField(Tabladetallemov, "items", 5); griddetallemov.Rows[nFilaAnt + 1].Cells["productid"].Value = xProductid; griddetallemov.Rows[nFilaAnt + 1].Cells["productname"].Value = xProductname; } else { griddetallemov.Rows[nFilaAnt].Cells["productid"].Value = xProductid; griddetallemov.Rows[nFilaAnt].Cells["productname"].Value = xProductname; if (modulo == "0500") { griddetallemov.Rows[nFilaAnt].Cells["nserie"].Value = xnserie; } } prodid = xProductid.ToString(); griddetallemov.CurrentCell = griddetallemov.Rows[griddetallemov.RowCount - 1].Cells["cantidad"]; griddetallemov.BeginEdit(true); if (xActivo) { ValidaTablaDetalle(xRollo, xPrecio); } else { ValidaTabladetallemovmov(xRollo); } } } } var BL_ = new tb_60movimientosBL(); var BE_ = new tb_60movimientoscab(); DataTable dt = new DataTable(); BE_.tip_op = "OP"; BE_.ser_op = ser_op.Text.Trim().PadLeft(4, '0'); BE_.num_op = num_op.Text.Trim().PadLeft(10, '0'); BE_.productoid = prodid.ToString(); BE_.moduloid = modulo.Trim().ToString(); BE_.idx = "ONE"; dt = BL_.GetvalidaMov(EmpresaID, BE_).Tables[0]; string arows = dt.Rows[0].Field<string>("Idx"); //if (arows == "0") //{ // MessageBox.Show("El Producto seleccionado no pertenece a la OP N°: " + ser_op.Text + "-" + num_op.Text + // ", \n Verificar OP ", "Confirmación", // MessageBoxButtons.OK, MessageBoxIcon.Exclamation); //} } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private DataTable Movimiento(String convalor) { try { DataTable DtReporte = new DataTable("Movimientos"); var BL = new tb_60movimientosBL(); var BE = new tb_60movimientos(); BE.moduloid = modulo; BE.local = local.Trim(); BE.tipodoc = tipodoc.SelectedValue.ToString(); BE.serdoc = serdoc.Text; BE.numdoc = numdoc.Text; BE.Convalor = convalor; DtReporte = BL.GetReport(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0]; if (DtReporte != null) { return DtReporte; } else { return DtReporte; } } catch (Exception ex) { throw ex; } }
private DataTable Movimiento_Rollo2() { try { DtReporte = new DataTable("Movimientos"); var BL = new tb_60movimientosBL(); var BE = new tb_60movimientos(); BE.moduloid = moduloid.Trim(); BE.local = local.Trim(); BE.tipodoc = tipdoc.Trim(); BE.serdoc = serdoc.Trim(); BE.numdoc = numdoc.Trim(); DtReporte = BL.GetReport(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0]; if (DtReporte != null) { return DtReporte; } else { return DtReporte; } return DtReporte; } catch (Exception ex) { return null; } }
private void Insert() { try { if (ctacte.Text.Trim().Length == 0) { MessageBox.Show("Ingrese Proveedor/Cliente !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (TabladetallePedido.Rows.Count == 0) { MessageBox.Show("Documento no tiene Items !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (numdoc.Text.Trim().Length == 10) { var BL = new tb_60movimientosBL(); var BE = new tb_60movimientos(); var Detalle = new tb_60movimientos.Item(); var ListaItems = new List<tb_60movimientos.Item>(); BE.dominioid = dominio; BE.moduloid = modulo; BE.local = local; BE.tipodoc = tipdoc.Text.ToString(); BE.serdoc = serdoc.Text.Trim(); BE.numdoc = numdoc.Text.ToString(); BE.fechdoc = Convert.ToDateTime(fechdoc.Text); BE.ctacteaccionid = string.Empty; BE.ctacte = ctacte.Text.Trim().ToUpper(); BE.ctactename = ctactename.Text.Trim().ToUpper(); if (ser_op.Text.Trim().Length > 0 && num_op.Text.Trim().Length > 0) { BE.tip_op = "OP"; BE.ser_op = ser_op.Text.Trim().PadLeft(4, '0'); BE.num_op = num_op.Text.Trim().PadLeft(10, '0'); } BE.codctadebe = string.Empty; BE.codctahaber = string.Empty; BE.glosa = glosa.Text.Trim().ToUpper().ToString(); try { BE.fechentrega = Convert.ToDateTime(fechentrega.Text.Trim()); } catch { BE.fechentrega = Convert.ToDateTime("01/01/1900"); } Detalle.perianio = fechdoc.Value.Year.ToString(); Detalle.perimes = fechdoc.Value.Month.ToString().PadLeft(2, '0'); Detalle.status = "0"; Detalle.usuar = VariablesPublicas.Usuar; var item = 0; foreach (DataRow fila in TabladetallePedido.Rows) { Detalle = new tb_60movimientos.Item(); item++; Detalle.fechdoc = Convert.ToDateTime(fechdoc.Text); Detalle.ctacteaccionid = string.Empty; Detalle.ctacte = ctacte.Text.Trim().ToUpper(); Detalle.ctactename = ctactename.Text.Trim().ToUpper(); if (ser_op.Text.Trim().Length > 0 && num_op.Text.Trim().Length > 0) { Detalle.tip_op = "OP"; Detalle.ser_op = ser_op.Text.Trim().PadLeft(4, '0'); Detalle.num_op = num_op.Text.Trim().PadLeft(10, '0'); } Detalle.itemref = fila["itemref"].ToString(); Detalle.itemsdet = item.ToString().PadLeft(5, '0'); Detalle.rollo = fila["rollo"].ToString(); Detalle.productid = fila["productid"].ToString(); Detalle.productname = fila["productname"].ToString(); Detalle.Ubicacion = fila["ubicacion"].ToString(); Detalle.cantidad = Convert.ToDecimal(fila["cantidad"].ToString()); Detalle.valor = Convert.ToDecimal(fila["valor"].ToString()); Detalle.importe = Convert.ToDecimal(fila["importe"].ToString()); Detalle.precunit = Convert.ToDecimal(fila["precunit"].ToString()); Detalle.importfac = Convert.ToDecimal(fila["importfac"].ToString()); Detalle.totimpto = Convert.ToDecimal(fila["totimpto"].ToString()); Detalle.almacaccionid = fila["almacaccionid"].ToString(); Detalle.glosa = glosa.Text.Trim().ToUpper().ToString(); Detalle.codctadebe = string.Empty; Detalle.codctahaber = string.Empty; Detalle.perianio = fechdoc.Value.Year.ToString(); Detalle.perimes = fechdoc.Value.Month.ToString().PadLeft(2, '0'); Detalle.status = "0"; Detalle.usuar = VariablesPublicas.Usuar; if (fila["productid"].ToString().Trim().Length == 13 && Convert.ToDecimal(fila["cantidad"]) > 0 && Convert.ToDecimal(fila["importfac"]) > 0) { ListaItems.Add(Detalle); } else { MessageBox.Show("Documento DETALLE EN FORMATO INCORRECTO !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (ListaItems.Count == 0) { MessageBox.Show("Documento SIN DETALLE Y/O DETALLE INCORRECTO !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } BE.ListaItems = ListaItems; if (BL.Insert(EmpresaID, BE)) { NIVEL_FORMS(); MessageBox.Show("Datos grabados correctamente !!!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); form_bloqueado(false); tipdoc.Enabled = false; btn_nuevo.Enabled = true; btn_imprimir.Enabled = true; btn_salir.Enabled = true; } } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }