private void cmdConsultar_Click(object sender, EventArgs e) { LimpiarControles(); OpcionControles(true); this.Size = this.MaximumSize; opcion = 3; idxG = grdView.CurrentRow.Index; try { PuiCatLstPrecios pui = new PuiCatLstPrecios(db); pui.keyCveLstPrecio = grdView[0, grdView.CurrentRow.Index].Value.ToString(); pui.EditarLstPrecios(); txtClaveLstPrecio.Text = pui.keyCveLstPrecio; txtDescripcion.Text = pui.cmpNombre; chkEsDeCosto.Checked = (pui.cmpEsDeCosto == 1) ? true : false; chkEsDeVenta.Checked = (pui.cmpEsDeVenta == 1) ? true : false; chkEstatus.Checked = (pui.cmpEstatus == 1) ? true : false; OpcionControles(false); } catch (Exception ex) { MessageBoxAdv.Show("Tienes que seleccionar un registro\n" + ex.Message, "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void Agregar() { if (Validar()) { PuiCatLstPrecios pui = new PuiCatLstPrecios(db); pui.keyCveLstPrecio = txtClaveLstPrecio.Text; pui.cmpNombre = txtDescripcion.Text; pui.cmpEsDeCosto = (chkEsDeCosto.Checked == true) ? 1 : 0; pui.cmpEsDeVenta = (chkEsDeVenta.Checked == true) ? 1 : 0; pui.cmpEstatus = (chkEstatus.Checked == true) ? 1 : 0; if (pui.AgregarLstPrecios() >= 1) { if (pui.AddLstPreciosDet() >= 1) { MessageBoxAdv.Show("Registro agregado", "Confirmacion", MessageBoxButtons.OK, MessageBoxIcon.Information); LlenaGridView(); this.Size = this.MinimumSize; } else { MessageBoxAdv.Show("Existe un error al insertar el registro", "Error al insertar", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void Editar() { try { if (Validar()) { PuiCatLstPrecios pui = new PuiCatLstPrecios(db); pui.keyCveLstPrecio = txtClaveLstPrecio.Text; pui.cmpNombre = txtDescripcion.Text; pui.cmpEsDeCosto = (chkEsDeCosto.Checked == true) ? 1 : 0; pui.cmpEsDeVenta = (chkEsDeVenta.Checked == true) ? 1 : 0; pui.cmpEstatus = (chkEstatus.Checked == true) ? 1 : 0; chkEstatus.Checked = (pui.cmpEstatus == 1) ? true : false; if (pui.ActualizaLstPrecios() >= 0) { MessageBoxAdv.Show("Registro Actualizado", "Confirmacion", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Size = this.MinimumSize; } LlenaGridView(); //grdView.CurrentRow.Index = idxG; } } catch (Exception ex) { MessageBoxAdv.Show("Tienes que seleccionar un registro \n" + ex.Message + " " + ex.StackTrace.ToString(), "Error al editar", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void grdView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { if (!DtError) { try { double NewValCell = Convert.ToDouble(grdView[3, grdView.CurrentRow.Index].Value.ToString()); if (NewValCell != OldValCell) { PuiCatLstPrecios Lstp = new PuiCatLstPrecios(db); Lstp.keyCveLstPrecio = CveLstPre; Lstp.cmpCveArticulo = grdView[0, grdView.CurrentRow.Index].Value.ToString(); Lstp.cmpPrecio = NewValCell; Lstp.cmpFechaModifacion = user.FecServer; if (Lstp.UpdLstPrecio_Art() <= 0) { MessageBoxAdv.Show("Error al actualizar precio", "Existe un error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBoxAdv.Show(ex.Message, "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } DtError = false; }
private void LlenaGridView() { PuiCatLstPrecios pui = new PuiCatLstPrecios(db); pui.keyCveLstPrecio = CveLstPre; DatosTbl = pui.LstArticulo_LstPrecio(txtBuscar.Text); DataSet Ds = new DataSet(); try { DatosTbl.Fill(Ds); grdView.Columns.Clear(); grdView.DataSource = Ds.Tables[0]; grdView.Columns["Precio"].ReadOnly = false; grdView.Columns["Articulo"].ReadOnly = true; grdView.Columns["Descripcion"].ReadOnly = true; grdView.Columns["Modelo"].ReadOnly = true; grdView.Columns["FechaModifacion"].ReadOnly = true; grdView.Columns["FechaModifacion"].Visible = false; } catch (Exception ex) { MessageBoxAdv.Show(ex.Message, "Error al cargar listado", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LlecboLstPrecio() { PuiCatLstPrecios lin = new PuiCatLstPrecios(db); cboLstPrecio.DataSource = lin.LLenaCboLstPrecio(); cboLstPrecio.ValueMember = "Clave"; cboLstPrecio.DisplayMember = "Descripcion"; }
private void cmdBuscar_Click(object sender, EventArgs e) { PuiCatLstPrecios pui = new PuiCatLstPrecios(db); DatosTbl = pui.BuscaLstPrecios(txtBuscar.Text); DataSet ds = new DataSet(); DatosTbl.Fill(ds); grdView.Rows.Clear(); for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { object[] tmp = ds.Tables[0].Rows[j].ItemArray; grdView.Rows.Add(tmp); } }
private void cmdEliminar_Click(object sender, EventArgs e) { try { if (MessageBoxAdv.Show("Esta seguro de eliminar el registro " + grdView[0, grdView.CurrentRow.Index].Value.ToString(), "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { PuiCatLstPrecios pui = new PuiCatLstPrecios(db); pui.keyCveLstPrecio = grdView[0, grdView.CurrentRow.Index].Value.ToString(); pui.EliminaLstPrecios(); LlenaGridView(); this.Size = this.MinimumSize; } } catch (Exception ex) { MessageBoxAdv.Show("Tienes que seleccionar un registro\n" + ex.Message, "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void grdView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { if (!DtError) { try { double CostoUltimo = Convert.ToDouble(grdView[3, grdView.CurrentRow.Index].Value.ToString()); double Porcentaje = Convert.ToDouble(grdView[4, grdView.CurrentRow.Index].Value.ToString()); double Precio = Convert.ToDouble(grdView[5, grdView.CurrentRow.Index].Value.ToString()); if (Porcentaje != OldValCell) { PuiCatLstPrecios Lstp = new PuiCatLstPrecios(db); Lstp.keyCveLstPrecio = grdView[6, grdView.CurrentRow.Index].Value.ToString(); Lstp.cmpCveArticulo = grdView[0, grdView.CurrentRow.Index].Value.ToString(); Precio = ((CostoUltimo / 100) * Porcentaje) + CostoUltimo; Lstp.cmpPrecio = Precio; Lstp.cmpPorcentaje = Porcentaje; Lstp.cmpFechaModifacion = user.FecServer; if (Lstp.UpdLstPrecio_Art() <= 0) { MessageBoxAdv.Show("Error al actualizar precio", "Existe un error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { grdView[5, grdView.CurrentRow.Index].Value = Precio; FormatRow(grdView.Rows[e.RowIndex], 1); } } } catch (Exception ex) { MessageBoxAdv.Show(ex.Message, "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } DtError = false; }
private void LlenaGridView() { PuiCatLstPrecios pui = new PuiCatLstPrecios(db); DatosTbl = pui.LstArticulo_LstPrecio(CveLstPre, txtBuscar.Text, (String.IsNullOrEmpty(CveAr) ? 0:1)); //Será 0 cuando venga de LstPrecioMaster y 1 de RegArti DataSet Ds = new DataSet(); try { DatosTbl.Fill(Ds); grdView.Columns.Clear(); grdView.DataSource = Ds.Tables[0]; grdView.Columns["Precio"].ReadOnly = true; grdView.Columns["CveArticulo"].ReadOnly = true; grdView.Columns["Descripcion"].ReadOnly = true; grdView.Columns["CostoUltimo"].ReadOnly = true; grdView.Columns["Porcentaje"].ReadOnly = false; grdView.Columns["CostoUltimo"].HeaderText = "Últ. Compra"; grdView.Columns["CveLstPrecio"].Visible = false; if (!String.IsNullOrEmpty(CveAr)) { grdView.Columns["CveArticulo"].Visible = false; grdView.Columns["Descripcion"].Visible = false; grdView.Columns["CveArticulo"].HeaderText = "Artículo"; } else { grdView.Columns["Nombre"].Visible = false; grdView.Columns["Nombre"].HeaderText = "Lista precio"; grdView.Columns["Nombre"].Width = 200; } } catch (Exception ex) { MessageBoxAdv.Show(ex.Message, "Error al cargar listado", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LlenaGridView() { PuiCatLstPrecios pui = new PuiCatLstPrecios(db); DatosTbl = pui.ListarLstPrecios(); DataSet Ds = new DataSet(); try { DatosTbl.Fill(Ds); grdView.Rows.Clear(); for (int j = 0; j < Ds.Tables[0].Rows.Count; j++) { object[] tmp = Ds.Tables[0].Rows[j].ItemArray; grdView.Rows.Add(tmp); } } catch (Exception ex) { MessageBoxAdv.Show(ex.Message, "Error al cargar listado", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private int getPrecio() { int Err = 0; PuiCatLstPrecios pui = new PuiCatLstPrecios(db); SqlDataAdapter Datos = null; DataSet Ds = new DataSet(); object[] ObjA = null; pui.keyCveLstPrecio = LstPre_Clie; pui.cmpCveArticulo = IdArt; Datos = pui.GetPrecioArticulo(); Datos.Fill(Ds); if (Ds.Tables[0].Rows.Count > 0) { ObjA = Ds.Tables[0].Rows[0].ItemArray; } else { pui.keyCveLstPrecio = LstPre_Alm; pui.cmpNombre = IdArt; Datos = pui.GetPrecioArticulo(); Datos.Fill(Ds); if (Ds.Tables[0].Rows.Count > 0) { ObjA = Ds.Tables[0].Rows[0].ItemArray; } else { Err = 1; } } if (Err == 0) { double Ppre = Convert.ToDouble(ObjA[4]); int rPre = Ppre.CompareTo(0); if (rPre > 0) { PuiCatImpuestos I = new PuiCatImpuestos(db); if (!String.IsNullOrEmpty(CveIEPS)) { I.keyCveImpuesto = CveIEPS; I.EditarImpuesto(); if (I.cmpValor > 0) { Ppre += Ppre * (I.cmpValor / 100); } } if (!String.IsNullOrEmpty(CveImp)) { I.keyCveImpuesto = CveImp; I.EditarImpuesto(); if (I.cmpValor > 0) { Ppre += Ppre * (I.cmpValor / 100); } } lblPrecioArt.Text = Util.FormtStrDec(ObjA[4].ToString());//ObjA[4].ToString(); } else { Err = 1; } } return(Err); }