Example #1
0
        public ActionResult Edit(int id, [Bind(Include = "prod_Id,prod_Codigo,prod_CodigoBarras,prod_Descripcion,prod_Marca,prod_Modelo,prod_Talla,prod_Color,pscat_Id,uni_Id,prov_Id,prod_EsActivo,prod_RazonInactivacion,prod_UsuarioCrea,prod_FechaCrea,prod_UsuarioModifica,prod_FechaModifica, pcat_Id")] tbProducto tbProducto, string pcat_Id)
        {
            string UserName = "";

            try
            {
                int EmployeeID = Function.GetUser(out UserName);
                if (ModelState.IsValid)
                {
                    IEnumerable <Object> List = null;
                    string Msj = "";
                    List = db.UDP_Inv_tbProducto_Update(tbProducto.prod_Id,
                                                        tbProducto.prod_CodigoBarras,
                                                        tbProducto.prod_Descripcion.ToUpper(),
                                                        tbProducto.prod_Marca.ToUpper(),
                                                        tbProducto.prod_Modelo.ToUpper(),
                                                        tbProducto.prod_Talla.ToUpper(),
                                                        tbProducto.prod_Color.ToUpper(),
                                                        tbProducto.pscat_Id,
                                                        tbProducto.uni_Id,
                                                        tbProducto.prov_Id,
                                                        GeneralFunctions.Activo,
                                                        tbProducto.prod_RazonInactivacion,
                                                        EmployeeID,
                                                        Function.DatetimeNow()
                                                        );
                    foreach (UDP_Inv_tbProducto_Update_Result producto in List)
                    {
                        Msj = producto.MensajeError;
                    }
                    if (Msj.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("Producto", "EditPost", UserName, Msj);
                        ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                        ViewBag.uni_Id   = new SelectList(db.tbUnidadMedida, "uni_Id", "uni_Descripcion", tbProducto.uni_Id);
                        ViewBag.pscat_Id = new SelectList(db.tbProductoSubcategoria, "pscat_Id", "pscat_Descripcion", tbProducto.pscat_Id);
                        ViewBag.prov_Id  = new SelectList(db.tbProveedor, "prov_Id", "prov_Nombre", tbProducto.prov_Id);
                        ViewBag.pcat_Id  = new SelectList(db.tbProductoCategoria, "pcat_Id", "pcat_Descripcion");
                        return(View(tbProducto));
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
                ViewBag.uni_Id   = new SelectList(db.tbUnidadMedida, "uni_Id", "uni_Descripcion", tbProducto.uni_Id);
                ViewBag.pscat_Id = new SelectList(db.tbProductoSubcategoria, "pscat_Id", "pscat_Descripcion", tbProducto.pscat_Id);
                ViewBag.prov_Id  = new SelectList(db.tbProveedor, "prov_Id", "prov_Nombre", tbProducto.prov_Id);
                ViewBag.pcat_Id  = new SelectList(db.tbProductoCategoria, "pcat_Id", "pcat_Descripcion");
                return(View(tbProducto));
            }
            catch (Exception Ex)
            {
                Function.BitacoraErrores("Producto", "EditPost", UserName, Ex.Message.ToString());
                ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                return(View(tbProducto));
            }
        }
        public ActionResult Create([Bind(Include = "Lianvide_Id,Lianvi_Id,Lianvide_FechaGasto,tpv_Id,Lianvide_MontoGasto,Lianvide_Concepto,Lianvide_UsuarioCrea,Lianvide_FechaCrea,Lianvide_UsuarioModifica,Lianvide_FechaModifica")] tbLiquidacionAnticipoViaticoDetalle tbLiquidacionAnticipoViaticoDetalle, HttpPostedFileBase ArchivoPath)
        {
            {
                IEnumerable <object> Detalle = null;
                string UserName     = "";
                string MsjError     = "";
                var    listaDetalle = (List <tbLiquidacionAnticipoViaticoDetalle>)Session["NombreLiquidaciondetalle"];

                try
                {
                    if (ModelState.IsValid)
                    {
                        ViewBag.Lianvi_Id = new SelectList(db.tbLiquidacionAnticipoViatico, "Lianvi_Id", "Lianvi_Correlativo");
                        ViewBag.tpv_Id    = new SelectList(db.tbTipoViatico, "tpv_Id", "tpv_Descripcion");
                        int EmployeeID = Function.GetUser(out UserName);
                        Detalle = db.UDP_Adm_tbLiquidacionAnticipoViaticoDetalle_Insert(tbLiquidacionAnticipoViaticoDetalle.Lianvide_Id,
                                                                                        tbLiquidacionAnticipoViaticoDetalle.Lianvi_Id,
                                                                                        tbLiquidacionAnticipoViaticoDetalle.Lianvide_FechaGasto,
                                                                                        tbLiquidacionAnticipoViaticoDetalle.tpv_Id,
                                                                                        tbLiquidacionAnticipoViaticoDetalle.Lianvide_MontoGasto,
                                                                                        tbLiquidacionAnticipoViaticoDetalle.Lianvide_Concepto
                                                                                        , "hols", EmployeeID, Function.DatetimeNow());

                        foreach (UDP_Adm_tbLiquidacionAnticipoViaticoDetalle_Insert_Result categoria in Detalle)
                        {
                            MsjError = categoria.MensajeError;
                        }
                        if (MsjError.StartsWith("-1"))
                        {
                            ViewBag.Lianvi_Id = new SelectList(db.tbLiquidacionAnticipoViatico, "Lianvi_Id", "Lianvi_Correlativo");
                            ViewBag.tpv_Id    = new SelectList(db.tbTipoViatico, "tpv_Id", "tpv_Descripcion");
                            Function.BitacoraErrores("LiquidacionAnticipoViatico", "CreatePost", UserName, MsjError);
                            ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                            return(View(tbLiquidacionAnticipoViaticoDetalle));
                        }

                        else
                        {
                            ViewBag.Lianvi_Id        = new SelectList(db.tbLiquidacionAnticipoViatico, "Lianvi_Id", "Lianvi_Correlativo");
                            ViewBag.tpv_Id           = new SelectList(db.tbTipoViatico, "tpv_Id", "tpv_Descripcion");
                            TempData["swalfunction"] = "true";

                            return(View(tbLiquidacionAnticipoViaticoDetalle));
                        }
                    }
                }

                catch (Exception Ex)
                {
                    ViewBag.Lianvi_Id = new SelectList(db.tbLiquidacionAnticipoViatico, "Lianvi_Id", "Lianvi_Correlativo");
                    ViewBag.tpv_Id    = new SelectList(db.tbTipoViatico, "tpv_Id", "tpv_Descripcion");
                    Function.BitacoraErrores("LiquidacionAnticipoViatico", "CreatePost", UserName, Ex.Message.ToString());
                }
            }
            return(View(tbLiquidacionAnticipoViaticoDetalle));
        }
Example #3
0
        public ActionResult Create([Bind(Include = "insf_Id,insf_Nombre,insf_Contacto,insf_Telefono,insf_Correo,insf_Activo,insf_UsuarioCrea,insf_FechaCrea,insf_UsuarioModifica,insf_FechaModifica")] tbInstitucionFinanciera tbInstitucionFinanciera)
        {
            string UserName = "";

            try
            {
                int EmployeeID = Function.GetUser(out UserName);
                if (ModelState.IsValid)
                {
                    IEnumerable <Object> List = null;
                    string Msj = "";
                    List = db.UDP_Plani_tbInstitucionFinanciera_Insert(tbInstitucionFinanciera.insf_Id, tbInstitucionFinanciera.insf_Nombre,
                                                                       tbInstitucionFinanciera.insf_Contacto,
                                                                       tbInstitucionFinanciera.insf_Telefono,
                                                                       tbInstitucionFinanciera.insf_Correo,
                                                                       EmployeeID,
                                                                       Function.DatetimeNow(),
                                                                       GeneralFunctions.Activo
                                                                       );
                    foreach (UDP_Plani_tbInstitucionFinanciera_Insert_Result TipoSangre in List)
                    {
                        Msj = TipoSangre.MensajeError;
                    }
                    if (Msj.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("InstitucionFinanciera", "CreatePost", UserName, Msj);
                        return(View(tbInstitucionFinanciera));
                    }
                    if (Msj.StartsWith("-2"))
                    {
                        ModelState.AddModelError("", "Ya existe una Institución con el mismo nombre.");
                        return(View());
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception Ex)
            {
                Function.BitacoraErrores("InstitucionFinanciera", "CreatePost", UserName, Ex.Message.ToString());

                return(View());
            }
            return(View());
        }
Example #4
0
        public ActionResult Create([Bind(Include = "tps_Id,tps_Descripcion,tps_UsuarioCrea,tps_FechaCrea,tps_UsuarioModifica,tps_FechaModifica")] tbTipoSangre tbTipoSangre)
        {
            string UserName = "";

            try
            {
                int EmployeeID = Function.GetUser(out UserName);
                if (ModelState.IsValid)
                {
                    IEnumerable <Object> List = null;
                    string Msj = "";
                    List = db.UDP_Gral_tbTipoSangre_Insert(tbTipoSangre.tps_Descripcion, EmployeeID, Function.DatetimeNow());
                    foreach (UDP_Gral_tbTipoSangre_Insert_Result TipoSangre in List)
                    {
                        Msj = TipoSangre.MensajeError;
                    }
                    if (Msj.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("TipoSangre", "CreatePost", UserName, Msj);
                        ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                        return(View());
                    }
                    if (Msj.StartsWith("-2"))
                    {
                        ModelState.AddModelError("", "Ya existe un Tipo de sangre con el mismo nombre.");
                        return(View());
                    }
                    else
                    {
                        TempData["swalfunction"] = "true";
                        return(RedirectToAction("Index"));
                    }
                }
                return(View(tbTipoSangre));
            }
            catch (Exception Ex)
            {
                Function.BitacoraErrores("TipoSangre", "CreatePost", UserName, Ex.Message.ToString());
                ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                return(View());
            }



            return(View(tbTipoSangre));
        }
Example #5
0
        public ActionResult Edit([Bind(Include = "tptran_Id,tptran_Descripcion,tptran_UsuarioCrea,tptran_FechaCrea,tptran_UsuarioModifica,tptran_FechaModifica")] tbTipoTransporte tbTipoTransporte)
        {
            string UserName = "";

            try
            {
                int EmployeeID = Function.GetUser(out UserName);

                if (ModelState.IsValid)
                {
                    if (db.tbTipoTransporte.Any(a => a.tptran_Descripcion == tbTipoTransporte.tptran_Descripcion && a.tptran_Id != tbTipoTransporte.tptran_Id))
                    {
                        ModelState.AddModelError("", "Ya existe un Tipo de Transporte con el mismo nombre.");
                        return(View(tbTipoTransporte));
                    }

                    IEnumerable <Object> List = null;
                    string Msj = "";
                    List = db.UDP_Gral_tbTipoTransporte_Update(tbTipoTransporte.tptran_Id, tbTipoTransporte.tptran_Descripcion, EmployeeID, Function.DatetimeNow());
                    foreach (UDP_Gral_tbTipoTransporte_Update_Result trans in List)
                    {
                        Msj = trans.MensajeError;
                    }
                    if (Msj.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("TipoTransporte", "EditPost", UserName, Msj);
                        ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                        return(View());
                    }

                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
                return(View(tbTipoTransporte));
            }

            catch (Exception Ex)
            {
                Function.BitacoraErrores("TipoTransporte", "EditPost", UserName, Ex.Message.ToString());
                ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                return(View());
            }
        }
        public ActionResult Create([Bind(Include = "pto_Id,are_Id,pto_Descripcion,pto_UsuarioCrea,pto_FechaCrea,pto_UsuarioModifica,pto_FechaModifica")] tbPuesto tbPuesto)
        {
            string UserName = "";

            ViewBag.are_Id = new SelectList(db.tbArea, "are_Id", "are_Descripcion", tbPuesto.are_Id);
            try
            {
                int EmployeeID = Function.GetUser(out UserName);
                if (ModelState.IsValid)
                {
                    IEnumerable <Object> List = null;
                    string ErrorMessage       = "";
                    List = db.UDP_Gral_tbPuesto_Insert(tbPuesto.are_Id, tbPuesto.pto_Descripcion, EmployeeID, Function.DatetimeNow());
                    foreach (UDP_Gral_tbPuesto_Insert_Result Puesto in List)
                    {
                        ErrorMessage = Puesto.MensajeError;
                    }
                    if (ErrorMessage.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("Cargos", "CreatePost", UserName, ErrorMessage);
                        ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                        return(View());
                    }
                    if (ErrorMessage.StartsWith("-2"))
                    {
                        ModelState.AddModelError("", "Este cargo ya éxiste para esta área.");
                        return(View());
                    }
                    else
                    {
                        TempData["swalfunction"] = "true";

                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception Ex)
            {
                Function.BitacoraErrores("Cargos", "CreatePost", UserName, Ex.Message.ToString());
                ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                return(View());
            }

            return(View(tbPuesto));
        }
Example #7
0
        public ActionResult Create([Bind(Include = "are_Id,are_Descripcion,are_UsuarioCrea")] tbArea tbArea)
        {
            string UserName = "";

            try
            {
                int EmployeeID = Function.GetUser(out UserName);
                if (ModelState.IsValid)
                {
                    IEnumerable <object> _List = null;
                    string ErrorMessage        = "";
                    _List = db.UDP_Gral_tbArea_Insert(tbArea.are_Descripcion, EmployeeID, Function.DatetimeNow());
                    foreach (UDP_Gral_tbArea_Insert_Result Area in _List)
                    {
                        ErrorMessage = Area.MensajeError;
                    }
                    if (ErrorMessage.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("Area", "CreatePost", UserName, ErrorMessage);
                        ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                        return(View(tbArea));
                    }
                    if (ErrorMessage.StartsWith("-2"))
                    {
                        ModelState.AddModelError("", "Ya existe un Área con el mismo nombre.");
                        return(View(tbArea));
                    }
                    else
                    {
                        TempData["swalfunction"] = "true";

                        return(RedirectToAction("Index"));
                    }
                }
                return(View(tbArea));
            }
            catch (Exception Ex)
            {
                Function.BitacoraErrores("Area", "CreatePost", UserName, Ex.Message.ToString());
                ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                return(View(tbArea));
            }
        }
        public ActionResult Create([Bind(Include = "tipmo_id,tipmo_Movimiento")] tbTipoMovimiento tbTipoMovimiento)
        {
            string UserName = "";

            try
            {
                int EmployeeID = Function.GetUser(out UserName);
                if (ModelState.IsValid)
                {
                    if (isDuplicated(tbTipoMovimiento))
                    {
                        ModelState.AddModelError("", "Este tipo de movimiento ya esta registrado.");
                        return(View(tbTipoMovimiento));
                    }

                    IEnumerable <Object> List = null;
                    string Msj = "";
                    List = db.UDP_Gral_tbTipoMovimiento_Insert(tbTipoMovimiento.tipmo_Movimiento, EmployeeID, Function.DatetimeNow());
                    foreach (UDP_Gral_tbTipoMovimiento_Insert_Result tbMovimiento in List)
                    {
                        Msj = tbMovimiento.MensajeError;
                    }
                    if (Msj.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("TipoMovimiento", "CreatePost", UserName, Msj);
                        ModelState.AddModelError("Codigo Error" + Msj, "No se pudo insertar el registro, favor contacte al administrador.");
                        return(View());
                    }
                    else
                    {
                        TempData["swalfunction"] = GeneralFunctions._isCreated;
                        return(RedirectToAction("Index"));
                    }
                }
                return(View(tbTipoMovimiento));
            }
            catch (Exception Ex)
            {
                Function.BitacoraErrores("TipoMovimiento", "CreatePost", UserName, Ex.Message.ToString());
                ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                return(View());
            }
        }
Example #9
0
        public ActionResult Create([Bind(Include = "acte_Id,acte_Descripcion,acte_UsuarioCrea,acte_FechaCrea,acte_UsuarioModifica,acte_FechaModifica")] tbActividadEconomica tbActividadEconomica)
        {
            string UserName = "";

            try
            {
                int EmployeeID = Function.GetUser(out UserName);
                if (ModelState.IsValid)
                {
                    IEnumerable <Object> List = null;
                    string ErrorMessage       = "";
                    tbActividadEconomica.acte_UsuarioCrea = EmployeeID;
                    List = db.UDP_Gral_tbActividadEconomica_Insert(tbActividadEconomica.acte_Descripcion, EmployeeID, Function.DatetimeNow());
                    foreach (UDP_Gral_tbActividadEconomica_Insert_Result acti in List)
                    {
                        ErrorMessage = acti.MensajeError;
                    }
                    if (ErrorMessage.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("ActividadEconomica", "CreatePost", UserName, ErrorMessage);
                        ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                        return(View(tbActividadEconomica));
                    }
                    if (ErrorMessage.StartsWith("-2"))
                    {
                        ModelState.AddModelError("", "Ya existe una Actividad Ecónomica con el mismo nombre.");
                        return(View(tbActividadEconomica));
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception Ex)
            {
                Function.BitacoraErrores("ActividadEconomica", "CreatePost", UserName, Ex.Message.ToString());
                ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                return(View(tbActividadEconomica));
            }
            return(View(tbActividadEconomica));
        }
        public ActionResult Create([Bind(Include = "tmo_Id,tmo_Abreviatura,tmo_Nombre")] tbMoneda tbMoneda)
        {
            string UserName = "";

            try
            {
                int EmployeeID = Function.GetUser(out UserName);
                if (ModelState.IsValid)
                {
                    IEnumerable <Object> List = null;
                    string Msj = "";
                    List = db.UDP_Gral_tbMoneda_Insert(tbMoneda.tmo_Id, tbMoneda.tmo_Abreviatura, tbMoneda.tmo_Nombre, EmployeeID, Function.DatetimeNow());
                    foreach (UDP_Gral_tbMoneda_Insert_Result Moneda in List)
                    {
                        Msj = Moneda.MensajeError;
                    }
                    if (Msj.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("Moneda", "CreatePost", UserName, Msj);
                        ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                        return(View(tbMoneda));
                    }
                    if (Msj.StartsWith("-2"))
                    {
                        ModelState.AddModelError("", "Ya existe una Moneda con el mismo nombre.");
                        return(View(tbMoneda));
                    }
                    else
                    {
                        TempData["swalfunction"] = "true";
                        return(RedirectToAction("Index"));
                    }
                }
                return(View(tbMoneda));
            }
            catch (Exception Ex)
            {
                Function.BitacoraErrores("Moneda", "CreatePost", UserName, Ex.Message.ToString());
                ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                return(View());
            }
        }
        public ActionResult Create([Bind(Include = "deif_IdDeduccionInstFinanciera,emp_Id,insf_Id,deif_Monto,deif_Comentarios,deif_UsuarioCrea,deif_FechaCrea,deif_UsuarioModifica,deif_FechaModifica,deif_Activo")] tbDeduccionInstitucionFinanciera tbDeduccionInstitucionFinanciera)
        {
            string UserName = "";

            try
            {
                ViewBag.insf_Id  = new SelectList(db.tbInstitucionFinanciera, "insf_Id", "insf_Nombre");
                ViewBag.Empleado = db.tbEmpleado.Where(x => x.est_Id == 5).ToList();
                int EmployeeID = Function.GetUser(out UserName);
                if (ModelState.IsValid)
                {
                    IEnumerable <object> _List = null;
                    string ErrorMessage        = "";
                    _List = db.UDP_Plani_tbDeduccionInstitucionFinanciera_Insert(tbDeduccionInstitucionFinanciera.insf_Id, tbDeduccionInstitucionFinanciera.emp_Id, tbDeduccionInstitucionFinanciera.deif_Monto, tbDeduccionInstitucionFinanciera.deif_Comentarios, EmployeeID, Function.DatetimeNow(), GeneralFunctions.Activo);
                    foreach (UDP_Plani_tbDeduccionInstitucionFinanciera_Insert_Result Area in _List)
                    {
                        ErrorMessage = Area.MensajeError;
                    }
                    if (ErrorMessage.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("DeduccionFinanciera", "CreatePost", UserName, ErrorMessage);
                        ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                        return(View(tbDeduccionInstitucionFinanciera));
                    }

                    else
                    {
                        TempData["swalfunction"] = "true";

                        return(RedirectToAction("Index"));
                    }
                }
                return(View(tbDeduccionInstitucionFinanciera));
            }
            catch (Exception Ex)
            {
                Function.BitacoraErrores("DeduccionFinanciera", "CreatePost", UserName, Ex.Message.ToString());
                ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                return(View(tbDeduccionInstitucionFinanciera));
            }
        }
Example #12
0
        public ActionResult Create([Bind(Include = "Lianvi_Id,Lianvi_Correlativo,Anvi_Id,Lianvi_FechaLiquida,Lianvi_FechaInicioViaje,Lianvi_FechaFinViaje,Lianvi_Comentario,est_Id,Lianvi_RazonRechazo")] tbLiquidacionAnticipoViatico tbLiquidacionAnticipoViatico, int?Id)
        {
            {
                string UserName   = "",
                       ErrorEmail = "";
                try
                {
                    cGetUserInfo GetEmployee = null;
                    cGetUserInfo EmpJefe = null;
                    bool         Result = false, ResultAdm = false;

                    if (ModelState.IsValid)
                    {
                        int EmployeeID = Function.GetUser(out UserName);


                        IEnumerable <object> _List = null;
                        string ErrorMessage        = "";
                        _List = db.UDP_Adm_tbLiquidacionAnticipoViatico_Insert(tbLiquidacionAnticipoViatico.Anvi_Id,
                                                                               tbLiquidacionAnticipoViatico.Lianvi_FechaLiquida,
                                                                               tbLiquidacionAnticipoViatico.Lianvi_FechaInicioViaje,
                                                                               tbLiquidacionAnticipoViatico.Lianvi_FechaFinViaje,
                                                                               tbLiquidacionAnticipoViatico.Lianvi_Comentario,
                                                                               GeneralFunctions.Enviada,
                                                                               tbLiquidacionAnticipoViatico.Lianvi_RazonRechazo,
                                                                               EmployeeID, Function.DatetimeNow());
                        foreach (UDP_Adm_tbLiquidacionAnticipoViatico_Insert_Result Area in _List)
                        {
                            ErrorMessage = Area.MensajeError;
                        }
                        if (ErrorMessage.StartsWith("-1"))
                        {
                            Function.BitacoraErrores("LiquidacionAnticipoViatico", "CreatePost", UserName, ErrorMessage);
                            ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                            return(View(tbLiquidacionAnticipoViatico));
                        }

                        else
                        {
                            TempData["swalfunction"] = "true";


                            Session["NombreLiquidacione"] = ErrorMessage;


                            return(RedirectToAction("Create", "LiquidacionAnticipoViaticoDetalle"));
                        }
                    }
                }

                catch (Exception Ex)
                {
                    Function.BitacoraErrores("LiquidacionAnticipoViatico", "CreatePost", UserName, Ex.Message.ToString());

                    return(RedirectToAction("Create", "LiquidacionAnticipoViaticoDetalle"));
                }
            }
            return(RedirectToAction("Create", "LiquidacionAnticipoViaticoDetalle"));
        }
        public ActionResult Create([Bind(Include = "est_Id,est_Descripcion")] tbEstado tbEstado)
        {
            string UserName = "";

            try
            {
                int EmployeeID = Function.GetUser(out UserName);
                if (ModelState.IsValid)
                {
                    IEnumerable <Object> List = null;
                    string Msj = "";
                    List = db.UDP_Gral_tbEstado_Insert(tbEstado.est_Descripcion, EmployeeID, Function.DatetimeNow());
                    foreach (UDP_Gral_tbEstado_Insert_Result Estado in List)
                    {
                        Msj = Estado.MensajeError;
                    }
                    if (Msj.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("Estado", "CreatePost", UserName, Msj);
                        ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                        return(View());
                    }
                    if (Msj.StartsWith("-2"))
                    {
                        Function.BitacoraErrores("Estado", "CreatePost", UserName, Msj);
                        ModelState.AddModelError("", "Ya existe un estado con el mismo nombre.");
                        return(View());
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception Ex)
            {
                Function.BitacoraErrores("Estado", "CreatePost", UserName, Ex.Message.ToString());
                ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                return(View());
            }
            return(View());
        }
        public ActionResult Create([Bind(Include = "par_Id,par_NombreEmpresa,par_TelefonoEmpresa,par_CorreoEmpresa,par_CorreoEmisor,par_CorreoRRHH,par_Password,par_Servidor,par_Puerto,par_PathLogo, par_PorcentajeAdelantoSalario,par_FrecuenciaAdelantoSalario")] tbParametro tbParametro,
                                   HttpPostedFileBase FotoPath
                                   )
        {
            string UserName = "";


            try
            {
                int EmployeeID = Function.GetUser(out UserName);
                var path       = "";
                if (FotoPath == null)
                {
                    ModelState.AddModelError("par_PathLogo", "Imagen requerida.");
                }

                if (ModelState.IsValid)
                {
                    if (FotoPath != null)
                    {
                        if (FotoPath.ContentLength > 0)
                        {
                            if (Path.GetExtension(FotoPath.FileName).ToLower() == ".jpg" || Path.GetExtension(FotoPath.FileName).ToLower() == ".png" || Path.GetExtension(FotoPath.FileName).ToLower() == ".jpeg")
                            {
                                string Extension = Path.GetExtension(FotoPath.FileName).ToLower();
                                string Archivo   = "1" + Path.GetExtension(FotoPath.FileName).ToLower();
                                path = Path.Combine(Server.MapPath("~/Content/img/"), Archivo);
                                FotoPath.SaveAs(path);
                                tbParametro.par_PathLogo = "~/Content/img/" + Archivo;
                            }
                            else
                            {
                                ModelState.AddModelError("par_PathLogo", "Formato de archivo incorrecto, favor adjuntar una fotografía con extensión .jpg");
                                return(View(tbParametro));
                            }
                        }
                    }

                    IEnumerable <object> List = null;
                    var MsjError = "";

                    List = db.UDP_Conf_tbParametro_Insert(tbParametro.par_NombreEmpresa.ToUpper(),
                                                          tbParametro.par_TelefonoEmpresa,
                                                          tbParametro.par_CorreoEmpresa,
                                                          tbParametro.par_CorreoEmisor,
                                                          tbParametro.par_CorreoRRHH,
                                                          tbParametro.par_Password,
                                                          tbParametro.par_Servidor,
                                                          tbParametro.par_Puerto,
                                                          tbParametro.par_PathLogo,
                                                          tbParametro.par_PorcentajeAdelantoSalario,
                                                          tbParametro.par_FrecuenciaAdelantoSalario

                                                          );
                    foreach (UDP_Conf_tbParametro_Insert_Result parametro in List)
                    {
                        MsjError = parametro.MensajeError;
                    }

                    if (MsjError.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("Parametro", "CreatePost", UserName, MsjError);
                        ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                        return(View(tbParametro));
                    }
                    else
                    {
                        TempData["swalfunction"] = GeneralFunctions._isCreated;
                        return(RedirectToAction("Details/" + MsjError));
                    }
                }
                {
                    ModelState.AddModelError("par_PathLogo", "Imagen requerida.");
                    var errors = ModelState.Values.SelectMany(v => v.Errors);
                }
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Function.BitacoraErrores("Parametro", "CreatePost", UserName, ve.ErrorMessage.ToString() + " " + ve.PropertyName.ToString());
                        ModelState.AddModelError("", ve.ErrorMessage.ToString() + " " + ve.PropertyName.ToString());
                        return(View(tbParametro));
                    }
                }
            }
            catch (Exception Ex)
            {
                Function.BitacoraErrores("Parametro", "CreatePost", UserName, Ex.Message.ToString());
                ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                return(View(tbParametro));
            }
            return(View(tbParametro));
        }
Example #15
0
        public ActionResult Create([Bind(Include = "Ansal_Id,Ansal_Correlativo,emp_Id,Ansal_JefeInmediato,Ansal_GralFechaSolicitud,Ansal_MontoSolicitado,tpsal_id,Ansal_Justificacion,Ansal_Comentario,est_Id,Ansal_RazonRechazo,Cantidad,Sueldo,Porcentaje")] tbAnticipoSalario tbAnticipoSalario)
        {
            string UserName = "", ErrorEmail = "", ErrorMessage = "";
            bool   Result = false, ResultAdm = false;
            IEnumerable <object> Insert = null;

            try
            {
                cGetUserInfo GetEmployee = null;
                int          EmployeeID  = Function.GetUser(out UserName);

                IEnumerable <object> Employee = (from _tbEmp in db.tbEmpleado
                                                 where _tbEmp.emp_EsJefe == true && _tbEmp.est_Id == GeneralFunctions.empleadoactivo && _tbEmp.emp_Id != EmployeeID
                                                 select new { emp_Id = _tbEmp.emp_Id, emp_Nombres = _tbEmp.emp_Nombres + " " + _tbEmp.emp_Apellidos }).ToList();

                ViewBag.Ansal_JefeInmediato = new SelectList(Employee, "emp_Id", "emp_Nombres", tbAnticipoSalario.Ansal_JefeInmediato);
                ViewBag.tpsal_id            = new SelectList(db.tbTipoSalario, "tpsal_id", "tpsal_Descripcion", tbAnticipoSalario.tpsal_id);

                tbAnticipoSalario.emp_Id = EmployeeID;
                tbAnticipoSalario.Ansal_GralFechaSolicitud = Function.DatetimeNow();
                tbAnticipoSalario.est_Id = GeneralFunctions.Enviada;

                var _Parameters = (from _tbParm in db.tbParametro select _tbParm).FirstOrDefault();
                var vSueldo     = (from _tbSueldo in db.tbSueldo where _tbSueldo.emp_Id == EmployeeID select _tbSueldo.sue_Cantidad).FirstOrDefault();
                var _percent    = vSueldo * (Convert.ToDecimal(_Parameters.par_PorcentajeAdelantoSalario) / 100);

                if (String.IsNullOrEmpty(tbAnticipoSalario.Ansal_Comentario))
                {
                    tbAnticipoSalario.Ansal_Comentario = GeneralFunctions.stringDefault;
                }
                tbAnticipoSalario.Ansal_MontoSolicitado = Convert.ToDecimal(tbAnticipoSalario.Cantidad.Replace(",", ""));

                if (tbAnticipoSalario.Ansal_MontoSolicitado > vSueldo)
                {
                    ModelState.AddModelError("Cantidad", "El monto no puede ser mayor que el sueldo.");
                }

                if (tbAnticipoSalario.Ansal_MontoSolicitado > _percent)
                {
                    ModelState.AddModelError("Cantidad", "El monto no puede ser mayor que el pocentaje permitido.");
                }


                if (ModelState.IsValid)
                {
                    Insert = db.UDP_Adm_tbAnticipoSalario_Insert(EmployeeID,
                                                                 tbAnticipoSalario.Ansal_JefeInmediato,
                                                                 Function.DatetimeNow(),
                                                                 tbAnticipoSalario.Ansal_MontoSolicitado,
                                                                 tbAnticipoSalario.tpsal_id,
                                                                 tbAnticipoSalario.Ansal_Justificacion,
                                                                 tbAnticipoSalario.Ansal_Comentario,
                                                                 tbAnticipoSalario.est_Id,
                                                                 tbAnticipoSalario.Ansal_RazonRechazo,
                                                                 EmployeeID,
                                                                 Function.DatetimeNow());
                    foreach (UDP_Adm_tbAnticipoSalario_Insert_Result Res in Insert)
                    {
                        ErrorMessage = Res.MensajeError;
                    }
                    if (ErrorMessage.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("AnticipoSalario", "CreatePost", UserName, ErrorMessage);
                        ModelState.AddModelError("", "No se pudo insertar el registro contacte al administrador.");
                    }
                    else
                    {
                        GetEmployee = Function.GetUserInfo(EmployeeID);

                        Result    = Function.LeerDatos(out ErrorEmail, ErrorMessage, GetEmployee.emp_Nombres, GeneralFunctions.stringEmpty, GeneralFunctions.msj_Enviada, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, GetEmployee.emp_CorreoElectronico);
                        ResultAdm = Function.LeerDatos(out ErrorEmail, ErrorMessage, _Parameters.par_NombreEmpresa, GetEmployee.emp_Nombres, GeneralFunctions.msj_ToAdmin, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, _Parameters.par_CorreoRRHH);

                        if (!Result)
                        {
                            Function.BitacoraErrores("AnticipoSalario", "CreatePost", UserName, ErrorEmail);
                        }
                        if (!ResultAdm)
                        {
                            Function.BitacoraErrores("AnticipoSalario", "CreatePost", UserName, ErrorEmail);
                        }

                        TempData["swalfunction"] = GeneralFunctions.sol_Enviada;
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                Function.BitacoraErrores("AnticipoViatico", "CreatePost", UserName, ex.Message.ToString());
            }
            return(View(tbAnticipoSalario));
        }
        public ActionResult Create([Bind(Include = "emp_Id,Reemga_JefeInmediato,Reemga_GralFechaSolicitud," +
                                                   "Reemga_FechaViaje,Reemga_Cliente,mun_codigo,Reemga_PropositoVisita,Reemga_DiasVisita,Reemga_Comentario,est_Id")] tbSolicitudReembolsoGastos tbSolicitudReembolsoGastos, string dep_codigo)
        {
            IEnumerable <object> Insert = null;



            string UserName = "", ErrorEmail = "", ErrorMessage = "";

            try
            {
                cGetUserInfo GetEmployee = null;
                cGetUserInfo EmpJefe = null;
                bool         Result = false, ResultAdm = false;


                int EmployeeID = Function.GetUser(out UserName);

                IEnumerable <object> Employee = (from _tbEmp in db.tbEmpleado
                                                 where _tbEmp.emp_EsJefe == true && _tbEmp.est_Id == GeneralFunctions.empleadoactivo && _tbEmp.emp_Id != EmployeeID
                                                 select new { emp_Id = _tbEmp.emp_Id, emp_Nombres = _tbEmp.emp_Nombres + " " + _tbEmp.emp_Apellidos }).ToList();

                ViewBag.emp_Id = new SelectList(db.tbEmpleado, "emp_Id", "emp_Nombres");
                ViewBag.est_Id = new SelectList(db.tbEstado, "est_Id", "est_Descripcion");

                ViewBag.Reemga_JefeInmediato = new SelectList(Employee, "emp_Id", "emp_Nombres");
                ViewBag.dep_codigo           = new SelectList(db.tbDepartamento, "dep_Codigo", "dep_Nombre");
                ViewBag.mun_Codigo           = new SelectList(db.tbMunicipio, "mun_codigo", "mun_nombre");
                tbSolicitudReembolsoGastos.Reemga_RazonRechazo = GeneralFunctions.stringDefault;
                tbSolicitudReembolsoGastos.emp_Id = EmployeeID;
                tbSolicitudReembolsoGastos.Reemga_GralFechaSolicitud = Function.DatetimeNow();
                tbSolicitudReembolsoGastos.est_Id = GeneralFunctions.Enviada;



                if (tbSolicitudReembolsoGastos.mun_codigo == "Seleccione")
                {
                    ModelState.AddModelError("mun_codigo", "El campo Municipio es obligatorio.");
                }
                else
                {
                    ViewBag.muncodigo = tbSolicitudReembolsoGastos.mun_codigo;
                }


                if (String.IsNullOrEmpty(dep_codigo))
                {
                    ModelState.AddModelError("Reemga_UsuarioCrea", "El campo Departamento es obligatorio.");
                }



                if (ModelState.IsValid)
                {
                    Insert = db.UDP_Adm_tbSolicitudReembolsoGastos_Insert(tbSolicitudReembolsoGastos.emp_Id,
                                                                          tbSolicitudReembolsoGastos.Reemga_JefeInmediato,
                                                                          tbSolicitudReembolsoGastos.Reemga_GralFechaSolicitud,
                                                                          tbSolicitudReembolsoGastos.Reemga_FechaViaje,
                                                                          tbSolicitudReembolsoGastos.Reemga_Cliente,
                                                                          tbSolicitudReembolsoGastos.mun_codigo,
                                                                          tbSolicitudReembolsoGastos.Reemga_PropositoVisita,
                                                                          tbSolicitudReembolsoGastos.Reemga_DiasVisita,
                                                                          tbSolicitudReembolsoGastos.Reemga_Comentario,
                                                                          tbSolicitudReembolsoGastos.est_Id,
                                                                          tbSolicitudReembolsoGastos.Reemga_RazonRechazo,
                                                                          EmployeeID,
                                                                          Function.DatetimeNow());
                    foreach (UDP_Adm_tbSolicitudReembolsoGastos_Insert_Result Reembolso in Insert)
                    {
                        ErrorMessage = Reembolso.MensajeError;
                    }



                    if (ErrorMessage.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("SolicitudReembolsoGastos", "CreatePost", UserName, ErrorMessage);
                        ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");

                        return(View(tbSolicitudReembolsoGastos));
                    }

                    else
                    {
                        GetEmployee = Function.GetUserInfo(EmployeeID);
                        EmpJefe     = Function.GetUserInfo(tbSolicitudReembolsoGastos.Reemga_JefeInmediato ?? 0);

                        Result    = Function.LeerDatos(out ErrorEmail, ErrorMessage, GetEmployee.emp_Nombres, GeneralFunctions.stringEmpty, GeneralFunctions.msj_Enviada, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, GetEmployee.emp_CorreoElectronico);
                        ResultAdm = Function.LeerDatos(out ErrorEmail, ErrorMessage, EmpJefe.emp_Nombres, GetEmployee.emp_Nombres, GeneralFunctions.msj_ToAdmin, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, EmpJefe.emp_CorreoElectronico);


                        if (!Result)
                        {
                            Function.BitacoraErrores("AccionPersonal", "CreatePost", UserName, ErrorEmail);
                        }
                        if (!ResultAdm)
                        {
                            Function.BitacoraErrores("AccionPersonal", "CreatePost", UserName, ErrorEmail);
                        }

                        // GetEmployee = Function.GetUserInfo(EmployeeID);
                        // var _Parameters = (from _tbParm in db.tbParametro select _tbParm).FirstOrDefault();
                        // Result = Function.LeerDatos(out ErrorEmail, ErrorMessage, GetEmployee.emp_Nombres, GeneralFunctions.stringEmpty, GeneralFunctions.msj_Enviada, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, GetEmployee.emp_CorreoElectronico);
                        //ResultAdm = Function.LeerDatos(out ErrorEmail, ErrorMessage, EmpJefe.emp_Nombres, GetEmployee.emp_Nombres, GeneralFunctions.msj_ToAdmin, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, EmpJefe.emp_CorreoElectronico);
                        // if (!Result) Function.BitacoraErrores("SolicitudReembolsoGastos", "CreatePost", UserName, ErrorEmail);
                        // if (!ResultAdm) Function.BitacoraErrores("SolicitudReembolsoGastos", "CreatePost", UserName, ErrorEmail);
                        // TempData["swalfunction"] = "true";

                        Session["Reemga_Id"] = ErrorMessage;
                        return(RedirectToAction("Create", "SolicitudReembolsoGastosDetalles"));
                    }
                }
            }


            catch (Exception ex)
            {
                Function.BitacoraErrores("SolicitudReembolsoGastos", "CreatePost", UserName, ex.Message.ToString());
                return(RedirectToAction("Create", "SolicitudReembolsoGastos"));
            }
            return(RedirectToAction("Create", "SolicitudReembolsoGastosDetalles"));
        }
        public ActionResult Create([Bind(Include = "VPE_JefeInmediato,tperm_Id,VPE_GralFechaSolicitud,VPE_FechaInicio,VPE_FechaFin,VPE_CantidadDias,VPE_MontoSolicitado,VPE_Comentario,VPE_RazonRechazo")] tbVacacionesPermisosEspeciales tbVacacionesPermisosEspeciales)
        {
            string UserName = "", ErrorEmail = "", ErrorMessage = "";
            bool   Result = false, ResultAdm = false;
            IEnumerable <object> Insert = null;

            try
            {
                if (tbVacacionesPermisosEspeciales.VPE_FechaFin > tbVacacionesPermisosEspeciales.VPE_FechaFin)
                {
                    ModelState.AddModelError("ValidationSummary", "La Fecha de inicio no puede ser mayor que la final.");
                }
                int          EmployeeID  = Function.GetUser(out UserName);
                cGetUserInfo GetEmployee = null;
                cGetUserInfo EmpJefe     = null;

                IEnumerable <object> Employee = (from _tbEmp in db.tbEmpleado
                                                 where _tbEmp.emp_EsJefe == true && _tbEmp.est_Id == GeneralFunctions.empleadoactivo && _tbEmp.emp_Id != EmployeeID
                                                 select new { emp_Id = _tbEmp.emp_Id, emp_Nombres = _tbEmp.emp_Nombres + " " + _tbEmp.emp_Apellidos }).ToList();

                ViewBag.VPE_JefeInmediato = new SelectList(Employee, "emp_Id", "emp_Nombres", tbVacacionesPermisosEspeciales.VPE_JefeInmediato);
                ViewBag.est_Id            = new SelectList(db.tbEstado, "est_Id", "est_Descripcion", tbVacacionesPermisosEspeciales.est_Id);
                ViewBag.tperm_Id          = new SelectList(db.tbTipoPermiso, "tperm_Id", "tperm_Descripcion", tbVacacionesPermisosEspeciales.tperm_Id);

                tbVacacionesPermisosEspeciales.emp_Id = EmployeeID;
                tbVacacionesPermisosEspeciales.VPE_GralFechaSolicitud = Function.DatetimeNow();
                tbVacacionesPermisosEspeciales.est_Id = GeneralFunctions.Enviada;



                if (String.IsNullOrEmpty(tbVacacionesPermisosEspeciales.VPE_Comentario))
                {
                    tbVacacionesPermisosEspeciales.VPE_Comentario = GeneralFunctions.stringDefault;
                }

                if (ModelState.IsValid)
                {
                    Insert = db.UDP_Adm_tbVacacionesPermisosEspeciales_Insert(EmployeeID,
                                                                              tbVacacionesPermisosEspeciales.VPE_JefeInmediato,
                                                                              tbVacacionesPermisosEspeciales.tperm_Id,
                                                                              tbVacacionesPermisosEspeciales.est_Id,
                                                                              Function.DatetimeNow(),
                                                                              tbVacacionesPermisosEspeciales.VPE_FechaInicio,
                                                                              tbVacacionesPermisosEspeciales.VPE_FechaFin,
                                                                              tbVacacionesPermisosEspeciales.VPE_CantidadDias,
                                                                              tbVacacionesPermisosEspeciales.VPE_Comentario,
                                                                              tbVacacionesPermisosEspeciales.VPE_RazonRechazo,
                                                                              EmployeeID,
                                                                              Function.DatetimeNow());

                    foreach (UDP_Adm_tbVacacionesPermisosEspeciales_Insert_Result Res in Insert)
                    {
                        ErrorMessage = Res.MensajeError;
                    }

                    if (ErrorMessage.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("VacacionesPermisosEspeciales", "CreatePost", UserName, ErrorMessage);
                        ModelState.AddModelError("", "No se pudo insertar el registro contacte al administrador.");
                    }
                    else
                    {
                        GetEmployee = Function.GetUserInfo(EmployeeID);
                        EmpJefe     = Function.GetUserInfo(tbVacacionesPermisosEspeciales.VPE_JefeInmediato);


                        Result    = Function.LeerDatos(out ErrorEmail, ErrorMessage, GetEmployee.emp_Nombres, GeneralFunctions.stringEmpty, GeneralFunctions.msj_Enviada, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, GetEmployee.emp_CorreoElectronico);
                        ResultAdm = Function.LeerDatos(out ErrorEmail, ErrorMessage, EmpJefe.emp_Nombres, GetEmployee.emp_Nombres, GeneralFunctions.msj_ToAdmin, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, EmpJefe.emp_CorreoElectronico);

                        if (!Result)
                        {
                            Function.BitacoraErrores("VacacionesPermisosEspeciales", "CreatePost", UserName, ErrorEmail);
                        }
                        if (!ResultAdm)
                        {
                            Function.BitacoraErrores("VacacionesPermisosEspeciales", "CreatePost", UserName, ErrorEmail);
                        }

                        TempData["swalfunction"] = GeneralFunctions.sol_Enviada;
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                Function.BitacoraErrores("VacacionesPermisosEspeciales", "CreatePost", UserName, ex.Message.ToString());
            }

            return(View(tbVacacionesPermisosEspeciales));
        }
        public async Task <ActionResult> Create([Bind(Include = "are_Id,Reqco_GralFechaSolicitud,Reqco_Comentario,Reqco_RazonRechazo")] tbRequisionCompra tbRequisionCompra)
        {
            string UserName = "", ErrorMessage = "", Scope = "";
            IEnumerable <object> Insert = null;

            try
            {
                int EmployeeID = Function.GetUser(out UserName);

                IEnumerable <object> Employee = (from _tbEmp in db.tbEmpleado
                                                 where _tbEmp.emp_EsJefe == true && _tbEmp.est_Id == GeneralFunctions.empleadoactivo && _tbEmp.emp_Id != EmployeeID
                                                 select new { emp_Id = _tbEmp.emp_Id, emp_Nombres = _tbEmp.emp_Nombres + " " + _tbEmp.emp_Apellidos }).ToList();


                ViewBag.are_Id = new SelectList(db.tbArea, "are_Id", "are_Descripcion", tbRequisionCompra.are_Id);
                ViewBag.emp_Id = new SelectList(db.tbEmpleado, "emp_Id", "emp_Nombres", tbRequisionCompra.emp_Id);
                ViewBag.est_Id = new SelectList(db.tbEstado, "est_Id", "est_Descripcion", tbRequisionCompra.est_Id);

                tbRequisionCompra.emp_Id = EmployeeID;
                tbRequisionCompra.Reqco_GralFechaSolicitud = Function.DatetimeNow();
                tbRequisionCompra.est_Id = GeneralFunctions.Enviada;

                var _Parameters = (from _tbParm in db.tbParametro select _tbParm).FirstOrDefault();


                if (String.IsNullOrEmpty(tbRequisionCompra.Reqco_Comentario))
                {
                    tbRequisionCompra.Reqco_Comentario = GeneralFunctions.stringDefault;
                }

                if (ModelState.IsValid)
                {
                    Insert = db.UDP_Adm_tbRequisionCompra_Insert(EmployeeID,
                                                                 tbRequisionCompra.are_Id,
                                                                 Function.DatetimeNow(),
                                                                 tbRequisionCompra.Reqco_Comentario,
                                                                 tbRequisionCompra.est_Id,
                                                                 tbRequisionCompra.Reqco_RazonRechazo,
                                                                 EmployeeID,
                                                                 Function.DatetimeNow());
                    foreach (UDP_Adm_tbRequisionCompra_Insert_Result Res in Insert)
                    {
                        ErrorMessage = Res.MensajeError; Scope = Res.ScopeIdentity;
                    }
                    if (ErrorMessage.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("RequisionCompra", "CreatePost", UserName, ErrorMessage);
                        ModelState.AddModelError("", "No se pudo insertar el registro contacte al administrador.");
                    }
                    else
                    {
                        Session["Reqco_Id"]      = Scope;
                        TempData["swalfunction"] = GeneralFunctions.sol_Enviada;

                        return(RedirectToAction("Create", "RequisionCompraDetalle"));
                    }
                }
            }
            catch (Exception ex)
            {
                Function.BitacoraErrores("RequisionCompra", "CreatePost", UserName, ex.Message.ToString() + " " + ex.InnerException.Message.ToString());
            }
            return(View(tbRequisionCompra));
        }
        public ActionResult Create([Bind(Include = "Lianvi_Id,Lianvi_Correlativo,Anvi_Id,Lianvi_FechaLiquida,Lianvi_FechaInicioViaje,Lianvi_FechaFinViaje,Lianvi_Comentario,est_Id,Lianvi_RazonRechazo")] tbLiquidacionAnticipoViatico tbLiquidacionAnticipoViatico, int?Id)
        {
            {
                string UserName   = "",
                       ErrorEmail = "";
                try
                {
                    cGetUserInfo GetEmployee = null;
                    if (ModelState.IsValid)
                    {
                        int  EmployeeID = Function.GetUser(out UserName);
                        bool Result = false, ResultAdm = false;

                        IEnumerable <object> _List = null;
                        string ErrorMessage        = "";
                        _List = db.UDP_Adm_tbLiquidacionAnticipoViatico_Insert(tbLiquidacionAnticipoViatico.Anvi_Id,
                                                                               tbLiquidacionAnticipoViatico.Lianvi_FechaLiquida,
                                                                               tbLiquidacionAnticipoViatico.Lianvi_FechaInicioViaje,
                                                                               tbLiquidacionAnticipoViatico.Lianvi_FechaFinViaje,
                                                                               tbLiquidacionAnticipoViatico.Lianvi_Comentario,
                                                                               GeneralFunctions.Enviada,
                                                                               tbLiquidacionAnticipoViatico.Lianvi_RazonRechazo,
                                                                               EmployeeID, Function.DatetimeNow());
                        foreach (UDP_Adm_tbLiquidacionAnticipoViatico_Insert_Result Area in _List)
                        {
                            ErrorMessage = Area.MensajeError;
                        }
                        if (ErrorMessage.StartsWith("-1"))
                        {
                            Function.BitacoraErrores("LiquidacionAnticipoViatico", "CreatePost", UserName, ErrorMessage);
                            ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                            return(View(tbLiquidacionAnticipoViatico));
                        }

                        else
                        {
                            var _Parameters = (from _tbParm in db.tbParametro select _tbParm).FirstOrDefault();
                            GetEmployee = Function.GetUserInfo(EmployeeID);

                            Result    = Function.LeerDatos(out ErrorEmail, ErrorMessage, GetEmployee.emp_Nombres, GeneralFunctions.stringEmpty, GeneralFunctions.msj_Enviada, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, GetEmployee.emp_CorreoElectronico);
                            ResultAdm = Function.LeerDatos(out ErrorEmail, ErrorMessage, _Parameters.par_NombreEmpresa, GetEmployee.emp_Nombres, GeneralFunctions.msj_ToAdmin, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, _Parameters.par_CorreoEmpresa);

                            if (!Result)
                            {
                                Function.BitacoraErrores("LiquidacionAnticipoViatico", "CreatePost", UserName, ErrorEmail);
                            }
                            if (!ResultAdm)
                            {
                                Function.BitacoraErrores("LiquidacionAnticipoViatico", "CreatePost", UserName, ErrorEmail);
                            }
                            TempData["swalfunction"] = "true";


                            Session["NombreLiquidacion"] = ErrorMessage;


                            return(RedirectToAction("Create", "LiquidacionAnticipoViaticoDetalle"));
                        }
                    }
                }

                catch (Exception Ex)
                {
                    Function.BitacoraErrores("LiquidacionAnticipoViatico", "CreatePost", UserName, Ex.Message.ToString());

                    return(RedirectToAction("Create", "LiquidacionAnticipoViaticoDetalle"));
                }
            }
            return(RedirectToAction("Create", "LiquidacionAnticipoViaticoDetalle"));
        }
Example #20
0
        public ActionResult Create([Bind(Include = "sue_Id,emp_Id,sue_Cantidad,tmo_Id,Cantidad,Employee")] tbSueldo tbSueldo)
        {
            //decimal Cantidad = Convert.ToDecimal(tbSueldo.sue_Cantidad.ToString().Replace(",", ""));
            string UserName = "";

            try
            {
                var Existe = (from based in db.tbSueldo where based.emp_Id == tbSueldo.emp_Id select new { emp_Id = based.emp_Id }).SingleOrDefault();

                if (Existe != null)
                {
                    ViewBag.Existencia = Existe;
                    ModelState.AddModelError("", "Esta empleado ya tiene sueldo.");
                }
                IEnumerable <object> Employee = (from _tbEmp in db.tbEmpleado where _tbEmp.est_Id == GeneralFunctions.empleadoactivo
                                                 select new  { emp_Id = _tbEmp.emp_Id, emp_Nombres = _tbEmp.emp_Nombres + " " + _tbEmp.emp_Apellidos }).ToList();
                //if (tbSueldo.sue_Cantidad == 0)
                //{
                //    ModelState.AddModelError("sue_Cantidad", "El campo Sueldo es obligatorio.");
                //}
                int EmployeeID = Function.GetUser(out UserName);

                if (ModelState.IsValid)
                {
                    IEnumerable <object> _List = null;
                    string MsjError            = "";
                    string _Cant = tbSueldo.Cantidad.Replace(",", "");
                    tbSueldo.sue_Cantidad = Convert.ToDecimal(_Cant);
                    _List = db.UDP_rrhh_tbSueldo_Insert(tbSueldo.emp_Id, tbSueldo.sue_Cantidad, tbSueldo.tmo_Id, EmployeeID, Function.DatetimeNow());
                    foreach (UDP_rrhh_tbSueldo_Insert_Result Sueldo in _List)
                    {
                        MsjError = Sueldo.MensajeError;
                    }
                    if (MsjError.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("Sueldo", "CreatePost", UserName, MsjError);
                        ViewBag.tmo_Id = new SelectList(db.tbMoneda, "tmo_Id", "tmo_Nombre", tbSueldo.tmo_Id);
                        ViewBag.emp_Id = new SelectList(Employee, "emp_Id", "emp_Nombres", tbSueldo.emp_Id);
                        ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                        return(View(tbSueldo));
                    }
                    if (MsjError.StartsWith("-2"))
                    {
                        ModelState.AddModelError("", "Ya existe un sueldo con el mismo nombre.");
                        ViewBag.tmo_Id = new SelectList(db.tbMoneda, "tmo_Id", "tmo_Nombre", tbSueldo.tmo_Id);
                        ViewBag.emp_Id = new SelectList(Employee, "emp_Id", "emp_Nombres", tbSueldo.emp_Id);
                        return(View(tbSueldo));
                    }
                    else
                    {
                        if (Session["EmpID"] == null)
                        {
                            TempData["swalfunction"] = GeneralFunctions._isCreated;
                            return(RedirectToAction("Index"));
                        }

                        else
                        {
                            Session["EmpID"]         = null;
                            TempData["swalfunction"] = GeneralFunctions._isCreated;
                            return(RedirectToAction("Index", "Empleado"));
                        }
                    }
                }
                ViewBag.tmo_Id = new SelectList(db.tbMoneda, "tmo_Id", "tmo_Nombre", tbSueldo.tmo_Id);
                ViewBag.emp_Id = new SelectList(Employee, "emp_Id", "emp_Nombres", tbSueldo.emp_Id);
                return(View(tbSueldo));
            }
            catch (Exception Ex)
            {
                Function.BitacoraErrores("Sueldo", "CreatePost", UserName, Ex.Message.ToString());
                ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                ViewBag.tmo_Id = new SelectList(db.tbMoneda, "tmo_Id", "tmo_Nombre", tbSueldo.tmo_Id);
                ViewBag.emp_Id = new SelectList(db.tbEmpleado, "emp_Id", "emp_Nombres", tbSueldo.emp_Id);


                return(View(tbSueldo));
            }
        }
Example #21
0
        public ActionResult Create([Bind(Include = "prov_Id,prov_Nombre,prov_NombreContacto,prov_Direccion,mun_codigo,prov_Email,prov_Telefono,prov_RTN,acte_Id,prov_UsuarioCrea,prov_FechaCrea,prov_UsuarioModifica,prov_FechaModifica")] tbProveedor tbProveedor, string dep_codigo)
        {
            string UserName = "";

            try
            {
                int EmployeeID = Function.GetUser(out UserName);
                if (tbProveedor.mun_codigo == "Seleccione")
                {
                    ModelState.AddModelError("mun_codigo", "El campo Municipio es obligatorio.");
                }
                else
                {
                    ViewBag.munCodigo = tbProveedor.mun_codigo;
                }

                if (String.IsNullOrEmpty(dep_codigo))
                {
                    ModelState.AddModelError("prov_UsuarioCrea", "El campo Departamento es obligatorio.");
                }
                if (ModelState.IsValid)
                {
                    ViewBag.selectedMun = tbProveedor.mun_codigo;
                    ViewBag.acte_Id     = new SelectList(db.tbActividadEconomica, "acte_Id", "acte_Descripcion");
                    IEnumerable <Object> List = null;
                    string Msj = "";
                    List = db.UDP_Inv_tbProveedor_Insert(tbProveedor.prov_Id,
                                                         tbProveedor.prov_Nombre,
                                                         tbProveedor.prov_NombreContacto,
                                                         tbProveedor.prov_Direccion,
                                                         tbProveedor.mun_codigo,
                                                         tbProveedor.prov_Email,
                                                         tbProveedor.prov_Telefono,
                                                         tbProveedor.prov_RTN,
                                                         tbProveedor.acte_Id,
                                                         EmployeeID, Function.DatetimeNow());
                    foreach (UDP_Inv_tbProveedor_Insert_Result Permiso in List)
                    {
                        Msj = Permiso.MensajeError;
                    }
                    if (Msj.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("Proveedor", "CreatePost", UserName, Msj);
                        ViewBag.dep_codigo = new SelectList(db.tbDepartamento, "dep_Codigo", "dep_Nombre", dep_codigo);
                        ViewBag.acte_Id    = new SelectList(db.tbActividadEconomica, "acte_Id", "acte_Descripcion", tbProveedor.acte_Id);
                        ViewBag.mun_Codigo = new SelectList(db.tbMunicipio, "mun_codigo", "dep_codigo", tbProveedor.mun_codigo);
                        return(View());
                    }
                    if (Msj.StartsWith("-2"))
                    {
                        ViewBag.dep_codigo = new SelectList(db.tbDepartamento, "dep_Codigo", "dep_Nombre", dep_codigo);
                        ViewBag.acte_Id    = new SelectList(db.tbActividadEconomica, "acte_Id", "acte_Descripcion", tbProveedor.acte_Id);
                        ViewBag.mun_Codigo = new SelectList(db.tbMunicipio, "mun_codigo", "dep_codigo", tbProveedor.mun_codigo);
                        ModelState.AddModelError("", "Este RTN ya fue registrado.");
                        return(View(tbProveedor));
                    }
                    else
                    {
                        TempData["swalfunction"] = "true";
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception Ex)
            {
                Function.BitacoraErrores("Proveedor", "CreatePost", UserName, Ex.Message.ToString());
                ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                return(View());
            }
            ViewBag.dep_codigo = new SelectList(db.tbDepartamento, "dep_Codigo", "dep_Nombre", dep_codigo);
            ViewBag.acte_Id    = new SelectList(db.tbActividadEconomica, "acte_Id", "acte_Descripcion");
            ViewBag.mun_Codigo = new SelectList(db.tbMunicipio, "mun_codigo", "dep_codigo", tbProveedor.mun_codigo);

            if (dep_codigo != "ajax")
            {
                return(View("Create"));
            }
            else
            {
                return(Json("Create"));
            }
        }
        public ActionResult Create([Bind(Include = "Lianvide_Id,Lianvi_Id,Lianvide_FechaGasto,tpv_Id,Lianvide_MontoGasto,Lianvide_Concepto,Lianvide_UsuarioCrea,Lianvide_FechaCrea,Lianvide_UsuarioModifica,Lianvide_FechaModifica")] tbLiquidacionAnticipoViaticoDetalle tbLiquidacionAnticipoViaticoDetalle, HttpPostedFileBase ArchivoPath)
        {
            string UserName         = "";
            string MsjError         = "";
            string ErrorEmail       = "";
            var    listaLiquidacion = (List <tbLiquidacionAnticipoViaticoDetalle>)Session["NombreLiquidaciondetalle"];

            try
            {
                cGetUserInfo GetEmployee = null;
                cGetUserInfo EmpJefe = null;
                bool         Result = false, ResultAdm = false;
                ViewBag.tpv_Id = new SelectList(db.tbTipoViatico, "tpv_Id", "tpv_Descripcion");
                IEnumerable <object> lista = null;
                int EmployeeID             = Function.GetUser(out UserName);
                if (listaLiquidacion != null)
                {
                    if (listaLiquidacion.Count > 0)
                    {
                        foreach (tbLiquidacionAnticipoViaticoDetalle Sol in listaLiquidacion)
                        {
                            lista = db.UDP_Adm_tbLiquidacionAnticipoViaticoDetalle_Insert(tbLiquidacionAnticipoViaticoDetalle.Lianvi_Id, Sol.Lianvide_FechaGasto, Sol.tpv_Id, Sol.Lianvide_MontoGasto, Sol.Lianvide_Concepto, Sol.Lianvide_Archivo, EmployeeID, Function.DatetimeNow());
                            foreach (UDP_Adm_tbLiquidacionAnticipoViaticoDetalle_Insert_Result SolicitudDetalle in lista)
                            {
                                MsjError = SolicitudDetalle.MensajeError;
                            }
                            if (MsjError.StartsWith("-1"))
                            {
                                ModelState.AddModelError("", "No se pudo insertar el registro detalle, favor contacte al administrador.");
                                return(View(tbLiquidacionAnticipoViaticoDetalle));
                            }
                        }
                    }
                }

                GetEmployee = Function.GetUserInfo(EmployeeID);
                EmpJefe     = Function.GetUserInfo(EmployeeID);

                Result    = Function.LeerDatos(out ErrorEmail, MsjError, GetEmployee.emp_Nombres, GeneralFunctions.stringEmpty, GeneralFunctions.msj_Enviada, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, GetEmployee.emp_CorreoElectronico);
                ResultAdm = Function.LeerDatos(out ErrorEmail, MsjError, EmpJefe.emp_Nombres, GetEmployee.emp_Nombres, GeneralFunctions.msj_ToAdmin, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, EmpJefe.emp_CorreoElectronico);


                if (!Result)
                {
                    Function.BitacoraErrores("AccionPersonal", "CreatePost", UserName, ErrorEmail);
                }
                if (!ResultAdm)
                {
                    Function.BitacoraErrores("AccionPersonal", "CreatePost", UserName, ErrorEmail);
                }


                return(RedirectToAction("Index", "LiquidacionAnticipoViatico"));
            }
            catch (Exception)
            {
                TempData["swalfunction"] = GeneralFunctions._isCreated;
                ViewBag.Reemga_Id        = new SelectList(db.tbSolicitudReembolsoGastos, "Reemga_Id", "Reemga_Id");
                ViewBag.Reemga_Id        = new SelectList(db.tbSolicitudReembolsoGastos, "Reemga_Id", "Reemga_Correlativo");
                ViewBag.tpv_Id           = new SelectList(db.tbTipoViatico, "tpv_Id", "tpv_Descripcion");
                ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                return(View(tbLiquidacionAnticipoViaticoDetalle));
            }
        }
Example #23
0
        public async Task <ActionResult> Create([Bind(Include = "Acp_Id,Acp_Correlativo,emp_Id,Acp_JefeInmediato,Acp_FechaSolicitud,tipmo_id,Acp_Comentario,est_Id,Acp_RazonRechazo,Acp_UsuarioCrea,Acp_FechaCrea,Acp_UsuarioModifica,Acp_FechaModifica")] tbAccionPersonal tbAccionPersonal)
        {
            string UserName   = "",
                   ErrorEmail = "";

            try
            {
                cGetUserInfo GetEmployee = null;
                cGetUserInfo EmpJefe = null;
                bool         Result = false, ResultAdm = false;
                int          EmployeeID = Function.GetUser(out UserName);
                tbAccionPersonal.emp_Id             = EmployeeID;
                tbAccionPersonal.Acp_FechaSolicitud = Function.DatetimeNow();
                tbAccionPersonal.est_Id             = GeneralFunctions.Enviada;



                if (ModelState.IsValid)
                {
                    IEnumerable <object> Insert = null;
                    string ErrorMessage         = "";


                    Insert = db.UDP_Adm_tbAccionPersonal_Insert(EmployeeID,
                                                                tbAccionPersonal.Acp_JefeInmediato,
                                                                Function.DatetimeNow(),
                                                                tbAccionPersonal.Acp_Comentario,
                                                                GeneralFunctions.Enviada,
                                                                tbAccionPersonal.tipmo_id,
                                                                EmployeeID,
                                                                Function.DatetimeNow()
                                                                );
                    foreach (UDP_Adm_tbAccionPersonal_Insert_Result Res in Insert)
                    {
                        ErrorMessage = Res.MensajeError;
                    }

                    if (ErrorMessage.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("AccionPersonal", "CreatePost", UserName, ErrorMessage);
                        ModelState.AddModelError("", "No se pudo insertar el registro contacte al administrador.");
                    }
                    else
                    {
                        GetEmployee = Function.GetUserInfo(EmployeeID);
                        EmpJefe     = Function.GetUserInfo(tbAccionPersonal.Acp_JefeInmediato);

                        Result    = Function.LeerDatos(out ErrorEmail, ErrorMessage, GetEmployee.emp_Nombres, GeneralFunctions.stringEmpty, GeneralFunctions.msj_Enviada, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, GetEmployee.emp_CorreoElectronico);
                        ResultAdm = Function.LeerDatos(out ErrorEmail, ErrorMessage, EmpJefe.emp_Nombres, GetEmployee.emp_Nombres, GeneralFunctions.msj_ToAdmin, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, EmpJefe.emp_CorreoElectronico);


                        if (!Result)
                        {
                            Function.BitacoraErrores("AccionPersonal", "CreatePost", UserName, ErrorEmail);
                        }
                        if (!ResultAdm)
                        {
                            Function.BitacoraErrores("AccionPersonal", "CreatePost", UserName, ErrorEmail);
                        }

                        TempData["swalfunction"] = GeneralFunctions.sol_Enviada;
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                Function.BitacoraErrores("AccionPersonal", "CreatePost", UserName, ex.Message.ToString());
                return(RedirectToAction("Index"));
            }
            IEnumerable <object> Employee = (from _tbEmp in db.tbEmpleado
                                             where _tbEmp.emp_EsJefe == true
                                             select new { emp_Id = _tbEmp.emp_Id, emp_Nombres = _tbEmp.emp_Nombres + " " + _tbEmp.emp_Apellidos }).ToList();

            ViewBag.est_Id = new SelectList(db.tbEstado, "est_Id", "est_Descripcion");

            ViewBag.Acp_JefeInmediato = new SelectList(Employee, "emp_Id", "emp_Nombres");
            ViewBag.tipmo_id          = new SelectList(db.tbTipoMovimiento, "tipmo_id", "tipmo_Movimiento");
            ViewBag.emp_Id            = new SelectList(db.tbEmpleado, "emp_Id", "emp_Nombres");
            return(View(tbAccionPersonal));
        }
Example #24
0
        public ActionResult Create([Bind(Include = "Anvi_Id,Anvi_Correlativo,emp_Id,Anvi_JefeInmediato,Anvi_GralFechaSolicitud,Anvi_FechaViaje,Anvi_Cliente,mun_Codigo,Anvi_PropositoVisita,Anvi_DiasVisita,Anvi_Hospedaje,Anvi_tptran_Id,Anvi_Autorizacion,Anvi_Comentario,est_Id,Anvi_RazonRechazo,Anvi_UsuarioCrea,Anvi_FechaCrea,Anvi_UsuarioModifica,Anvi_FechaModifica")] tbAnticipoViatico tbAnticipoViatico, string dep_codigo)
        {
            string UserName = "", ErrorEmail = "", ErrorMessage = "";
            bool   Result = false, ResultAdm = false;
            IEnumerable <object> Insert = null;

            if (tbAnticipoViatico.mun_Codigo == "Seleccione Municipio")
            {
                ModelState.AddModelError("mun_codigo", "El campo Municipio es obligatorio.");
            }
            else
            {
                ViewBag.munCodigo = tbAnticipoViatico.mun_Codigo;
            }
            if (String.IsNullOrEmpty(dep_codigo))
            {
                ModelState.AddModelError("Anvi_UsuarioCrea", "El campo Departamento es obligatorio.");
            }
            try
            {
                int EmployeeID = Function.GetUser(out UserName);

                IEnumerable <object> Employee = (from _tbEmp in db.tbEmpleado
                                                 where _tbEmp.emp_EsJefe == true && _tbEmp.est_Id == GeneralFunctions.empleadoactivo && _tbEmp.emp_Id != EmployeeID
                                                 select new { emp_Id = _tbEmp.emp_Id, emp_Nombres = _tbEmp.emp_Nombres + " " + _tbEmp.emp_Apellidos }).ToList();

                ViewBag.dep_codigo         = new SelectList(db.tbDepartamento, "dep_Codigo", "dep_Nombre", dep_codigo);
                ViewBag.Anvi_JefeInmediato = new SelectList(db.tbEmpleado, "emp_Id", "emp_Nombres", tbAnticipoViatico.Anvi_JefeInmediato);
                ViewBag.mun_Codigo         = new SelectList(db.tbMunicipio, "mun_codigo", "dep_codigo", tbAnticipoViatico.mun_Codigo);
                ViewBag.Anvi_tptran_Id     = new SelectList(db.tbTipoTransporte, "tptran_Id", "tptran_Descripcion", tbAnticipoViatico.Anvi_tptran_Id);

                tbAnticipoViatico.emp_Id = EmployeeID;
                tbAnticipoViatico.Anvi_GralFechaSolicitud = Function.DatetimeNow();
                tbAnticipoViatico.est_Id = GeneralFunctions.Enviada;



                if (String.IsNullOrEmpty(tbAnticipoViatico.Anvi_Comentario))
                {
                    tbAnticipoViatico.Anvi_Comentario = GeneralFunctions.stringDefault;
                }

                if (ModelState.IsValid)
                {
                    Insert = db.UDP_Adm_tbAnticipoViatico_Insert(EmployeeID,
                                                                 tbAnticipoViatico.Anvi_JefeInmediato,
                                                                 Function.DatetimeNow(),
                                                                 tbAnticipoViatico.Anvi_FechaViaje,
                                                                 tbAnticipoViatico.Anvi_Cliente.ToUpper(),
                                                                 tbAnticipoViatico.mun_Codigo,
                                                                 tbAnticipoViatico.Anvi_PropositoVisita,
                                                                 tbAnticipoViatico.Anvi_DiasVisita,
                                                                 tbAnticipoViatico.Anvi_Hospedaje,
                                                                 tbAnticipoViatico.Anvi_tptran_Id,
                                                                 tbAnticipoViatico.Anvi_Autorizacion,
                                                                 tbAnticipoViatico.Anvi_Comentario,
                                                                 tbAnticipoViatico.est_Id,
                                                                 EmployeeID,
                                                                 Function.DatetimeNow());
                    foreach (UDP_Adm_tbAnticipoViatico_Insert_Result Res in Insert)
                    {
                        ErrorMessage = Res.MensajeError;
                    }

                    if (ErrorMessage.StartsWith("-1"))
                    {
                        Function.BitacoraErrores("AnticipoViatico", "CreatePost", UserName, ErrorMessage);
                        ModelState.AddModelError("", "No se pudo insertar el registro contacte al administrador.");
                    }
                    else
                    {
                        var GetEmployee = Function.GetUserInfo(EmployeeID);
                        var EmpJefe     = Function.GetUserInfo(tbAnticipoViatico.Anvi_JefeInmediato);

                        Result    = Function.LeerDatos(out ErrorEmail, ErrorMessage, GetEmployee.emp_Nombres, GeneralFunctions.stringEmpty, GeneralFunctions.msj_Enviada, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, GetEmployee.emp_CorreoElectronico);
                        ResultAdm = Function.LeerDatos(out ErrorEmail, ErrorMessage, EmpJefe.emp_Nombres, GetEmployee.emp_Nombres, GeneralFunctions.msj_ToAdmin, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, EmpJefe.emp_CorreoElectronico);


                        if (!Result)
                        {
                            Function.BitacoraErrores("AnticipoViatico", "CreatePost", UserName, ErrorEmail);
                        }
                        if (!ResultAdm)
                        {
                            Function.BitacoraErrores("AnticipoViatico", "CreatePost", UserName, ErrorEmail);
                        }

                        TempData["swalfunction"] = GeneralFunctions.sol_Enviada;
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                Function.BitacoraErrores("AnticipoViatico", "CreatePost", UserName, ex.Message.ToString());
            }

            return(View(tbAnticipoViatico));
        }
Example #25
0
        public ActionResult Create([Bind(Include = "Reqco_Id")] tbRequisionCompraDetalle tbRequisionCompraDetalle)
        {
            IEnumerable <object> List = null;
            string UserName = "", ErrorEmail = "", ErrorMessage = "", MensajeError = "";
            bool   Result = false, ResultAdm = false;
            var    listaDetalle = (List <tbRequisionCompraDetalle>)Session["RequisionCompraDetalle"];

            try
            {
                ViewBag.prod_Id  = new SelectList(db.tbProducto, "prod_Id", "prod_Descripcion");
                ViewBag.Producto = db.tbProducto.Where(x => x.prod_EsActivo == true).ToList();
                int          EmployeeID  = Function.GetUser(out UserName);
                cGetUserInfo GetEmployee = null;
                cGetUserInfo EmpJefe     = null;
                ErrorMessage = (from _d in db.tbRequisionCompra where _d.Reqco_Id == tbRequisionCompraDetalle.Reqco_Id select _d.Reqco_Correlativo).FirstOrDefault();

                if (listaDetalle != null)
                {
                    if (listaDetalle.Count > 0)
                    {
                        foreach (tbRequisionCompraDetalle RequisionCompraDetalle in listaDetalle)
                        {
                            List = db.UDP_Adm_tbRequisionCompraDetalle_Insert(tbRequisionCompraDetalle.Reqco_Id,
                                                                              RequisionCompraDetalle.prod_Id, RequisionCompraDetalle.Cantidad, RequisionCompraDetalle.Reqde_Justificacion, EmployeeID, Function.DatetimeNow());
                            foreach (UDP_Adm_tbRequisionCompraDetalle_Insert_Result RequisionCompra in List)
                            {
                                MensajeError = RequisionCompra.MensajeError;
                            }
                            if (MensajeError.StartsWith("-1"))
                            {
                                ModelState.AddModelError("", "No se pudo insertar el registro detalle, favor contacte al administrador.");
                                return(View(tbRequisionCompraDetalle));
                            }
                        }
                        var UserInfo = (from _emp in db.tbEmpleado
                                        join _pto in db.tbPuesto on _emp.pto_Id equals _pto.pto_Id
                                        join _are in db.tbArea on _pto.are_Id equals _are.are_Id
                                        where _emp.emp_Id == EmployeeID
                                        select new { _emp, _are, _pto }).FirstOrDefault();

                        var UserAreaInfo = (from _emp in db.tbEmpleado
                                            join _pto in db.tbPuesto on _emp.pto_Id equals _pto.pto_Id
                                            join _are in db.tbArea on _pto.are_Id equals _are.are_Id
                                            where _emp.emp_EsJefe == true && _pto.are_Id == UserInfo._are.are_Id && _pto.pto_Id == UserInfo._pto.pto_Id
                                            select new { _emp, _are }).FirstOrDefault();

                        GetEmployee = Function.GetUserInfo(EmployeeID);
                        EmpJefe     = Function.GetUserInfo(UserAreaInfo._emp.emp_Id);


                        Result    = Function.LeerDatos(out ErrorEmail, ErrorMessage, GetEmployee.emp_Nombres, GeneralFunctions.stringEmpty, GeneralFunctions.msj_Enviada, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, GetEmployee.emp_CorreoElectronico);
                        ResultAdm = Function.LeerDatos(out ErrorEmail, ErrorMessage, EmpJefe.emp_Nombres, GetEmployee.emp_Nombres, GeneralFunctions.msj_ToAdmin, GeneralFunctions.stringEmpty, GeneralFunctions.stringEmpty, EmpJefe.emp_CorreoElectronico);

                        if (!Result)
                        {
                            Function.BitacoraErrores("VacacionesPermisosEspeciales", "CreatePost", UserName, ErrorEmail);
                        }
                        if (!ResultAdm)
                        {
                            Function.BitacoraErrores("VacacionesPermisosEspeciales", "CreatePost", UserName, ErrorEmail);
                        }
                        return(RedirectToAction("Index", "RequisionCompra"));
                    }
                    ModelState.AddModelError("ValidationSummary", "Agregar un registro a la tabla");
                }
            }

            catch (Exception Ex)
            {
                Function.BitacoraErrores("RequisionCompraDetalle", "CreatePost", UserName, Ex.Message.ToString());
            }
            return(View(tbRequisionCompraDetalle));
        }