示例#1
0
        protected void BtnSalvar_Click(object sender, EventArgs e)
        {
            Model.Modulo modulo = getData();
            var          db     = new ModuloDB();

            if ((IdH.Value == "0") || (IdH.Value == ""))
            {
                if (db.Insert(modulo))
                {
                    LblMsg.Text = "Registro inserido!";
                    LoadGrid();
                }
                else
                {
                    LblMsg.Text = "Erro ao inserir registro";
                }
            }
            else
            {
                if (db.Update(modulo, int.Parse(IdH.Value)))
                {
                    LblMsg.Text = "Registro atualizado!";
                }
                else
                {
                    LblMsg.Text = "Erro ao atualizar registro";
                }
            }

            LoadGrid();
        }
示例#2
0
        protected void GVModulo_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int         index = Convert.ToInt32(e.CommandArgument);
            GridViewRow row   = GVModulo.Rows[index];

            int id = Convert.ToInt32(row.Cells[0].Text);

            var db = new ModuloDB();

            if (e.CommandName == "Excluir")
            {
                db.Delete(id);
                LoadGrid();
            }
            else if (e.CommandName == "Editar")
            {
                Model.Modulo modulo = db.SelectById(id);

                DdlAmbiente.Text = modulo.Ambiente;
                DdlSquad.Text    = modulo.Squad.ToString();
                IdH.Value        = modulo.Id.ToString();
            }
        }