protected void btnGuardar_Click(object sender, EventArgs e) { BE_Usuario objSesionLogin = (BE_Usuario)Context.Session[Constantes.USUARIO_SESION]; BE_UsuarioTienda objUsuTienda = BL_UsuarioTienda.GetUsuarioTienda(objSesionLogin.codUsuario); try { BE_DetalleProductoTienda objProductoTienda = new BE_DetalleProductoTienda(); objProductoTienda.codTienda = objUsuTienda.codTienda; objProductoTienda.codProducto = ddlProducto.SelectedValue; objProductoTienda.cntProducto = Convert.ToInt16(txtCantidad.Text); objProductoTienda.dscUsuCreacion = objSesionLogin.codUsuario; objProductoTienda.dscUsuModificacion = objSesionLogin.codUsuario; if (hfAccion.Value == Constantes.ACCION_NUEVO) { if (BL_DetalleProductoTienda.InsertarProductoTienda(objProductoTienda) == true) { string script = "$(function(){bettosimport.util.alertURL('" + Constantes.SUCCESS_DEFAULT_MESSAGE + "','" + WebUtil.AbsoluteWebRoot + "INV/DetalleProductoTienda.aspx" + "')})"; ScriptManager.RegisterStartupScript(this, Page.GetType(), "", script, true); } else { string script = "$(function(){bettosimport.util.showMessage('" + Constantes.ERROR_DEFAULT_MESSAGE + "','" + Constantes.ALERT_DANGER + "')})"; ScriptManager.RegisterStartupScript(this, Page.GetType(), "", script, true); } } } catch (Exception) { string script = "$(function(){bettosimport.util.showMessage('" + Constantes.ERROR_DEFAULT_MESSAGE + "','" + Constantes.ALERT_DANGER + "')})"; ScriptManager.RegisterStartupScript(this, Page.GetType(), "", script, true); } }
public static bool InsertarProductoTienda(BE_DetalleProductoTienda objDetalleProducto) { bool resultado = false; try { using (MySqlConnection cn = new MySqlConnection(cnMySql())) { cn.Open(); using (MySqlTransaction trx = cn.BeginTransaction()) { try { using (MySqlCommand cmd = new MySqlCommand("SP_Inv_DetalleProductoTienda_InsertarEnTienda", cn)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Transaction = trx; cmd.Parameters.Add("_codProducto", MySqlDbType.VarChar, 20).Value = objDetalleProducto.codProducto; cmd.Parameters.Add("_codTienda", MySqlDbType.VarChar, 3).Value = objDetalleProducto.codTienda; cmd.Parameters.Add("_cntProducto", MySqlDbType.Int16).Value = objDetalleProducto.cntProducto; cmd.Parameters.Add("_dscUsuCreacion", MySqlDbType.VarChar, 10).Value = objDetalleProducto.dscUsuCreacion; cmd.ExecuteNonQuery(); } trx.Commit(); resultado = true; } catch (Exception ex) { trx.Rollback(); resultado = false; throw ex; } } } } catch (Exception ex) { resultado = false; throw ex; } return(resultado); }
public static List <BE_DetalleProductoTienda> ListarProductosTienda(string dscProducto, string codTienda) { try { using (MySqlConnection cn = new MySqlConnection(cnMySql())) { cn.Open(); using (MySqlCommand cmd = new MySqlCommand("SP_Inv_DetalleProductoTienda_ListarEnTienda", cn)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add("_dscProducto", MySqlDbType.VarChar).Value = dscProducto; cmd.Parameters.Add("_codTienda", MySqlDbType.VarChar).Value = codTienda; using (MySqlDataReader lector = cmd.ExecuteReader()) { List <BE_DetalleProductoTienda> lstDetalleProd = new List <BE_DetalleProductoTienda>(); BE_DetalleProductoTienda objDetalleProducto; while (lector.Read()) { objDetalleProducto = new BE_DetalleProductoTienda(); objDetalleProducto.id = Convert.ToInt64(lector["id"]); objDetalleProducto.dscProducto = Convert.ToString(lector["dscProducto"]); objDetalleProducto.dscTienda = Convert.ToString(lector["dscTienda"]); objDetalleProducto.cntProducto = Convert.ToInt16(lector["cntProducto"]); lstDetalleProd.Add(objDetalleProducto); } return(lstDetalleProd); } } } } catch (Exception ex) { throw ex; } }
public static bool InsertarProductoTienda(BE_DetalleProductoTienda objDetalleProducto) { return(DA_DetalleProductoTienda.InsertarProductoTienda(objDetalleProducto)); }