/// <summary> /// Funcion que guarda los datos auxiliares del documento /// </summary> /// <param name="cn"></param> /// <param name="tr"></param> internal void GuardaDatosAux(ref MySqlConnection cn, ref MySqlTransaction tr) { PRODUCTOS.Productos auxL = PRODUCTOS.Productos.ObtenInstancia(); string sql = _SQL_LINEAS_CADO; sql = sql.Replace("[IDELEM]", (this._datos["ID_ELEM"] != DBNull.Value ? this._datos["ID_ELEM"].ToString() : "0")); foreach (DataRow d in this._lineas.Rows) { d["ID_ELEM_CAB"] = this._datos["ID_ELEM"]; if (d["ID_ELEM"].ToString() == "") { Elemento auxe = new Elemento(); auxe.TIPO_ELEMENTO = "LID"; d["ID_ELEM"] = auxe.ObtenIDNuevoElemento(ref cn, ref tr); Thread.Sleep(10); if (d["ID_ELEM_PROD"].ToString() != "") { try { Int64 idelemprod = Convert.ToInt64(d["ID_ELEM_PROD"].ToString()); Producto auxp = auxL.Buscar(idelemprod); if (auxp != null) { //auxp.datos["EXISTENCIAS_PROD"] = Convert.ToInt32((auxp.datos["EXISTENCIAS_PROD"].ToString() != "" ? auxp.datos["EXISTENCIAS_PROD"].ToString() : "0")) - Convert.ToInt32((d["CANTIDAD_LIDO"].ToString() != "" ? d["CANTIDAD_LIDO"].ToString() : "0")); auxp.ActualizaStock((-1) * Convert.ToInt32((d["CANTIDAD_LIDO"].ToString() != "" ? d["CANTIDAD_LIDO"].ToString() : "0"))); auxp.Guardar(); } } catch (Exception err) { } } } } auxL.Guardar(ref cn, ref tr); IGlobal.guardar_datos(sql, ref this._lineas, ref cn, ref tr); }
private void TBoxlecturaCodigo_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Enter && this.TBoxlecturaCodigo.Text != "") { DataRow[] prod = this.listadoGenProd.Datos.Select("COD_BARRAS='" + this.TBoxlecturaCodigo.Text + "'"); if (prod.Length > 0) { if (prod.Length == 1) { Producto aux = this.listadoGenProd.Buscar(Convert.ToInt64(prod[0]["ID_ELEM"])); switch (this.ModoBarra) { case MODO_BARRA_BUSQ.BUSQUEDA: if (aux != null) { CRM.PRODUCTOS.FrmProducto FrmFichaProd = new LFVBNewTPV.CRM.PRODUCTOS.FrmProducto(aux); FrmFichaProd.MdiParent = this; FrmFichaProd.Show(); } break; case MODO_BARRA_BUSQ.ALMACEN: //prod[0]["EXISTENCIAS_PROD"] = Convert.ToInt64((prod[0]["EXISTENCIAS_PROD"].ToString() != "" ? prod[0]["EXISTENCIAS_PROD"].ToString() : "0")) + Convert.ToInt32((this.TBoxNumeroItemsEnt.Text.Trim()!=""?this.TBoxNumeroItemsEnt.Text:"1")); if (aux != null) { aux.ActualizaStock(Convert.ToInt32((this.TBoxNumeroItemsEnt.Text.Trim() != ""?this.TBoxNumeroItemsEnt.Text:"1"))); aux.Guardar(); } this.listadoGenProd.Refrescar(); break; } } else { CRM.PRODUCTOS.FrmProductos FrmListado = new LFVBNewTPV.CRM.PRODUCTOS.FrmProductos(); FrmListado.MdiParent = this; FrmListado.Show(); FrmListado.TBoxFiltroCodBarras.Text = this.TBoxlecturaCodigo.Text; } } else { if (MessageBox.Show("El producto no existe, ¿Desea crearlo?", "Producto inexistente", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Producto aux = this.listadoGenProd.Nuevo(); string codfami = (this.CmbFamiliaDef.ComboBox.SelectedValue != null ? this.CmbFamiliaDef.ComboBox.SelectedValue.ToString() : ""); string codsufa = (this.CmbSubFamiliaDef.ComboBox.SelectedValue != null ? this.CmbSubFamiliaDef.ComboBox.SelectedValue.ToString() : ""); CRM.PRODUCTOS.FrmProducto FrmFichaProd = new LFVBNewTPV.CRM.PRODUCTOS.FrmProducto(aux, this.TBoxlecturaCodigo.Text, codfami, codsufa, this.TBoxNumeroItemsEnt.Text); FrmFichaProd.MdiParent = this; FrmFichaProd.Show(); } } } }