예제 #1
0
        public SCE_GRUPOTDA_BE ObtenerPorID(int Id)
        {
            SCE_GRUPOTDA_BE BE = null;

            try
            {
                using (SqlConnection cn = new SqlConnection(SCE_SQLCONEXION.GetCadConexion(usrLogin)))
                {
                    cn.Open();

                    string sql = "SP_SCE_GRUPOTDA_GET";

                    using (SqlCommand cmd = new SqlCommand(sql, cn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;

                        cmd.Parameters.AddWithValue("@ID_GRUPO", Id);

                        SqlDataReader reader = cmd.ExecuteReader();

                        if (reader.Read())
                        {
                            BE = new SCE_GRUPOTDA_BE();

                            BE.ID_GRUPO  = Convert.ToInt32(reader["ID_GRUPO"]);
                            BE.NOM_GRUPO = Convert.ToString(reader["NOM_GRUPO"]);

                            /* LLENA LA LISTA DE TIENDAS DEL GRUPO */
                            List <SCE_GRUPOTDA_TIENDA_BE> lstTIENDAS = new List <SCE_GRUPOTDA_TIENDA_BE>();

                            SqlDataReader drTIENDAS = null;
                            drTIENDAS = getTiendas(Id);

                            while (drTIENDAS.Read())
                            {
                                SCE_GRUPOTDA_TIENDA_BE TIENDA = new SCE_GRUPOTDA_TIENDA_BE();
                                TIENDA.ID_GRUPO   = drTIENDAS.GetInt32(0);
                                TIENDA.ID_TIENDA  = drTIENDAS.GetInt32(1);
                                TIENDA.NOM_TIENDA = drTIENDAS.GetString(2);
                                lstTIENDAS.Add(TIENDA);
                            }

                            BE.TIENDAS = lstTIENDAS;
                        }

                        return(BE);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    protected void btnGuardarGrupo_Click(object sender, EventArgs e)
    {
        string strMsg = "";
        List <SCE_GRUPOTDA_TIENDA_BE> lstTiendas = new List <SCE_GRUPOTDA_TIENDA_BE>();

        if (hidId.Value == "")
        {
            strMsg = GRUPOTDA_BL.IsValid(0, txtDescripcion.Text.Trim().ToUpper(), (bool)Session["operacion"]);

            if (strMsg.Length > 0)
            {
                Util.RegisterAsyncAlert(upnlGrupTdas, "__Alerta__", strMsg);
                return;
            }

            for (int iN = 0; iN < ((DataTable)Session["dtTiendas"]).Rows.Count; iN++)
            {
                GRUPOTDA_TIENDA_BE = new SCE_GRUPOTDA_TIENDA_BE();

                GRUPOTDA_TIENDA_BE.ID_TIENDA = Convert.ToInt32(((DataTable)Session["dtTiendas"]).Rows[iN][0].ToString());
                lstTiendas.Add(GRUPOTDA_TIENDA_BE);
            }

            GRUPOTDA_BL.Insertar(txtDescripcion.Text.Trim().ToUpper(), lstTiendas);

            //Util.RegisterAsyncAlert(upnlGrupTdas, "__Alerta__", Resources.Mensajes.msgGrupoTiendaAlertEjecución);
        }
        else
        {
            strMsg = GRUPOTDA_BL.IsValid(Convert.ToInt32(hidId.Value), txtDescripcion.Text.Trim().ToUpper(), (bool)Session["operacion"]);

            if (strMsg.Length > 0)
            {
                Util.RegisterAsyncAlert(upnlGrupTdas, "__Alerta__", strMsg);
                return;
            }

            for (int iE = 0; iE < ((DataTable)Session["dtTiendas"]).Rows.Count; iE++)
            {
                GRUPOTDA_TIENDA_BE = new SCE_GRUPOTDA_TIENDA_BE();

                GRUPOTDA_TIENDA_BE.ID_TIENDA = Convert.ToInt32(((DataTable)Session["dtTiendas"]).Rows[iE][0].ToString());
                lstTiendas.Add(GRUPOTDA_TIENDA_BE);
            }

            GRUPOTDA_BL.Actualizar(Convert.ToInt32(hidId.Value), txtDescripcion.Text.Trim().ToUpper(), lstTiendas);

            //Util.RegisterAsyncAlert(upnlGrupTdas, "__Alerta__", Resources.Mensajes.msgGrupoTiendaAlertModificacion);
        }

        Limpiar();
        LoadData();
        pnlDetalleGrupo.Visible = false;
    }