public bool Delete(string empresaid, tb_me_productos BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbMeProductos_DELETE", cnx)) { { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; 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); } } } }
public DataSet GenCodigo(string empresaid, tb_me_productos BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbMeGenNewItem", cnx)) { DataSet ds = new DataSet(); { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; cmd.Parameters.Add("@cencosid", SqlDbType.Char, 8).Value = BE.cencosid; } try { cnx.Open(); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } return ds; } catch (Exception ex) { throw new Exception(ex.Message); } } } }
public bool Update(string empresaid, tb_me_productos BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbMeProductos_UPDATE", cnx)) { { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; cmd.Parameters.Add("@productid", SqlDbType.Char, 13).Value = BE.productid; cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status; cmd.Parameters.Add("@productname", SqlDbType.VarChar, 500).Value = BE.productname; cmd.Parameters.Add("@unmed", SqlDbType.Char, 3).Value = BE.unmed; cmd.Parameters.Add("@peso", SqlDbType.Decimal).Value = BE.peso; cmd.Parameters.Add("@unmedpeso", SqlDbType.Char, 3).Value = BE.unmedpeso; cmd.Parameters.Add("@unmedenvase", SqlDbType.Char, 3).Value = BE.unmedenvase; cmd.Parameters.Add("@unidenvase", SqlDbType.Decimal).Value = BE.unidenvase; cmd.Parameters.Add("@precioenvase", SqlDbType.Decimal).Value = BE.precioenvase; cmd.Parameters.Add("@etiquetaname", SqlDbType.VarChar, 40).Value = BE.etiquetaname; cmd.Parameters.Add("@colorid", SqlDbType.Char, 3).Value = BE.colorid; cmd.Parameters.Add("@colorname", SqlDbType.VarChar, 30).Value = BE.colorname; cmd.Parameters.Add("@marcaid", SqlDbType.Char, 2).Value = BE.marcaid; cmd.Parameters.Add("@coleccionid", SqlDbType.Char, 3).Value = BE.coleccionid; cmd.Parameters.Add("@temporadaid", SqlDbType.Char, 1).Value = BE.temporadaid; cmd.Parameters.Add("@categoriaid", SqlDbType.Char, 2).Value = BE.categoriaid; cmd.Parameters.Add("@generoid", SqlDbType.Char, 1).Value = BE.generoid; cmd.Parameters.Add("@tejidoid", SqlDbType.Char, 2).Value = BE.tejidoid; cmd.Parameters.Add("@telaid", SqlDbType.Char, 2).Value = BE.telaid; cmd.Parameters.Add("@tallaid", SqlDbType.Char, 2).Value = BE.tallaid; cmd.Parameters.Add("@coltalla", SqlDbType.Char, 2).Value = BE.coltalla; cmd.Parameters.Add("@coltallaname", SqlDbType.Char, 4).Value = BE.coltallaname; cmd.Parameters.Add("@moneda", SqlDbType.Char, 1).Value = BE.moneda; cmd.Parameters.Add("@precventa", SqlDbType.Decimal).Value = BE.precventa; cmd.Parameters.Add("@precvent2", SqlDbType.Decimal).Value = BE.precvent2; cmd.Parameters.Add("@precvent3", SqlDbType.Decimal).Value = BE.precvent3; cmd.Parameters.Add("@precvent4", SqlDbType.Decimal).Value = BE.precvent4; cmd.Parameters.Add("@precvent5", SqlDbType.Decimal).Value = BE.precvent5; cmd.Parameters.Add("@precventant", SqlDbType.Decimal).Value = BE.precventant; cmd.Parameters.Add("@conce", SqlDbType.VarChar, 30).Value = BE.conce; cmd.Parameters.Add("@diluc", SqlDbType.VarChar, 30).Value = BE.diluc; cmd.Parameters.Add("@ctacte", SqlDbType.Char, 7).Value = BE.ctacte; cmd.Parameters.Add("@compo", SqlDbType.VarChar, 50).Value = BE.compo; cmd.Parameters.Add("@titulo", SqlDbType.VarChar, 80).Value = BE.titulo; cmd.Parameters.Add("@productidold", SqlDbType.Char, 15).Value = BE.productidold; cmd.Parameters.Add("@lineaid", SqlDbType.Char, 3).Value = BE.lineaid; cmd.Parameters.Add("@grupoid", SqlDbType.Char, 4).Value = BE.grupoid; cmd.Parameters.Add("@subgrupoid", SqlDbType.Char, 3).Value = BE.subgrupoid; cmd.Parameters.Add("@item", SqlDbType.Char, 3).Value = BE.item; cmd.Parameters.Add("@codctadebe", SqlDbType.Char, 10).Value = BE.codctadebe; cmd.Parameters.Add("@codctahaber", SqlDbType.Char, 10).Value = BE.codctahaber; cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar; cmd.Parameters.Add("@fepialmac", SqlDbType.DateTime).Value = BE.fepialmac; cmd.Parameters.Add("@feuialmac", SqlDbType.DateTime).Value = BE.feuialmac; cmd.Parameters.Add("@procedenciaid", SqlDbType.Char, 1).Value = BE.procedenciaid; cmd.Parameters.Add("@nserie", SqlDbType.VarChar, 20).Value = BE.nserie; cmd.Parameters.Add("@foto", SqlDbType.Image).Value = BE.Foto; } try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.Message); } } } }
public bool Update_CodigoOLD(string empresaid, tb_me_productos BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbMeProductos_UPDATE_CodigoOLD", cnx)) { { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; cmd.Parameters.Add("@productid", SqlDbType.Char, 13).Value = BE.productid; cmd.Parameters.Add("@productidold", SqlDbType.Char, 15).Value = BE.productidold; cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status; cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar; cmd.Parameters.Add("@fepialmac", SqlDbType.DateTime).Value = BE.fepialmac; cmd.Parameters.Add("@feuialmac", SqlDbType.DateTime).Value = BE.feuialmac; } try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private DataTable Movimiento_producto() { try { var TablaProducto = new DataTable("Producto"); var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); BE.moduloid = moduloid.Trim(); TablaProducto = BL.GetReport(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0]; if (TablaProducto != null) { return TablaProducto; } else { return null; } } catch (Exception ex) { return null; } }
private void btn_CargarProductos_Click(object sender, EventArgs e) { var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); BE.moduloid = modulo.ToString(); BE.filtro = "3"; TablaListaPrecios = BL.GetAll(EmpresaID, BE).Tables[0]; if (TablaListaPrecios.Rows.Count > 0) { dgb_listaPrecios.DataSource = TablaListaPrecios; btn_exportar.Enabled = true; btn_CargarProductos.Enabled = false; btn_importar.Enabled = false; TablaListaPrecios.AcceptChanges(); MessageBox.Show("Carga de Productos Completada...!!!"); } }
private void Insert() { try { if (productid.Text.Trim().Length != 13) { MessageBox.Show("Código de producto invalido !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (productname.Text.Trim().Length == 0) { MessageBox.Show("Ingrese nombre de producto !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (unmed.SelectedIndex == -1) { MessageBox.Show("Seleccione la unidad de medida !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (unmedenvase.SelectedIndex == -1) { MessageBox.Show("Seleccione la unidad de medida !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (unidenvase.Text == "") { MessageBox.Show("Ingrese Equivalente !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { tb_me_productosBL BL = new tb_me_productosBL(); tb_me_productos BE = new tb_me_productos(); BE.moduloid = modulo.Trim(); BE.lineaid = lineaid.Text.Trim(); BE.grupoid = grupoid.Text.Trim(); BE.subgrupoid = subgrupoid.Text.Trim(); BE.item = item.Text.Trim(); BE.productid = productid.Text.Trim(); BE.productname = productname.Text.Trim().ToUpper(); BE.nserie = nserie.Text.ToString(); BE.productidold = "0"; if (unmed.SelectedValue != null) BE.unmed = unmed.SelectedValue.ToString(); BE.precioenvase = Convert.ToDecimal(precioenvase.Text.Trim().PadLeft(1, '0')); if (unmedenvase.SelectedValue != null) BE.unmedenvase = unmedenvase.SelectedValue.ToString(); else unmedenvase.Text = ""; BE.procedenciaid = cenestado.SelectedIndex.ToString(); BE.unidenvase = Convert.ToDecimal(unidenvase.Text.Trim()); BE.unmedpeso = unmedpeso.Text.Trim().ToUpper(); BE.peso = Convert.ToDecimal(peso.Text.Trim().PadLeft(0, '0')); BE.status = "0"; BE.usuar = VariablesPublicas.Usuar.Trim(); // Asignando el valor de la imagen // Stream usado como buffer System.IO.MemoryStream ms = new System.IO.MemoryStream(); // Se guarda la imagen en el buffer if (go_foto.Image != null) { go_foto.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); } // Se extraen los bytes del buffer para asignarlos como valor para el // parámetro. BE.Foto = ms.GetBuffer(); if (BL.Insert(EmpresaID, BE)) { MessageBox.Show("Datos grabados correctamente !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); procesado = true; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cod_productid_TextChanged(object sender, EventArgs e) { if (cod_productid.Text.Length == 13) { var BE = new tb_me_productos(); var BL = new tb_me_productosBL(); var dt = new DataTable(); BE.moduloid = modulo.ToString(); BE.local = local.ToString(); BE.productid = cod_productid.Text.ToString().Trim(); BE.moneda = moneda.ToString(); BE.tipodoc = tipodoc.ToString(); BE.tcamb = tcamb; dt = BL.GetPrecCostoUltimo(VariablesPublicas.EmpresaID, BE).Tables[0]; foreach (DataRow fila in dt.Rows) { row = DataDetalleProductos.NewRow(); row["productid"] = fila["productid"].ToString(); row["productname"] = fila["productname"].ToString(); row["precunit"] = fila["precunit"].ToString(); DataDetalleProductos.Rows.Add(row); calcular_totales(); } dgb_listaproductos.DataSource = DataDetalleProductos; limpiar(); } }
private void btn_busqueda_Click(object sender, EventArgs e) { try { tb_me_productosBL BL = new tb_me_productosBL(); tb_me_productos BE = new tb_me_productos(); // DataTable TablaProducto = new DataTable(); BE.moduloid = modulo; BE.productname = txt_criterio.Text.Trim().ToUpper(); Tablaproducto = BL.GetAll(EmpresaID, BE).Tables[0]; if (Tablaproducto.Rows.Count > 0) { btn_imprimir.Enabled = true; dgb_productos.DataSource = Tablaproducto; //dgb_productos.Rows[0].Selected = false; //dgb_productos.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void get_nuevo_producto() { var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); var DT = new DataTable(); BE.moduloid = cbo_moduloides.SelectedValue.ToString(); BE.lineaid = lineaid.Text.Trim(); BE.grupoid = grupoid.Text.Trim(); BE.subgrupoid = subgrupoid.Text.Trim(); DT = BL.GetAll_nuevocodprod(EmpresaID, BE).Tables[0]; try { item.Text = DT.Rows[0]["item"].ToString().Substring(10, 3); productid.Text = lineaid.Text + grupoid.Text + subgrupoid.Text + item.Text; } catch (Exception ex) { item.Text = "000"; productid.Text = lineaid.Text + grupoid.Text + subgrupoid.Text + item.Text; } if (productid.Text.Trim().Length == 13) { generar_denominacion(); form_bloqueado(true); titulo.Focus(); btn_cancelar.Enabled = true; btn_grabar.Enabled = true; btn_log.Enabled = true; } }
private void btn_excel_Click(object sender, EventArgs e) { var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); var TablaMov_ordprod = new DataTable(); BE.moduloid = modulo.Trim(); BE.filtro = "2"; TablaMov_ordprod = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0]; if (TablaMov_ordprod.Rows.Count > 0) { ExportarExcel(TablaMov_ordprod); } }
private void btn_notepad_Click(object sender, EventArgs e) { var BE = new tb_me_productos(); var BL = new tb_me_productosBL(); var dt = new DataTable(); BE.moduloid = modulo.ToString(); dt = BL.GetAll_Pocket(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { String strDestinationFile; strDestinationFile = @"C:\ErpBapSoftNet_almacen\tb_me_productos.txt"; TextWriter tw = new StreamWriter(strDestinationFile); foreach (DataRow row in dt.Rows) { var items = new List<string>(); foreach (DataColumn col in dt.Columns) { items.Add(row[col.ColumnName].ToString()); } var linea = string.Join("|", items.ToArray()); tw.WriteLine(linea); } tw.Close(); MessageBox.Show("Proceso Terminado", "Información"); } }
private void Update_Foto() { try { var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); BE.moduloid = moduloiddes.SelectedValue.ToString(); if (moduloiddes.SelectedValue.ToString() == "0000") { MessageBox.Show("Seleccione Almacen", "Information"); return; } BE.local = localdes.SelectedValue.ToString(); BE.productid = productid.Text.Trim(); BE.docname = _nombreFoto.ToString(); var ms = new System.IO.MemoryStream(); if (modulo == "0500") { if (go_foto.Image != null) { go_foto.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); } } BE.Foto = ms.GetBuffer(); BL.Update_Foto(EmpresaID, BE); } catch (Exception) { throw; } }
private void Update() { try { if (productid.Text.Trim().Length != 13) { MessageBox.Show("Código de producto invalido !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (productname.Text.Trim().Length == 0) { MessageBox.Show("Ingrese nombre de producto !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (unmed.SelectedIndex == -1) { MessageBox.Show("Seleccione la unidad de medida !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (unmedenvase.SelectedIndex == -1) { MessageBox.Show("Seleccione la unidad de medida !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (unidenvase.Text == string.Empty) { MessageBox.Show("Ingrese Equivalente !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); BE.moduloid = moduloiddes.SelectedValue.ToString(); if (moduloiddes.SelectedValue.ToString() == "0000") { MessageBox.Show("Seleccione Almacen", "Information"); return; } BE.lineaid = lineaid.Text.Trim(); BE.grupoid = grupoid.Text.Trim(); BE.subgrupoid = subgrupoid.Text.Trim(); BE.item = item.Text.Trim(); BE.productid = productid.Text.Trim(); BE.productname = productname.Text.Trim().ToUpper(); BE.productidold = productidold.Text.Trim().ToUpper(); BE.titulo = titulo.Text.Trim().ToUpper(); BE.compo = compo.Text.Trim().ToUpper(); BE.colorid = colorid.Text.Trim(); BE.colorname = colorname.Text.Trim().ToUpper(); if (unmed.SelectedValue != null) { BE.unmed = unmed.SelectedValue.ToString(); } if (unmedenvase.SelectedValue != null) { BE.unmedenvase = unmedenvase.SelectedValue.ToString(); } BE.procedenciaid = procedenciaid.SelectedIndex.ToString(); BE.unidenvase = Convert.ToDecimal(unidenvase.Text.Trim()); BE.status = estado.SelectedIndex.ToString(); BE.usuar = VariablesPublicas.Usuar.Trim(); BE.nserie = nserie.Text.ToString(); var ms = new System.IO.MemoryStream(); if (modulo == "0500") { if (go_foto.Image != null) { go_foto.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); } } BE.Foto = ms.GetBuffer(); if (BL.Update(EmpresaID, BE)) { SEGURIDAD_LOG("M"); MessageBox.Show("Datos Modificado Correctamente !!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); procesado = true; } } } } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Llenar_Datos() { if (cbo_moduloides.SelectedIndex != -1 && cbo_moduloides.SelectedValue.ToString() != "0000" && cbo_moduloides.SelectedValue.ToString() != "0200") { var BE = new tb_me_productos(); var BL = new tb_me_productosBL(); BE.moduloid = cbo_moduloides.SelectedValue.ToString(); BE.productname = txtbusqueda.Text.Trim(); BE.filtro = "4"; Tablaproducto = BL.GetAll(EmpresaID, BE).Tables[0]; if (Tablaproducto.Rows.Count > 0) { MDI_dgb_productos.DataSource = Tablaproducto; } else { MDI_dgb_productos.DataSource = Tablaproducto; } } else { } }
public bool Update_Foto(string empresaid, tb_me_productos BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbMeProductos_UPDATE_FOTOS", 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("@docname", SqlDbType.VarChar, 100).Value = BE.docname; cmd.Parameters.Add("@foto", SqlDbType.Image).Value = BE.Foto; try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private void form_cargar_datos(String posicion) { try { tb_me_productosBL BL = new tb_me_productosBL(); tb_me_productos BE = new tb_me_productos(); DataTable dt = new DataTable(); BE.moduloid = modulo; if (productid.Text.Trim().Length > 0) { BE.productid = productid.Text.Trim(); } BE.posicion = posicion.Trim(); dt = BL.GetAll_paginacion(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { limpiar_documento(); ssModo = "EDIT"; lineaid.Text = dt.Rows[0]["lineaid"].ToString().Trim(); lineaname.Text = dt.Rows[0]["lineaname"].ToString().Trim(); grupoid.Text = dt.Rows[0]["grupoid"].ToString().Trim(); gruponame.Text = dt.Rows[0]["gruponame"].ToString().Trim(); subgrupoid.Text = dt.Rows[0]["subgrupoid"].ToString().Trim(); subgruponame.Text = dt.Rows[0]["subgruponame"].ToString().Trim(); item.Text = dt.Rows[0]["item"].ToString().Trim(); productid.Text = dt.Rows[0]["productid"].ToString().Trim(); productname.Text = dt.Rows[0]["productname"].ToString().Trim(); nserie.Text = dt.Rows[0]["nserie"].ToString().Trim(); // Agregado cenestado.SelectedIndex = Convert.ToInt32(dt.Rows[0]["procedenciaid"]); if (dt.Rows[0]["unmed"].ToString().Trim().Length > 0) unmed.SelectedValue = dt.Rows[0]["unmed"].ToString().Trim(); precioenvase.Text = dt.Rows[0]["precioenvase"].ToString().Trim().PadLeft(1, '0'); if (dt.Rows[0]["unmedenvase"].ToString().Trim().Length > 0) unmedenvase.SelectedValue = dt.Rows[0]["unmedenvase"].ToString().Trim(); else unmedenvase.SelectedIndex = -1; unidenvase.Text = dt.Rows[0]["unidenvase"].ToString().Trim(); unmedpeso.Text = dt.Rows[0]["unmedpeso"].ToString().Trim(); peso.Text = dt.Rows[0]["peso"].ToString().Trim().PadLeft(1, '0'); String foto = dt.Rows[0]["foto"].ToString(); if (dt.Rows[0]["foto"].ToString() != "") { byte[] MyData1 = null; MyData1 = (byte[])(dt.Rows[0]["foto"]); if (MyData1 != null && MyData1.Length != 0) { go_foto.Visible = true; go_foto.Image = null; System.IO.MemoryStream ms = new System.IO.MemoryStream(); // Se utiliza el MemoryStream para extraer la imagen ms.Write(MyData1, 0, MyData1.Length); go_foto.Image = Image.FromStream(ms); } else { go_foto.Visible = false; go_foto.ImageLocation = ""; } } else { go_foto.Visible = false; go_foto.ImageLocation = ""; } subgrupoid.Enabled = false; productid.Enabled = true; btn_editar.Enabled = true; btn_eliminar.Enabled = true; btn_imprimir.Enabled = true; btn_primero.Enabled = true; btn_anterior.Enabled = true; btn_siguiente.Enabled = true; btn_ultimo.Enabled = true; btn_log.Enabled = true; btn_salir.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public DataSet GetAll_paginacion(string empresaid, tb_me_productos BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbMeProductos_SEARCH_paginacion", cnx)) { DataSet ds = new DataSet(); { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; cmd.Parameters.Add("@productid", SqlDbType.Char, 13).Value = BE.productid; cmd.Parameters.Add("@posicion", SqlDbType.VarChar, 10).Value = BE.posicion; } try { cnx.Open(); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } return ds; } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private void form_cargar_datos(String posicion) { try { var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); var dt = new DataTable(); BE.moduloid = moduloiddes.SelectedValue.ToString(); if (productid.Text.Trim().Length > 0) { BE.productid = productid.Text.Trim(); } BE.posicion = posicion.Trim(); dt = BL.GetAll_paginacion(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { limpiar_documento(); ssModo = "EDIT"; lineaid.Text = dt.Rows[0]["lineaid"].ToString().Trim(); lineaname.Text = dt.Rows[0]["lineaname"].ToString().Trim(); grupoid.Text = dt.Rows[0]["grupoid"].ToString().Trim(); gruponame.Text = dt.Rows[0]["gruponame"].ToString().Trim(); subgrupoid.Text = dt.Rows[0]["subgrupoid"].ToString().Trim(); subgruponame.Text = dt.Rows[0]["subgruponame"].ToString().Trim(); item.Text = dt.Rows[0]["item"].ToString().Trim(); productid.Text = dt.Rows[0]["productid"].ToString().Trim(); productname.Text = dt.Rows[0]["productname"].ToString().Trim(); nom_producto = dt.Rows[0]["productname"].ToString().Trim(); productidold.Text = dt.Rows[0]["productidold"].ToString().Trim(); titulo.Text = dt.Rows[0]["titulo"].ToString().Trim(); compo.Text = dt.Rows[0]["compo"].ToString().Trim(); colorid.Text = dt.Rows[0]["colorid"].ToString().Trim(); colorname.Text = dt.Rows[0]["colorname"].ToString().Trim(); procedenciaid.SelectedIndex = Convert.ToInt32(dt.Rows[0]["paisid"]); txt_paisname.Text = dt.Rows[0]["paisname"].ToString().Trim(); nserie.Text = dt.Rows[0]["nserie"].ToString().Trim(); estado.SelectedIndex = Convert.ToInt32(dt.Rows[0]["status"]); if (dt.Rows[0]["unmed"].ToString().Trim().Length > 0) { unmed.SelectedValue = dt.Rows[0]["unmed"].ToString().Trim(); } if (dt.Rows[0]["unmedenvase"].ToString().Trim().Length > 0) { unmedenvase.SelectedValue = dt.Rows[0]["unmedenvase"].ToString().Trim(); } else { unmedenvase.SelectedIndex = -1; } unidenvase.Text = dt.Rows[0]["unidenvase"].ToString().Trim(); _nombreFoto = dt.Rows[0]["docname"].ToString().ToString(); dt.Rows[0]["foto"].ToString(); if (dt.Rows[0]["foto"].ToString() != string.Empty) { var MyData1 = (byte[])null; MyData1 = (byte[])(dt.Rows[0]["foto"]); if (MyData1 != null && MyData1.Length != 0) { vmContenidoFile = MyData1; go_foto.Visible = true; go_foto.Image = null; var ms = new System.IO.MemoryStream(); ms.Write(MyData1, 0, MyData1.Length); go_foto.Image = Image.FromStream(ms); } else { go_foto.Visible = false; go_foto.ImageLocation = string.Empty; } } else { go_foto.Visible = false; go_foto.ImageLocation = string.Empty; } subgrupoid.Enabled = false; productid.Enabled = true; btn_editar.Enabled = true; btn_eliminar.Enabled = true; btn_imprimir.Enabled = true; btn_primero.Enabled = true; btn_anterior.Enabled = true; btn_siguiente.Enabled = true; btn_ultimo.Enabled = true; btn_log.Enabled = true; btn_salir.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Delete() { try { if (productid.Text.Trim().Length != 13) { MessageBox.Show("Código de producto invalido !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { tb_me_productosBL BL = new tb_me_productosBL(); tb_me_productos BE = new tb_me_productos(); BE.moduloid = modulo.Trim(); BE.productid = productid.Text.Trim(); BE.status = "9"; BE.usuar = VariablesPublicas.Usuar.Trim(); if (BL.Delete(EmpresaID, BE)) { SEGURIDAD_LOG("E"); MessageBox.Show("Datos eliminados correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); NIVEL_FORMS(); limpiar_documento(); form_bloqueado(false); subgrupoid.Enabled = false; productid.Enabled = true; 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); } }
public DataSet GetAll_Pocket(string empresaid, tb_me_productos BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (var cmd = new SqlCommand("gspTbMeProductos_SEARCH_FOR_POCKET", cnx)) { var ds = new DataSet(); cmd.CommandTimeout = 0; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; try { cnx.Open(); using (var da = new SqlDataAdapter(cmd)) { da.Fill(ds); } return ds; } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private void get_nuevo_producto() { tb_me_productosBL BL = new tb_me_productosBL(); tb_me_productos BE = new tb_me_productos(); DataTable DT = new DataTable(); BE.moduloid = moduloid.Text.Trim(); BE.lineaid = lineaid.Text.Trim(); BE.grupoid = grupoid.Text.Trim(); BE.subgrupoid = subgrupoid.Text.Trim(); DT = BL.GetAll_nuevocodprod(EmpresaID, BE).Tables[0]; try { item.Text = Convert.ToString(Convert.ToInt16(DT.Rows[0]["item"].ToString().Substring(10, 3)) + 1).PadLeft(3, '0'); productid.Text = lineaid.Text + grupoid.Text + subgrupoid.Text + item.Text; } catch { item.Text = "000"; productid.Text = lineaid.Text + grupoid.Text + subgrupoid.Text + item.Text; } if (productid.Text.Trim().Length == 13) { generar_denominacion(); form_bloqueado(true); productname.Focus(); btn_cancelar.Enabled = true; btn_grabar.Enabled = true; btn_log.Enabled = true; } }
public DataSet GetPrecCostoUltimo(string empresaid, tb_me_productos BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbMePrecioCosto_SEARCH", 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("@productid", SqlDbType.Char, 13).Value = BE.productid; cmd.Parameters.Add("@moneda", SqlDbType.Char, 1).Value = BE.moneda; cmd.Parameters.Add("@tcamb", SqlDbType.Decimal).Value = BE.tcamb; cmd.Parameters.Add("@tipodoc", SqlDbType.Char, 2).Value = BE.tipodoc; } try { cnx.Open(); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } return ds; } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private void cod_productid_TextChanged(object sender, EventArgs e) { if (cod_productid.Text.Length == 13) { //Consultaremos la Query Para Cargar los Productos tb_me_productos BE = new tb_me_productos(); tb_me_productosBL BL = new tb_me_productosBL(); DataTable dt = new DataTable(); BE.moduloid = modulo.ToString(); BE.local = local.ToString(); BE.productid = cod_productid.Text.ToString().Trim(); BE.moneda = moneda.ToString(); BE.listaprecid = listaprecid; dt = BL.GetPrecList(VariablesPublicas.EmpresaID, BE).Tables[0]; foreach (DataRow fila in dt.Rows) { row = DataDetalleProductos.NewRow(); row["productid"] = fila["productid"].ToString(); row["productname"] = fila["productname"].ToString(); row["precunit"] = fila["precunit"].ToString(); DataDetalleProductos.Rows.Add(row); calcular_totales(); } dgb_listaproductos.DataSource = DataDetalleProductos; limpiar(); } }
public DataSet GetPrecList(string empresaid, tb_me_productos BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbMeListaPrecios_SEARCH_unitario", 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("@productid", SqlDbType.Char, 13).Value = BE.productid; cmd.Parameters.Add("@moneda", SqlDbType.Char, 1).Value = BE.moneda; cmd.Parameters.Add("@listaprecid", SqlDbType.Int).Value = BE.listaprecid; } try { cnx.Open(); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } return ds; } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private void ValidaProducto() { if (productid.Text.Trim().Length == 13) { var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); var dt = new DataTable(); BE.moduloid = modulo; BE.productid = productid.Text.Trim(); dt = BL.GetAll(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { lineaid.Text = dt.Rows[0]["lineaid"].ToString().Trim(); lineaname.Text = dt.Rows[0]["lineaname"].ToString().Trim(); grupoid.Text = dt.Rows[0]["grupoid"].ToString().Trim(); gruponame.Text = dt.Rows[0]["gruponame"].ToString().Trim(); subgrupoid.Text = dt.Rows[0]["subgrupoid"].ToString().Trim(); subgruponame.Text = dt.Rows[0]["subgruponame"].ToString().Trim(); productid.Text = dt.Rows[0]["productid"].ToString().Trim(); productname.Text = dt.Rows[0]["productname"].ToString().Trim(); } else { productid.Text = string.Empty; productname.Text = string.Empty; } } else { productid.Text = string.Empty; productname.Text = string.Empty; } }
public DataSet GetReport(string empresaid, tb_me_productos BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbMeProductos_REPORT", cnx)) { DataSet ds = new DataSet(); { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; cmd.Parameters.Add("@productid", SqlDbType.Char, 13).Value = BE.productid; cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status; cmd.Parameters.Add("@productname", SqlDbType.VarChar, 500).Value = BE.productname; cmd.Parameters.Add("@ctacte", SqlDbType.Char, 7).Value = BE.ctacte; cmd.Parameters.Add("@lineaid", SqlDbType.Char, 3).Value = BE.lineaid; cmd.Parameters.Add("@grupoid", SqlDbType.Char, 4).Value = BE.grupoid; cmd.Parameters.Add("@subgrupoid", SqlDbType.Char, 3).Value = BE.subgrupoid; } try { cnx.Open(); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } return ds; } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private DataTable Movimiento_rollostock() { try { var TablaRollostock = new DataTable("Stockrollo"); var BE = new tb_me_productos(); BE.moduloid = VariablesPublicas.Moduloid.Trim(); BE.lineaid = lineaid; BE.grupoid = grupoid; BE.subgrupoid = subgrupoid; BE.productid = productid; BE.colorid = colorid; BE.rollo = rollo; BE.fechdocini = Convert.ToDateTime(fechdocini.Trim().Substring(0, 10)); BE.fechdocfin = Convert.ToDateTime(fechdocfin.Trim().Substring(0, 10)); if (TablaRollostock != null) { return TablaRollostock; } else { return null; } } catch (Exception ex) { return null; } }
private void CargarDetalle(String xxproductid) { Decimal xprecio = 0, xvalor = 0, xcantidad = 0, tipcamb = 0; var desct1 = 0; Decimal imporfac = 0; Decimal import = 0; Decimal totimpx = 0; if (xxproductid.Trim().Length == 13) { var BE = new tb_me_productos(); var BL = new tb_me_productosBL(); var dt = new DataTable(); BE.moduloid = modulo; BE.local = local; BE.productid = xxproductid; BE.moneda = moneda.SelectedValue.ToString(); BE.tcamb = Convert.ToDecimal(tcamb.Text); BE.tipodoc = tipodoc.SelectedValue.ToString(); dt = BL.GetPrecCostoUltimo(VariablesPublicas.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(); Decimal lsStock = 0, dtCantidad = 0, mvCantidad = 0, dtstock = 0; lsStock = Convert.ToDecimal(dt.Rows[0]["stock"].ToString().Trim()); 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); xprecio = Convert.ToDecimal(dt.Rows[0]["precunit"].ToString().Trim()); 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; } //El Precio ya Lo Traigo sea Dolar O Soles xvalor = xprecio; _cal_Igv(); desct1 = 0; import = imporfac * (1 - (desct1 / 100)); //if (Equivalencias.Left(cbo_incprec.Text.Trim(), 1) == "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 = xvalor; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["importe"].Value = Math.Round(xcantidad * xvalor, 6); griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["dtotimpto"].Value = totimpx; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["precioanterior"].Value = xprecio; 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); } }