Пример #1
0
 protected void btnAgregar_Click(object sender, EventArgs e)
 {
     try
     {
         lgServicio = new LogicaServicio();
         HttpFileCollection file = Request.Files;
         util = new csUtilidades();
         for (int i = 0; i <= file.Count - 1; i++)
         {
             HttpPostedFile postefile = file[i];
             String[]       nombres   = new String[file.Count - 1];
             if (postefile.ContentLength > 0)
             {
                 int codService = int.Parse(ViewState["codServicio"].ToString());
                 int codNegocio = int.Parse(util.desencriptar(Request.Params["show"].ToString()));
                 postefile.SaveAs(Server.MapPath(@"media\img\") + Path.GetFileName(postefile.FileName));
                 servicio = new csServicio(codService, txtNombre.Text, txtDescripcion.Text, postefile.FileName.ToString(), "", "", int.Parse(txtValor.Text), codNegocio);
                 if (lgServicio.ModificarServicio(servicio))
                 {
                     Button2_ModalPopupExtender.Show();
                 }
                 else
                 {
                     ltError.Text = @"<div class='alert alert-danger'>
                   <strong>Error!</strong> " + "Servicio Modificado" + ".</div>";
                 }
             }
             else
             {
                 int codService = int.Parse(ViewState["codServicio"].ToString());
                 int codNegocio = int.Parse(util.desencriptar(Request.Params["show"].ToString()));
                 servicio = new csServicio(codService, txtNombre.Text, txtDescripcion.Text, "", "", "", int.Parse(txtValor.Text), codNegocio);
                 if (lgServicio.ModificarServicio2(servicio))
                 {
                     Button2_ModalPopupExtender.Show();
                 }
                 else
                 {
                     ltError.Text = @"<div class='alert alert-danger'>
                   <strong>Error!</strong> " + "Servicio Modificado" + ".</div>";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ltError.Text = @"<div class='alert alert-danger'>
                   <strong>Error!</strong> " + ex.Message + ".</div>";
     }
 }