public static List <GRUPOS> GRUPOS_POR_UNIDAD(string u_negocio) { DataTable dt = new DataTable(); string where = ""; if (u_negocio == "") { u_negocio = "-5"; } bool es_vendedor_2_session = (bool)HttpContext.Current.Session["bool_es_vendedor_2"]; if (!es_vendedor_2_session) { where = " where cod_unineg in (" + u_negocio + ") "; } else { where = " where cod_unineg in (" + HttpContext.Current.Session["unidad_"].ToString() + ") and cod_grupo = '" + HttpContext.Current.Session["grupo_"].ToString() + "'"; } try { dt = ReporteRNegocio.carga_grupo_unidad(where); ////dt.Rows.Add(new Object[] { "-1", "-- Todos --" }); DataView dv = dt.DefaultView; dv.Sort = "cod_app"; dt = dv.ToTable(); } catch { } var query = from item in dt.AsEnumerable() where 1 == 1 select new GRUPOS { COD_GRUPO = Convert.ToString(item["COD_GRUPO"]), }; return(query.ToList <GRUPOS>()); }
protected void G_usuarios_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "delete_") { usuarioEntity us = new usuarioEntity(); us.cod_usuario = G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[0].ToString(); string es_adm = usuarioBO.obtener_adm(us.cod_usuario); if (es_adm != "True") { if (usuarioBO.eliminar(us) == "OK") { h3_.InnerText = "Usuario Eliminado."; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "teeee", "<script language='javascript'>delete_adm();</script>", false); } cargar_usuarios(); } else { h3_.InnerText = "No puede eliminar un usuario Administrador."; } txt_clave.Text = ""; txt_cod_usuario.Text = ""; t_correo.Text = ""; r_enviar_correo.Checked = false; ScriptManager.RegisterStartupScript(Page, this.GetType(), "teeee", "<script language='javascript'>vaciar_editar();</script>", false); } if (e.CommandName == "Editar") { txt_cod_usuario.Enabled = false; //chk_adm.Attributes["AutoPostBack"] = "True"; h3_.InnerText = "Editar Usuario"; Session["SW_CLICK"] = "EDITAR"; USUARIOS.ActiveViewIndex = 1; //COD_USUARIO = G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[0].ToString(); Session["COD_USUARIO"] = G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[0].ToString(); l_grupos.Text = G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[4].ToString(); l_unidad_negocio.Text = G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[9].ToString(); l_pantallas.Text = G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[11].ToString(); t_correo.Text = G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[6].ToString(); t_cc.Text = G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[8].ToString(); txt_cod_usuario.Text = G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[0].ToString(); t_nombre_us.Text = G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[12].ToString(); txt_clave.Text = ""; l_grupos.Text = G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[4].ToString(); if (G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[2].ToString() == "True") { r_activo.Checked = true; } else { r_activo.Checked = false; } if (G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[5].ToString() == "True") { r_enviar_correo.Checked = true; } else { r_enviar_correo.Checked = false; } if (G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[7].ToString() == "True") { r_enviar_2.Checked = true; } else { r_enviar_2.Checked = false; } if (G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[10].ToString() == "1") { //es_vendedor_2 = false; Session["bool_es_vendedor_2"] = false; chk_adm.Checked = true; chk_vend.Checked = false; chk_otro.Checked = false; DIV2_3.Attributes["style"] = "display:none;"; DIV222.Attributes["style"] = "margin-right: 0px; margin-left: 0px; display:none;"; DIV555.Attributes["style"] = "display:block;"; } else if (G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[10].ToString() == "2") { //es_vendedor_2 = true; Session["bool_es_vendedor_2"] = true; //unidad_ = ReporteRNegocio.trae_u_negocio(txt_cod_usuario.Text.Trim()); Session["unidad_"] = ReporteRNegocio.trae_u_negocio(txt_cod_usuario.Text.Trim()); string negocio_aux = l_unidad_negocio.Text; DIV555.Attributes["style"] = "display:none;"; chk_adm.Checked = false; chk_vend.Checked = true; chk_otro.Checked = false; string grupo = ReporteRNegocio.grupos_usuario_v_report(txt_cod_usuario.Text).Trim(); Session["grupo_"] = grupo; if (grupo.Contains("Abarrotes") || grupo.Contains("Granos")) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "teeee", "<script language='javascript'>muestra_check();</script>", false); } cargar_unidad_negocio_vend(grupo); l_unidad_negocio.Text = negocio_aux; cargar_grupo_vend(grupo); cargar_pantallas_vend(grupo); DIV222.Attributes["style"] = "display:block;"; DIV2_3.Attributes["style"] = "margin-right: 0px; margin-left: 0px; display:block;"; string cod_un = ""; if (G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[9].ToString() == "") { cod_un = ReporteRNegocio.cod_unineg(grupo); } else { cod_un = G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[9].ToString(); } string where = " where cod_unineg in (" + cod_un + ") "; DataTable app = ReporteRNegocio.carga_app_unidad(where); cargar_app_uni(app); foreach (ListItem item in d_unidade_negocio.Items) { List <string> app2 = G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[9].ToString().Split(',').ToList(); foreach (string x in app2) { if (x.Trim() == item.Value.Trim()) { item.Selected = true; } } } foreach (ListItem item in d_pantallas.Items) { List <string> app2 = G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[11].ToString().Split(',').ToList(); foreach (string x in app2) { if (x.Trim() == item.Value.Trim()) { item.Selected = true; } } } } else { //es_vendedor_2 = false; Session["bool_es_vendedor_2"] = false; chk_adm.Checked = false; chk_vend.Checked = false; chk_otro.Checked = true; string grupo = ReporteRNegocio.grupos_usuario(txt_cod_usuario.Text).Trim(); string u_negoc = ReporteRNegocio.negocio_usuario(txt_cod_usuario.Text).Trim(); if (u_negoc == "" && grupo != "") { u_negoc = ReporteRNegocio.negocio_usuario_por_grupos(agregra_comillas(grupo)); } if (grupo.Contains("Abarrotes") || grupo.Contains("Granos")) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "teeee", "<script language='javascript'>muestra_check();</script>", false); } DIV2_3.Attributes["style"] = "margin-right: 0px; margin-left: 0px; display:block;"; DIV222.Attributes["style"] = "margin-right: 0px; margin-left: 0px; display:block;"; DIV555.Attributes["style"] = "display:block;"; cargar_unidad_negocio(); foreach (ListItem item in d_unidade_negocio.Items) { List <string> app2 = u_negoc.Split(',').ToList(); foreach (string x in app2) { if (x.Trim() == item.Value.Trim()) { item.Selected = true; } } } l_unidad_negocio.Text = u_negoc; string where = " where cod_unineg in (" + l_unidad_negocio.Text + ") "; if (grupo == "") { grupo = "-1"; } else { DataTable grupos = ReporteRNegocio.carga_grupo_unidad(" where cod_grupo in (" + agregra_comillas(grupo) + ")"); cargar_grupo_uni(grupos); foreach (ListItem item in d_grupos.Items) { if (G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[4].ToString().Contains(item.ToString())) { item.Selected = true; } } } if (u_negoc == "") { where = " where 1=2 "; } DataTable app = ReporteRNegocio.carga_app_unidad(where); cargar_app_uni(app); foreach (ListItem item in d_pantallas.Items) { List <string> app2 = G_usuarios.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[11].ToString().Split(',').ToList(); foreach (string x in app2) { if (x.Trim() == item.Value.Trim()) { item.Selected = true; } } } } } }