public ActionResult Create(Expense expense) { Expense expenseObj = new Expense(); try { expense.EmployeeID = AppUtils.GetLoginUserID(); expense.PaymentDate = AppUtils.GetDateTimeNow(); expenseObj = db.Expenses.Add(expense); db.SaveChanges(); if (expenseObj.ExpenseID > 0) { return(Json(new { SuccessInsert = true, expenseObj = expenseObj }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } } catch { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult UpdateSMSIDPass(SMSSenderIDPass smsSenderIdPass) { SMSSenderIDPass SMSSenderIDPass = db.SMSSenderIDPass.FirstOrDefault(); try { if (SMSSenderIDPass == null) { smsSenderIdPass.CreateBy = AppUtils.GetLoginEmployeeName(); smsSenderIdPass.CreateDate = AppUtils.dateTimeNow; db.SMSSenderIDPass.Add(smsSenderIdPass); db.SaveChanges(); } else { smsSenderIdPass.Status = SMSSenderIDPass.Status; smsSenderIdPass.SMSSenderIDPassID = SMSSenderIDPass.SMSSenderIDPassID; smsSenderIdPass.CreateBy = AppUtils.GetLoginEmployeeName(); smsSenderIdPass.CreateDate = AppUtils.dateTimeNow; smsSenderIdPass.UpdateBy = AppUtils.GetLoginEmployeeName(); smsSenderIdPass.UpdateDate = AppUtils.dateTimeNow; db.Entry(SMSSenderIDPass).CurrentValues.SetValues(smsSenderIdPass); db.SaveChanges(); } return(Json(new { Success = true })); } catch (Exception ex) { return(Json(new { Success = false })); } }
public JsonResult InsertLeaveType(LeaveSallaryType leaveType) { int LeaveTypeCounts = db.LeaveSallaryTypes.Count(); try { leaveType.TableStatusID = 1; db.LeaveSallaryTypes.Add(leaveType); db.SaveChanges(); LeaveSallaryType TypeInfo = new LeaveSallaryType { LeaveTypeId = leaveType.LeaveTypeId, LeaveTypeName = leaveType.LeaveTypeName, Persent = leaveType.Persent, }; return(Json(new { SuccessInsert = true, TypeInfos = TypeInfo, TypeCount = LeaveTypeCounts }, JsonRequestBehavior.AllowGet)); } catch { return(Json(new { SuccessInsert = 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 InsertCompanyFromPopUp(FormCollection form, HttpPostedFileBase CompanyImage) { Company Company_info = JsonConvert.DeserializeObject <Company>(form["CompanyDetails"]); Company Company_Check = db.Company.Where(s => s.CompanyName == Company_info.CompanyName.Trim() && s.Status != AppUtils.TableStatusIsDelete).FirstOrDefault(); if (Company_Check != null) { return(Json(new { success = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet)); } Company CompanyReturn = new Company(); try { Company_info.Status = AppUtils.TableStatusIsActive; Company_info.CreateBy = AppUtils.GetLoginUserID(); Company_info.CreateDate = AppUtils.GetDateTimeNow(); CompanyReturn = db.Company.Add(Company_info); db.SaveChanges(); SaveImageInFolderAndAddInformationInCompanyTable(ref Company_info, "LOGO", CompanyImage); if (CompanyReturn.CompanyID > 0) { 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)); } }
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")); }
public JsonResult InsertCompanyVsPayer(CompanyVSPayer CompanyVsPayer) { try { db.CompanyVSPayer.Add(CompanyVsPayer); CompanyVsPayer.CreateBy = AppUtils.GetLoginUserID(); CompanyVsPayer.CreateDate = AppUtils.GetDateTimeNow(); CompanyVsPayer.Status = AppUtils.TableStatusIsActive; db.SaveChanges(); return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult UpdateMacResellerPackagePrice(macReselleGivenPackageWithPriceModel macpricemodel) { try { int resellerID = AppUtils.GetLoginUserID(); Reseller reseller = db.Reseller.Find(resellerID); List <macReselleGivenPackageWithPriceModel> lstMacReselleGivenPackageWithPriceModel = (List <macReselleGivenPackageWithPriceModel>)SetPackageName((reseller.macReselleGivenPackageWithPrice != null) ? new JavaScriptSerializer().Deserialize <List <macReselleGivenPackageWithPriceModel> >(reseller.macReselleGivenPackageWithPrice) : new List <macReselleGivenPackageWithPriceModel>()); lstMacReselleGivenPackageWithPriceModel.Where(x => x.PID == macpricemodel.PID).FirstOrDefault().PPFromRS = macpricemodel.PPFromRS; reseller.macReselleGivenPackageWithPrice = JsonConvert.SerializeObject(lstMacReselleGivenPackageWithPriceModel); db.SaveChanges(); return(Json(new { Success = true, pid = macpricemodel.PID, price = macpricemodel.PPFromRS }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Success = false, PackageUpdateInformation = "" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult InsertHeadFromPopUp(Head Head) { try { int countHead = 0; if (AppUtils.GetLoginRoleID() == AppUtils.ResellerRole) { int resellerID = AppUtils.GetLoginUserID(); countHead = db.Head.Where(x => x.ResellerID == resellerID && x.Status != AppUtils.TableStatusIsDelete && x.HeadeName.ToLower() == Head.HeadeName).Count(); } else { countHead = db.Head.Where(x => x.ResellerID == null && x.Status != AppUtils.TableStatusIsDelete && x.HeadeName.ToLower() == Head.HeadeName).Count(); } if (countHead > 0) { return(Json(new { success = false, message = "Sorry Head Name Alraeady Exist." }, JsonRequestBehavior.AllowGet)); } if (AppUtils.GetLoginRoleID() == AppUtils.ResellerRole) { Head.ResellerID = AppUtils.GetLoginUserID(); } db.Head.Add(Head); Head.CreateBy = AppUtils.GetLoginUserID(); Head.CreateDate = AppUtils.GetDateTimeNow(); Head.Status = AppUtils.TableStatusIsActive; db.SaveChanges(); HeadViewModel HeadInfo = new HeadViewModel { HeadID = Head.HeadID, HeadName = Head.HeadeName, HeadTypeId = Head.HeadTypeID, UpdateHead = ISP_ManagementSystemModel.AppUtils.HasAccessInTheList(ISP_ManagementSystemModel.AppUtils.Update_Head) ? true : false, }; return(Json(new { SuccessInsert = true, HeadInfo = HeadInfo }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult CreateConfirm(AccountList accountlist) { var dbAccounlist = db.AccountList.Where(s => s.AccountTitle == accountlist.AccountTitle).FirstOrDefault(); if (dbAccounlist != null) { return(Json(new { nameExist = true })); } try { accountlist.CreateBy = AppUtils.GetLoginUserID(); accountlist.CreateData = AppUtils.GetDateTimeNow(); accountlist.Status = AppUtils.TableStatusIsActive; db.AccountList.Add(accountlist); db.SaveChanges(); AccountingHistory accountingHistory = new AccountingHistory(); //Mode 1 mean Create 2 mean Update SetInformationForAccountHistory(ref accountingHistory, accountlist, 1); db.AccountingHistory.Add(accountingHistory); db.SaveChanges(); return(Json(new { success = true })); } catch (Exception ex) { return(Json(new { success = false })); } }
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)); } }
public ActionResult InsertItemFromPopUp(Item Item_Client) { Item Item_Check = db.Item.Where(s => s.ItemName == Item_Client.ItemName.Trim()).FirstOrDefault(); if (Item_Check != null) { // TempData["AlreadyInsert"] = "Item Already Added. Choose different Item. "; return(Json(new { SuccessInsert = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet)); } Item Item_Return = new Item(); try { Item_Client.ItemFor = (int)AppUtils.ItemFor.General; Item_Client.CreatedBy = AppUtils.GetLoginUserID().ToString() /*AppUtils.GetLoginEmployeeName()*/; Item_Client.CreatedDate = AppUtils.GetDateTimeNow(); Item_Return = db.Item.Add(Item_Client); db.SaveChanges(); if (Item_Return.ItemID > 0) { // TempData["SaveSucessOrFail"] = "Save Successfully."; return(Json(new { SuccessInsert = true, Item = Item_Return, ItemFor = Enum.GetName(typeof(ItemFor), Item_Return.ItemFor.Value) }, JsonRequestBehavior.AllowGet)); } else { // TempData["SaveSucessOrFail"] = "Save Failed."; return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } } catch { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } }
public JsonResult InsertAccountOwner(AccountOwner OwnerDetails) { try { db.AccountOwner.Add(OwnerDetails); OwnerDetails.CreateBy = AppUtils.GetLoginUserID(); OwnerDetails.CreateDate = AppUtils.GetDateTimeNow(); OwnerDetails.Status = AppUtils.TableStatusIsActive; db.SaveChanges(); AccountOwnerViewModel accountOwner = new AccountOwnerViewModel { OwnerID = OwnerDetails.OwnerID, OwnerName = OwnerDetails.OwnerName }; return(Json(new { success = true, accountOwner = accountOwner }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult InsertZone(Zone Zone_Client) { Zone Zone_Check = db.Zone.Where(s => s.ZoneName == Zone_Client.ZoneName.Trim()).FirstOrDefault(); if (Zone_Check != null) { // TempData["AlreadyInsert"] = "Zone Already Added. Choose different Zone. "; return(Json(new { SuccessInsert = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet)); } Zone Zone_Return = new Zone(); try { Zone_Client.CreatedBy = AppUtils.GetLoginEmployeeName(); Zone_Client.CreatedDate = AppUtils.GetDateTimeNow(); Zone_Return = db.Zone.Add(Zone_Client); db.SaveChanges(); if (Zone_Return.ZoneID > 0) { // TempData["SaveSucessOrFail"] = "Save Successfully."; return(Json(new { SuccessInsert = true, Zone = Zone_Return }, JsonRequestBehavior.AllowGet)); } else { // TempData["SaveSucessOrFail"] = "Save Failed."; return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } } catch { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult InsertSupplier(Supplier Supplier_Client) { Supplier Supplier_Check = db.Supplier.Where(s => s.SupplierName == Supplier_Client.SupplierName.Trim()).FirstOrDefault(); if (Supplier_Check != null) { TempData["AlreadyInsert"] = "Supplier Already Added. Choose different Supplier. "; return(Json(new { SuccessInsert = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet)); } Supplier Supplier_Return = new Supplier(); try { Supplier_Client.CreatedBy = AppUtils.GetLoginEmployeeName(); Supplier_Client.CreatedDate = AppUtils.GetDateTimeNow(); Supplier_Return = db.Supplier.Add(Supplier_Client); db.SaveChanges(); if (Supplier_Return.SupplierID > 0) { TempData["SaveSucessOrFail"] = "Save Successfully."; return(Json(new { SuccessInsert = true, Supplier = Supplier_Return }, JsonRequestBehavior.AllowGet)); } else { TempData["SaveSucessOrFail"] = "Save Failed."; return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } } catch { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult InsertTimePeriodForSignal(TimePeriodForSignal TimePeriodForSignal_Client) { TimePeriodForSignal TimePeriodForSignal_Check = db.TimePeriodForSignal.Where(s => s.SignalSign == TimePeriodForSignal_Client.SignalSign).FirstOrDefault(); if (TimePeriodForSignal_Check != null) { TempData["AlreadyInsert"] = "Time Period For Signal Already Added. Choose different TimePeriodForSignal. "; return(Json(new { SuccessInsert = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet)); } TimePeriodForSignal TimePeriodForSignal_Return = new TimePeriodForSignal(); try { TimePeriodForSignal_Client.CreatedBy = AppUtils.GetLoginEmployeeName(); TimePeriodForSignal_Client.CreatedDate = AppUtils.GetDateTimeNow(); TimePeriodForSignal_Return = db.TimePeriodForSignal.Add(TimePeriodForSignal_Client); db.SaveChanges(); if (TimePeriodForSignal_Return.TimePeriodForSignalID > 0) { TempData["SaveSucessOrFail"] = "Save Successfully."; return(Json(new { SuccessInsert = true, TimePeriodForSignal = TimePeriodForSignal_Return }, JsonRequestBehavior.AllowGet)); } else { TempData["SaveSucessOrFail"] = "Save Failed."; return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } } catch { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult InsertMikrotik(Mikrotik Mikrotik_Client) { Mikrotik Mikrotik_Check = db.Mikrotik.Where(s => s.RealIP == Mikrotik_Client.RealIP.Trim()).FirstOrDefault(); if (Mikrotik_Check != null) { TempData["AlreadyInsert"] = "Mikrotik Already Added. Choose different Mikrotik. "; return(Json(new { SuccessInsert = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet)); } Mikrotik Mikrotik_Return = new Mikrotik(); try { Mikrotik_Client.CreatedBy = int.Parse(Session["LoggedUserID"].ToString()); Mikrotik_Client.CreatedDate = AppUtils.GetDateTimeNow(); Mikrotik_Return = db.Mikrotik.Add(Mikrotik_Client); db.SaveChanges(); if (Mikrotik_Return.MikrotikID > 0) { TempData["SaveSucessOrFail"] = "Save Successfully."; return(Json(new { SuccessInsert = true, Mikrotik = Mikrotik_Return }, JsonRequestBehavior.AllowGet)); } else { TempData["SaveSucessOrFail"] = "Save Failed."; return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } } catch { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult InsertBrand(Brand Brand_Client) { Brand brand_Check = db.Brand.Where(s => s.BrandName == Brand_Client.BrandName.Trim()).FirstOrDefault(); if (brand_Check != null) { // TempData["AlreadyInsert"] = "Brand Already Added. Choose different Brand. "; return(Json(new { SuccessInsert = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet)); } Brand brand_Return = new Brand(); try { Brand_Client.CreatedBy = AppUtils.GetLoginEmployeeName(); Brand_Client.CreatedDate = AppUtils.GetDateTimeNow(); brand_Return = db.Brand.Add(Brand_Client); db.SaveChanges(); if (brand_Return.BrandID > 0) { // TempData["SaveSucessOrFail"] = "Save Successfully."; return(Json(new { SuccessInsert = true, brand = brand_Return }, JsonRequestBehavior.AllowGet)); } else { // TempData["SaveSucessOrFail"] = "Save Failed."; return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } } catch { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult InsertIPPool(IPPool IPPool_Client) { IPPool IPPool_Check = db.IPPool.Where(s => s.PoolName == IPPool_Client.PoolName.Trim()).FirstOrDefault(); if (IPPool_Check != null) { TempData["AlreadyInsert"] = "IPPool Already Added. Choose different IPPool. "; return(Json(new { SuccessInsert = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet)); } IPPool IPPool_Return = new IPPool(); try { IPPool_Client.CreatedBy = int.Parse(Session["LoggedUserID"].ToString());//AppUtils.LoginUserID; IPPool_Client.CreatedDate = AppUtils.GetDateTimeNow(); IPPool_Return = db.IPPool.Add(IPPool_Client); db.SaveChanges(); if (IPPool_Return.IPPoolID > 0) { TempData["SaveSucessOrFail"] = "Save Successfully."; return(Json(new { SuccessInsert = true, IPPool = IPPool_Return }, JsonRequestBehavior.AllowGet)); } else { TempData["SaveSucessOrFail"] = "Save Failed."; return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } } catch { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult InsertAsset(Asset Asset_Client) { //Asset Asset_Check = db.Asset.Where(s => s.AssetName == Asset_Client.AssetName.Trim()).FirstOrDefault(); //if (Asset_Check != null) //{ // TempData["AlreadyInsert"] = "Asset Already Added. Choose different Asset. "; // return Json(new { SuccessInsert = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet); //} Asset Asset_Return = new Asset(); try { Asset_Client.CreatedBy = AppUtils.GetLoginEmployeeName(); Asset_Client.CreatedDate = AppUtils.GetDateTimeNow(); Asset_Return = db.Asset.Add(Asset_Client); db.SaveChanges(); if (Asset_Return.AssetID > 0) { TempData["SaveSucessOrFail"] = "Save Successfully."; return(Json(new { SuccessInsert = true, Asset = Asset_Return }, JsonRequestBehavior.AllowGet)); } else { TempData["SaveSucessOrFail"] = "Save Failed."; return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } } catch { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult InsertDistributionReason(DistributionReason DistributionReason_Client) { DistributionReason distributionReason_Check = db.DistributionReason.Where(s => s.DistributionReasonName == DistributionReason_Client.DistributionReasonName.Trim()).FirstOrDefault(); if (distributionReason_Check != null) { TempData["AlreadyInsert"] = "DistributionReason Already Added. Choose different DistributionReason. "; return(Json(new { SuccessInsert = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet)); } DistributionReason distributionReason_Return = new DistributionReason(); try { DistributionReason_Client.CreatedBy = AppUtils.GetLoginEmployeeName(); DistributionReason_Client.CreatedDate = AppUtils.GetDateTimeNow(); distributionReason_Return = db.DistributionReason.Add(DistributionReason_Client); db.SaveChanges(); if (distributionReason_Return.DistributionReasonID > 0) { TempData["SaveSucessOrFail"] = "Save Successfully."; return(Json(new { SuccessInsert = true, DistributionReason = distributionReason_Return }, JsonRequestBehavior.AllowGet)); } else { TempData["SaveSucessOrFail"] = "Save Failed."; return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } } catch { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult InsertPop(Pop Pop_Client) { Pop Pop_Check = db.Pop.Where(s => s.PopName == Pop_Client.PopName.Trim()).FirstOrDefault(); if (Pop_Check != null) { TempData["AlreadyInsert"] = "Pop Already Added. Choose different Pop. "; return(Json(new { SuccessInsert = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet)); } Pop Pop_Return = new Pop(); try { Pop_Client.CreatedBy = AppUtils.GetLoginEmployeeName(); Pop_Client.CreatedDate = AppUtils.GetDateTimeNow(); Pop_Return = db.Pop.Add(Pop_Client); db.SaveChanges(); if (Pop_Return.PopID > 0) { TempData["SaveSucessOrFail"] = "Save Successfully."; return(Json(new { SuccessInsert = true, Pop = Pop_Return }, JsonRequestBehavior.AllowGet)); } else { TempData["SaveSucessOrFail"] = "Save Failed."; return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } } catch { return(Json(new { SuccessInsert = false }, 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)); } }
public ActionResult InsertVendorFromPopUp(FormCollection form, HttpPostedFileBase VendorCreateImage) { Vendor Vendor_info = JsonConvert.DeserializeObject <Vendor>(form["VendorInformationForInsert"]); Vendor Vendor_Check = db.Vendor.Where(s => s.VendorName == Vendor_info.VendorName.Trim()).FirstOrDefault(); if (Vendor_Check != null) { return(Json(new { success = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet)); } Vendor Vendor_Return = new Vendor(); try { Vendor_info.Status = AppUtils.TableStatusIsActive; Vendor_info.CreateBy = AppUtils.GetLoginUserID(); Vendor_info.CreateDate = AppUtils.GetDateTimeNow(); var vendorType = db.VendorTypes.Find(Vendor_info.VendorTypeID).VendorTypeName; Vendor_Return = db.Vendor.Add(Vendor_info); db.SaveChanges(); SaveImageInFolderAndAddInformationInVendorTable(ref Vendor_info, AppUtils.ImageIsVendorLogo, VendorCreateImage); if (Vendor_Return.VendorID > 0) { db.SaveChanges(); return(Json(new { SuccessInsert = true, Vendor = Vendor_Return, VendorType = vendorType }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } }
public JsonResult InsertMeasurementUnit(MeasurementUnits measureUnit) { try { db.MeasurementUnits.Add(measureUnit); measureUnit.CreateBy = AppUtils.GetLoginUserID(); measureUnit.CreateDate = AppUtils.GetDateTimeNow(); measureUnit.Status = AppUtils.TableStatusIsActive; db.SaveChanges(); CustomMeasuremetUnit UnitInfo = new CustomMeasuremetUnit { MeasurementUnitID = measureUnit.MeasurementUnitID, UnitName = measureUnit.UnitName, UpdateMeasurementUnit = ISP_ManagementSystemModel.AppUtils.HasAccessInTheList(ISP_ManagementSystemModel.AppUtils.Update_Measurement_Unit) ? true : false, }; return(Json(new { SuccessInsert = true, UnitInfo = UnitInfo }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult SaveAdvanceAmount(int ClientDetailsID, int Amount, string Remarks) { //db.Entry(new Transaction()).CurrentValues.SetValues(new Transaction()); AdvancePayment advancePayment = db.AdvancePayment.Where(s => s.ClientDetailsID == ClientDetailsID).FirstOrDefault(); try { if (advancePayment != null) { advancePayment.UpdatePaymentBy = AppUtils.GetLoginEmployeeName(); advancePayment.UpdatePaymentDate = AppUtils.GetDateTimeNow(); advancePayment.AdvanceAmount += Amount; advancePayment.Remarks = Remarks; db.Entry(advancePayment).State = EntityState.Modified; db.SaveChanges(); } else { AdvancePayment insertAdvancePayment = new AdvancePayment(); insertAdvancePayment.ClientDetailsID = ClientDetailsID; insertAdvancePayment.AdvanceAmount = Amount; insertAdvancePayment.Remarks = Remarks; insertAdvancePayment.CreatePaymentBy = AppUtils.GetLoginEmployeeName(); insertAdvancePayment.FirstPaymentDate = AppUtils.GetDateTimeNow(); db.AdvancePayment.Add(insertAdvancePayment); db.SaveChanges(); } return(Json(new { Success = true }, JsonRequestBehavior.AllowGet)); } catch { return(Json(new { Success = false }, JsonRequestBehavior.AllowGet)); } }
public JsonResult InsertVendorType(VendorType vendorType) { try { db.VendorTypes.Add(vendorType); vendorType.CreateBy = AppUtils.GetLoginUserID(); vendorType.CreateDate = AppUtils.GetDateTimeNow(); vendorType.Status = AppUtils.TableStatusIsActive; db.SaveChanges(); VendorTypeViewModel vendorTypeView = new VendorTypeViewModel { VendorTypeID = vendorType.VendorTypeID, VendorTypeName = vendorType.VendorTypeName, UpdateVendorType = ISP_ManagementSystemModel.AppUtils.HasAccessInTheList(ISP_ManagementSystemModel.AppUtils.Update_Vendor_Type) ? true : false, }; return(Json(new { SuccessInsert = true, vendorTypeView = vendorTypeView }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult InsertNewDeposit(FormCollection form, HttpPostedFileBase DescriptionImage) { Deposit DepositInfo = JsonConvert.DeserializeObject <Deposit>(form["NewDepositInformation"]); Deposit DepositReturn = new Deposit(); try { DepositInfo.Status = AppUtils.TableStatusIsActive; DepositInfo.CreateBy = AppUtils.GetLoginUserID(); DepositInfo.CreateDate = AppUtils.GetDateTimeNow(); DepositReturn = db.Deposit.Add(DepositInfo); db.SaveChanges(); if (DescriptionImage != null) { SaveImageInFolderAndAddInformationInVendorTable(ref DepositInfo, "Description", DescriptionImage); } if (DepositReturn.DepositID > 0) { db.SaveChanges(); AccountingHistory accountingHistory = new AccountingHistory(); //Mode 1 mean Create 2 mean Update SetInformationForAccountHistory(ref accountingHistory, DepositReturn, 1); 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)); } }
public JsonResult InsertEmployee(FormCollection file, HttpPostedFileBase EmployeeOwnCreateImage, HttpPostedFileBase EmployeeNIDCreateImage) { Employee EmployeeDetails = JsonConvert.DeserializeObject <Employee>(file["Employee_details"]); Employee EmployeeDb = db.Employee.Where(s => s.LoginName == EmployeeDetails.LoginName).FirstOrDefault(); if (EmployeeDb != null) { return(Json(new { Success = false, LoginNameExist = true }, JsonRequestBehavior.AllowGet)); } Employee Employee_Return = new Employee(); try { EmployeeDetails.CreatedBy = AppUtils.GetLoginEmployeeName(); EmployeeDetails.CreatedDate = AppUtils.GetDateTimeNow(); Employee_Return = db.Employee.Add(EmployeeDetails); db.SaveChanges(); if (EmployeeNIDCreateImage != null) { SaveImageInFolderAndAddInformationInDVDSTable(ref EmployeeDetails, AppUtils.ImageIsNID, EmployeeNIDCreateImage); } if (EmployeeOwnCreateImage != null) { SaveImageInFolderAndAddInformationInDVDSTable(ref EmployeeDetails, AppUtils.ImageIsOWN, EmployeeOwnCreateImage); } db.SaveChanges(); if (Employee_Return.EmployeeID > 0) { db.SaveChanges(); return(Json(new { SuccessInsert = true, Vendor = Employee_Return }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } }
//[ValidateAntiForgeryToken] public ActionResult UpdatePackage(Package PackageInfoForUpdate) { Package package_Check = db.Package.Where(s => s.PackageID != PackageInfoForUpdate.PackageID && s.PackageName.ToLower() == PackageInfoForUpdate.PackageName.Trim().ToLower() && s.PackageForMyOrResellerUser == PackageInfoForUpdate.PackageForMyOrResellerUser).FirstOrDefault(); if (package_Check != null) { return(Json(new { UpdateSuccess = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet)); } if ((bool)Session["MikrotikOptionEnable"]) { Mikrotik mikrotik = db.Mikrotik.Find(PackageInfoForUpdate.MikrotikID); var ipPoolName = db.IPPool.Find(PackageInfoForUpdate.IPPoolID).PoolName; var oldPackageInfoForUpdate = db.Package.Find(PackageInfoForUpdate.PackageID); PackageInfoForUpdate.OldPackageName = oldPackageInfoForUpdate.PackageName; try {//ITikConnection connection = ConnectionFactory.CreateConnection(TikConnectionType.Api); ITikConnection connection = ConnectionFactory.OpenConnection(TikConnectionType.Api, mikrotik.RealIP, 8728, mikrotik.MikUserName, mikrotik.MikPassword); connection.CreateCommandAndParameters("/ppp/profile/set", ".id", oldPackageInfoForUpdate.PackageName, "name", PackageInfoForUpdate.PackageName.Trim(), "local-address", PackageInfoForUpdate.LocalAddress, "remote-address", ipPoolName, "incoming-filter", "mypppclients").ExecuteNonQuery(); //add profile //var profileadd = connection.CreateCommandAndParameters("ppp/profile/add", "name", "test1", "local-address", "10.0.0.1", "remote-address", "sp", "incoming-filter", "mypppclients"); //profileadd.ExecuteNonQuery(); } catch (Exception ex) { return(Json(new { Success = false, MikrotikFailed = true, Message = ex.Message }, JsonRequestBehavior.AllowGet)); } } try { var Package = db.Package.Where(s => s.PackageID == PackageInfoForUpdate.PackageID); PackageInfoForUpdate.CreatedBy = Package.FirstOrDefault().CreatedBy; PackageInfoForUpdate.CreatedDate = Package.FirstOrDefault().CreatedDate; PackageInfoForUpdate.UpdateBy = "Hasan"; PackageInfoForUpdate.UpdateDate = AppUtils.GetDateTimeNow(); db.Entry(Package.SingleOrDefault()).CurrentValues.SetValues(PackageInfoForUpdate); db.SaveChanges(); var package = new CustomPackage() { PackageID = PackageInfoForUpdate.PackageID, PackageName = PackageInfoForUpdate.PackageName, BandWith = PackageInfoForUpdate.BandWith, PackagePrice = PackageInfoForUpdate.PackagePrice.ToString(), Client = db.ClientDetails.Where(ss => ss.PackageID == PackageInfoForUpdate.PackageID).Count(), IPPoolName = (PackageInfoForUpdate.IPPoolID != null) ? db.IPPool.Find(PackageInfoForUpdate.IPPoolID).PoolName : "", LocalAddress = PackageInfoForUpdate.LocalAddress, MikrotikName = db.Mikrotik.Find(PackageInfoForUpdate.MikrotikID).MikName, PackageUpdate = ISP_ManagementSystemModel.AppUtils.HasAccessInTheList(ISP_ManagementSystemModel.AppUtils.Update_Package) ? true : false, }; var JSON = Json(new { UpdateSuccess = true, PackageUpdateInformation = package }, JsonRequestBehavior.AllowGet); JSON.MaxJsonLength = int.MaxValue; return(JSON); } catch { return(Json(new { UpdateSuccess = false, PackageUpdateInformation = "" }, JsonRequestBehavior.AllowGet)); } }