Esempio n. 1
0
        protected void btn_guardar_ServerClick(object sender, EventArgs e)
        {
            try
            {
                if (FormAccion == "Agregar")
                {
                    WSGestion.WSGestion wsgest = new WSGestion.WSGestion();
                    wsgest.Url = ConfigurationManager.AppSettings.Get("dirWs");
                    WSGestion.MOD_Articulo obj = new WSGestion.MOD_Articulo();

                    obj.ART_descripcion = txt_descripcion.Value;
                    obj.ART_id_centro_atencion = Convert.ToInt32(txt_cea_codigo.Value);
                    obj.ART_id_articulo = Convert.ToInt32(txt_codigo.Value);
                    obj.ART_codigo_barras = txt_codigo_barras.Value;
                    obj.ART_id_categoria_articulo = Convert.ToInt32(dl_categoria_articulo.SelectedValue);
                    obj.ART_id_unidad_medida = Convert.ToInt32(dl_unidad_medida.SelectedValue);
                    obj.ART_tipo = dl_tipo_articulo.SelectedValue;
                    obj.PRE_art_precio = Convert.ToDecimal(txt_precio.Value, CultureInfo.CreateSpecificCulture("en-US"));
                    obj.PRE_art_fecha = txt_fecha.Text;

                    if (wsgest.CRE_Articulo(obj))
                        Response.Redirect("frm_Grid_Articulo.aspx");
                    else
                    {
                        Alert_Mensaje.Attributes["class"] = "alert alert-danger";
                        mensaje_alerta = "En la creación del artículo a nivel de la base de datos ";
                        titulo_mensaje_alerta = "Error: ";
                        Alert_Mensaje.Visible = true;
                    }
                }

                if (FormAccion == "Editar")
                {
                    WSGestion.WSGestion wsgest = new WSGestion.WSGestion();
                    wsgest.Url = ConfigurationManager.AppSettings.Get("dirWs");
                    WSGestion.MOD_Articulo obj = new WSGestion.MOD_Articulo();

                    obj.ART_descripcion = txt_descripcion.Value;
                    obj.ART_id_centro_atencion = Convert.ToInt32(txt_cea_codigo.Value);
                    obj.ART_id_articulo = Convert.ToInt32(txt_codigo.Value);
                    obj.ART_codigo_barras = txt_codigo_barras.Value;
                    obj.ART_id_categoria_articulo = Convert.ToInt32(dl_categoria_articulo.SelectedValue);
                    obj.ART_id_unidad_medida = Convert.ToInt32(dl_unidad_medida.SelectedValue);
                    obj.ART_tipo = dl_tipo_articulo.SelectedValue;
                    obj.PRE_art_precio = Convert.ToDecimal(txt_precio.Value, CultureInfo.CreateSpecificCulture("en-US"));
                    obj.PRE_art_fecha = txt_fecha.Text;
                    wsgest.UPD_Articulo(obj);
                    Response.Redirect("frm_Grid_Articulo.aspx");
                }
            }

            catch (Exception exc)
            {
                Alert_Mensaje.Attributes["class"] = "alert alert-danger";
                mensaje_alerta = exc.ToString();
                titulo_mensaje_alerta = "Error: ";
                Alert_Mensaje.Visible = true;
            }
        }
        protected void btn_buscar_articulo_Click(object sender, EventArgs e)
        {
            if (txt_articulo.Value != "")
            {
                WSGestion.WSGestion wsgest = new WSGestion.WSGestion();
                wsgest.Url = ConfigurationManager.AppSettings.Get("dirWs");

                WSGestion.MOD_Articulo obj = new WSGestion.MOD_Articulo();

                obj = wsgest.SEL_GRID_BY_ID_Articulo(Convert.ToInt32(txt_articulo.Value), centro_seleccionado);

                if ( (obj.ART_id_articulo != 0) && (obj.ART_tipo == "T"))
                {
                    Alert_Mensaje.Visible = false;
                    txt_descripcion.Value = obj.ART_descripcion;
                }
                else
                {
                    txt_descripcion.Value = null;
                    txt_articulo.Value = null;
                    txt_articulo.Attributes.Add("onfocus", "this.select();");
                    txt_articulo.Focus();
                    Alert_Mensaje.Attributes["class"] = "alert alert-danger";
                    if (obj.ART_tipo == "S")
                    {
                        mensaje_alerta = "El artículo digitado es de tipo servicio y este no puede ser agregado a una bodega";
                    }
                    else
                    {
                        mensaje_alerta = "El artículo digitado no se encuentra en la base de datos";
                    }

                    titulo_mensaje_alerta = "Error: ";
                    Alert_Mensaje.Visible = true;
                }
            }
            else
            {
                txt_descripcion.Value = null;
                txt_articulo.Value = null;
                txt_articulo.Attributes.Add("onfocus", "this.select();");
                txt_articulo.Focus();
                Alert_Mensaje.Attributes["class"] = "alert alert-warning";
                mensaje_alerta = "Debe de digitar un dato en el campo artículo";
                titulo_mensaje_alerta = "Advertencia: ";
                Alert_Mensaje.Visible = true;
            }
        }
        private void Editar_Lineas()
        {
            WSGestion.WSGestion wsgest = new WSGestion.WSGestion();
            wsgest.Url = ConfigurationManager.AppSettings.Get("dirWs");
            DataTable dt = new DataTable();
            dt = (DataTable)Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Lineas"];

            try
            {

                WSGestion.MOD_Articulo obj = new WSGestion.MOD_Articulo();

                obj = wsgest.SEL_GRID_BY_ID_Articulo_For_Inventario(buscar, centro_seleccionado, sucursal_seleccionado, bodega_seleccionado);

                if (obj.CEA_nombre != null)
                {
                    WSGestion.MOD_Detalle_Entrada_Inventario obj2 = new WSGestion.MOD_Detalle_Entrada_Inventario();
                    obj2.DET_ent_inv_id_linea = Convert.ToInt32 (txt_linea.Value);
                    obj2.DET_ent_inv_id_entrada_inventario = codigo_seleccionado;
                    obj2.DET_ent_inv_id_centro_atencion = centro_seleccionado;
                    obj2.DET_ent_inv_id_articulo = obj.ART_id_articulo;
                    obj2.DET_ent_inv_cantidad = Convert.ToDouble(txt_cantidad.Value, CultureInfo.CreateSpecificCulture("en-US"));
                    wsgest.UPD_Detalle_Entrada_Inventario(obj2);

                    dt.Rows[Convert.ToInt32(txt_linea.Value) - 1]["Artículo"] = obj.ART_id_articulo.ToString();
                    dt.Rows[Convert.ToInt32(txt_linea.Value) - 1]["Descripción"] = obj.ART_descripcion.ToString();
                    dt.Rows[Convert.ToInt32(txt_linea.Value) - 1]["Cantidad"] = txt_cantidad.Value.ToString(CultureInfo.CreateSpecificCulture("en-US"));
                }
                else
                {
                    Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Error"] = "Artículo digitado no se encuentra en la base de datos";
                }

                gridview_lineas.DataSource = dt;
                gridview_lineas.DataBind();

            }
            catch (Exception exc)
            {
                Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Error"] = exc.ToString();
            }
        }
        private void Carga_Lineas()
        {
            WSGestion.WSGestion wsgest = new WSGestion.WSGestion();
            wsgest.Url = ConfigurationManager.AppSettings.Get("dirWs");
            DataTable dt = new DataTable();
            dt = (DataTable)Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Lineas"];

            try
            {
                WSGestion.MOD_Articulo obj = new WSGestion.MOD_Articulo();

                obj = wsgest.SEL_GRID_BY_ID_Articulo_For_Inventario(buscar, centro_seleccionado, sucursal_seleccionado,bodega_seleccionado);

                if (obj.CEA_nombre != null)
                {
                    WSGestion.MOD_Detalle_Entrada_Inventario obj2 = new WSGestion.MOD_Detalle_Entrada_Inventario();
                    obj2.DET_ent_inv_id_linea = ult_linea;
                    obj2.DET_ent_inv_id_entrada_inventario = codigo_seleccionado;
                    obj2.DET_ent_inv_id_centro_atencion = centro_seleccionado;
                    obj2.DET_ent_inv_id_articulo = obj.ART_id_articulo;
                    obj2.DET_ent_inv_cantidad = Convert.ToDouble(txt_cantidad.Value, CultureInfo.CreateSpecificCulture("en-US"));
                    int valor = wsgest.CRE_Detalle_Entrada_Inventario(obj2);
                    if (valor==1)
                    {
                        dt.Rows.Add(ult_linea, obj.ART_id_articulo, obj.ART_descripcion, Convert.ToDecimal(txt_cantidad.Value));
                        Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"ULT_Linea"] = dt.Rows.Count.ToString();
                    }
                    else
                    {
                        if (valor==2)
                        {
                            foreach (DataRow row in dt.Rows)
                            {

                                    if (row["Artículo"].ToString() == obj.ART_id_articulo.ToString())
                                    {
                                        row["Cantidad"] = (Convert.ToDecimal(row["Cantidad"].ToString()) + Convert.ToDecimal(txt_cantidad.Value)).ToString(CultureInfo.CreateSpecificCulture("en-US"));
                                    }

                            }
                        }
                        else
                        {
                            Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Error"] = "Se produjo un error en la ejecución de la sentencia en la base de datos";
                        }

                    }

                }
                else
                {
                    Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Error"] = "Artículo digitado no se encuentra en la base de datos o bien no pertenece a la bodega del documento";
                }

                gridview_lineas.DataSource = dt;
                gridview_lineas.DataBind();
            }
            catch (Exception exc)
            {
                Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Error"] = "Error: " + exc.ToString();
            }
        }
        private void Editar_Lineas()
        {
            WSGestion.WSGestion wsgest = new WSGestion.WSGestion();
            wsgest.Url = ConfigurationManager.AppSettings.Get("dirWs");
            DataTable dt = new DataTable();
            dt = (DataTable)Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Lineas"];

            try
            {
                wsgest.Url = ConfigurationManager.AppSettings.Get("dirWs");
                WSGestion.MOD_Articulo obj = new WSGestion.MOD_Articulo();

                obj = wsgest.SEL_GRID_BY_ID_Articulo_For_Inventario(buscar, centro_seleccionado, sucursal_seleccionado, bodega_seleccionado);

                if (obj.CEA_nombre != null)
                {
                    dt.Rows[Convert.ToInt32(txt_linea.Value) - 1]["Artículo"] = obj.ART_id_articulo.ToString();
                    dt.Rows[Convert.ToInt32(txt_linea.Value) - 1]["Descripción"] = obj.ART_descripcion.ToString();
                    dt.Rows[Convert.ToInt32(txt_linea.Value) - 1]["Cantidad"] = txt_cant_bodega.Value;
                }
                else
                {
                    Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Error"] = "Error: Artículo digitado no se encuentra en la base de datos";
                }

                gridview_lineas.DataSource = dt;
                gridview_lineas.DataBind();

            }
            catch (Exception exc)
            {
                Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Error"] = "Error: " + exc.ToString();
            }
        }
        private void Carga_Lineas()
        {
            WSGestion.WSGestion wsgest = new WSGestion.WSGestion();
            wsgest.Url = ConfigurationManager.AppSettings.Get("dirWs");
            DataTable dt = new DataTable();
            dt = (DataTable)Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Lineas"];

            try
            {
                wsgest.Url = ConfigurationManager.AppSettings.Get("dirWs");
                WSGestion.MOD_Articulo obj = new WSGestion.MOD_Articulo();

                obj = wsgest.SEL_GRID_BY_ID_Articulo(Convert.ToInt32(buscar), centro_seleccionado);

                if (obj.CEA_nombre != null)
                {
                    WSGestion.MOD_Bodega_Articulo obj2 = new WSGestion.MOD_Bodega_Articulo();
                    obj2.BXA_id_articulo = obj.ART_id_articulo;
                    obj2.BXA_id_bodega = bodega_seleccionado;
                    obj2.BXA_id_centro_atencion = centro_seleccionado;
                    obj2.BXA_id_sucursal = bodega_seleccionado;
                    obj2.BXA_cantidad = 0;

                    if (wsgest.CRE_Bodega_Articulo(obj2))
                    {
                        dt.Rows.Add(ult_linea, obj.ART_id_articulo, obj.ART_descripcion, 0);
                        Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"ULT_Linea"] = dt.Rows.Count.ToString();
                    }
                    else
                    {
                        Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Error"] = "En la asignación del artículo a la bodega";
                    }

                }
                else
                {
                    Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Error"] = "Artículo digitado no se encuentra en la base de datos";
                }

                gridview_lineas.DataSource = dt;
                gridview_lineas.DataBind();
            }
            catch (Exception exc)
            {
                Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Error"] =  exc.ToString();
            }
        }
