Example #1
0
 public ActionResult Delete(mobile mob)
 {
     if (ModelState.IsValid)
     {
         mc.Entry(mob).State = EntityState.Deleted;
         mc.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View());
 }
		public ServiceError (string Title, mobile.models.ViewModels.ViewModel view)
		{		
			this.Padding = new Thickness (0, 0);
			var layout = new RelativeLayout ();

			NavigationPage.SetHasBackButton (this, false);

			this.Title = Title;

			imgRefresh = new Button {
				Text = "Refresh"
			};

			imgRefresh.IsVisible = true;

//			var gesture = new TapGestureRecognizer ();
//			gesture.NumberOfTapsRequired = 1;
//
//			gesture.SetBinding (TapGestureRecognizer.CommandProperty, "RefreshCommand");
//			imgRefresh.GestureRecognizers.Add (gesture);
			imgRefresh.SetBinding (Button.CommandProperty, "RefreshCommand");
			layout.Children.Add(imgRefresh,
				Constraint.RelativeToParent( (parent) => {
					// x
					return (parent.Width / 2) - 64;
				}),
				Constraint.RelativeToParent( (parent) => {
					// Y
					return (parent.Height / 2) - 64;
				}),
				// width
				Constraint.Constant(128),
				// height
				Constraint.Constant(128)
			);

			lblError = new Label { Text = "Error Loading" };

			this.Content = new StackLayout {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
				Children = {
					new StackLayout
					{
						HorizontalOptions = LayoutOptions.FillAndExpand,
						Padding = new Thickness(10, 10, 10, 10),
						Children = {
							lblError
						}
					},
					layout
				}
			};
		}
Example #3
0
        // delete mobile action
        public ActionResult Delete(int id)
        {
            mobile mb = mc.mobiles.Single(x => x.mobile_id == id);

            if (mb == null)
            {
                return(HttpNotFound());
            }

            return(View(mb));
        }
Example #4
0
 public ActionResult editmobile(mobile mobiledata)
 {
     dBaseEntities1.Entry(mobiledata).State = EntityState.Modified;
     dBaseEntities1.SaveChanges();
     return(RedirectToAction("showmobile"));
 }
