Пример #1
0
        public ActionResult addCompany(ResponseAdminCompanyList item1, RequestAdminCompany item2,
                                       ResponseAdminCompanyDetail item3, ResponseAdminCompany item4)
        {
            // Método para agregar opciones de catálogo
            if (ModelState.IsValid)
            {
                LogicAdminCompany adm = new LogicAdminCompany();

                item2.stateRecord  = true;
                item2.flag         = 'N';
                item2.dateRegister = DateTime.Now;
                item2.userRegister = Session["user"].ToString();
                item2.dateUpdate   = DateTime.Now;
                item2.userUpdate   = Session["user"].ToString();
                item4 = adm.setCompany(item2);

                if (item4.code == 50000)
                {
                    Session.Add("msgOk", item4.message);
                }
                else
                {
                    Session.Add("msgEr", item4.message);
                }
            }

            Tuple <ResponseAdminCompanyList, RequestAdminCompany, ResponseAdminCompanyDetail, ResponseAdminCompany> response =
                new Tuple <ResponseAdminCompanyList, RequestAdminCompany, ResponseAdminCompanyDetail, ResponseAdminCompany>(item1, item2, item3, item4);

            return(RedirectToAction("Company"));
        }
Пример #2
0
        public ResponseAdminCompanyList getAdminCompanyList(RequestAdminCompany request)
        {
            try
            {
                DataTable                  dt  = new DataTable();
                DataAdminCompany           dat = new DataAdminCompany();
                ResponseAdminCompanyDetail admin;
                ResponseAdminCompanyList   response = new ResponseAdminCompanyList();

                dt = dat.getAdminCompany(request);

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        response.code    = 1;
                        response.message = "Se encontraron registros";
                        response.status  = 1;
                        response.lst     = new List <ResponseAdminCompanyDetail>();

                        foreach (DataRow dr in dt.Rows)
                        {
                            admin = new ResponseAdminCompanyDetail();

                            admin.id           = int.Parse(dr["id"].ToString());
                            admin.name         = dr["name"].ToString();
                            admin.city         = dr["city"].ToString();
                            admin.address      = dr["address"].ToString();
                            admin.stateRecord  = bool.Parse(dr["stateRecord"].ToString());
                            admin.userRegister = dr["userRegister"].ToString();
                            admin.dateRegister = DateTime.Parse(dr["dateRegister"].ToString());
                            admin.userUpdate   = dr["userUpdate"].ToString();
                            admin.dateUpdate   = DateTime.Parse(dr["dateUpdate"].ToString());

                            response.lst.Add(admin);
                        }
                    }
                    else
                    {
                        response.code    = 0;
                        response.message = "No se encontraron registros";
                        response.status  = 0;
                    }
                }
                else
                {
                    response.code    = 0;
                    response.message = "No se encontraron registros";
                    response.status  = 0;
                }

                return(response);
            }
            catch (System.Data.SqlClient.SqlException exSql)
            {
                // Cuando sea una excepción por SQL ya vendrá el mensaje de error controlado
                throw exSql;
            }
            catch (Exception ex)
            {
                // Registrar el error real
                DataLogError datError = new DataLogError();
                LogError     error    = new LogError();

                error.module       = "ADMIN";
                error.method       = "getAdminCompanyList";
                error.errorMessage = ex.Message;
                error.moreInfo     = request.id.ToString();

                datError.newError(error);

                // Modificar la excepción
                Exception exResult = new Exception("Error no controlado, favor consultar con el administrador del sistema.");
                throw exResult;
            }
        }