예제 #1
0
 public SetPladged(PladgedEntity pladged)
 {
     this.pladged = pladged;
     SetPladgedInfo();
     InitializeComponent();
     DataContext = this;
 }
 public PladgedForm(PladgedEntity newPladged, int UserID)
 {
     this.userID     = UserID;
     this.newPladged = newPladged;
     InitializeComponent();
     fillType();
     DataContext = this;
 }
예제 #3
0
 private void PladgedDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         SelectedPladged = (PladgedEntity)PladgedDataGrid.SelectedValue;
     }
     catch (NullReferenceException) { }
 }
 public static void FindPladget(ref PladgedEntity pladged, int ID)
 {
     using (var dbConnection = new DatabaseContext())
     {
         pladged = (from pl in dbConnection.Pladgeds
                    where pl.ID == ID
                    select pl).FirstOrDefault();
     }
 }
        public static string AddnewItem(PladgedEntity pladged)
        {
            using (var dbConnection = new DatabaseContext())
            {
                try
                {
                    dbConnection.Pladgeds.Add(pladged);
                    dbConnection.SaveChanges();

                    //user.spent += pladged.Price;
                    //UserOption.updateUser(ref user);

                    return("Готово");
                }
                catch (Exception)
                {
                    return("Something went wrong");
                }
            }
        }
예제 #6
0
        private void AddPladgetButton_Click(object sender, RoutedEventArgs e)
        {
            PladgedEntity newPladged = new PladgedEntity();
            PladgedForm   pf         = new PladgedForm(newPladged, this.user.ID);

            new Thread(x =>
            {
                while (true)
                {
                    if (pf.FlagIsClosed)
                    {
                        PladgetOption.AddnewItem(newPladged);
                        daySpent      += newPladged.Price;
                        ReadyToRefresh = true;
                        break;
                    }
                }
            }).Start();
            pf.Show();
        }
        public static void updatePladged(PladgedEntity Modifiedpladged)
        {
            using (var dbConnection = new DatabaseContext())
            {
                int pladgedID = Modifiedpladged.ID;
                var pladged   = dbConnection.Pladgeds.SingleOrDefault(x => x.ID == pladgedID);

                if (pladged != null)
                {
                    pladged.DeadLine = Modifiedpladged.DeadLine;
                    pladged.IsClosed = Modifiedpladged.IsClosed;
                    pladged.returned = Modifiedpladged.returned;

                    dbConnection.SaveChanges();
                }
                else
                {
                    dbConnection.Pladgeds.Add(Modifiedpladged);
                    dbConnection.SaveChanges();
                }
            }
        }