Пример #1
0
 public void InsertOrUpdate(OSModel OS)
 {
     try
     {
         bd.Entry(OS).State = OS.Id == 0 ? EntityState.Added : EntityState.Modified;
         bd.SaveChanges();
     }
     catch (Exception)
     {
         throw new Exception("Error ao cadastrar um OS!");
     }
 }
Пример #2
0
 public void FormCadastro_InsertItem()
 {
     var db = new OSCrud();
     var item2 = new OSModel();
     var usuario = Context.User.Identity.Name;
     TryUpdateModel(item2);
     if (ModelState.IsValid)
     {
         db.InsertOrUpdate(item2);
         gridDados.DataBind();
     }
 }
Пример #3
0
        protected void btnSalvar_Click(object sender, EventArgs e)
        {
            var OS = new OSCrud();
            var objOS = new OSModel();

            objOS.Id = Convert.ToInt32(hdn.Value);
            objOS.servico = txtServicoModal.Text;
            objOS.problema = txtProblemaModal.Text;

            OS.InsertOrUpdate(objOS);

            gridDados.DataBind();
        }
Пример #4
0
        protected void gridDados_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            var os = new OSCrud();
            var objeOS = new OSModel();
            var id = Convert.ToInt32(e.CommandArgument);
            hdn.Value = id.ToString();

            switch (e.CommandName)
            {
                case "Excluir":
                    os.Delete(id);
                    gridDados.DataBind();
                    break;

                case "Editar":

                    CarregarModal(id);
                    //ModalUpdate.Show();
                    break;

                default:
                    break;
            }
        }