public bool CierreDePeriodoLogistica(string empresaid, tb_60local_stock BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbCmLocalStock_CierreMes", cnx)) { { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local; cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio; cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes; } try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private void btnReorganizar_Click(object sender, EventArgs e) { fech_ini.Text = DateTime.Now.ToLongTimeString(); var BL = new tb_60local_stockBL(); var BE = new tb_60local_stock(); BE.moduloid = cboModuloid.SelectedValue.ToString(); BE.local = cboLocal.SelectedValue.ToString(); BE.perianio = cboPerianio.SelectedValue.ToString(); BE.grabacp = "S"; BE.desdehistorico = chkDesdeHistorico.Checked; try { if (BL.ReorgTotal(VariablesPublicas.EmpresaID.ToString(), BE)) { fech_fin.Text = DateTime.Now.ToLongTimeString(); MessageBox.Show("Proceso terminado Correctamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Contactese con Sistema !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_process_Click(object sender, EventArgs e) { try { if (localdes.SelectedIndex == -1) { MessageBox.Show("Seleccione Local ..!!!"); return; } else { if (cboanio.SelectedValue.ToString().Trim().Length != 4) { MessageBox.Show("Seleccione Año ..!!!"); return; } else { var BL = new tb_60local_stockBL(); var BE = new tb_60local_stock(); BE.moduloid = moduloiddes.SelectedValue.ToString(); BE.local = localdes.SelectedValue.ToString(); BE.perianio = cboanio.SelectedValue.ToString(); if (BL.Reorg_CostUlt(VariablesPublicas.EmpresaID.ToString(), BE)) { MessageBox.Show("Proceso terminado Correctamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); nuevo(); } else { MessageBox.Show("Contactese con Sistema !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void _RecalculoGrid() { if (almacaccionid.Length > 0) { try { foreach (DataGridViewRow fila in griddetallemov.Rows) { Decimal precunit = 0, tipcamb = 0; Decimal imporfac = 0; var desct1 = 0; Decimal totimpx = 0; Decimal import = 0; Decimal valor = 0; Decimal xcantidad = 0, xprecio = 0, xstock = 0, xcostopromed = 0; var xproductid = string.Empty; xproductid = Convert.ToString(griddetallemov.Rows[fila.Index].Cells["productid"].Value); xcantidad = Convert.ToDecimal(griddetallemov.Rows[fila.Index].Cells["cantidad"].Value); xprecio = Convert.ToDecimal(griddetallemov.Rows[fila.Index].Cells["precunit"].Value); xstock = Convert.ToDecimal(griddetallemov.Rows[fila.Index].Cells["stock"].Value); xcostopromed = Convert.ToDecimal(griddetallemov.Rows[fila.Index].Cells["costopromed"].Value); if (xcantidad < 0) { MessageBox.Show("Cantidad no puede ser negativo!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); xcantidad = 0; griddetallemov.Rows[fila.Index].Cells["cantidad"].Value = xcantidad; return; } if (xprecio < 0) { MessageBox.Show("Precio no puede ser negativo!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); xprecio = 0; griddetallemov.Rows[fila.Index].Cells["precunit"].Value = xprecio; return; } precunit = Math.Round(Convert.ToDecimal(xprecio), 6); tipcamb = Convert.ToDecimal(tcamb.Text.Trim()); if (tipcamb <= 0) { tipcamb = 1; } _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); } if (almacaccionid.Trim().Substring(0, 1) == "2" && almacaccionid.Trim().Substring(0, 1) == "0") { if (xcantidad <= xstock) { valor = Math.Round(Convert.ToDecimal(xcostopromed), 6); } else { MessageBox.Show("Cantidad fuera de rango!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); xcantidad = 0; griddetallemov.Rows[fila.Index].Cells["cantidad"].Value = xcantidad; return; } } else { if (almacaccionid.Trim().Substring(0, 1) == "1" && almacaccionid.Trim().Substring(0, 1) == "0") { valor = precunit; } } 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]; if (moneda.SelectedValue.ToString() == "$") { if (tipref.SelectedIndex != -1) { if (tipref.SelectedValue.ToString() == "OC") { precunit = xprecio; } else { precunit = precunit * tipcamb; xprecio = xprecio / tipcamb; } } else { precunit = precunit * tipcamb; xprecio = xprecio / tipcamb; } } else { if (moneda.Text == "S/.") { } } imporfac = Math.Round(xcantidad * Convert.ToDecimal(xprecio), 6); griddetallemov.Rows[fila.Index].Cells["valor"].Value = precunit; griddetallemov.Rows[fila.Index].Cells["importe"].Value = Math.Round(xcantidad * precunit, 6); griddetallemov.Rows[fila.Index].Cells["precunit"].Value = xprecio; griddetallemov.Rows[fila.Index].Cells["dtotimpto"].Value = totimpx; griddetallemov.Rows[fila.Index].Cells["importfac"].Value = Math.Round(imporfac, 2); } calcular_totales(); } catch (Exception ex) { var error = string.Empty; error = ex.GetType().ToString(); if (error == "System.Data.ConstraintException") { MessageBox.Show("Producto ya existe!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void ValidaTabladetallemovcopia(String vaproductid) { 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 = vaproductid.Trim(); 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; BE.productid = xproductid; DT = BL.GetAll(EmpresaID, BE).Tables[0]; if (DT.Rows.Count > 0) { foreach (DataGridViewRow fila in griddetallemov.Rows) { foreach (DataGridViewColumn col in griddetallemov.Columns) { if (fila.Index >= 0) { if (Convert.ToString(griddetallemov.Rows[fila.Index].Cells["productid"].Value) == vaproductid.ToString()) { griddetallemov.Rows[fila.Index].Cells["productid"].Value = DT.Rows[0]["productid"].ToString().Trim(); griddetallemov.Rows[fila.Index].Cells["productname"].Value = DT.Rows[0]["productname"].ToString().Trim(); griddetallemov.Rows[fila.Index].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[fila.Index].Cells["cantidad"].Value); mvCantidad = Convert.ToDecimal(griddetallemov.Rows[fila.Index].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[fila.Index].Cells["stock_old"].Value = lsStock; griddetallemov.Rows[fila.Index].Cells["stock"].Value = dtstock; griddetallemov.Rows[fila.Index].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")); xprecio = 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")); 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"); } } griddetallemov.Rows[fila.Index].Cells["precventa"].Value = xprecventa; griddetallemov.Rows[fila.Index].Cells["costoultimo"].Value = xcostoultimo; griddetallemov.Rows[fila.Index].Cells["costopromed"].Value = xcostoprom; xcantidad = Convert.ToDecimal(griddetallemov.Rows[fila.Index].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[fila.Index].Cells["valor"].Value = xprecunit; griddetallemov.Rows[fila.Index].Cells["importe"].Value = Math.Round(xcantidad * xprecunit, 6); griddetallemov.Rows[fila.Index].Cells["dtotimpto"].Value = totimpx; griddetallemov.Rows[fila.Index].Cells["cantidad"].Value = xcantidad; griddetallemov.Rows[fila.Index].Cells["precunit"].Value = xprecunit; griddetallemov.Rows[fila.Index].Cells["importfac"].Value = Math.Round(imporfac, 2); Tabladetallemov.AcceptChanges(); griddetallemov.CurrentCell = griddetallemov.Rows[griddetallemov.RowCount - 1].Cells["cantidad"]; } } break; } } } 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); } }
private void DetalleMovimiento(String xtipodocalt, String xnumdocalt) { try { Decimal xxprecventa = 0, xxcostoultimo = 0, xxstock = 0, xxcostopromed = 0; griddetallemov.AutoGenerateColumns = false; var BL = new tb_60movimientosdetBL(); var BE = new tb_60movimientosdet(); var dt = new DataTable(); BE.moduloid = modulo; if (modulo == "0500") { griddetallemov.Columns[4].Visible = true; griddetallemov.Columns[6].Visible = false; griddetallemov.Width = 1085; } else { if (modulo == "0330") { griddetallemov.Columns[4].Visible = false; griddetallemov.Columns[6].Visible = true; } else { griddetallemov.Columns[4].Visible = false; griddetallemov.Columns[6].Visible = false; } } BE.local = local; BE.tipodoc = xtipodocalt.ToString(); BE.serdoc = serdoc.Text.Trim().PadLeft(4, '0'); BE.numdoc = xnumdocalt.ToString(); dt = BL.GetAll_datosdetalle(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { statcostopromed = dt.Rows[0]["statcostopromed"].ToString(); tiptransac = dt.Rows[0]["tiptransac"].ToString(); incprec = dt.Rows[0]["incprec"].ToString().Trim(); } if (Tabladetallemov != null) { Tabladetallemov.Clear(); } foreach (DataRow fila in dt.Rows) { var BL2 = new tb_60local_stockBL(); var BE2 = new tb_60local_stock(); var dt2 = new DataTable(); BE2.moduloid = modulo; BE2.productid = fila["productid"].ToString(); dt2.Clear(); dt2 = BL2.GetAll(EmpresaID, BE2).Tables[0]; if (dt2.Rows.Count > 0) { if (almacaccionid.Trim() == "20" || almacaccionid.Trim() == "21") { lbl_valor.Text = "Cost.Prom"; xxprecventa = Convert.ToDecimal(dt2.Rows[0]["precventa"]); xxcostopromed = Convert.ToDecimal(dt2.Rows[0]["costopromed"]); } else { if (almacaccionid.Trim() == "10" || almacaccionid.Trim() == "11") { lbl_valor.Text = "Cost.Ultm"; xxcostoultimo = Convert.ToDecimal(dt2.Rows[0]["costoultimo"]); } } xxstock = Convert.ToDecimal(dt2.Rows[0]["stock"]); } row = Tabladetallemov.NewRow(); row["itemref"] = fila["itemref"].ToString(); row["items"] = fila["items"].ToString(); row["productid"] = fila["productid"].ToString().Trim(); row["productname"] = fila["productname"].ToString().Trim(); row["rollo"] = fila["rollo"].ToString(); row["stock"] = xxstock; row["stock_old"] = xxstock; row["precventa"] = xxprecventa; row["costoultimo"] = xxcostoultimo; row["costopromed"] = xxcostopromed; var cantidad = Math.Round(Convert.ToDecimal(fila["cantidad"]), 4); var cantidadcta = Math.Round(Convert.ToDecimal(fila["cantidadcta"]), 4); Decimal total; total = cantidad - cantidadcta; row["cantidad"] = total; row["cantidad_old"] = Math.Round(Convert.ToDecimal(fila["cantidad"]), 4); row["precunit"] = Math.Round(Convert.ToDecimal(Convert.ToDecimal(fila["precunit"]).ToString("###,###,##0.000000")), 6); row["importfac"] = Math.Round(Convert.ToDecimal(fila["importfac"]), 2); row["valor"] = Math.Round(Convert.ToDecimal(fila["valor"]), 6); row["importe"] = Math.Round(Convert.ToDecimal(fila["importe"]), 6); row["totimpto"] = Math.Round(Math.Round(Convert.ToDecimal(fila["importe"]), 6) * (Convert.ToDecimal(18) / 100), 6); row["almacaccionid"] = almacaccionid.Trim(); row["unmed"] = fila["unmed"].ToString().Trim(); row["ubicacion"] = fila["ubicacion"].ToString().Trim(); row["nserie"] = fila["nserie"].ToString().Trim(); Tabladetallemov.Rows.Add(row); } griddetallemov.DataSource = Tabladetallemov; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_process_Click(object sender, EventArgs e) { fech_ini.Text = DateTime.Now.ToLongTimeString(); tb_60local_stockBL BL = new tb_60local_stockBL(); tb_60local_stock BE = new tb_60local_stock(); BE.moduloid = ((D60ALMACEN.MainAlmacen)MdiParent).moduloid; BE.local = ((D60ALMACEN.MainAlmacen)MdiParent).local; BE.perianio = perianio; BE.perimes = perimes; BE.grabacp = "S"; try { if (BL.CierreDePeriodo(VariablesPublicas.EmpresaID.ToString(), BE)) { fech_fin.Text = DateTime.Now.ToLongTimeString(); MessageBox.Show("Proceso terminado Correctamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Contactese con Sistema !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_busqueda_Click(object sender, EventArgs e) { var TablaProductostock = new DataTable("Productostock"); try { var BL = new tb_60local_stockBL(); var BE = new tb_60local_stock(); if (cbomodulo.SelectedIndex != -1) { BE.moduloid = cbomodulo.SelectedValue.ToString(); } else { MessageBox.Show("!!! ...Seleccione el Módulo ... !!!", "Información"); return; } if (cbomodulo.SelectedValue.ToString() == "0200") { MessageBox.Show("!!! ...Seleccione Otro Módulo ... !!!", "Información"); return; } if (localdes.SelectedIndex != -1) { BE.local = localdes.SelectedValue.ToString(); } else { MessageBox.Show("!!!... Seleccione Local ...!!!", "Información"); return; } BE.lineaid = lineaid.Text.Trim(); BE.grupoid = grupoid.Text.Trim(); BE.subgrupoid = subgrupoid.Text.Trim(); BE.productid = productid.Text.Trim(); BE.colorid = colorid.Text.Trim(); BE.status = chkTodos.Checked ? "1" : "0"; TablaProductostock = BL.GetAll_productostock(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0]; if (TablaProductostock != null) { Examinar3.DataSource = TablaProductostock; Examinar3.RefreshDataSource(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ValidaTablaDetalle(String valrollo, Decimal xPrecio) { 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; } griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["productname"].Value = string.Empty; txt_stock.Text = "0"; txt_valor.Text = "0"; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["cantidad"].Value = "0"; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["precunit"].Value = "0"; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["importfac"].Value = "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]; 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["rollo"].Value = DTR.Rows[0]["rollo"].ToString().Trim(); griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["stock"].Value = Convert.ToDecimal(DTR.Rows[0]["rollostock"].ToString().Trim().PadLeft(1, '0')); griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].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[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; 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(xPrecio), 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[griddetallemov.CurrentCell.RowIndex].Cells["valor"].Value = xpreciorollo; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["importe"].Value = Math.Round(xcantidad * xPrecio, 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 = xPrecio; 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); } } else { MessageBox.Show("Rollo no Existe !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool ReorgTotal(string empresaid, tb_60local_stock BE) { return tablaDA.ReorgTotal(empresaid, BE); }
public bool ReorgAnioMes(string empresaid, tb_60local_stock BE) { return tablaDA.ReorgAnioMes(empresaid, BE); }
public bool Insert(string empresaid, tb_60local_stock BE) { return tablaDA.Insert(empresaid, BE); }
public DataSet GetAll_productostock(string empresaid, tb_60local_stock BE) { return tablaDA.GetAll_productostock(empresaid, BE); }
public DataSet ConsumosProd(string empresaid, tb_60local_stock BE) { return tablaDA.ConsumosProd(empresaid, BE); }
public bool CierreDePeriodoLogistica(string empresaid, tb_60local_stock BE) { return tablaDA.CierreDePeriodoLogistica(empresaid, BE); }
private DataTable consumos_productos() { try { DtReporte = new DataTable(); var BL = new tb_60local_stockBL(); var BE = new tb_60local_stock(); BE.moduloid = moduloid.ToString(); BE.perimes = Mesdoini.ToString(); BE.perianio = Peranio.ToString(); BE.procedenciaid = procedenciaid.ToString(); BE.filtro = "1"; DtReporte = BL.ConsumosProd(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0]; if (DtReporte != null) { return DtReporte; } else { return DtReporte; } } catch (Exception ex) { throw ex; } }
public DataSet ConsumosProd(string empresaid, tb_60local_stock BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTb60LocalStock_CONSUMO", cnx)) { DataSet ds = new DataSet(); { cmd.CommandTimeout = 0; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; cmd.Parameters.Add("@perianio", SqlDbType.Char,4).Value = BE.perianio; cmd.Parameters.Add("@perimes", SqlDbType.Char,2).Value = BE.perimes; cmd.Parameters.Add("@procedenciaid", SqlDbType.Char, 1).Value = BE.procedenciaid; cmd.Parameters.Add("@filtro", SqlDbType.Char, 1).Value = BE.filtro; } try { cnx.Open(); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } return ds; } catch (Exception ex) { throw new Exception(ex.Message); } } } }
public bool Reorg_CostUlt(string empresaid, tb_60local_stock BE) { return tablaDA.Reorg_CostUlt(empresaid, BE); }
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); } }
public bool Update(string empresaid, tb_60local_stock BE) { return tablaDA.Update(empresaid, BE); }
private void btn_excel_Click(object sender, EventArgs e) { var TablaProductostock = new DataTable("Productostock"); try { var BL = new tb_60local_stockBL(); var BE = new tb_60local_stock(); BE.moduloid = modulo.Trim(); BE.local = local.Trim(); BE.lineaid = lineaid.Text.Trim(); BE.grupoid = grupoid.Text.Trim(); BE.subgrupoid = subgrupoid.Text.Trim(); BE.productid = productid.Text.Trim(); BE.colorid = colorid.Text.Trim(); BE.status = chkTodos.Checked ? "1" : "0"; TablaProductostock = BL.GetAll_productostock(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0]; if (TablaProductostock != null) { Examinar3.DataSource = TablaProductostock; Examinar3.RefreshDataSource(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool Delete(string empresaid, tb_60local_stock BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTb60LocalStock_DELETE", cnx)) { { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local; cmd.Parameters.Add("@productid", SqlDbType.Char, 13).Value = BE.productid; } try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private void ImpresionTomaInv() { var tablaReport = new DataTable(); var BL = new tb_60local_stockBL(); var BE = new tb_60local_stock(); BE.moduloid = ((D60ALMACEN.MainAlmacen)MdiParent).moduloid; BE.local = ((D60ALMACEN.MainAlmacen)MdiParent).local; BE.lineaid = lineaid.Text.Trim(); BE.status = "0"; tablaReport = BL.GetAll_productostock(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0]; if (tablaReport.Rows.Count == 0) { MessageBox.Show("No existe Información Procesada", "Mensaje del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { var miForma = new Frm_Reportes(); var reporteInventario = new REPORTES.CR_tomainventario(); miForma.Text = "Toma de Inventario : Linea"; reporteInventario.DataDefinition.FormulaFields["almacen"].Text = "'" + ((D60ALMACEN.MainAlmacen)MdiParent).moduloname + "'"; miForma.Table = tablaReport; miForma.Reporte = reporteInventario; miForma.Show(); } }
public DataSet GetAll(string empresaid, tb_60local_stock BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTb60LocalStock_SEARCH2", cnx))// MODIFICAMOS TEMPORALMENTE { DataSet ds = new DataSet(); { cmd.CommandTimeout = 0; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local; cmd.Parameters.Add("@productid", SqlDbType.Char, 13).Value = BE.productid; cmd.Parameters.Add("@productname", SqlDbType.VarChar, 60).Value = BE.productname; } try { cnx.Open(); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } return ds; } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private void Tabla_detOC2() { Decimal xxprecventa = 0, xxcostoultimo = 0, xxstock = 0, xxcostopromed = 0; griddetallemov.AutoGenerateColumns = false; var BL = new tb_cm_ordendecompradetBL(); var BE = new tb_cm_ordendecompradet(); var dt = new DataTable(); BE.moduloid = "0100"; BE.local = "001"; BE.tipodoc = tipref.SelectedValue.ToString(); BE.serdoc = serref.Text.Trim(); BE.numdoc = numdococ1.Text.Trim() + numdococ.Text.Trim(); dt = BL.GetAll2(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { foreach (DataRow fila in dt.Rows) { var BL2 = new tb_60local_stockBL(); var BE2 = new tb_60local_stock(); var dt2 = new DataTable(); BE2.moduloid = modulo; BE2.productid = fila["productid"].ToString(); dt2 = BL2.GetAll(EmpresaID, BE2).Tables[0]; if (dt2.Rows.Count > 0) { if (almacaccionid.Trim() == "20" || almacaccionid.Trim() == "21") { lbl_valor.Text = "Cost.Prom"; xxprecventa = Convert.ToDecimal(dt2.Rows[0]["precventa"]); xxcostopromed = Convert.ToDecimal(dt2.Rows[0]["costopromed"]); } else { if (almacaccionid.Trim() == "10" || almacaccionid.Trim() == "11") { lbl_valor.Text = "Cost.Ultm"; xxcostoultimo = Convert.ToDecimal(dt2.Rows[0]["costoultimo"]); } } xxstock = Convert.ToDecimal(dt2.Rows[0]["stock"]); } tipoperacionid.Text = "COMPRA"; row = Tabladetallemov.NewRow(); row["itemref"] = fila["itemref"].ToString(); row["items"] = fila["items"].ToString(); row["productid"] = fila["productid"].ToString().Trim(); row["productname"] = fila["productname"].ToString().Trim(); var cantidad_c = Math.Round(Convert.ToDecimal(fila["cantidad_c"]), 4); var cantidadcta_c = Math.Round(Convert.ToDecimal(fila["cantidadcta_c"]), 4); if (tipref.SelectedIndex != -1) { var stock_old = Math.Round(Convert.ToDecimal(fila["cantidad_c"]), 4); var total = cantidad_c - cantidadcta_c; row["stock_old"] = total; row["stock"] = stock_old - total; } else { row["stock"] = xxstock; row["stock_old"] = xxstock; } row["precventa"] = xxprecventa; row["costoultimo"] = xxcostoultimo; row["costopromed"] = xxcostopromed; Decimal saldo; saldo = cantidad_c - cantidadcta_c; row["cantidad"] = saldo; row["cantidad_old"] = Math.Round(Convert.ToDecimal(fila["cantidad"]), 4); row["precunit"] = Math.Round(Convert.ToDecimal(Convert.ToDecimal(fila["precunit_c"]).ToString("###,###,##0.000000")), 6); var precunit = Math.Round(Convert.ToDecimal(Convert.ToDecimal(fila["precunit_c"]).ToString("###,###,##0.000000")), 6); Decimal importe; importe = cantidad_c * precunit; row["importfac"] = importe; row["valor"] = Math.Round(Convert.ToDecimal(fila["valor"]), 6); row["importe"] = Math.Round(Convert.ToDecimal(fila["importe"]), 6); row["totimpto"] = Math.Round(Math.Round(Convert.ToDecimal(fila["importe"]), 6) * (Convert.ToDecimal(18) / 100), 6); row["almacaccionid"] = almacaccionid.Trim(); Tabladetallemov.Rows.Add(row); griddetallemov.DataSource = Tabladetallemov; } _RecalculoGrid(); } else { MessageBox.Show(" !!!... Informacion de la Orden ...!!! \n" + "\n » La Orden Todabia no ha Sido Generada " + "\n » O la Orden esta Generada en Otra Guia " + "\n\n »» Verifica Tus Ordenes Pendientes ", "Localizando Orden", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); tipref.Enabled = true; tipref.SelectedIndex = -1; tipref.Enabled = true; numdococ1.Text = "2014"; numdococ.Text = string.Empty; return; } }
public DataSet GetAll_productostock(string empresaid, tb_60local_stock BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTb60LocalStock_SEARCH_stockactual", cnx)) { DataSet ds = new DataSet(); { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local; cmd.Parameters.Add("@lineaid", SqlDbType.VarChar, 3).Value = BE.lineaid; cmd.Parameters.Add("@grupoid", SqlDbType.VarChar, 4).Value = BE.grupoid; cmd.Parameters.Add("@subgrupoid", SqlDbType.VarChar, 3).Value = BE.subgrupoid; cmd.Parameters.Add("@productid", SqlDbType.VarChar, 13).Value = BE.productid; cmd.Parameters.Add("@productidold", SqlDbType.VarChar, 10).Value = BE.productidold; cmd.Parameters.Add("@colorid", SqlDbType.VarChar, 3).Value = BE.colorid; cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status; cmd.Parameters.Add("@procedencia", SqlDbType.Char, 1).Value = BE.procedenciaid; } try { cnx.Open(); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } return ds; } catch (Exception ex) { throw new Exception(ex.Message); } } } }
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 //} }
public bool ReorgTotal(string empresaid, tb_60local_stock BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTb60LocalStock_ReorgTotal", cnx)) { { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 0; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local; cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio; cmd.Parameters.Add("@grabacp", SqlDbType.Char, 2).Value = 'S'; cmd.Parameters.Add("@desdehistorico", SqlDbType.Bit).Value = BE.desdehistorico; } try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private void btn_actualizar_Click(object sender, EventArgs e) { foreach (DataGridViewRow fila in griddetallemov.Rows) { var xproductid = griddetallemov.Rows[fila.Index].Cells["productid"].Value.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]; if (DT.Rows.Count > 0) { griddetallemov.Rows[fila.Index].Cells["productname"].Value = DT.Rows[0]["productname"].ToString().Trim(); } else { MessageBox.Show("Producto no existe !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Producto no existe !!! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public bool Update(string empresaid, tb_60local_stock BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTb60LocalStock_UPDATE", cnx)) { { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local; cmd.Parameters.Add("@productid", SqlDbType.Char, 13).Value = BE.productid; cmd.Parameters.Add("@stockini01", SqlDbType.Decimal).Value = BE.stockini01; cmd.Parameters.Add("@stockini02", SqlDbType.Decimal).Value = BE.stockini02; cmd.Parameters.Add("@stockini03", SqlDbType.Decimal).Value = BE.stockini03; cmd.Parameters.Add("@stockini04", SqlDbType.Decimal).Value = BE.stockini04; cmd.Parameters.Add("@stockini05", SqlDbType.Decimal).Value = BE.stockini05; cmd.Parameters.Add("@stockini06", SqlDbType.Decimal).Value = BE.stockini06; cmd.Parameters.Add("@stockini07", SqlDbType.Decimal).Value = BE.stockini07; cmd.Parameters.Add("@stockini08", SqlDbType.Decimal).Value = BE.stockini08; cmd.Parameters.Add("@stockini09", SqlDbType.Decimal).Value = BE.stockini09; cmd.Parameters.Add("@stockini10", SqlDbType.Decimal).Value = BE.stockini10; cmd.Parameters.Add("@stockini11", SqlDbType.Decimal).Value = BE.stockini11; cmd.Parameters.Add("@stockini12", SqlDbType.Decimal).Value = BE.stockini12; cmd.Parameters.Add("@valorini01", SqlDbType.Decimal).Value = BE.valorini01; cmd.Parameters.Add("@valorini02", SqlDbType.Decimal).Value = BE.valorini02; cmd.Parameters.Add("@valorini03", SqlDbType.Decimal).Value = BE.valorini03; cmd.Parameters.Add("@valorini04", SqlDbType.Decimal).Value = BE.valorini04; cmd.Parameters.Add("@valorini05", SqlDbType.Decimal).Value = BE.valorini05; cmd.Parameters.Add("@valorini06", SqlDbType.Decimal).Value = BE.valorini06; cmd.Parameters.Add("@valorini07", SqlDbType.Decimal).Value = BE.valorini07; cmd.Parameters.Add("@valorini08", SqlDbType.Decimal).Value = BE.valorini08; cmd.Parameters.Add("@valorini09", SqlDbType.Decimal).Value = BE.valorini09; cmd.Parameters.Add("@valorini10", SqlDbType.Decimal).Value = BE.valorini10; cmd.Parameters.Add("@valorini11", SqlDbType.Decimal).Value = BE.valorini11; cmd.Parameters.Add("@valorini12", SqlDbType.Decimal).Value = BE.valorini12; cmd.Parameters.Add("@stockini", SqlDbType.Decimal).Value = BE.stockini; cmd.Parameters.Add("@valorini", SqlDbType.Decimal).Value = BE.valorini; cmd.Parameters.Add("@stock", SqlDbType.Decimal).Value = BE.stock; cmd.Parameters.Add("@valoractual", SqlDbType.Decimal).Value = BE.valoractual; cmd.Parameters.Add("@pendingreso", SqlDbType.Decimal).Value = BE.pendingreso; cmd.Parameters.Add("@pendsalida", SqlDbType.Decimal).Value = BE.pendsalida; cmd.Parameters.Add("@costopromed", SqlDbType.Decimal).Value = BE.costopromed; cmd.Parameters.Add("@costoultimo", SqlDbType.Decimal).Value = BE.costoultimo; cmd.Parameters.Add("@codigoubic", SqlDbType.Char, 5).Value = BE.codigoubic; cmd.Parameters.Add("@cantingreso", SqlDbType.Decimal).Value = BE.cantingreso; cmd.Parameters.Add("@impoingreso", SqlDbType.Decimal).Value = BE.impoingreso; cmd.Parameters.Add("@cantsalida", SqlDbType.Decimal).Value = BE.cantsalida; cmd.Parameters.Add("@imposalida", SqlDbType.Decimal).Value = BE.imposalida; cmd.Parameters.Add("@nivelreposicion", SqlDbType.Decimal).Value = BE.nivelreposicion; } try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.Message); } } } }