Esempio n. 7
0
        private void Carga_Editar()
        {
            try
            {
                WSGestion.WSGestion wsgest = new WSGestion.WSGestion();
                wsgest.Url = ConfigurationManager.AppSettings.Get("dirWs");
                WSGestion.MOD_Articulo obj = new WSGestion.MOD_Articulo();
                obj = wsgest.SEL_GRID_BY_ID_Articulo(codigo_seleccionado, centro_seleccionado);
                txt_descripcion.Value = obj.ART_descripcion;
                txt_codigo.Value = obj.ART_id_articulo.ToString();
                txt_codigo_barras.Value = obj.ART_codigo_barras;
                txt_cea_codigo.Value = obj.ART_id_centro_atencion.ToString();
                txt_cea_nombre.Value = obj.CEA_nombre;
                txt_precio.Value = obj.PRE_art_precio.ToString(CultureInfo.CreateSpecificCulture("en-US"));
                txt_fecha.Text = obj.PRE_art_fecha;
                dl_tipo_articulo.SelectedValue = obj.ART_tipo;
                dl_unidad_medida.SelectedValue = obj.ART_id_unidad_medida.ToString();
                dl_categoria_articulo.SelectedValue = obj.ART_id_categoria_articulo.ToString();

                dl_tipo_articulo.Enabled = false;
                txt_codigo.Disabled = true;

            }
            catch (Exception exc)
            {
                WSGestion.WSGestion wsgest = new WSGestion.WSGestion();
                wsgest.Url = ConfigurationManager.AppSettings.Get("dirWs");
                Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Codigo_Select"] = "0";
                Alert_Mensaje.Attributes["class"] = "alert alert-danger";
                mensaje_alerta = exc.ToString();
                titulo_mensaje_alerta = "Error: ";
                Alert_Mensaje.Visible = true;
            }
        }
        private void Carga_Lineas()
        {
            WSGestion.WSGestion wsgest = new WSGestion.WSGestion();
            wsgest.Url = ConfigurationManager.AppSettings.Get("dirWs");
            DataTable dt = new DataTable();
            dt = (DataTable)Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Lineas"];

            try
            {

                WSGestion.MOD_Articulo obj = new WSGestion.MOD_Articulo();

                obj = wsgest.SEL_GRID_BY_ID_Articulo(Convert.ToInt32(buscar), centro);

                if (obj.CEA_nombre != null)
                {
                    dt.Rows.Add(obj.ART_id_articulo, obj.ART_descripcion, Convert.ToInt32(txt_cantidad.Value),obj.PRE_art_precio,(Convert.ToInt32(txt_cantidad.Value)*obj.PRE_art_precio));
                }
                else
                {
                    Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Error"] = "Error: Artículo digitado no se encuentra en la base de datos";
                }

                gridview_lineas.DataSource = dt;
                gridview_lineas.DataBind();
            }
            catch (Exception exc)
            {
                Session[wsgest.Get_usu_id_session(Session.SessionID.ToString())+"Error"] = "Error: " + exc.ToString();
            }
        }