Пример #1
0
        protected void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {

                BllUnicom.Unicom ObjGrabar = new BllUnicom.Unicom();
                if (TxtCodigo.Text != "")
                {
                    ObjGrabar.UnicId =(TxtCodigo.Text);
                    ObjGrabar.Nombre_Unicom = TxtNumMedidor.Text;
                    if (BllUnicom.Exist(TxtCodigo.Text) == 0)
                    {
                        long r = ObjGrabar.Insert();
                        if (r > 0)
                        {
                            Metodos.divMensaje(Constantes.Succes, Constantes.Guardado, PnlMsg, Constantes.Ok);
                            TxtCodigo.Text = r.ToString().PadLeft(5, '0');
                            FillUnicom();
                            updateGrid.Update();
                            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "mostrarDatos();", true);
                        }
                        updateGrid.Update();
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "mostrarDatos();", true);
                    }
                    else
                    {
                      long r = ObjGrabar.Update();
                        if (r > 0)
                        {
                            Metodos.divMensaje(Constantes.Succes, Constantes.Actualizar, PnlMsg, Constantes.Ok);
                            FillUnicom();
                            updateGrid.Update();
                        }
                        updateGrid.Update();
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "mostrarDatos();", true);
                    }

                }

                updateGrid.Update();
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "mostrarGrid();", true);

            }
            catch (Exception ex)
            {
                Metodos.divMensaje(Constantes.Danger, Constantes.errorGeneral, PnlMsg, Constantes.Fallo);
                UpdateNew.Update();
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "mostrarGrid();", true);
            }
        }
Пример #2
0
        protected void BtnSelect_Command(object sender, CommandEventArgs e)
        {
            try
            {
                if (e.CommandName != "Page")
                {
                    BllUnicom.Unicom Row = new BllUnicom.Unicom();
                    List<BllUnicom.Unicom> Rows = new List<BllUnicom.Unicom>();
                    Rows = (List<BllUnicom.Unicom>)Session["ListUnicom"];

                    if (Rows.Exists(b => b.UnicId.ToString() == e.CommandArgument.ToString()))
                    {
                        Row = Rows.Where(b => b.UnicId.ToString() == e.CommandArgument.ToString()).First();
                        TxtCodigo.Enabled = false;
                        TxtCodigo.Text = Row.UnicId.ToString();
                        TxtNumMedidor.Text = Row.Nombre_Unicom;
                        UpdateNew.Update();
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "mostrarDatos();", true);

                    }
                }
            }
            catch (Exception ex)
            {
                Metodos.divMensaje(Constantes.Danger, Constantes.ErrorAlConsultarDatos, PnlMsg, Constantes.Fallo);
                UpdateNew.Update();
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "mostrarGrid();", true);
            }
        }