Beispiel #1
0
        public ActionResult UpdateOwnerDetails(AccountOwner OwnerDetails)
        {
            try
            {
                AccountOwner accountOwner = new AccountOwner();
                accountOwner                 = db.AccountOwner.Find(OwnerDetails.OwnerID);
                accountOwner.OwnerName       = OwnerDetails.OwnerName;
                accountOwner.UpdateBy        = AppUtils.GetLoginUserID();
                accountOwner.UpdateDate      = AppUtils.GetDateTimeNow();
                db.Entry(accountOwner).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                var owner =
                    new AccountOwnerViewModel()
                {
                    OwnerID   = accountOwner.OwnerID,
                    OwnerName = accountOwner.OwnerName,
                };
                var JSON = Json(new { success = true, owner = owner }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch (Exception ex)
            {
                return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult UpdateAttendanceType(AttendanceType type)
        {
            try
            {
                AttendanceType dbAttendanceType = new AttendanceType();
                dbAttendanceType = db.AttendanceTypes.Find(type.AttendanceTypeID);
                dbAttendanceType.AttendanceName  = type.AttendanceName;
                dbAttendanceType.UpdateBy        = AppUtils.GetLoginUserID();
                dbAttendanceType.UpdateDate      = AppUtils.GetDateTimeNow();
                db.Entry(dbAttendanceType).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                var AttendacnceType =
                    new AttendanceTypeViewModel()
                {
                    AttendanceTypeID     = type.AttendanceTypeID,
                    AttendanceName       = type.AttendanceName,
                    UpdateAttendanceType = ISP_ManagementSystemModel.AppUtils.HasAccessInTheList(ISP_ManagementSystemModel.AppUtils.Update_Attendance_Type) ? true : false,
                };
                var JSON = Json(new { UpdateSuccess = true, AttenDanceTypeInformation = AttendacnceType }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch
            {
                return(Json(new { UpdateSuccess = false, EMPLH = "" }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #3
0
        public ActionResult UpdateDeposit(FormCollection form, HttpPostedFileBase DepositUpdateImage)
        {
            Deposit Deposit_Details = JsonConvert.DeserializeObject <Deposit>(form["Deposit_details"]);
            Deposit Deposit_Db      = db.Deposit.Where(s => s.DepositID == Deposit_Details.DepositID).FirstOrDefault();

            try
            {
                AddGivenImageInCurrentRow(ref Deposit_Db, Deposit_Details, "DescriptionFile", DepositUpdateImage, form["DescriptionFilePath"]);

                if (Deposit_Db.DepositID > 0)
                {
                    SetClientDepositToDatabaseDB(ref Deposit_Db, Deposit_Details);

                    db.Entry(Deposit_Db).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    AccountingHistory accountingHistory = db.AccountingHistory.Where(x => x.DepositID == Deposit_Db.DepositID).FirstOrDefault();
                    //Mode 1 mean Create 2 mean Update
                    SetInformationForAccountHistory(ref accountingHistory, Deposit_Db, 2);
                    db.AccountingHistory.Add(accountingHistory);
                    db.SaveChanges();
                    return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #4
0
        public ActionResult UpdateVendorType(VendorType VendorType)
        {
            try
            {
                VendorType dbVendorType = new VendorType();
                dbVendorType = db.VendorTypes.Find(VendorType.VendorTypeID);
                dbVendorType.VendorTypeName  = VendorType.VendorTypeName;
                dbVendorType.UpdateBy        = AppUtils.GetLoginUserID();
                dbVendorType.UpdateDate      = AppUtils.GetDateTimeNow();
                db.Entry(dbVendorType).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                var vendor =
                    new VendorTypeViewModel()
                {
                    VendorTypeID     = VendorType.VendorTypeID,
                    VendorTypeName   = VendorType.VendorTypeName,
                    UpdateVendorType = ISP_ManagementSystemModel.AppUtils.HasAccessInTheList(ISP_ManagementSystemModel.AppUtils.Update_Vendor_Type) ? true : false,
                };
                var JSON = Json(new { UpdateSuccess = true, vendor = vendor }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch (Exception ex)
            {
                return(Json(new { UpdateSuccess = false }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #5
0
        public ActionResult UpdateInitialBalance(AccountList accountlist)
        {
            try
            {
                AccountList Account = new AccountList();
                Account = db.AccountList.Find(accountlist.AccountListID);
                Account.InitialBalance  = accountlist.InitialBalance;
                Account.UpdateBy        = AppUtils.GetLoginUserID();
                Account.UpdateDate      = AppUtils.GetDateTimeNow();
                db.Entry(Account).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();


                AccountingHistory accountingHistory = db.AccountingHistory.Where(x => x.AccountListID == accountlist.AccountListID).FirstOrDefault();
                //Mode 1 mean Create 2 mean Update
                SetInformationForAccountHistory(ref accountingHistory, accountlist, 2);
                db.Entry(accountingHistory).State = EntityState.Modified;
                db.SaveChanges();

                var JSON = Json(new { success = true }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch (Exception ex)
            {
                return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #6
0
        //[ValidateAntiForgeryToken]
        public ActionResult UpdateItem(Item ItemInfoForUpdate)
        {
            try
            {
                Item Item_Check = db.Item.Where(s => s.ItemID != ItemInfoForUpdate.ItemID && s.ItemName == ItemInfoForUpdate.ItemName.Trim()).FirstOrDefault();

                if (Item_Check != null)
                {
                    return(Json(new { UpdateSuccess = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet));
                }

                var Item_db = db.Item.Where(s => s.ItemID == ItemInfoForUpdate.ItemID);
                ItemInfoForUpdate.ItemFor     = Item_db.FirstOrDefault().ItemFor;
                ItemInfoForUpdate.CreatedBy   = Item_db.FirstOrDefault().CreatedBy;
                ItemInfoForUpdate.CreatedDate = Item_db.FirstOrDefault().CreatedDate;
                ItemInfoForUpdate.UpdateBy    = AppUtils.GetLoginEmployeeName();
                ItemInfoForUpdate.UpdateDate  = AppUtils.GetDateTimeNow();

                db.Entry(Item_db.SingleOrDefault()).CurrentValues.SetValues(ItemInfoForUpdate);
                db.SaveChanges();

                TempData["UpdateSucessOrFail"] = "Update Successfully.";
                var Item_Return = Item_db.Select(s => new { ItemID = s.ItemID, PackageName = s.ItemName, ItemFor = s.ItemFor });
                var JSON        = Json(new { UpdateSuccess = true, ItemUpdateInformation = Item_Return, ItemFor = Enum.GetName(typeof(ItemFor), Item_Return.FirstOrDefault().ItemFor) }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch
            {
                TempData["UpdateSucessOrFail"] = "Update Fail.";
                return(Json(new { UpdateSuccess = false, ItemUpdateInformation = "" }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #7
0
        public ActionResult UpdateVendorFromPopUp(FormCollection form, HttpPostedFileBase VendorUpdateImage)
        {
            Vendor Vendor_details = JsonConvert.DeserializeObject <Vendor>(form["Vendor_details"]);
            Vendor vendor_DB      = db.Vendor.Where(s => s.VendorID == Vendor_details.VendorID).FirstOrDefault();

            try
            {
                //AddGivenImageInCurrentRow(ref vendor_DB, Vendor_details, "Vendor_Image", VendorUpdateImage, Vendor_details.VendorImagePath);
                AddGivenImageInCurrentRow(ref vendor_DB, Vendor_details, "Vendor_Image", VendorUpdateImage, form["VendorImagePath"]);
                if (vendor_DB.VendorID > 0)
                {
                    vendor_DB.VendorName          = Vendor_details.VendorName;
                    vendor_DB.VendorEmail         = Vendor_details.VendorEmail;
                    vendor_DB.VendorAddress       = Vendor_details.VendorAddress;
                    vendor_DB.VendorContactPerson = Vendor_details.VendorContactPerson;
                    vendor_DB.VendorTypeID        = Vendor_details.VendorTypeID;
                    vendor_DB.CompanyName         = Vendor_details.CompanyName;
                    vendor_DB.UpdateBy            = AppUtils.GetLoginUserID();
                    vendor_DB.UpdateDate          = AppUtils.GetDateTimeNow();
                    db.Entry(vendor_DB).State     = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    return(Json(new { UpdateSuccess = true, vendor = vendor_DB, vendorTypeName = db.VendorTypes.Find(vendor_DB.VendorTypeID).VendorTypeName }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
            }
        }
        //[ValidateAntiForgeryToken]
        public ActionResult UpdateDutyShift(DutyShift DutyShiftForUpdate)
        {
            try
            {
                DutyShift dutyShift = new DutyShift();
                dutyShift             = db.DutyShifts.Find(DutyShiftForUpdate.DutyShiftID);
                dutyShift.UpdateBy    = AppUtils.GetLoginUserID();
                dutyShift.UpdateTime  = AppUtils.GetDateTimeNow();
                dutyShift.StartHour   = DutyShiftForUpdate.StartHour;
                dutyShift.StartMinute = DutyShiftForUpdate.StartMinute;
                dutyShift.EndHour     = DutyShiftForUpdate.EndHour;
                dutyShift.EndMinute   = DutyShiftForUpdate.EndMinute;

                db.Entry(dutyShift).State = EntityState.Modified;
                db.SaveChanges();

                DutyShiftViewModel Shift = new DutyShiftViewModel();
                Shift.DutyShiftID = dutyShift.DutyShiftID;
                Shift.StartHour   = dutyShift.StartHour;
                Shift.StartMinute = dutyShift.StartMinute;
                Shift.EndMinute   = dutyShift.EndMinute;
                Shift.EndHour     = dutyShift.EndHour;


                return(Json(new { UpdateSuccess = true, Shift = Shift }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new { UpdateSuccess = false, EMPLH = "" }, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult UpdateIPPool(IPPool IPPoolInfoForUpdate)
        {
            try
            {
                IPPool IPPool_Check = db.IPPool.Where(s => s.IPPoolID != IPPoolInfoForUpdate.IPPoolID && s.PoolName == IPPoolInfoForUpdate.PoolName.Trim()).FirstOrDefault();

                if (IPPool_Check != null)
                {
                    //TempData["AlreadyInsert"] = "IPPool Already Added. Choose different IPPool. ";

                    return(Json(new { UpdateSuccess = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet));
                }

                var IPPool_db = db.IPPool.Where(s => s.IPPoolID == IPPoolInfoForUpdate.IPPoolID);
                IPPoolInfoForUpdate.CreatedBy   = IPPool_db.FirstOrDefault().CreatedBy;
                IPPoolInfoForUpdate.CreatedDate = IPPool_db.FirstOrDefault().CreatedDate;
                IPPoolInfoForUpdate.UpdateBy    = AppUtils.GetLoginUserID();
                IPPoolInfoForUpdate.UpdateDate  = AppUtils.GetDateTimeNow();

                db.Entry(IPPool_db.SingleOrDefault()).CurrentValues.SetValues(IPPoolInfoForUpdate);
                db.SaveChanges();

                TempData["UpdateSucessOrFail"] = "Update Successfully.";
                var IPPool_Return = IPPool_db;
                var JSON          = Json(new { UpdateSuccess = true, IPPoolUpdateInformation = IPPool_Return }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch
            {
                TempData["UpdateSucessOrFail"] = "Update Fail.";
                return(Json(new { UpdateSuccess = false, IPPoolUpdateInformation = "" }, JsonRequestBehavior.AllowGet));
            }
        }
        //[ValidateAntiForgeryToken]
        public ActionResult UpdateComplainType(ComplainType ComplainTypeInfoForUpdate)
        {
            try
            {
                ComplainType band_Check = db.ComplainType.Where(s => s.ComplainTypeID != ComplainTypeInfoForUpdate.ComplainTypeID && s.ComplainTypeName == ComplainTypeInfoForUpdate.ComplainTypeName.Trim()).FirstOrDefault();

                if (band_Check != null)
                {
                    //TempData["AlreadyInsert"] = "ComplainType Already Added. Choose different ComplainType. ";

                    return(Json(new { UpdateSuccess = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet));
                }

                var ComplainType_db = db.ComplainType.Where(s => s.ComplainTypeID == ComplainTypeInfoForUpdate.ComplainTypeID);
                ComplainTypeInfoForUpdate.CreatedBy   = ComplainType_db.FirstOrDefault().CreatedBy;
                ComplainTypeInfoForUpdate.CreatedDate = ComplainType_db.FirstOrDefault().CreatedDate;
                ComplainTypeInfoForUpdate.UpdateBy    = AppUtils.GetLoginEmployeeName();
                ComplainTypeInfoForUpdate.UpdateDate  = AppUtils.GetDateTimeNow();

                db.Entry(ComplainType_db.SingleOrDefault()).CurrentValues.SetValues(ComplainTypeInfoForUpdate);
                db.SaveChanges();

                TempData["UpdateSucessOrFail"] = "Update Successfully.";
                var ComplainTypes = ComplainType_db.Select(s => new { ComplainTypeID = s.ComplainTypeID, PackageName = s.ComplainTypeName, ShowMessageBox = s.ShowMessageBox == true ? "Yes":"No" });
                var JSON          = Json(new { UpdateSuccess = true, ComplainTypeUpdateInformation = ComplainTypes }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch
            {
                TempData["UpdateSucessOrFail"] = "Update Fail.";
                return(Json(new { UpdateSuccess = false, ComplainTypeUpdateInformation = "" }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #11
0
        //[ValidateAntiForgeryToken]
        public ActionResult UpdateDistributionReason(DistributionReason DistributionReasonInfoForUpdate)
        {
            try
            {
                DistributionReason distributionReason_Check = db.DistributionReason.Where(s => s.DistributionReasonID != DistributionReasonInfoForUpdate.DistributionReasonID && s.DistributionReasonName == DistributionReasonInfoForUpdate.DistributionReasonName.Trim()).FirstOrDefault();

                if (distributionReason_Check != null)
                {
                    //TempData["AlreadyInsert"] = "DistributionReason Already Added. Choose different DistributionReason. ";

                    return(Json(new { UpdateSuccess = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet));
                }

                var distributionReason_db = db.DistributionReason.Where(s => s.DistributionReasonID == DistributionReasonInfoForUpdate.DistributionReasonID);
                DistributionReasonInfoForUpdate.CreatedBy   = distributionReason_db.FirstOrDefault().CreatedBy;
                DistributionReasonInfoForUpdate.CreatedDate = distributionReason_db.FirstOrDefault().CreatedDate;
                DistributionReasonInfoForUpdate.UpdateBy    = AppUtils.GetLoginEmployeeName();
                DistributionReasonInfoForUpdate.UpdateDate  = AppUtils.GetDateTimeNow();

                db.Entry(distributionReason_db.SingleOrDefault()).CurrentValues.SetValues(DistributionReasonInfoForUpdate);
                db.SaveChanges();

                TempData["UpdateSucessOrFail"] = "Update Successfully.";
                var distributionReason_Return = distributionReason_db.Select(s => new { DistributionReasonID = s.DistributionReasonID, PackageName = s.DistributionReasonName });
                var JSON = Json(new { UpdateSuccess = true, DistributionReasonUpdateInformation = distributionReason_Return }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch
            {
                TempData["UpdateSucessOrFail"] = "Update Fail.";
                return(Json(new { UpdateSuccess = false, DistributionReasonUpdateInformation = "" }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #12
0
        //[ValidateAntiForgeryToken]
        public ActionResult UpdateBrand(Brand BrandInfoForUpdate)
        {
            try
            {
                Brand band_Check = db.Brand.Where(s => s.BrandID != BrandInfoForUpdate.BrandID && s.BrandName == BrandInfoForUpdate.BrandName.Trim()).FirstOrDefault();

                if (band_Check != null)
                {
                    //TempData["AlreadyInsert"] = "Brand Already Added. Choose different Brand. ";

                    return(Json(new { UpdateSuccess = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet));
                }

                var brand_db = db.Brand.Where(s => s.BrandID == BrandInfoForUpdate.BrandID);
                BrandInfoForUpdate.CreatedBy   = brand_db.FirstOrDefault().CreatedBy;
                BrandInfoForUpdate.CreatedDate = brand_db.FirstOrDefault().CreatedDate;
                BrandInfoForUpdate.UpdateBy    = AppUtils.GetLoginEmployeeName();
                BrandInfoForUpdate.UpdateDate  = AppUtils.GetDateTimeNow();

                db.Entry(brand_db.SingleOrDefault()).CurrentValues.SetValues(BrandInfoForUpdate);
                db.SaveChanges();

                TempData["UpdateSucessOrFail"] = "Update Successfully.";
                var brands = brand_db.Select(s => new { BrandID = s.BrandID, PackageName = s.BrandName });
                var JSON   = Json(new { UpdateSuccess = true, BrandUpdateInformation = brands }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch
            {
                TempData["UpdateSucessOrFail"] = "Update Fail.";
                return(Json(new { UpdateSuccess = false, BrandUpdateInformation = "" }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #13
0
        //[ValidateAntiForgeryToken]
        public ActionResult UpdateSupplier(Supplier SupplierInfoForUpdate)
        {
            try
            {
                Supplier Supplier_Check = db.Supplier.Where(s => s.SupplierID != SupplierInfoForUpdate.SupplierID && s.SupplierName == SupplierInfoForUpdate.SupplierName.Trim()).FirstOrDefault();

                if (Supplier_Check != null)
                {
                    //TempData["AlreadyInsert"] = "Supplier Already Added. Choose different Supplier. ";

                    return(Json(new { UpdateSuccess = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet));
                }

                var Supplier_db = db.Supplier.Where(s => s.SupplierID == SupplierInfoForUpdate.SupplierID);
                SupplierInfoForUpdate.CreatedBy   = Supplier_db.FirstOrDefault().CreatedBy;
                SupplierInfoForUpdate.CreatedDate = Supplier_db.FirstOrDefault().CreatedDate;
                SupplierInfoForUpdate.UpdateBy    = AppUtils.GetLoginEmployeeName();
                SupplierInfoForUpdate.UpdateDate  = AppUtils.GetDateTimeNow();

                db.Entry(Supplier_db.SingleOrDefault()).CurrentValues.SetValues(SupplierInfoForUpdate);
                db.SaveChanges();

                TempData["UpdateSucessOrFail"] = "Update Successfully.";
                var Supplier_Return = Supplier_db.Select(s => new { SupplierID = s.SupplierID, PackageName = s.SupplierName, SupplierAddress = s.SupplierAddress });
                var JSON            = Json(new { UpdateSuccess = true, SupplierUpdateInformation = Supplier_Return }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch
            {
                TempData["UpdateSucessOrFail"] = "Update Fail.";
                return(Json(new { UpdateSuccess = false, SupplierUpdateInformation = "" }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #14
0
        public ActionResult UpdateMikrotik(Mikrotik MikrotikInfoForUpdate)
        {
            try
            {
                Mikrotik Mikrotik_Check = db.Mikrotik.Where(s => s.MikrotikID != MikrotikInfoForUpdate.MikrotikID && s.RealIP == MikrotikInfoForUpdate.RealIP.Trim()).FirstOrDefault();

                if (Mikrotik_Check != null)
                {
                    //TempData["AlreadyInsert"] = "Mikrotik Already Added. Choose different Mikrotik. ";

                    return(Json(new { UpdateSuccess = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet));
                }

                var Mikrotik_db = db.Mikrotik.Where(s => s.MikrotikID == MikrotikInfoForUpdate.MikrotikID);
                MikrotikInfoForUpdate.CreatedBy   = Mikrotik_db.FirstOrDefault().CreatedBy;
                MikrotikInfoForUpdate.CreatedDate = Mikrotik_db.FirstOrDefault().CreatedDate;
                MikrotikInfoForUpdate.UpdateBy    = AppUtils.GetLoginUserID();
                MikrotikInfoForUpdate.UpdateDate  = AppUtils.GetDateTimeNow();

                db.Entry(Mikrotik_db.SingleOrDefault()).CurrentValues.SetValues(MikrotikInfoForUpdate);
                db.SaveChanges();

                TempData["UpdateSucessOrFail"] = "Update Successfully.";
                var Mikrotik_Return = Mikrotik_db;
                var JSON            = Json(new { UpdateSuccess = true, MikrotikUpdateInformation = Mikrotik_Return }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch (Exception ex)
            {
                TempData["UpdateSucessOrFail"] = "Update Fail.";
                return(Json(new { UpdateSuccess = false, MikrotikUpdateInformation = "" }, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult SetUserPermission(List <ISPAccessList> model, int?UserRightID)
        {
            string info = "";

            foreach (var item in model)
            {
                if (item.IsGranted)
                {
                    info += item.AccessValue + ",";
                }
            }
            info = info.TrimEnd(',');
            try
            {
                UserRightPermission dbd = db.UserRightPermission.Where(s => s.UserRightPermissionID == UserRightID).FirstOrDefault();
                if (dbd != null)
                {
                    dbd.UserRightPermissionDetails = info;
                    db.Entry(dbd).State            = EntityState.Modified;
                    db.SaveChanges();
                }
                TempData["UserRightID"] = UserRightID;
                TempData["ShowMessage"] = "Permission Saved Successfully";
            }
            catch (Exception ex)
            {
                TempData["ShowMessage"] = "Failed to Save Permission. Contact With administrator.";
            }
            //ViewBag.UserRightID = new SelectList(db.UserRightPermission.Select(s => new { UserRightPermissionName = s.UserRightPermissionName, UserRightPermissionID = s.UserRightPermissionID }).ToList(), "UserRightPermissionID", "UserRightPermissionName");
            //ViewBag.EmployeeID = new SelectList(db.Employee.Select(s => new { EmployeeID = s.EmployeeID, Name = s.Name }).ToList(), "EmployeeID", "Name");

            //            List<ISPAccessList> lstISPAccessList = db.ISPAccessList.ToList();
            TempData["tmpListOfAccess"] = model;
            return(RedirectToAction("UserRightPermission", "Account"));
        }
Beispiel #16
0
        //[ValidateAntiForgeryToken]
        public ActionResult UpdateAsset(Asset AssetInfoForUpdate)
        {
            try
            {
                Asset Asset_Check = db.Asset.Where(s => s.AssetID == AssetInfoForUpdate.AssetID).FirstOrDefault();

                if (Asset_Check == null)
                {
                    //TempData["AlreadyInsert"] = "Asset Already Added. Choose different Asset. ";

                    return(Json(new { UpdateSuccess = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet));
                }

                var Asset_db = db.Asset.Where(s => s.AssetID == AssetInfoForUpdate.AssetID);
                //AssetInfoForUpdate.PurchaseDate = AssetInfoForUpdate.PurchaseDate.AddHours(DateTime.Now.Hour).AddMinutes(DateTime.Now.Minute).AddSeconds(DateTime.Now.Second);
                //AssetInfoForUpdate.WarrentyStartDate = (AssetInfoForUpdate.WarrentyStartDate != null) ? AssetInfoForUpdate.WarrentyStartDate.Value.AddHours(DateTime.Now.Hour).AddMinutes(DateTime.Now.Minute).AddSeconds(DateTime.Now.Second) : AssetInfoForUpdate.WarrentyStartDate;
                //AssetInfoForUpdate.WarrentyEndDate = AssetInfoForUpdate.WarrentyEndDate.Value.AddHours(DateTime.Now.Hour).AddMinutes(DateTime.Now.Minute).AddSeconds(DateTime.Now.Second);

                AssetInfoForUpdate.CreatedBy   = Asset_db.FirstOrDefault().CreatedBy;
                AssetInfoForUpdate.CreatedDate = Asset_db.FirstOrDefault().CreatedDate;
                AssetInfoForUpdate.UpdateBy    = AppUtils.GetLoginEmployeeName();
                AssetInfoForUpdate.UpdateDate  = AppUtils.GetDateTimeNow();

                db.Entry(Asset_db.SingleOrDefault()).CurrentValues.SetValues(AssetInfoForUpdate);
                db.SaveChanges();

                TempData["UpdateSucessOrFail"] = "Update Successfully.";
                var temp         = Asset_db.ToList();
                var Asset_Return = Asset_db.Select(s =>
                                                   new
                {
                    AssetID           = s.AssetID,
                    AssetTypeName     = s.AssetType.AssetTypeName,
                    AssetName         = s.AssetName,
                    AssetValue        = s.AssetValue,
                    PurchaseDate      = s.PurchaseDate,
                    SerialNumber      = s.SerialNumber,
                    WarrentyStartDate = s.WarrentyStartDate,
                    WarrentyEndDate   = s.WarrentyEndDate
                });
                var JSON = Json(new { UpdateSuccess = true, AssetUpdateInformation = Asset_Return }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch
            {
                TempData["UpdateSucessOrFail"] = "Update Fail.";
                return(Json(new { UpdateSuccess = false, AssetUpdateInformation = "" }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #17
0
        //[ValidateAntiForgeryToken]
        public ActionResult UpdateTimePeriodForSignal(TimePeriodForSignal TimePeriodForSignalInfoForUpdate)
        {
            try
            {
                TimePeriodForSignal TimePeriodForSignal_Check = db.TimePeriodForSignal.Where(s => s.TimePeriodForSignalID == TimePeriodForSignalInfoForUpdate.TimePeriodForSignalID).FirstOrDefault();

                if (TimePeriodForSignal_Check == null)
                {
                    //TempData["AlreadyInsert"] = "TimePeriodForSignal Already Added. Choose different TimePeriodForSignal. ";

                    return(Json(new { UpdateSuccess = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet));
                }

                TimePeriodForSignal TimePeriodForSignal_Check_IfDuplicateDataExist = db.TimePeriodForSignal.Where(s => s.TimePeriodForSignalID != TimePeriodForSignalInfoForUpdate.TimePeriodForSignalID && s.SignalSign == TimePeriodForSignalInfoForUpdate.SignalSign).FirstOrDefault();

                if (TimePeriodForSignal_Check_IfDuplicateDataExist != null)
                {
                    //TempData["AlreadyInsert"] = "TimePeriodForSignal Already Added. Choose different TimePeriodForSignal. ";

                    return(Json(new { UpdateSuccess = false, DuplicateSignExist = true }, JsonRequestBehavior.AllowGet));
                }

                var TimePeriodForSignal_db = db.TimePeriodForSignal.Where(s => s.TimePeriodForSignalID == TimePeriodForSignalInfoForUpdate.TimePeriodForSignalID);
                TimePeriodForSignalInfoForUpdate.CreatedBy   = TimePeriodForSignal_db.FirstOrDefault().CreatedBy;
                TimePeriodForSignalInfoForUpdate.CreatedDate = TimePeriodForSignal_db.FirstOrDefault().CreatedDate;
                TimePeriodForSignalInfoForUpdate.UpdateBy    = AppUtils.GetLoginEmployeeName();
                TimePeriodForSignalInfoForUpdate.UpdateDate  = AppUtils.GetDateTimeNow();

                db.Entry(TimePeriodForSignal_db.SingleOrDefault()).CurrentValues.SetValues(TimePeriodForSignalInfoForUpdate);
                db.SaveChanges();

                TempData["UpdateSucessOrFail"] = "Update Successfully.";
                var temp = TimePeriodForSignal_db.ToList();
                var TimePeriodForSignal_Return = TimePeriodForSignal_db.Select(s =>
                                                                               new
                {
                    TimePeriodForSignalID = s.TimePeriodForSignalID,
                    UpToHours             = s.UpToHours,
                    SignalSign            = s.SignalSign
                });
                var JSON = Json(new { UpdateSuccess = true, TimePeriodForSignalUpdateInformation = TimePeriodForSignal_Return }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch
            {
                TempData["UpdateSucessOrFail"] = "Update Fail.";
                return(Json(new { UpdateSuccess = false, TimePeriodForSignalUpdateInformation = "" }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #18
0
        //[ValidateAntiForgeryToken]
        public ActionResult UpdateZone(Zone ZoneInfoForUpdate)
        {
            try
            {
                Zone band_Check = new Zone();
                if (AppUtils.GetLoginUserID() == AppUtils.ResellerRole)
                {
                    int resellerID = AppUtils.GetLoginUserID();
                    band_Check = db.Zone.Where(s => s.ZoneID != ZoneInfoForUpdate.ZoneID && s.ResellerID == resellerID && s.ZoneName.ToLower() == ZoneInfoForUpdate.ZoneName.Trim().ToLower()).FirstOrDefault();
                    ZoneInfoForUpdate.ResellerID = resellerID;
                }
                else if (AppUtils.GetLoginRoleID() == AppUtils.AdminRole && ZoneInfoForUpdate.ResellerID.HasValue)
                {
                    ZoneInfoForUpdate = db.Zone.Where(s => s.ZoneID != ZoneInfoForUpdate.ZoneID && s.ResellerID == ZoneInfoForUpdate.ResellerID && s.ZoneName.ToLower() == ZoneInfoForUpdate.ZoneName.Trim().ToLower()).FirstOrDefault();
                }
                else
                {
                    band_Check = db.Zone.Where(s => s.ZoneID != ZoneInfoForUpdate.ZoneID && s.ResellerID == ZoneInfoForUpdate.ResellerID && s.ZoneName.ToLower() == ZoneInfoForUpdate.ZoneName.Trim().ToLower()).FirstOrDefault();
                }


                if (band_Check != null)
                {
                    //TempData["AlreadyInsert"] = "Zone Already Added. Choose different Zone. ";

                    return(Json(new { UpdateSuccess = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet));
                }

                var Zone_db = db.Zone.Where(s => s.ZoneID == ZoneInfoForUpdate.ZoneID);
                ZoneInfoForUpdate.CreatedBy   = Zone_db.FirstOrDefault().CreatedBy;
                ZoneInfoForUpdate.CreatedDate = Zone_db.FirstOrDefault().CreatedDate;
                ZoneInfoForUpdate.UpdateBy    = AppUtils.GetLoginUserID().ToString();
                ZoneInfoForUpdate.UpdateDate  = AppUtils.GetDateTimeNow();

                db.Entry(Zone_db.SingleOrDefault()).CurrentValues.SetValues(ZoneInfoForUpdate);
                db.SaveChanges();

                TempData["UpdateSucessOrFail"] = "Update Successfully.";
                var Zones = Zone_db.Select(s => new { ZoneID = s.ZoneID, PackageName = s.ZoneName });
                var JSON  = Json(new { UpdateSuccess = true, ZoneUpdateInformation = Zones }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch (Exception ex)
            {
                TempData["UpdateSucessOrFail"] = "Update Fail.";
                return(Json(new { UpdateSuccess = false, ZoneUpdateInformation = "" }, JsonRequestBehavior.AllowGet));
            }
        }
        public JsonResult InsertAccountListVsAmountTransfer(AccountListVsAmountTransfer AccountListVsAmountTransferDetails)
        {
            try
            {
                AccountListVsAmountTransferDetails.CreateBy   = AppUtils.GetLoginUserID();
                AccountListVsAmountTransferDetails.CreateDate = AppUtils.GetDateTimeNow();
                AccountListVsAmountTransferDetails.Status     = AppUtils.TableStatusIsActive;
                AccountListVsAmountTransferDetails.CurrencyID = 1;

                var FromAccountForAmountChange = db.AccountList.Where(s => s.AccountListID == AccountListVsAmountTransferDetails.FromAccountID).FirstOrDefault();
                var ToAccountForAmountChange   = db.AccountList.Where(s => s.AccountListID == AccountListVsAmountTransferDetails.ToAccountID).FirstOrDefault();

                FromAccountForAmountChange.InitialBalance = (FromAccountForAmountChange.InitialBalance - AccountListVsAmountTransferDetails.Amount);
                ToAccountForAmountChange.InitialBalance   = (ToAccountForAmountChange.InitialBalance + AccountListVsAmountTransferDetails.Amount);

                db.Entry(FromAccountForAmountChange).State = System.Data.Entity.EntityState.Modified;
                db.Entry(ToAccountForAmountChange).State   = System.Data.Entity.EntityState.Modified;
                db.AccountListVsAmountTransfer.Add(AccountListVsAmountTransferDetails);
                db.SaveChanges();

                if (AccountListVsAmountTransferDetails.AccountListVsAmountTransferID > 0)
                {
                    AccountListVsAmountTransfer AccountListVsAmountTransferIn  = new AccountListVsAmountTransfer();
                    AccountListVsAmountTransfer AccountListVsAmountTransferOut = new AccountListVsAmountTransfer();
                    SetInOutDateDuringCreate(ref AccountListVsAmountTransferIn, ref AccountListVsAmountTransferOut, AccountListVsAmountTransferDetails);
                    db.AccountListVsAmountTransfer.Add(AccountListVsAmountTransferIn);
                    db.AccountListVsAmountTransfer.Add(AccountListVsAmountTransferOut);
                    db.SaveChanges();
                }

                return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
            }
        }