Пример #1
0
        public ActionResult IndexSuppliers()
        {
            ViewBag.AllowAdd      = this.HasPermission(ControllerName.Setups + "-CreateSuppliers");
            ViewBag.AllowEdit     = this.HasPermission(ControllerName.Setups + "-EditSuppliers");
            ViewBag.AllowLoadEdit = this.HasPermission(ControllerName.Setups + "-LoadEditSuppliers");
            ViewBag.AllowDelete   = this.HasPermission(ControllerName.Setups + "-DeleteSuppliers");

            DataTable dtRegion = RegionsBI.GetRegions();

            ViewData["RegionName"] = General.DataTableToSelectList(dtRegion, "RegionId", "RegionName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtDistrict = DistrictsBI.GetDistricts();

            ViewData["DistrictName"] = General.DataTableToSelectList(dtDistrict, "DistrictId", "DistrictName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });


            Suppliers eSuppliers = new Suppliers();

            eSuppliers.dtSuppliers = SuppliersBI.GetSuppliers();
            return(View(eSuppliers));
        }
Пример #2
0
        public ActionResult DeleteSuppliers(Suppliers eSuppliers)
        {
            string message = "";

            try
            {
                if (eSuppliers.SupplierId > 0)
                {
                    FASM_Enums.InfoMessages DeleteResult = SuppliersBI.DeleteSuppliers(eSuppliers.SupplierId);
                    switch (DeleteResult)
                    {
                    case FASM_Enums.InfoMessages.Success:
                        message = "Successfully Deleted!";
                        break;

                    case FASM_Enums.InfoMessages.Failed:
                        message = "Still in Use!";
                        break;
                    }
                    return(new JsonResult {
                        Data = message, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    });
                }
            }
            catch (Exception ex)
            {
                ViewBag.CatchedMsg = ex.Message;
            }
            return(View());
        }
Пример #3
0
        public ActionResult IndexAssetRegister()
        {
            ViewBag.AllowAdd    = this.HasPermission(ControllerName.AssetManagement + "-CreateAssetRegister");
            ViewBag.AllowEdit   = this.HasPermission(ControllerName.AssetManagement + "-EditAssetRegister");
            ViewBag.AllowDelete = this.HasPermission(ControllerName.AssetManagement + "-DeleteAssetRegister");

            DataTable dtGetAssetName = AssetDefinitionBI.GetAssetDefinition();

            ViewData["AssetName"] = General.DataTableToSelectList(dtGetAssetName, "AssetDefinitionId", "AssetName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetSupplier = SuppliersBI.GetSuppliers();

            ViewData["SupplierName"] = General.DataTableToSelectList(dtGetSupplier, "SupplierId", "SupplierFullName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetLocation = LocationBI.GetLocation();

            ViewData["LocationName"] = General.DataTableToSelectList(dtGetLocation, "LocationId", "LocationName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetDepartment = DepartmentsBI.GetDepartments();

            ViewData["DepartmentName"] = General.DataTableToSelectList(dtGetDepartment, "DepartmentId", "DepartmentName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetCustodian = EmployeesBI.GetEmployees();

            ViewData["CustodianName"] = General.DataTableToSelectList(dtGetCustodian, "EmployeeId", "FirstName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });


            DataTable dtGetAssetConditions = General.GetAssetConditions();

            ViewData["AssetConditions"] = General.DataTableToSelectList(dtGetAssetConditions, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetAssetStatus = General.GetAssetStatus();

            ViewData["AssetStatuses"] = General.DataTableToSelectList(dtGetAssetStatus, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            ViewBag.PreloadDate = DateTime.Now.ToString("dd MMMM yyyy");

            AssetRegister eAssetRegister = new AssetRegister();

            eAssetRegister.dtAssetRegister = AssetRegisterBI.GetAssetRegister();
            return(View(eAssetRegister));
        }
Пример #4
0
        public ActionResult CreateAssetRegister()
        {
            AssetRegister eAssetRegister = new AssetRegister();
            DataTable     dtGetAssetName = AssetDefinitionBI.GetAssetDefinition();

            ViewData["AssetName"] = General.DataTableToSelectList(dtGetAssetName, "AssetDefinitionId", "AssetName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetSupplier = SuppliersBI.GetSuppliers();

            ViewData["SupplierName"] = General.DataTableToSelectList(dtGetSupplier, "SupplierId", "SupplierFullName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetLocation = LocationBI.GetLocation();

            ViewData["LocationName"] = General.DataTableToSelectList(dtGetLocation, "LocationId", "LocationName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetDepartment = DepartmentsBI.GetDepartments();

            ViewData["DepartmentName"] = General.DataTableToSelectList(dtGetDepartment, "DepartmentId", "DepartmentName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetCustodian = EmployeesBI.GetEmployees();

            ViewData["CustodianName"] = General.DataTableToSelectList(dtGetCustodian, "EmployeeId", "FirstName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });


            DataTable dtGetAssetConditions = General.GetAssetConditions();

            ViewData["AssetConditions"] = General.DataTableToSelectList(dtGetAssetConditions, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetAssetStatus = General.GetAssetStatus();

            ViewData["AssetStatuses"] = General.DataTableToSelectList(dtGetAssetStatus, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            ViewBag.PreloadDate = DateTime.Now.ToString("dd MMMM yyyy");
            return(View(eAssetRegister));
        }
Пример #5
0
        public ActionResult EditSuppliers(Suppliers eSuppliers)
        {
            if (eSuppliers.isLoad == false)
            {
                DataTable dtRegion = RegionsBI.GetRegions();
                ViewData["RegionName"] = General.DataTableToSelectList(dtRegion, "RegionId", "RegionName", "0", TopEmptyItem: new SelectListItem {
                    Value = "0", Text = ""
                });

                DataTable dtDistrict = DistrictsBI.GetDistricts();
                ViewData["DistrictName"] = General.DataTableToSelectList(dtDistrict, "DistrictId", "DistrictName", "0", TopEmptyItem: new SelectListItem {
                    Value = "0", Text = ""
                });

                eSuppliers.SupplierId = Convert.ToInt32(Request.Params["SupplierId"]);
                SuppliersBI.LoadSuppliers(ref eSuppliers);
                return(PartialView(eSuppliers));
            }
            else
            {
                string message = "";
                if (ModelState.IsValid)
                {
                    try
                    {
                        FASM_Enums.InfoMessages Results = SuppliersBI.SaveSuppliers(ref eSuppliers);

                        switch (Results)
                        {
                        case FASM_Enums.InfoMessages.Success:
                            message = FASM_Msg.Updated;
                            break;

                        case FASM_Enums.InfoMessages.AlreadyExist:
                            message = "Sorry! the Email " + eSuppliers.Email + " " + FASM_Msg.AlreadyExist;
                            break;
                        }
                        return(Json(new { msg = message, JsonRequestBehavior.AllowGet }));
                    }
                    catch (Exception ex)
                    {
                        ViewBag.CatchedMsg = ex.Message;
                    }
                }
            }

            return(View(eSuppliers));
        }
Пример #6
0
        public ActionResult CreateSuppliers(Suppliers eSuppliers)
        {
            string message = "";

            if (ModelState.IsValid)
            {
                try
                {
                    DataTable dtRegion = RegionsBI.GetRegions();
                    ViewData["RegionName"] = General.DataTableToSelectList(dtRegion, "RegionId", "RegionName", "0", TopEmptyItem: new SelectListItem {
                        Value = "0", Text = ""
                    });

                    DataTable dtDistrict = DistrictsBI.GetDistricts();
                    ViewData["DistrictName"] = General.DataTableToSelectList(dtDistrict, "DistrictId", "DistrictName", "0", TopEmptyItem: new SelectListItem {
                        Value = "0", Text = ""
                    });

                    FASM_Enums.InfoMessages SaveResult = SuppliersBI.SaveSuppliers(ref eSuppliers);
                    switch (SaveResult)
                    {
                    case FASM_Enums.InfoMessages.Success:
                        message = FASM_Msg.SuccessfulSaved;
                        break;

                    case FASM_Enums.InfoMessages.AlreadyExist:
                        message = FASM_Msg.AlreadyExist;
                        break;
                    }
                    return(Json(new { msg = message, JsonRequestBehavior.AllowGet }));
                }
                catch (Exception ex)
                {
                    ViewBag.CatchedMsg = ex.Message;
                }
            }

            return(View(eSuppliers));
        }
Пример #7
0
        public ActionResult EditAssetRegister(AssetRegister eAssetRegister)
        {
            if (ModelState.IsValid)
            {
                DataTable dtGetAssetName = AssetDefinitionBI.GetAssetDefinition();
                ViewData["AssetName"] = General.DataTableToSelectList(dtGetAssetName, "AssetDefinitionId", "AssetName", "0", TopEmptyItem: new SelectListItem {
                    Value = "0", Text = ""
                });

                DataTable dtGetSupplier = SuppliersBI.GetSuppliers();
                ViewData["SupplierName"] = General.DataTableToSelectList(dtGetSupplier, "SupplierId", "SupplierFullName", "0", TopEmptyItem: new SelectListItem {
                    Value = "0", Text = ""
                });

                DataTable dtGetLocation = LocationBI.GetLocation();
                ViewData["LocationName"] = General.DataTableToSelectList(dtGetLocation, "LocationId", "LocationName", "0", TopEmptyItem: new SelectListItem {
                    Value = "0", Text = ""
                });

                DataTable dtGetDepartment = DepartmentsBI.GetDepartments();
                ViewData["DepartmentName"] = General.DataTableToSelectList(dtGetDepartment, "DepartmentId", "DepartmentName", "0", TopEmptyItem: new SelectListItem {
                    Value = "0", Text = ""
                });

                DataTable dtGetCustodian = EmployeesBI.GetEmployees();
                ViewData["CustodianName"] = General.DataTableToSelectList(dtGetCustodian, "EmployeeId", "FirstName", "0", TopEmptyItem: new SelectListItem {
                    Value = "0", Text = ""
                });

                DataTable dtGetAssetConditions = General.GetAssetConditions();
                ViewData["AssetConditions"] = General.DataTableToSelectList(dtGetAssetConditions, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                    Value = "0", Text = ""
                });

                DataTable dtGetAssetStatus = General.GetAssetStatus();
                ViewData["AssetStatuses"] = General.DataTableToSelectList(dtGetAssetStatus, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                    Value = "0", Text = ""
                });

                ViewBag.PurchaseDate = eAssetRegister.PurchaseDate.ToString("dd/MMM/yyyy");
                if (eAssetRegister.WarrantyExpiry != null)
                {
                    ViewBag.WarantyExpiry = Convert.ToDateTime(eAssetRegister.WarrantyExpiry).ToString("dd/MMM/yyyy");
                }
                if (eAssetRegister.ImagePath != null)
                {
                    ViewBag.ImagePath = eAssetRegister.ImagePath;
                }
                try
                {
                    HttpPostedFileBase file = Request.Files["ImageFile"];
                    if (file.FileName != "")
                    {
                        Random rmd       = new Random();
                        string FileName  = Path.GetFileNameWithoutExtension(file.FileName);
                        string Extension = Path.GetExtension(eAssetRegister.ImageFile.FileName);
                        if (Extension == ".jpg" || Extension == ".png")
                        {
                            FileName = FileName + rmd.Next(100) + Extension;
                            eAssetRegister.ImagePath = "~/images/" + FileName;

                            AssetRegister eNewAssetRegister = new AssetRegister();
                            eNewAssetRegister.AssetRegisterId = eAssetRegister.AssetRegisterId;
                            AssetRegisterBI.LoadAssetRegister(ref eNewAssetRegister);
                            string filepath = eNewAssetRegister.ImagePath;
                            //Deleting the old photo
                            if (filepath != "")
                            {
                                filepath = Server.MapPath(filepath);
                                if (System.IO.File.Exists(filepath))
                                {
                                    System.IO.File.Delete(filepath);
                                }
                            }
                            //Saving the updated image
                            FileName = Path.Combine(Server.MapPath("/images/"), FileName);
                            file.SaveAs(FileName);
                        }
                        else
                        {
                            ModelState.AddModelError("Success", "Unrequired format. Only .jpg and .png images are permitted");
                            ViewBag.ReturnMsg = "Failed";
                            return(View(eAssetRegister));
                        }
                    }
                    else
                    {
                        AssetRegister eNewAssetRegister = new AssetRegister();
                        eNewAssetRegister.AssetRegisterId = eAssetRegister.AssetRegisterId;
                        AssetRegisterBI.LoadAssetRegister(ref eNewAssetRegister);
                        string filepath = eNewAssetRegister.ImagePath;
                        eAssetRegister.ImagePath = filepath;
                    }
                    FASM_Enums.InfoMessages Results = AssetRegisterBI.SaveAssetRegister(ref eAssetRegister);
                    switch (Results)
                    {
                    case FASM_Enums.InfoMessages.Success:
                        ModelState.AddModelError("Success", FASM_Msg.Updated);
                        ViewBag.ReturnMsg = "Success";
                        break;

                    case FASM_Enums.InfoMessages.AlreadyExist:
                        ModelState.AddModelError("Success", "Sorry! the Asset Code already exist");
                        ViewBag.ReturnMsg = "Failed";
                        break;
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
            }
            return(View(eAssetRegister));
        }
Пример #8
0
        public ActionResult EditAssetRegister()
        {
            AssetRegister eAssetRegister = new AssetRegister();

            DataTable dtGetAssetName = AssetDefinitionBI.GetAssetDefinition();

            ViewData["AssetName"] = General.DataTableToSelectList(dtGetAssetName, "AssetDefinitionId", "AssetName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetSupplier = SuppliersBI.GetSuppliers();

            ViewData["SupplierName"] = General.DataTableToSelectList(dtGetSupplier, "SupplierId", "SupplierFullName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetLocation = LocationBI.GetLocation();

            ViewData["LocationName"] = General.DataTableToSelectList(dtGetLocation, "LocationId", "LocationName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetDepartment = DepartmentsBI.GetDepartments();

            ViewData["DepartmentName"] = General.DataTableToSelectList(dtGetDepartment, "DepartmentId", "DepartmentName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetCustodian = EmployeesBI.GetEmployees();

            ViewData["CustodianName"] = General.DataTableToSelectList(dtGetCustodian, "EmployeeId", "FirstName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });


            DataTable dtGetAssetConditions = General.GetAssetConditions();

            ViewData["AssetConditions"] = General.DataTableToSelectList(dtGetAssetConditions, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetAssetStatus = General.GetAssetStatus();

            ViewData["AssetStatuses"] = General.DataTableToSelectList(dtGetAssetStatus, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            try
            {
                string IdVal = Url.RequestContext.RouteData.Values["Id"].ToString();
                if (General.IsNumeric(IdVal))
                {
                    eAssetRegister.AssetRegisterId = int.Parse(IdVal);
                }

                if (eAssetRegister.AssetRegisterId > 0)
                {
                    AssetRegisterBI.LoadAssetRegister(ref eAssetRegister);
                    ViewBag.PurchaseDate = eAssetRegister.PurchaseDate.ToString("dd/MMM/yyyy");
                    if (eAssetRegister.WarrantyExpiry != null)
                    {
                        ViewBag.WarantyExpiry = Convert.ToDateTime(eAssetRegister.WarrantyExpiry).ToString("dd/MMM/yyyy");
                    }
                    if (eAssetRegister.ImagePath != null)
                    {
                        ViewBag.ImagePath = eAssetRegister.ImagePath;
                    }
                }
                if (eAssetRegister.AssetRegisterId == 0)
                {
                    return(RedirectToAction("IndexAssetIdentity", ControllerName.AssetManagement));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
            }
            return(View(eAssetRegister));
        }
Пример #9
0
        public ActionResult CreateAssetRegister(AssetRegister eAssetRegister)
        {
            DataTable dtGetAssetName = AssetDefinitionBI.GetAssetDefinition();

            ViewData["AssetName"] = General.DataTableToSelectList(dtGetAssetName, "AssetDefinitionId", "AssetName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetSupplier = SuppliersBI.GetSuppliers();

            ViewData["SupplierName"] = General.DataTableToSelectList(dtGetSupplier, "SupplierId", "SupplierFullName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetLocation = LocationBI.GetLocation();

            ViewData["LocationName"] = General.DataTableToSelectList(dtGetLocation, "LocationId", "LocationName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetDepartment = DepartmentsBI.GetDepartments();

            ViewData["DepartmentName"] = General.DataTableToSelectList(dtGetDepartment, "DepartmentId", "DepartmentName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetCustodian = EmployeesBI.GetEmployees();

            ViewData["CustodianName"] = General.DataTableToSelectList(dtGetCustodian, "EmployeeId", "FirstName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetAssetConditions = General.GetAssetConditions();

            ViewData["AssetConditions"] = General.DataTableToSelectList(dtGetAssetConditions, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtGetAssetStatus = General.GetAssetStatus();

            ViewData["AssetStatuses"] = General.DataTableToSelectList(dtGetAssetStatus, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            ViewBag.PreloadDate = DateTime.Now.ToString("dd MMMM yyyy");

            HttpPostedFileBase file = Request.Files["ImageFile"];

            if (file.FileName != "")
            {
                Random rmd       = new Random();
                string FileName  = Path.GetFileNameWithoutExtension(file.FileName);
                string Extension = Path.GetExtension(eAssetRegister.ImageFile.FileName);
                if (Extension == ".jpg" || Extension == ".png")
                {
                    FileName = FileName + rmd.Next(100) + Extension;
                    eAssetRegister.ImagePath = "~/images/" + FileName;
                    FileName = Path.Combine(Server.MapPath("/images/"), FileName);
                    file.SaveAs(FileName);
                }
                else
                {
                    ModelState.AddModelError("Success", "Unrequired format. Only .jpg and .png images are permitted");
                    ViewBag.ReturnMsg = "Failed";
                    return(View(eAssetRegister));
                }
            }
            if (ModelState.IsValid)
            {
                try
                {
                    FASM_Enums.InfoMessages SaveResult = AssetRegisterBI.SaveAssetRegister(ref eAssetRegister);
                    switch (SaveResult)
                    {
                    case FASM_Enums.InfoMessages.Success:
                        ModelState.AddModelError("Success", FASM_Msg.SuccessfulSaved);
                        ViewBag.ReturnMsg = "Success";
                        break;

                    case FASM_Enums.InfoMessages.AlreadyExist:
                        ModelState.AddModelError("Success", "Asset Code already exist!");
                        ViewBag.ReturnMsg = "Failed";
                        break;
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
            }
            return(View(eAssetRegister));
        }