Example #5
0
        static void sort(FileStream aFile)
        {
            int k;
            do
            {
                Console.WriteLine("Введите по какому столбику сортировать:");
                k = Convert.ToInt32(Console.ReadLine()) - 1;
            }
            while (k > 2 || k < 0);
            Encoder e = Encoding.UTF8.GetEncoder();
            Decoder d = Encoding.UTF8.GetDecoder();
            char[] charbuf = new char[50];
            byte[] bytebuf = new byte[50];
            aFile.Seek(0, SeekOrigin.Begin);
            string buf = "";
            char[] sep = { '\t' };
            string[] mas1 = new string[4];
            int kol = 0;
            int kolSt = 0;
            mobile[] baza = new mobile[3];
            while (aFile.Read(bytebuf, 0, bytebuf.Length) != 0)
            {
                kol = 0;
                buf = "";
                while (kol < 2)
                {
                    d.GetChars(bytebuf, 0, bytebuf.Length, charbuf, 0, true);
                    for (int i = 0; i < charbuf.Length; i++)
                    {
                        buf += charbuf[i];
                    }
                    Array.Clear(bytebuf, 0, 50);
                    Array.Clear(charbuf, 0, 50);
                    mas1 = buf.Split(sep, StringSplitOptions.RemoveEmptyEntries);
                    if (mas1.Length != 3 && mas1.Length != 4) break;
                    baza[kol].name = mas1[0];
                    baza[kol].chastota = Convert.ToInt32(mas1[1]);
                    baza[kol].price = Convert.ToDouble(mas1[2]);
                    Array.Clear(mas1, 0, mas1.Length);
                    buf = ""; kol++;
                    if (kol != 2) aFile.Read(bytebuf, 0, bytebuf.Length);
                }
                if (k == 0)
                {
                    for (int i = 0; i < kol - 1; i++)
                    {
                        for (int j = 0; j < kol - i - 1; j++)
                        {
                            if ((baza[j].name.CompareTo(baza[j + 1].name)) == 1)
                            {
                                baza[2] = baza[j];
                                baza[j] = baza[j + 1];
                                baza[j + 1] = baza[2];
                                aFile.Seek(kolSt * 50, SeekOrigin.Begin);
                                Array.Clear(charbuf, 0, 50);
                                Array.Clear(bytebuf, 0, 50);
                                for (int g = 0; g < kol; g++)
                                {
                                    if (g == 1) aFile.Seek(kolSt * 50 + 50, SeekOrigin.Begin);
                                    buf = baza[g].name + '\t' + baza[g].chastota + '\t' + baza[g].price;
                                    charbuf = buf.ToCharArray();
                                    e.GetBytes(charbuf, 0, charbuf.Length, bytebuf, 0, true);
                                    charbuf = new char[50];
                                    aFile.Write(bytebuf, 0, 50);
                                    Array.Clear(charbuf, 0, 50);
                                    Array.Clear(bytebuf, 0, 50);
                                }
                                kolSt=0;
                                aFile.Seek(kolSt * 50, SeekOrigin.Begin);
                            }
                            else
                            {
                                kolSt++;
                                aFile.Seek(kolSt * 50, SeekOrigin.Begin);
                            }
                        }
                    }
                }
                if (k == 1)
                {

                    for (int i = 0; i < kol - 1; i++)
                        for (int j = 0; j < kol - i - 1; j++)
                            if (baza[j].chastota > baza[j + 1].chastota)
                            {
                                baza[2] = baza[j];
                                baza[j] = baza[j + 1];
                                baza[j + 1] = baza[2];
                                aFile.Seek(kolSt * 50, SeekOrigin.Begin);
                                Array.Clear(charbuf, 0, 50);
                                Array.Clear(bytebuf, 0, 50);
                                for (int g = 0; g < kol; g++)
                                {
                                    if (g == 1) aFile.Seek(kolSt * 50 + 50, SeekOrigin.Begin);
                                    buf = baza[g].name + '\t' + baza[g].chastota + '\t' + baza[g].price;
                                    charbuf = buf.ToCharArray();
                                    e.GetBytes(charbuf, 0, charbuf.Length, bytebuf, 0, true);
                                    charbuf = new char[50];
                                    aFile.Write(bytebuf, 0, 50);
                                    Array.Clear(charbuf, 0, 50);
                                    Array.Clear(bytebuf, 0, 50);
                                }
                                kolSt=0;
                                aFile.Seek(kolSt * 50, SeekOrigin.Begin);
                            }
                            else
                            {
                                kolSt++;
                                aFile.Seek(kolSt * 50, SeekOrigin.Begin);
                            }
                }
                if (k == 2)
                {
                    for (int i = 0; i < kol - 1; i++)
                        for (int j = 0; j < kol - i - 1; j++)
                            if (baza[j].price > baza[j + 1].price)
                            {
                                baza[2] = baza[j];
                                baza[j] = baza[j + 1];
                                baza[j + 1] = baza[2];
                                aFile.Seek(kolSt * 50, SeekOrigin.Begin);
                                Array.Clear(charbuf, 0, 50);
                                Array.Clear(bytebuf, 0, 50);
                                for (int g = 0; g < kol; g++)
                                {
                                    if (g == 1) aFile.Seek(kolSt * 50 + 50, SeekOrigin.Begin);
                                    buf = baza[g].name + '\t' + baza[g].chastota + '\t' + baza[g].price;
                                    charbuf = buf.ToCharArray();
                                    e.GetBytes(charbuf, 0, charbuf.Length, bytebuf, 0, true);
                                    charbuf = new char[50];
                                    aFile.Write(bytebuf, 0, 50);
                                    Array.Clear(charbuf, 0, 50);
                                    Array.Clear(bytebuf, 0, 50);
                                }
                                kolSt = 0;
                                aFile.Seek(kolSt * 50, SeekOrigin.Begin);
                            }
                            else
                            {
                                kolSt++;
                                aFile.Seek(kolSt * 50, SeekOrigin.Begin);
                            }
                }
            }
            vivod(aFile);
        }