public ActionResult DeleteClient(int?id) { try { if (id != null) { var clientpayment = ObjEntities.ClientsPayments.SingleOrDefault(e => e.Client == id); if (clientpayment.Id > 0 && int.Parse(clientpayment.Due_Amount) > 0) { TempData["Warning"] = "Cannot Delete Client having due amount.Please Pay Full Due Amount"; return(RedirectToAction("ClientsGridView")); } else { var client = ObjEntities.ClientsViews.SingleOrDefault(e => e.Id == id); if (client != null) { ObjEntities.ClientsViews.Remove(client ?? throw new InvalidOperationException()); ObjEntities.SaveChanges(); TempData["Success"] = "Successfully deleted"; return(RedirectToAction("ClientsGridView")); } } } } catch (Exception ex) { } return(RedirectToAction("ClientsGridView")); }
public ActionResult Register(UserProfile usr, HttpPostedFileBase file) { try { var checkEmail = con.UserProfiles.Where(s => s.Email == usr.Email).Any(); if (checkEmail == true) { TempData["Error"] = "This Email is already exist please choose a different one"; return(RedirectToAction("Register")); } else { if (file != null) { string Imagename = Path.GetFileName(file.FileName); string PhysicalPath = Path.Combine(Server.MapPath("~/UserImage/"), Imagename); file.SaveAs(PhysicalPath); usr.Image = Imagename; } con.UserProfiles.Add(usr); con.SaveChanges(); TempData["Success"] = "User Added Successfully"; return(RedirectToAction("Register")); } } catch (Exception ex) { } TempData["Heading"] = 10; return(RedirectToAction("Register")); }
public ActionResult DeleteEstriacksTypes(int?id) { try { if (id != null) { var eshtiracksType = entities.EshtiracksTypes.SingleOrDefault(e => e.Id == id); var checktype = entities.ClientsViews.SingleOrDefault(e => e.Type == id); if (checktype == null) { entities.EshtiracksTypes.Remove(eshtiracksType ?? throw new InvalidOperationException()); entities.SaveChanges(); TempData["Success"] = "Successfully Deleted"; return(RedirectToAction("TypesofEstiracks")); } else { TempData["Error"] = "Subscription type is using by " + checktype.Name + ". Cannot delete subscription type " + eshtiracksType.Description; } } } catch (Exception ex) { } return(RedirectToAction("TypesofEstiracks")); }
public ActionResult ClientsGridView(ClientsView clientsview, FormCollection Form) { try { if (ModelState.IsValid) { using (ArchitectureEntitiesModel ObjEntities = new ArchitectureEntitiesModel()) { clientsview.Date = DateTime.Parse(clientsview.Date.ToShortTimeString()); clientsview.FullPaymentuptodate = DateTime.Parse(clientsview.FullPaymentuptodate.ToShortTimeString()); clientsview.EntryDate = DateTime.Parse(DateTime.Now.ToShortTimeString()); ObjEntities.ClientsViews.Add(clientsview); ObjEntities.SaveChanges(); int id = clientsview.Id; if (id > 0) { TempData["Success"] = "Successfully Saved"; } else { TempData["Failed"] = "Not Saved"; } } } } catch (Exception ex) { } //TempData["ClientData"] = ObjEntities.ClientsView.ToList(); return(RedirectToAction("ClientsGridView")); }
public ActionResult AddExpense(ClientsExpense clientexpense) { try { if (ModelState.IsValid) { using (ArchitectureEntitiesModel ObjEntities = new ArchitectureEntitiesModel()) { clientexpense.EntryDate = DateTime.Now; ObjEntities.ClientsExpenses.Add(clientexpense); ObjEntities.SaveChanges(); int id = clientexpense.Id; if (id > 0) { TempData["Success"] = "Successfully Saved"; } else { TempData["Failed"] = "Not Saved"; } } } } catch (Exception ex) { } //var Clients = new SelectList(ObjEntities.ClientsView.ToList(), "Id", "Name"); //ViewData["ClientPayment"] = Clients; return(RedirectToAction("ChooseExpense"));; }
public ActionResult UpdateClientsGridView(ClientsView clientsview) { try { using (ArchitectureEntitiesModel entities = new ArchitectureEntitiesModel()) { ClientsView updatedclientsview = (from c in entities.ClientsViews where c.Id == clientsview.Id select c).FirstOrDefault(); updatedclientsview.Name = clientsview.Name; updatedclientsview.Location = clientsview.Location; updatedclientsview.Type = clientsview.Type; updatedclientsview.Date = clientsview.Date; updatedclientsview.Amount = clientsview.Amount; updatedclientsview.FullPaymentuptodate = clientsview.FullPaymentuptodate; updatedclientsview.EntryDate = DateTime.Now; entities.SaveChanges(); TempData["Success"] = "Successfully Updated"; } } catch (Exception ex) { } return(RedirectToAction("ClientsGridView")); }
public ActionResult UpdateTypesofEstirack(EshtiracksType Eshtirackstype) { try { using (ArchitectureEntitiesModel entities = new ArchitectureEntitiesModel()) { EshtiracksType updatedTypesofEstiracks = (from c in entities.EshtiracksTypes where c.Id == Eshtirackstype.Id select c).FirstOrDefault(); updatedTypesofEstiracks.Description = Eshtirackstype.Description; updatedTypesofEstiracks.Amount = Eshtirackstype.Amount; entities.SaveChanges(); int id = Eshtirackstype.Id; if (id > 0) { TempData["Success"] = "Successfully Updated"; TempData["Heading"] = 1; return(RedirectToAction("TypesofEstiracks")); } else { TempData["Failed"] = "Not Updated"; return(View()); } } } catch (Exception ex) { TempData["Failed"] = "Exception Occured"; return(View()); } }
public ActionResult TypesofEstiracks(EshtiracksType Eshtirackstype) { try { if (ModelState.IsValid) { using (ArchitectureEntitiesModel entities = new ArchitectureEntitiesModel()) { entities.EshtiracksTypes.Add(Eshtirackstype); entities.SaveChanges(); int id = Eshtirackstype.Id; if (id > 0) { TempData["Success"] = "Successfully Saved"; } else { TempData["Failed"] = "Not Saved"; } } } } catch (Exception ex) { TempData["Failed"] = "Exception Occured"; return(View()); } return(RedirectToAction("TypesofEstiracks")); }
public ActionResult UpdateClientsPayment(ClientsPayment clientspayment) { try { using (ArchitectureEntitiesModel entities = new ArchitectureEntitiesModel()) { var getclientpayment = ObjEntities.ClientsPayments.Where(e => e.Client == clientspayment.Client).FirstOrDefault(); var getclient = ObjEntities.ClientsViews.Where(e => e.Id == clientspayment.Client).FirstOrDefault(); if (getclientpayment != null) { if (Convert.ToInt32(clientspayment.Paid_Amount) <= Convert.ToInt32(getclient.Amount)) { int Due = Convert.ToInt32(getclient.Amount) - Convert.ToInt32(clientspayment.Paid_Amount); getclientpayment.Paid_Amount = clientspayment.Paid_Amount; getclientpayment.Due_Amount = Due.ToString(); //getclientpayment.EntryDate = Convert.ToDateTime(clientspayment.Month); entities.SaveChanges(); TempData["Success"] = "Data Updated successfully"; } else { TempData["Warning"] = "Paid Amount Should be less than due amount!"; return(RedirectToAction("EditClientsPayment")); } } //if (long.Parse(clientspayment.Paid_Amount.ToString()) <= long.Parse(getclientpayment.Due_Amount.ToString())) //{ // ClientsPayment updatedclientspayment = (from c in entities.ClientsPayments // where c.Id == clientspayment.Id // select c).FirstOrDefault(); // updatedclientspayment.Client = clientspayment.Client; // updatedclientspayment.Month = clientspayment.Month; // updatedclientspayment.Paid_Amount = Convert.ToString(long.Parse((updatedclientspayment.Paid_Amount)) + long.Parse((clientspayment.Paid_Amount))); // updatedclientspayment.Due_Amount = Convert.ToString(long.Parse((getclient.Amount)) - long.Parse((updatedclientspayment.Paid_Amount))); // updatedclientspayment.Month = clientspayment.Month; // updatedclientspayment.EntryDate = DateTime.Now; // entities.SaveChanges(); // TempData["Success"] = "Successfully updated"; //} //else //{ // TempData["Warning"] = "Paid Amount Should be less than due amount!"; // return RedirectToAction("EditClientsPayment"); //} } } catch (Exception ex) { } return(RedirectToAction("AddPayments")); }
private void UpdateClientsPayment(string Amount, int id) { using (ArchitectureEntitiesModel entities = new ArchitectureEntitiesModel()) { ClientsView updatedclientsview = (from c in entities.ClientsViews where c.Id == id select c).FirstOrDefault(); long clientamount = long.Parse(updatedclientsview.Amount); long clientpayments = long.Parse(Amount); long updatedamount = clientamount - clientpayments; updatedclientsview.Amount = updatedamount.ToString(); updatedclientsview.EntryDate = DateTime.Now; entities.SaveChanges(); } }
public ActionResult UpdateClientsExpense(ClientsExpense clientsexpense) { try { using (ArchitectureEntitiesModel entities = new ArchitectureEntitiesModel()) { ClientsExpense updatedclientsexpenset = (from c in entities.ClientsExpenses where c.Id == clientsexpense.Id select c).FirstOrDefault(); updatedclientsexpenset.Expensetype = clientsexpense.Expensetype; updatedclientsexpenset.Amount = clientsexpense.Amount; updatedclientsexpenset.EntryDate = DateTime.Now; entities.SaveChanges(); TempData["Success"] = "Successfully Updated"; } } catch (Exception ex) { } return(RedirectToAction("ChooseExpense")); }
public ActionResult UpdateExpensesListNames(ExpenseListName expenselistname, HttpPostedFileBase ImageFile) { try { using (ArchitectureEntitiesModel entities = new ArchitectureEntitiesModel()) { ExpenseListName updatedexpenselistname = (from c in entities.ExpenseListNames where c.Id == expenselistname.Id select c).FirstOrDefault(); updatedexpenselistname.Description = expenselistname.Description; //expenselistname.ImageFile = new HttpPostedFile(); //Extract Image File Name. if (ImageFile != null) { string fileName = System.IO.Path.GetFileName(ImageFile.FileName); // Set the Image File Path. string filePath = "~/Images/avatars/" + fileName; //Save the Image File in Folder. ImageFile.SaveAs(Server.MapPath(filePath)); updatedexpenselistname.IconPath = filePath; } entities.SaveChanges(); int id = expenselistname.Id; if (id > 0) { TempData["Success"] = "Successfully Updated"; } } } catch (Exception ex) { } return(RedirectToAction("ExpensesListNames")); }
public ActionResult AddPayments(ClientsPayment clientpayment) { try { if (ModelState.IsValid) { //UpdateClientsPayment(clientpayment.Paid_Amount,clientpayment.Client); using (ArchitectureEntitiesModel ObjEntities = new ArchitectureEntitiesModel()) { var getclient = ObjEntities.ClientsViews.Where(e => e.Id == clientpayment.Client).FirstOrDefault(); //My Code Saad Bhatti var chkData = ObjEntities.ClientsPayments.Where(c => c.Client == clientpayment.Client && c.EntryDate.Year == clientpayment.Month.Year && c.EntryDate.Month == clientpayment.Month.Month).FirstOrDefault(); if (chkData != null) { if (Convert.ToInt32(getclient.Amount) >= Convert.ToInt32(clientpayment.Paid_Amount) + Convert.ToInt32(chkData.Paid_Amount)) { if (long.Parse(clientpayment.Paid_Amount.ToString()) <= long.Parse(getclient.Amount.ToString())) { int TotalAmount = Convert.ToInt32(getclient.Amount); int Due = Convert.ToInt32(TotalAmount) - (Convert.ToInt32(clientpayment.Paid_Amount) + (Convert.ToInt32(chkData.Paid_Amount))); int Paid = Convert.ToInt32(chkData.Paid_Amount) + Convert.ToInt32(clientpayment.Paid_Amount); chkData.Paid_Amount = Paid.ToString(); chkData.Due_Amount = Due.ToString(); ObjEntities.SaveChanges(); //clientpayment.EntryDate = DateTime.Now; //chkData.Due_Amount = Due.ToString(); //ObjEntities.ClientsPayments.Add(clientpayment); //ObjEntities.SaveChanges(); //int id1 = 0; //id1 = clientpayment.Id; //if (id1 > 0) //{ // var getmonth = ObjEntities.tblMonth.Where(e => e.Id == clientpayment.Month).FirstOrDefault(); TempData["Success"] = Session["UserName"] + " " + "Added" + " " + clientpayment.Paid_Amount + " " + "for" + " " + getclient.Name + " " + "for" + " " + "Month" + "-" + clientpayment.Month.Month; tblNotification tblnotification = new tblNotification(); tblnotification.NotificationMessage = Session["UserName"] + " " + "Added" + " " + clientpayment.Paid_Amount + " " + "for" + " " + getclient.Name + " " + "for" + " " + "Month" + "-" + clientpayment.Month.Month; tblnotification.IsShow = 0; ObjEntities.tblNotifications.Add(tblnotification); ObjEntities.SaveChanges(); //} } else { TempData["Warning"] = "Paid Amount Should be less than due amount!"; } } else { TempData["Warning"] = "Paid Amount Should be less than due amount!"; } } else { int id = 0; clientpayment.EntryDate = Convert.ToDateTime(clientpayment.Month); clientpayment.Due_Amount = Convert.ToString(long.Parse((getclient.Amount)) - long.Parse((clientpayment.Paid_Amount))); ObjEntities.ClientsPayments.Add(clientpayment); ObjEntities.SaveChanges(); id = clientpayment.Id; if (id > 0) { // var getmonth = ObjEntities.tblMonth.Where(e => e.Id == clientpayment.Month).FirstOrDefault(); TempData["Success"] = Session["UserName"] + " " + "Added" + " " + clientpayment.Paid_Amount + "Payment" + " " + "for" + " " + getclient.Name + " " + "for" + " " + "Month" + "-" + clientpayment.Month; tblNotification tblnotification = new tblNotification(); tblnotification.NotificationMessage = Session["UserName"] + " " + "Added" + " " + clientpayment.Paid_Amount + " " + "for" + " " + getclient.Name + " " + "for" + " " + "Month" + "-" + clientpayment.Month; tblnotification.IsShow = 0; ObjEntities.tblNotifications.Add(tblnotification); ObjEntities.SaveChanges(); } } } } //var Clients = new SelectList(ObjEntities.ClientsView.ToList(), "Id", "Name"); //ViewData["ClientPayment"] = Clients; } catch (Exception ex) { } return(RedirectToAction("AddPayments")); }