public static int[] GetNumbersOfPlaces(this HtmlHelper helper, int routeId) //Метод, расширяющий хелпер @Html { List <int> freetickets = new List <int>(); List <int> busytickets = new List <int>(); using (WorkWithDatabase db = new WorkWithDatabase()) { int RouteId = routeId; var countst = db.GetEntityById <Route, int>(RouteId).MaxNumberOfPlace; if (countst > 0) { int countOfPlace = Convert.ToInt32(countst); int[] masplace = new int[countOfPlace]; busytickets = db.GetEntityList <Ticket>().Where(x => x.Route.Id.Equals(RouteId)).Select(x => x.NumberOfPlace).ToList(); for (int i = 1; i <= countOfPlace; i++) { if (!busytickets.Contains(i)) { freetickets.Add(i); } } } } return(freetickets.ToArray()); }
public ManagerOfLogging(WorkWithDatabase databaseWorker) { this.databaseWorker = databaseWorker; if (!databaseWorker.GetTableNames().Contains("dbo." + table)) { databaseWorker.CreateTable(table, columnsTypes); } }
public ActionResult Index() { List<Route> Listroutes = new List<Route>(); using (WorkWithDatabase db = new WorkWithDatabase()) { Listroutes = db.GetEntityList<Route>(); } return View(Listroutes); }
public ActionResult ReturnTicket(int ticketId) { using (WorkWithDatabase db = new WorkWithDatabase()) { Ticket tic = db.GetEntityById <Ticket, int>(ticketId); tic.IsDeleted = true; db.Commit(); } return(RedirectToAction("TicketInformation")); }
public ActionResult Index() { List <Route> Listroutes = new List <Route>(); using (WorkWithDatabase db = new WorkWithDatabase()) { Listroutes = db.GetEntityList <Route>(); } return(View(Listroutes)); }
public ActionResult BuyBookTicket(int tickId) { using (WorkWithDatabase db = new WorkWithDatabase()) { Ticket tick = db.GetEntityById <Ticket, int>(tickId); tick.Condition = TypeOfTicketEnum.Bought; db.Commit(); } return(RedirectToAction("TicketInformation")); }
public ActionResult TicketInformation() { List <Ticket> tickets = new List <Ticket>(); using (WorkWithDatabase db = new WorkWithDatabase()) { string s1 = Session[BookTickets.Properties.Resources.LogInUserName].ToString(); string s2 = Session[BookTickets.Properties.Resources.LogInUserPassword].ToString(); var t = db.GetEntityList <Person>().Where(x => x.LogName.Equals(s1) && x.Password.Equals(s2)).Select(x => x.PersonID).FirstOrDefault(); tickets = db.GetEntityList <Ticket>().Where(x => x.Person.PersonID.Equals(t)).ToList(); } return(View("InformationAboutTicket", tickets)); }
private bool check(string name, string pass) { using (WorkWithDatabase db = new WorkWithDatabase()) { try { return(db.GetEntityList <Person>().Where(x => x.LogName.Equals(name) && x.Password.Equals(pass)).Count() > 0); } catch (Exception ex) { return(false); } } }
public ActionResult Buy() { Ticket ticket = new Ticket(); using (WorkWithDatabase db = new WorkWithDatabase()) { string s = Session[BookTickets.Properties.Resources.RouteID].ToString(); if (s != null) { int r = Convert.ToInt32(s); var rout = db.GetEntityById<Route, int>(r); ticket.Route = rout; } } return View("Buy", ticket); }
public ActionResult Buy() { Ticket ticket = new Ticket(); using (WorkWithDatabase db = new WorkWithDatabase()) { string s = Session[BookTickets.Properties.Resources.RouteID].ToString(); if (s != null) { int r = Convert.ToInt32(s); var rout = db.GetEntityById <Route, int>(r); ticket.Route = rout; } } return(View("Buy", ticket)); }
public ViewResult Registration(Person regPerson) { if (ModelState.IsValid) { Session[BookTickets.Properties.Resources.LogInUserPassword] = regPerson.Password.GetHashCode().ToString(); Session[BookTickets.Properties.Resources.LogInUserName] = regPerson.LogName; using (WorkWithDatabase db = new WorkWithDatabase()) { regPerson.Password = regPerson.Password.GetHashCode().ToString(); db.Insert <Person>(regPerson); db.Commit(); } return(View("Thanks", regPerson)); } else { return(View()); } }
//--------------------------------------------------------------------------------------------------------------------------------------------------- //Action on long click on the item in choosing the use list. private void ListOfUsers_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e) { //Creating a new layout for deleting one user. AlertDialog.Builder Object = new AlertDialog.Builder(this); LayoutInflater inflater = LayoutInflater.From(this); LinearLayout layout = new LinearLayout(this); View FormViewDelete = inflater.Inflate(Resource.Layout.DeleteUserForm, layout); Object.SetView(FormViewDelete); TextView DeleteUserTextView = FormViewDelete.FindViewById <TextView>(Resource.Id.DeleteUserText); DeleteUserTextView.Text = Resources.GetString(Resource.String.DeleteUser) + Classes.WorkWithDatabase.SQConnection.Table <Classes.User>().ElementAt(e.Position).Name + " ?"; //Action on pressing posititve button. Object.SetPositiveButton(Resource.String.OK, new EventHandler <DialogClickEventArgs>(delegate(object Sender, DialogClickEventArgs e1) { //If current user is deleted, then the current user isn't choosed. if (Classes.User.CurrentUser == e.Position) { Classes.User.CurrentUser = -1; } //Deleting fromm the DB. WorkWithDatabase.DeleteUser(TempList.ElementAt(e.Position)); //Deleting from the list. TempList.RemoveAt(e.Position); var adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, TempList); ListOfUsers.Adapter = adapter; })); //Action on pressing negative button. Object.SetNegativeButton(Resource.String.Cancel, new EventHandler <DialogClickEventArgs>(delegate(object Sender, DialogClickEventArgs e1) { })); //Showing the new form for deleting a user. Object.Show(); }
public ActionResult Buy(Ticket tick) { if (tick.NumberOfPlace != 0) { using (WorkWithDatabase db = new WorkWithDatabase()) { tick.Condition = TypeOfTicketEnum.Bought; string s1 = Session[BookTickets.Properties.Resources.LogInUserName].ToString(); string s2 = Session[BookTickets.Properties.Resources.LogInUserPassword].ToString(); var per = db.GetEntityList <Person>().Where(x => x.LogName.Equals(s1) && x.Password.Equals(s2)).FirstOrDefault(); var route = db.GetEntityById <Route, int>(tick.Route.RouteID); tick.Person = per; tick.Route = route; db.Insert <Ticket>(tick); db.Commit(); } return(RedirectToAction("TicketInformation")); } else { return(View()); } }
public ActionResult Buy(Ticket tick) { if (tick.NumberOfPlace != 0) { using (WorkWithDatabase db = new WorkWithDatabase()) { tick.Condition = TypeOfTicketEnum.Bought; string s1 = Session[BookTickets.Properties.Resources.LogInUserName].ToString(); string s2 = Session[BookTickets.Properties.Resources.LogInUserPassword].ToString(); var per = db.GetEntityList<Person>().Where(x => x.LogName.Equals(s1) && x.Password.Equals(s2)).FirstOrDefault(); var route = db.GetEntityById<Route, int>(tick.Route.RouteID); tick.Person = per; tick.Route = route; db.Insert<Ticket>(tick); db.Commit(); } return RedirectToAction("TicketInformation"); } else { return View(); } }
//--------------------------------------------------------------------------------------------------------------------------------------------------- //Setting parametres for a user. private void SetParametersButton_Click(object sender, EventArgs e) { //Creating a new layout for setting parameters of a user. AlertDialog.Builder Object = new AlertDialog.Builder(this); LayoutInflater inflater = LayoutInflater.From(this); LinearLayout layout = new LinearLayout(this); View FormViewsSetParametres = inflater.Inflate(Resource.Layout.SetParametresForm, layout); Object.SetView(FormViewsSetParametres); //Action on pressing posititve button. Object.SetPositiveButton(Resource.String.AddEntry, new EventHandler <DialogClickEventArgs>(delegate(object Sender, DialogClickEventArgs e1) { //If the user is choosed. if (Classes.User.CurrentUser != -1) { //Getting data and changing the symbols. string sForChangeWeight = FormViewsSetParametres.FindViewById <TextView>(Resource.Id.WeightEdit).Text; string sForChangeHeight = FormViewsSetParametres.FindViewById <TextView>(Resource.Id.HeightEdit).Text; DateTime DTForData = System.DateTime.Now; sForChangeWeight = sForChangeWeight.Replace(".", ","); sForChangeHeight = sForChangeHeight.Replace(".", ","); //If weight wasn't entered correctly. if (!CheckingData.CheckForLenth(sForChangeWeight, 0, 8) || !CheckingData.CheckForValue(double.Parse(sForChangeWeight), 0, 500)) { Toast.MakeText(this, CheckingData.RequestToCorrectEnter("weight"), ToastLength.Long).Show(); } else //If height wasn't entered correctly. if (!CheckingData.CheckForLenth(sForChangeHeight, 0, 8) || !CheckingData.CheckForValue(double.Parse(sForChangeHeight), 0, 300)) { Toast.MakeText(this, CheckingData.RequestToCorrectEnter("height"), ToastLength.Long).Show(); } //If everything was entered correctly. else { //Creating temporary parameters for a new user. Classes.ParametresOfUser TempParametres = new Classes.ParametresOfUser(DTForData, double.Parse(sForChangeWeight), double.Parse(sForChangeHeight)); //For showing results of changes. string sForIndexResults = ""; string sForParametersResults = ""; //Creating a new layout for showing user changes. AlertDialog.Builder Object_ = new AlertDialog.Builder(this); LayoutInflater inflater_ = LayoutInflater.From(this); LinearLayout layout_ = new LinearLayout(this); View FormViewChangeParameters = inflater.Inflate(Resource.Layout.ParametersChangesForm, layout_); Object_.SetView(FormViewChangeParameters); //Change of user's BMI. if (!CheckingData.ComparingValues(TempParametres.Index, 15.0)) { sForIndexResults = Resources.GetString(Resource.String.BMIout) + " " + TempParametres.Index + ". ATTENTION: you are very severely underweight!"; } else if (!CheckingData.ComparingValues(TempParametres.Index, 16.0)) { sForIndexResults = Resources.GetString(Resource.String.BMIout) + " " + TempParametres.Index + ". ATTENTION: you are severely underweight!"; } else if (!CheckingData.ComparingValues(TempParametres.Index, 18.5)) { sForIndexResults = Resources.GetString(Resource.String.BMIout) + " " + TempParametres.Index + ". You are underweight!"; } else if (!CheckingData.ComparingValues(TempParametres.Index, 25.0)) { sForIndexResults = Resources.GetString(Resource.String.BMIout) + " " + TempParametres.Index + ". You have healthy weight for your height."; } else if (!CheckingData.ComparingValues(TempParametres.Index, 30.0)) { sForIndexResults = Resources.GetString(Resource.String.BMIout) + " " + TempParametres.Index + ". You are overweight!"; } else if (!CheckingData.ComparingValues(TempParametres.Index, 35.0)) { sForIndexResults = Resources.GetString(Resource.String.BMIout) + " " + TempParametres.Index + ". ATTENTION: you are moderately overweight!"; } else if (!CheckingData.ComparingValues(TempParametres.Index, 40.0)) { sForIndexResults = Resources.GetString(Resource.String.BMIout) + " " + TempParametres.Index + ". ATTENTION: you are severely overweight!"; } else { sForIndexResults = Resources.GetString(Resource.String.BMIout) + " " + TempParametres.Index + ". ATTENTION: you are very severely overweight!"; } Object_.SetPositiveButton(Resource.String.OK, new EventHandler <DialogClickEventArgs>(delegate(object Sender_, DialogClickEventArgs e1_) { })); FormViewChangeParameters.FindViewById <TextView>(Resource.Id.TextForIndex).Text = sForIndexResults; //Change of user's weight and height. //If the list of parameters isn't empty. if (WorkWithDatabase.GetUser(User.CurrentUser).Parameters.Count != 0) { //Сhange of weight. if (WorkWithDatabase.GetUser(User.CurrentUser).Parameters.Last().Weight > TempParametres.Weight) { sForParametersResults = "You've lost " + Math.Abs(WorkWithDatabase.GetUser(User.CurrentUser).Parameters.Last().Weight - TempParametres.Weight) + " kilograms."; } else if (WorkWithDatabase.GetUser(User.CurrentUser).Parameters.Last().Weight < TempParametres.Weight) { sForParametersResults = "You've gained " + Math.Abs(WorkWithDatabase.GetUser(User.CurrentUser).Parameters.Last().Weight - TempParametres.Weight) + " kilograms."; } //Сhange of height. if (WorkWithDatabase.GetUser(User.CurrentUser).Parameters.Last().Height < TempParametres.Height) { sForParametersResults = sForParametersResults + " You're " + Math.Abs(WorkWithDatabase.GetUser(User.CurrentUser).Parameters.Last().Height - TempParametres.Height) + " centimeters taller now."; } } FormViewChangeParameters.FindViewById <TextView>(Resource.Id.TextForParameters).Text = sForParametersResults; Object_.Show(); Classes.User TempUser = WorkWithDatabase.GetUser(User.CurrentUser); TempUser.Parameters.Add(TempParametres); Classes.WorkWithDatabase.SQConnection.UpdateWithChildren(TempUser); } } else { Toast.MakeText(this, Resource.String.Unchoosed, ToastLength.Long).Show(); } })); //Action on pressing negative button. Object.SetNegativeButton(Resource.String.Cancel, new EventHandler <DialogClickEventArgs>(delegate(object Sender, DialogClickEventArgs e1) { })); //Showing the new form for entering the paatametres. Object.Show(); }
public static int[] GetNumbersOfPlaces(this HtmlHelper helper, int routeId)//Метод, расширяющий хелпер @Html { List<int> freetickets = new List<int>(); List<int> busytickets = new List<int>(); using (WorkWithDatabase db = new WorkWithDatabase()) { int RouteId = routeId; var countst = db.GetEntityById<Route, int>(RouteId).MaxNumberOfPlace; if (countst > 0) { int countOfPlace = Convert.ToInt32(countst); int[] masplace = new int[countOfPlace]; busytickets = db.GetEntityList<Ticket>().Where(x => x.Route.Id.Equals(RouteId)).Select(x => x.NumberOfPlace).ToList(); for (int i = 1; i <= countOfPlace; i++) { if (!busytickets.Contains(i)) { freetickets.Add(i); } } } } return freetickets.ToArray(); }
//--------------------------------------------------------------------------------------------------------------------------------------------------- //Action on short click on the item in choosing the use list. private void ListOfUsers_ItemClick(object sender, AdapterView.ItemClickEventArgs e) { //Setting the current user and displaying info about him/her. Classes.User.CurrentUser = e.Position; Toast.MakeText(this, WorkWithDatabase.GetUser(User.CurrentUser).ToString(), ToastLength.Long).Show(); }
public ActionResult ReturnTicket(int ticketId) { using (WorkWithDatabase db = new WorkWithDatabase()) { Ticket tic = db.GetEntityById<Ticket, int>(ticketId); tic.IsDeleted = true; db.Commit(); } return RedirectToAction("TicketInformation"); }
public ViewResult Registration(Person regPerson) { if (ModelState.IsValid) { Session[BookTickets.Properties.Resources.LogInUserPassword] = regPerson.Password.GetHashCode().ToString(); Session[BookTickets.Properties.Resources.LogInUserName] = regPerson.LogName; using (WorkWithDatabase db = new WorkWithDatabase()) { regPerson.Password = regPerson.Password.GetHashCode().ToString(); db.Insert<Person>(regPerson); db.Commit(); } return View("Thanks", regPerson); } else { return View(); } }
private bool check(string name, string pass) { using (WorkWithDatabase db = new WorkWithDatabase()) { try { return db.GetEntityList<Person>().Where(x => x.LogName.Equals(name) && x.Password.Equals(pass)).Count() > 0; } catch (Exception ex) { return false; } } }
public ActionResult BuyBookTicket(int tickId) { using (WorkWithDatabase db = new WorkWithDatabase()) { Ticket tick = db.GetEntityById<Ticket, int>(tickId); tick.Condition = TypeOfTicketEnum.Bought; db.Commit(); } return RedirectToAction("TicketInformation"); }
public ActionResult TicketInformation() { List<Ticket> tickets = new List<Ticket>(); using (WorkWithDatabase db = new WorkWithDatabase()) { string s1 = Session[BookTickets.Properties.Resources.LogInUserName].ToString(); string s2 = Session[BookTickets.Properties.Resources.LogInUserPassword].ToString(); var t = db.GetEntityList<Person>().Where(x => x.LogName.Equals(s1) && x.Password.Equals(s2)).Select(x => x.PersonID).FirstOrDefault(); tickets = db.GetEntityList<Ticket>().Where(x => x.Person.PersonID.Equals(t)).ToList(); } return View("InformationAboutTicket", tickets); }