コード例 #1
0
        private async Task SaveDepth()
        {
            SQLExecute sqlexec = new SQLExecute();
            await sqlexec.SqlInsertDepth(Properties.Settings.Default.DBName, depths);

            depths.Clear();
        }
コード例 #2
0
        private async Task SaveKilometer()
        {
            SQLExecute sqlexec = new SQLExecute();
            await sqlexec.SqlInsertKilometer(Properties.Settings.Default.DBName, kilometers);

            kilometers.Clear();
        }
コード例 #3
0
        private async Task SaveShift()
        {
            SQLExecute sqlexec = new SQLExecute();
            await sqlexec.SqlInsertShift(Properties.Settings.Default.DBName, shifts);

            shifts.Clear();
        }
コード例 #4
0
        private async Task FillCombosRun()
        {
            DateTime   todayyo = DateTime.Today;
            string     none    = "none";
            SQLExecute sqlexec = new SQLExecute();

            taxi = await sqlexec.SQLGetTaxi(Properties.Settings.Default.DBName, 0, none, 0, none, none, none, 0, none, none, 0, todayyo, none, true);

            owner.Clear();
            owner.Clear();
            driver.Clear();
            depthsAll.Clear();
            depthsAllPaid.Clear();
            person.Clear();

            owner = await sqlexec.SQLGetPerson(Properties.Settings.Default.DBName, 0, none, none, none, 0, 0, none, 0, todayyo, none, 2, false);

            driver = await sqlexec.SQLGetPerson(Properties.Settings.Default.DBName, 0, none, none, none, 0, 0, none, 0, todayyo, none, 1, false);

            depthsAll = await sqlexec.SQLGetDepth(Properties.Settings.Default.DBName, 0, 0, none, todayyo, null, none, 0, none, 0, none, false);

            depthsAllPaid = await sqlexec.SQLGetDepth(Properties.Settings.Default.DBName, 0, 0, none, todayyo, "", none, 0, none, 0, none, false);

            person.AddRange(driver);
            person.AddRange(owner);
        }
コード例 #5
0
        private async void Loadstart()
        {
            SQLExecute sqlexec = new SQLExecute();

            allTaxi.AddRange(await sqlexec.SQLGetTaxi(Properties.Settings.Default.DBName, 0, "none", 0, "none", "none", "none", 0, "none", "none", 0, DateTime.Today, "none", true));
            allDrivers.AddRange(await sqlexec.SQLGetPerson(Properties.Settings.Default.DBName, 0, "none", "none", "none", 0, 0, "none", 0, DateTime.Today, "none", 1, false));
            allPrimaryDriver.AddRange(await sqlexec.SQLGetPrimaryDriver(Properties.Settings.Default.DBName, 0, 0, 0, true));
        }
コード例 #6
0
        private async Task <int> TakeLastKlm(int taxiID)
        {
            SQLExecute       sqlexe = new SQLExecute();
            int              max    = -1;
            List <Kilometer> kilos  = await sqlexe.SQLGetKilometer(Properties.Settings.Default.DBName, 0, taxiID, 0, "none", DateTime.Today, "none", 0, "none", 0, "none", 0, false);


            foreach (Kilometer k in kilos)
            {
                if (k.KlmFinish > max)
                {
                    max = k.KlmFinish;
                }
            }
            return(max);
        }
コード例 #7
0
        private async Task SaveIfPrimaryDriver(List <PrimaryDriver> primedriver)
        {
            SQLExecute sqlexec = new SQLExecute();

            foreach (PrimaryDriver pr in primedriver)
            {
                List <PrimaryDriver> primedr = new List <PrimaryDriver>();
                primedr = await sqlexec.SQLGetPrimaryDriver(Properties.Settings.Default.DBName, 0, pr.TaxiID, pr.PersonID, false);

                if (primedr.Count == 0)
                {
                    List <PrimaryDriver> temp = new List <PrimaryDriver>();
                    temp.Add(pr);
                    await sqlexec.SqlInsertPrimaryDriver(Properties.Settings.Default.DBName, temp);
                }
            }
        }
コード例 #8
0
        private async Task <List <Person> > GetDriverComboBox(int id)
        {
            if (id == 0)
            {
                return(allDrivers);
            }
            List <PrimaryDriver> templist   = new List <PrimaryDriver>();
            List <Person>        tempPerson = new List <Person>();


            SQLExecute sqlexec = new SQLExecute();

            return(await Task.Run(() => sqlexec.SqlGetDriversForTaxi(Properties.Settings.Default.DBName, id)));

            //templist.AddRange( allPrimaryDriver.Where(p => p.TaxiID == id).ToList());
            //foreach (PrimaryDriver pd in templist)
            //{
            //    tempPerson.AddRange(allDrivers.Where(Person => Person.PersonID == pd.PersonID).ToList());
            //}
            //return tempPerson;
        }
コード例 #9
0
        private async void Button_Click_Save(object sender, RoutedEventArgs e)
        {
            //depthsUpdate
            string query = "";

            if (depthsUpdate.Count == 0)
            {
                return;
            }
            foreach (Depth d in depthsUpdate)
            {
                //query += $"UPDATE Depth SET Paid = '{d.Paid}' WHERE DepthID = '{d.DepthID}'; ";
                query += $"UPDATE Depth SET RepaidAmount = '{d.RepaidAmount}' WHERE DepthID = '{d.DepthID}';";
                if (d.Amount == d.RepaidAmount)
                {
                    query += $"UPDATE Depth SET Paid = '' WHERE DepthID = '{d.DepthID}'; ";
                    //Create Income's
                    if (true)
                    {
                    }
                }
                else
                {
                    query += $"UPDATE Depth SET Paid = NULL WHERE DepthID = '{d.DepthID}'; ";
                }
            }

            SQLExecute sqlexec = new SQLExecute();
            await Task.Run(() => sqlexec.SQLCommand(Properties.Settings.Default.DBName, query));

            string   none    = "none";
            DateTime todayyo = DateTime.Today;

            //Create Income's
            depthsAll = await sqlexec.SQLGetDepth(Properties.Settings.Default.DBName, 0, 0, none, todayyo, null, none, 0, none, 0, none, false);

            depthsAllPaid = await sqlexec.SQLGetDepth(Properties.Settings.Default.DBName, 0, 0, none, todayyo, "", none, 0, none, 0, none, false);
            await refreshAll();
        }
コード例 #10
0
        private async void ButtonSave_Click(object sender, RoutedEventArgs e)
        {
            //Create Shift Object
            Shift newshift = new Shift();

            try
            {
                newshift.PersonID = Int32.Parse(cmbDriver.SelectedValue.ToString());
            }
            catch
            {
                MessageBox.Show("You Must select a Driver");
                return;
            }
            try
            {
                newshift.TaxiID = Int32.Parse(cmbTaxi.SelectedValue.ToString());
            }
            catch
            {
                MessageBox.Show("You Must select a Taxi");
                return;
            }

            if (!DatePicker1.Value.HasValue)
            {
                newshift.ShiftDate = DateTime.Today;
            }
            else
            {
                newshift.ShiftDate = DatePicker1.Value.Value;
            }
            if (TxtXZ.Text != "")
            {
                newshift.XZ = Convert.ToDecimal(TxtXZ.Text);
            }
            if (TxtOil.Text != "")
            {
                newshift.Oil = Convert.ToDecimal(TxtOil.Text);
            }
            if (TxtXZFpa.Text != "")
            {
                newshift.XZFPA = Convert.ToDecimal(TxtXZFpa.Text);
            }
            if (TxtOilFpa.Text != "")
            {
                newshift.OilFPA = Convert.ToDecimal(TxtOilFpa.Text);
            }
            if (TxtShift.Text != "")
            {
                newshift.ShiftPayment = Convert.ToDecimal(TxtShift.Text);
            }
            if (TxtIka.Text != "")
            {
                newshift.Insurance = Convert.ToDecimal(TxtIka.Text);
            }
            if (TxtFpa.Text != "")
            {
                newshift.FPA = Convert.ToDecimal(TxtFpa.Text);
            }
            if (TxtComment.Text != "")
            {
                newshift.Comment = TxtComment.Text;
            }

            shifts.Add(newshift);
            //Create kilometer object
            Kilometer newkilometer = new Kilometer();

            if (TxtKmlFrom.Text != "")
            {
                newkilometer.KlmStart = Int32.Parse(TxtKmlFrom.Text);
            }
            if (TxtKmlTo.Text != "")
            {
                newkilometer.KlmFinish = Int32.Parse(TxtKmlTo.Text);
            }
            if (TxtKmlDifference.Text != "")
            {
                newkilometer.KlmShift = Int32.Parse(TxtKmlDifference.Text);
            }

            if (!DatePicker1.Value.HasValue)
            {
                newkilometer.ShiftDate = DateTime.Today;
            }
            else
            {
                newkilometer.ShiftDate = DatePicker1.Value.Value;
            }
            try
            {
                newkilometer.PersonID = Int32.Parse(cmbDriver.SelectedValue.ToString());
            }
            catch
            {
                MessageBox.Show("You Must select a Driver");
                return;
            }
            try
            {
                newkilometer.TaxiID = Int32.Parse(cmbTaxi.SelectedValue.ToString());
            }
            catch
            {
                MessageBox.Show("You Must select a Taxi");
                return;
            }
            kilometers.Add(newkilometer);
            //Create Depth object
            Depth newdepth = new Depth();

            try
            {
                newdepth.Amount = Convert.ToDecimal(TxtAmount.Text);
            }
            catch
            {
                MessageBox.Show("The Total must be a decimal xxxx.xx ");
                return;
            }
            if (TxtComment.Text != "")
            {
                newdepth.Comment = TxtComment.Text;
            }
            newdepth.RepaidAmount = 0;
            newdepth.Paid         = null;
            if (!DatePicker1.Value.HasValue)
            {
                newdepth.DepthDate = DateTime.Today;
            }
            else
            {
                newdepth.DepthDate = DatePicker1.Value.Value;
            }
            try
            {
                newdepth.PersonID = Int32.Parse(cmbDriver.SelectedValue.ToString());
            }
            catch
            {
                MessageBox.Show("You Must select a Driver");
                return;
            }
            try
            {
                newdepth.TaxiID = Int32.Parse(cmbTaxi.SelectedValue.ToString());
            }
            catch
            {
                MessageBox.Show("You Must select a Taxi");
                return;
            }
            List <PrimaryDriver> primedr = new List <PrimaryDriver>();

            primedr.Add(new PrimaryDriver {
                TaxiID = Int32.Parse(cmbTaxi.SelectedValue.ToString()), PersonID = Int32.Parse(cmbDriver.SelectedValue.ToString())
            });
            depths.Add(newdepth);



            CreateDatatableStrings strings = new CreateDatatableStrings();
            SQLExecute             sqlexec = new SQLExecute();
            await sqlexec.SQLCommand(Properties.Settings.Default.DBName, strings.FOREIGN_KEY(0));

            await Task.Run(() => SaveKilometer());

            await Task.Run(() => SaveShift());

            await Task.Run(() => SaveDepth());

            await Task.Run(() => SaveIfPrimaryDriver(primedr));

            await sqlexec.SQLCommand(Properties.Settings.Default.DBName, strings.FOREIGN_KEY(1));

            ClearAll();
        }
コード例 #11
0
        private async Task CreateCompoments(int taxiID, int personID)
        {
            DynamicGrid.Children.Clear();
            SQLExecute sqlexe  = new SQLExecute();
            string     all     = "all";
            string     none    = "none";
            DateTime   todayyo = DateTime.Today;

            //CheckBoxPaid


            bool taxiflag   = taxiID != 0;
            bool personflag = personID != 0;

            depths.Clear();
            if (CheckBoxPaid.IsChecked.Value)
            {
                if (CheckBoxAll.IsChecked.Value)
                {
                    depths.AddRange(depthsAllPaid);
                }
                else
                {
                    if (taxiflag && personflag)
                    {
                        depths.AddRange(depthsAllPaid.Where(Depth => Depth.TaxiID == taxiID && Depth.PersonID == personID).ToList());
                    }
                    else if (taxiflag)
                    {
                        depths.AddRange(depthsAllPaid.Where(Depth => Depth.TaxiID == taxiID).ToList());
                    }
                    else if (personflag)
                    {
                        depths.AddRange(depthsAllPaid.Where(Depth => Depth.PersonID == personID).ToList());
                    }
                }
            }
            else
            {
                if (CheckBoxAll.IsChecked.Value)
                {
                    depths.AddRange(depthsAll);
                }
                else
                {
                    if (taxiflag && personflag)
                    {
                        depths.AddRange(depthsAll.Where(Depth => Depth.TaxiID == taxiID && Depth.PersonID == personID).ToList());
                    }
                    else if (taxiflag)
                    {
                        depths.AddRange(depthsAll.Where(Depth => Depth.TaxiID == taxiID).ToList());
                    }
                    else if (personflag)
                    {
                        depths.AddRange(depthsAll.Where(Depth => Depth.PersonID == personID).ToList());
                    }
                }
            }
            // if (!taxiflag || !driverflag || !ownerflag) depths = await Task.Run(() => sqlexe.SQLGetDepth(Properties.Settings.Default.DBName, taxiID, ownerID, driverID, none,todayyo,null,none,0,none,0,none,false));
            // else if (taxiflag && driverflag && ownerflag) depths = await Task.Run(() => sqlexe.SQLGetDepth(Properties.Settings.Default.DBName, taxiID, ownerID, driverID, none, todayyo, null, none, 0, none, 0, none, true));

            if (depths.Count == 0)
            {
                Viewbox viewNone = new Viewbox();
                //viewNone.Stretch = Stretch.Uniform;
                viewNone.HorizontalAlignment = HorizontalAlignment.Center;
                viewNone.VerticalAlignment   = VerticalAlignment.Center;
                viewNone.Stretch             = Stretch.Uniform;
                DynamicGrid.Children.Add(viewNone);
                Grid.SetRow(viewNone, 0);
                Grid.SetColumn(viewNone, 0);
                Grid.SetColumnSpan(viewNone, 3);



                TextBlock newtextboxNoResults = new TextBlock();
                newtextboxNoResults.Text                = "No Results were found!";
                newtextboxNoResults.Foreground          = new SolidColorBrush(Colors.Black);
                newtextboxNoResults.MinWidth            = 30;
                newtextboxNoResults.VerticalAlignment   = VerticalAlignment.Center;
                newtextboxNoResults.HorizontalAlignment = HorizontalAlignment.Center;
                newtextboxNoResults.Padding             = new Thickness(20);
                //newtextboxNoResults.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
                //viewNone.Children.Add(newtextboxNoResults);
                viewNone.Child = newtextboxNoResults;
                return;
            }

            DynamicScroll.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            DynamicScroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;

            Border borderHeader = new Border();

            DynamicGrid.Children.Add(borderHeader);
            Grid.SetRow(borderHeader, 0);
            Grid.SetColumn(borderHeader, 0);
            Grid.SetColumnSpan(borderHeader, 9);
            borderHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));



            //TextBlock newtextboxDepthidHeader = new TextBlock();
            //newtextboxDepthidHeader.Text = "DepthID";
            //newtextboxDepthidHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            //newtextboxDepthidHeader.MinWidth = 30;
            //newtextboxDepthidHeader.Padding = new Thickness(0, 0, 10, 0);
            //DynamicGrid.Children.Add(newtextboxDepthidHeader);
            //Grid.SetColumn(newtextboxDepthidHeader, 0);
            //Grid.SetRow(newtextboxDepthidHeader, 0);

            TextBlock newtextboxOwnerIDHeader = new TextBlock();

            newtextboxOwnerIDHeader.Text       = "Borrower";
            newtextboxOwnerIDHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            newtextboxOwnerIDHeader.MinWidth   = 30;
            newtextboxOwnerIDHeader.Padding    = new Thickness(10, 0, 10, 0);

            newtextboxOwnerIDHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
            DynamicGrid.Children.Add(newtextboxOwnerIDHeader);
            Grid.SetColumn(newtextboxOwnerIDHeader, 1);
            Grid.SetRow(newtextboxOwnerIDHeader, 0);

            // Taxi

            TextBlock newtextboxTaxiIDHeader = new TextBlock();

            newtextboxTaxiIDHeader.Text       = "Taxi";
            newtextboxTaxiIDHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            newtextboxTaxiIDHeader.MinWidth   = 30;
            newtextboxTaxiIDHeader.Padding    = new Thickness(10, 0, 10, 0);
            newtextboxTaxiIDHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
            DynamicGrid.Children.Add(newtextboxTaxiIDHeader);
            Grid.SetColumn(newtextboxTaxiIDHeader, 2);
            Grid.SetRow(newtextboxTaxiIDHeader, 0);


            TextBlock newtextboxDepthDateHeader = new TextBlock();

            newtextboxDepthDateHeader.Text       = "Date";
            newtextboxDepthDateHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            newtextboxDepthDateHeader.MinWidth   = 30;
            newtextboxDepthDateHeader.Padding    = new Thickness(10, 0, 10, 0);
            newtextboxDepthDateHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
            DynamicGrid.Children.Add(newtextboxDepthDateHeader);
            Grid.SetColumn(newtextboxDepthDateHeader, 3);
            Grid.SetRow(newtextboxDepthDateHeader, 0);

            TextBlock newTextAmountHeader = new TextBlock();

            newTextAmountHeader.Text       = "Amount";
            newTextAmountHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            newTextAmountHeader.MinWidth   = 30;
            newTextAmountHeader.Padding    = new Thickness(10, 0, 10, 0);
            newTextAmountHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
            DynamicGrid.Children.Add(newTextAmountHeader);
            Grid.SetColumn(newTextAmountHeader, 4);
            Grid.SetRow(newTextAmountHeader, 0);

            TextBlock newTextRepaidAmountHeader = new TextBlock();

            newTextRepaidAmountHeader.Text       = "Repaid";
            newTextRepaidAmountHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            newTextRepaidAmountHeader.MinWidth   = 30;
            newTextRepaidAmountHeader.Padding    = new Thickness(10, 0, 10, 0);
            newTextRepaidAmountHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
            DynamicGrid.Children.Add(newTextRepaidAmountHeader);
            Grid.SetColumn(newTextRepaidAmountHeader, 5);
            Grid.SetRow(newTextRepaidAmountHeader, 0);

            TextBlock newTextLeftHeader = new TextBlock();

            newTextLeftHeader.Text       = "Left";
            newTextLeftHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            newTextLeftHeader.MinWidth   = 30;
            newTextLeftHeader.Padding    = new Thickness(10, 0, 10, 0);
            newTextLeftHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
            DynamicGrid.Children.Add(newTextLeftHeader);
            Grid.SetColumn(newTextLeftHeader, 6);
            Grid.SetRow(newTextLeftHeader, 0);

            CheckBox newCheckboxHeader = new CheckBox();

            newCheckboxHeader.Click            += new RoutedEventHandler(CheckBoxHeader_Checked);
            newCheckboxHeader.Padding           = new Thickness(2, 1, 2, 1);
            newCheckboxHeader.VerticalAlignment = VerticalAlignment.Center;
            DynamicGrid.Children.Add(newCheckboxHeader);
            Grid.SetColumn(newCheckboxHeader, 7);
            Grid.SetRow(newCheckboxHeader, 0);

            TextBlock newTextPaymentHeader = new TextBlock();

            newTextPaymentHeader.Text       = "Payment";
            newTextPaymentHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            newTextPaymentHeader.MinWidth   = 30;
            newTextPaymentHeader.Padding    = new Thickness(10, 0, 10, 0);
            newTextPaymentHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
            DynamicGrid.Children.Add(newTextPaymentHeader);
            Grid.SetColumn(newTextPaymentHeader, 8);
            Grid.SetRow(newTextPaymentHeader, 0);

            DynamicGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });                                                                              //flag = row number

            Border borderHeader2 = new Border();

            DynamicGrid.Children.Add(borderHeader2);
            Grid.SetRow(borderHeader2, 1);
            Grid.SetColumn(borderHeader2, 0);
            Grid.SetColumnSpan(borderHeader2, 9);
            borderHeader2.Background = new SolidColorBrush(Color.FromRgb(134, 136, 137));


            // <Header/>

            int flag = 2;

            foreach (Depth newDepth in depths)
            {
                DynamicGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });                                                                              //flag = row number


                Border border = new Border();
                DynamicGrid.Children.Add(border);
                Grid.SetRow(border, flag);
                Grid.SetColumn(border, 0);
                Grid.SetColumnSpan(border, 9);
                border.Padding = new Thickness(4);
                if (flag % 2 == 1)
                {
                    border.Background = new SolidColorBrush(Color.FromRgb(200, 202, 206));
                }
                if (flag % 2 == 0)
                {
                    border.Background = new SolidColorBrush(Color.FromRgb(233, 244, 210));
                }

                string nameID = newDepth.DepthID.ToString();
                //TextBlock newtextboxDepthid = new TextBlock();
                //newtextboxDepthid.Text = newDepth.DepthID.ToString();
                //newtextboxDepthid.MinWidth = 30;
                //newtextboxDepthid.Margin = new Thickness(10, 0, 10, 0);
                //DynamicGrid.Children.Add(newtextboxDepthid);
                //Grid.SetColumn(newtextboxDepthid, 0);
                //Grid.SetRow(newtextboxDepthid, flag);

                //Owner



                // List<Owner> newOwner = await Task.Run(() => sqlexe.SQLGetOwner(Properties.Settings.Default.DBName, tempOwnerID,"none", "none", "none",0,0, "none",0,DateTime.Today, "none",false));
                List <Person> newPerson = new List <Person>();
                newPerson.AddRange(owner.Where(Person => Person.PersonID == newDepth.PersonID));
                newPerson.AddRange(driver.Where(Person => Person.PersonID == newDepth.PersonID));

                TextBlock newtextboxPersonID = new TextBlock();
                foreach (Person oq in newPerson)
                {
                    newtextboxPersonID.Text = oq.FullName;
                }
                newtextboxPersonID.MinWidth = 30;
                newtextboxPersonID.Margin   = new Thickness(10, 0, 10, 0);
                DynamicGrid.Children.Add(newtextboxPersonID);
                Grid.SetColumn(newtextboxPersonID, 1);
                Grid.SetRow(newtextboxPersonID, flag);


                // Taxi

                if (newDepth.TaxiID != 0)
                {
                    //List<Taxi> newTaxi = await Task.Run(() => sqlexe.SQLGetTaxi(Properties.Settings.Default.DBName, tempTaxiID,"none",0m, "none", "none", "none",0, "none", "none",0,DateTime.Today, "none",false));
                    var newTaxi = taxi.Where(Taxi => Taxi.TaxiID == newDepth.TaxiID);

                    TextBlock newtextboxTaxiID = new TextBlock();
                    foreach (Taxi tx in newTaxi)
                    {
                        newtextboxTaxiID.Text = tx.LicensePlate;
                    }
                    newtextboxTaxiID.MinWidth = 30;
                    newtextboxTaxiID.Margin   = new Thickness(10, 0, 10, 0);
                    DynamicGrid.Children.Add(newtextboxTaxiID);
                    Grid.SetColumn(newtextboxTaxiID, 2);
                    Grid.SetRow(newtextboxTaxiID, flag);
                }
                string    tempdate            = newDepth.DepthDate.ToString();
                TextBlock newtextboxDepthDate = new TextBlock();
                newtextboxDepthDate.Text     = tempdate.Substring(0, tempdate.Length - 9);
                newtextboxDepthDate.MinWidth = 30;
                newtextboxDepthDate.Margin   = new Thickness(10, 0, 10, 0);
                DynamicGrid.Children.Add(newtextboxDepthDate);
                Grid.SetColumn(newtextboxDepthDate, 3);
                Grid.SetRow(newtextboxDepthDate, flag);

                TextBlock newTextAmount = new TextBlock();
                newTextAmount.Text     = newDepth.Amount.ToString();
                newTextAmount.MinWidth = 30;
                newTextAmount.Margin   = new Thickness(10, 0, 10, 0);
                DynamicGrid.Children.Add(newTextAmount);
                Grid.SetColumn(newTextAmount, 4);
                Grid.SetRow(newTextAmount, flag);

                TextBlock newTextRepaidAmount = new TextBlock();
                newTextRepaidAmount.Text     = newDepth.RepaidAmount.ToString();
                newTextRepaidAmount.MinWidth = 30;
                newTextRepaidAmount.Margin   = new Thickness(10, 0, 10, 0);
                DynamicGrid.Children.Add(newTextRepaidAmount);
                Grid.SetColumn(newTextRepaidAmount, 5);
                Grid.SetRow(newTextRepaidAmount, flag);


                TextBlock newTextLeftt = new TextBlock();
                newTextLeftt.Text     = (double.Parse(newTextAmount.Text) - double.Parse(newTextRepaidAmount.Text)).ToString();
                newTextLeftt.MinWidth = 30;
                newTextLeftt.Margin   = new Thickness(10, 0, 10, 0);
                DynamicGrid.Children.Add(newTextLeftt);
                Grid.SetColumn(newTextLeftt, 6);
                Grid.SetRow(newTextLeftt, flag);



                CheckBox newCheckbox = new CheckBox();
                newCheckbox.Name = "Check" + nameID;
                if (newDepth.Paid == "")
                {
                    newCheckbox.IsChecked = true;
                }
                newCheckbox.Checked   += CheckBox_Checked;
                newCheckbox.Unchecked += CheckBox_Unchecked;
                DynamicGrid.Children.Add(newCheckbox);
                newCheckbox.Padding           = new Thickness(2, 1, 2, 1);
                newCheckbox.VerticalAlignment = VerticalAlignment.Center;
                Grid.SetColumn(newCheckbox, 7);
                Grid.SetRow(newCheckbox, flag);


                TextBox newTextPayment = new TextBox();
                newTextPayment.Name          = "TextB" + nameID;
                newTextPayment.LostFocus    += TextBox_Changed;
                newTextPayment.MinWidth      = 30;
                newTextPayment.TextAlignment = TextAlignment.Center;
                newTextPayment.Margin        = new Thickness(10, 1, 10, 1);
                DynamicGrid.Children.Add(newTextPayment);
                Grid.SetColumn(newTextPayment, 8);
                Grid.SetRow(newTextPayment, flag);


                flag++;
            }
        }
コード例 #12
0
        private async void Button_Click_Save(object sender, RoutedEventArgs e)
        {
            _busyIndicator.IsBusy = true;

            // check if it is time to save
            decimal sum        = GetSum();        // sum = all in decimalUpDown
            decimal totaldepth = GetTotalDepth(); // TotalDepth = all depth remain
            bool    askedOnce  = false;


            //This never happens


            //vazi arnitika
            if (sum < TotalPaid && sum != totaldepth)
            {
                MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show($"Περισσεύουν {TotalPaid - sum } ευρώ που δεν έχουν τοποθετηθεί σε κάποιο χρέος. Θέλετε να τα τοποθετήσετε στο αποθεματικό παρόλο που υπάρχουν ανοιχτοί λογαριασμοί;", "ΠΡΟΣΟΧΗ", MessageBoxButton.YesNo);
                // if (result == MessageBoxResult.Yes) reserveNEW += TotalPaid - sum;
                if (result == MessageBoxResult.No)
                {
                    _busyIndicator.IsBusy = false;
                    return;
                }
            }
            if (comentbox.Text == "")
            {
                MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show($"Δεν έχετε συμπληρώσει κάποιο σχόλιο, Θέλετε να δημιουργηθεί αυτόματα;", "ΠΡΟΣΟΧΗ", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    CreateComment();
                    askedOnce = true;
                    //ask to add to comment
                }
                else if (result == MessageBoxResult.Cancel)
                {
                    _busyIndicator.IsBusy = false; return;
                }
                else if (result == MessageBoxResult.No)
                {
                    askedOnce = true;
                }
            }
            if (!askedOnce)
            {
                MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show($"Είστε σίγουροι ότι θέλετε να κάνετε αποθήκευση των αλλαγών;", "ΠΡΟΣΟΧΗ", MessageBoxButton.YesNo, MessageBoxImage.Information);

                if (result == MessageBoxResult.No)
                {
                    return;
                }
            }

            SQLExecute sqlexec = new SQLExecute();
            //start
            string query = "";

            foreach (Depth d in depths)
            {
                int tempID = d.DepthID;

                string stDif    = "D" + tempID;
                string stPaid   = "P" + tempID;
                string stCheck  = "C" + tempID;
                string stRepaid = "R" + tempID;

                TextBlock     repaid = (TextBlock)DynamicGrid.FindName(stRepaid);
                DecimalUpDown paid   = (DecimalUpDown)DynamicGrid.FindName(stPaid);
                TextBlock     dif    = (TextBlock)DynamicGrid.FindName(stDif);
                CheckBox      check  = (CheckBox)DynamicGrid.FindName(stCheck);

                if (paid.Value != 0.0m)
                {
                    query += $"UPDATE Depth SET RepaidAmount = '{paid.Value + decimal.Parse(repaid.Text)}' WHERE DepthID = '{tempID}';";
                    if (dif.Text == paid.Value.ToString())
                    {
                        query += $"UPDATE Depth SET Paid = '' WHERE DepthID = '{tempID}'; ";
                    }
                    else
                    {
                        query += $"UPDATE Depth SET Paid = NULL WHERE DepthID = '{d.DepthID}'; ";
                    }
                }
            }

            //if ( reserveNEW+ reserveOLD!= Currentperson.Reserve)


            decimal reserveNEW = reserveOLD + (TotalPaid - sum);

            query += $"UPDATE Person SET Reserve = {reserveNEW} WHERE PersonID = '{Currentperson.PersonID}'; ";

            /*
             * if (sum != TotalPaid)
             * {
             *  decimal reserveNEW = 0.0m;
             *
             *
             *  if (sum < TotalPaid) reserveNEW = reserveOLD + (TotalPaid - sum);
             *  if (sum > TotalPaid) reserveNEW = reserveOLD - (sum - TotalPaid);
             *
             *  decimal test = reserveOLD + (TotalPaid - sum);
             *
             *  query += $"UPDATE Person SET Reserve = {reserveNEW} WHERE PersonID = '{Currentperson.PersonID}'; ";
             *
             *  //string temp = comentbox.Text;
             *  //decimal difRes = reserveNEW + reserveOLD - Currentperson.Reserve;
             *  //if(difRes > 0)
             *  //{
             *  //    temp += $" / Πρόσθετο αποθεματικό : {difRes}. ";
             *  //    comentbox.Text = temp;
             *  //}
             * }
             */
            List <Income> IncomeList = new List <Income>();

            IncomeList.Add(new Income {
                PersonID = (int)ComboBoxDepthPerson.SelectedValue, Amount = TotalPaid, Comment = comentbox.Text, Date = DatePicker1.Value ?? DateTime.Today, TypeIncomeID = 1
            });
            await Task.Run(() => sqlexec.SqlInsertIncome(Properties.Settings.Default.DBName, IncomeList));


            await Task.Run(() => sqlexec.SQLCommand(Properties.Settings.Default.DBName, query));


            int tempindex = ComboBoxDepthPerson.SelectedIndex;

            FillCombos(1);
            ResetData();
            await refreshAll();

            _busyIndicator.IsBusy             = false;
            ComboBoxDepthPerson.SelectedIndex = tempindex;
            //DrawInfos();
        }
コード例 #13
0
        private async Task CreateCompoments(int personID)
        {
            EventHandler = false;

            foreach (string s in RegisteredNames)
            {
                UnregisterName(s);
            }
            RegisteredNames.Clear();

            DynamicGrid.Children.Clear();
            if (personID == -1)
            {
                EventHandler = true; return;
            }
            SQLExecute sqlexe  = new SQLExecute();
            string     all     = "all";
            string     none    = "none";
            DateTime   todayyo = DateTime.Today;

            depths.Clear();

            if (personID == 0)
            {
                depths.AddRange(depthsAll.OrderBy(o => o.DepthDate).ToList());//reserveNEW = 0.0m;
            }
            depths.AddRange(depthsAll.Where(Depth => Depth.PersonID == personID).ToList().OrderBy(o => o.DepthDate).ToList());

            if (depths.Count == 0)
            {
                Viewbox viewNone = new Viewbox();
                //viewNone.Stretch = Stretch.Uniform;
                viewNone.HorizontalAlignment = HorizontalAlignment.Center;
                viewNone.VerticalAlignment   = VerticalAlignment.Center;
                viewNone.Stretch             = Stretch.Uniform;
                DynamicGrid.Children.Add(viewNone);
                Grid.SetRow(viewNone, 0);
                Grid.SetColumn(viewNone, 0);
                Grid.SetColumnSpan(viewNone, 3);



                TextBlock newtextboxNoResults = new TextBlock();
                newtextboxNoResults.Text                = "No Results were found!";
                newtextboxNoResults.Foreground          = new SolidColorBrush(Colors.Black);
                newtextboxNoResults.MinWidth            = 30;
                newtextboxNoResults.VerticalAlignment   = VerticalAlignment.Center;
                newtextboxNoResults.HorizontalAlignment = HorizontalAlignment.Center;
                newtextboxNoResults.Padding             = new Thickness(20);
                //newtextboxNoResults.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
                //viewNone.Children.Add(newtextboxNoResults);
                viewNone.Child = newtextboxNoResults;
                EventHandler   = true;
                return;
            }

            //DynamicScroll.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            //DynamicScroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;

            Border borderHeader = new Border();

            DynamicGrid.Children.Add(borderHeader);
            Grid.SetRow(borderHeader, 0);
            Grid.SetColumn(borderHeader, 0);
            Grid.SetColumnSpan(borderHeader, 9);
            borderHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));



            //TextBlock newtextboxDepthidHeader = new TextBlock();
            //newtextboxDepthidHeader.Text = "DepthID";
            //newtextboxDepthidHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            //newtextboxDepthidHeader.MinWidth = 30;
            //newtextboxDepthidHeader.Padding = new Thickness(0, 0, 10, 0);
            //DynamicGrid.Children.Add(newtextboxDepthidHeader);
            //Grid.SetColumn(newtextboxDepthidHeader, 0);
            //Grid.SetRow(newtextboxDepthidHeader, 0);

            TextBlock newtextboxOwnerIDHeader = new TextBlock();

            newtextboxOwnerIDHeader.Text       = "Borrower";
            newtextboxOwnerIDHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            newtextboxOwnerIDHeader.MinWidth   = 30;
            newtextboxOwnerIDHeader.Padding    = new Thickness(10, 0, 10, 0);

            newtextboxOwnerIDHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
            DynamicGrid.Children.Add(newtextboxOwnerIDHeader);
            Grid.SetColumn(newtextboxOwnerIDHeader, 1);
            Grid.SetRow(newtextboxOwnerIDHeader, 0);

            // Taxi

            TextBlock newtextboxTaxiIDHeader = new TextBlock();

            newtextboxTaxiIDHeader.Text       = "Taxi";
            newtextboxTaxiIDHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            newtextboxTaxiIDHeader.MinWidth   = 30;
            newtextboxTaxiIDHeader.Padding    = new Thickness(10, 0, 10, 0);
            newtextboxTaxiIDHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
            DynamicGrid.Children.Add(newtextboxTaxiIDHeader);
            Grid.SetColumn(newtextboxTaxiIDHeader, 2);
            Grid.SetRow(newtextboxTaxiIDHeader, 0);


            TextBlock newtextboxDepthDateHeader = new TextBlock();

            newtextboxDepthDateHeader.Text       = "Date";
            newtextboxDepthDateHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            newtextboxDepthDateHeader.MinWidth   = 30;
            newtextboxDepthDateHeader.Padding    = new Thickness(10, 0, 10, 0);
            newtextboxDepthDateHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
            DynamicGrid.Children.Add(newtextboxDepthDateHeader);
            Grid.SetColumn(newtextboxDepthDateHeader, 3);
            Grid.SetRow(newtextboxDepthDateHeader, 0);

            TextBlock newTextAmountHeader = new TextBlock();

            newTextAmountHeader.Text       = "Amount";
            newTextAmountHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            newTextAmountHeader.MinWidth   = 30;
            newTextAmountHeader.Padding    = new Thickness(10, 0, 10, 0);
            newTextAmountHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
            DynamicGrid.Children.Add(newTextAmountHeader);
            Grid.SetColumn(newTextAmountHeader, 4);
            Grid.SetRow(newTextAmountHeader, 0);

            TextBlock newTextRepaidAmountHeader = new TextBlock();

            newTextRepaidAmountHeader.Text       = "Repaid";
            newTextRepaidAmountHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            newTextRepaidAmountHeader.MinWidth   = 30;
            newTextRepaidAmountHeader.Padding    = new Thickness(10, 0, 10, 0);
            newTextRepaidAmountHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
            DynamicGrid.Children.Add(newTextRepaidAmountHeader);
            Grid.SetColumn(newTextRepaidAmountHeader, 5);
            Grid.SetRow(newTextRepaidAmountHeader, 0);

            TextBlock newTextLeftHeader = new TextBlock();

            newTextLeftHeader.Text       = "Left";
            newTextLeftHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            newTextLeftHeader.MinWidth   = 30;
            newTextLeftHeader.Padding    = new Thickness(10, 0, 10, 0);
            newTextLeftHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
            DynamicGrid.Children.Add(newTextLeftHeader);
            Grid.SetColumn(newTextLeftHeader, 6);
            Grid.SetRow(newTextLeftHeader, 0);

            CheckBox newCheckboxHeader = new CheckBox();

            newCheckboxHeader.Click += new RoutedEventHandler(CheckBoxHeader_Checked);
            newCheckboxHeader.Name   = "AllChecks";
            RegisterName(newCheckboxHeader.Name, newCheckboxHeader);
            RegisteredNames.Add(newCheckboxHeader.Name);
            newCheckboxHeader.Padding           = new Thickness(2, 1, 2, 1);
            newCheckboxHeader.VerticalAlignment = VerticalAlignment.Center;
            DynamicGrid.Children.Add(newCheckboxHeader);
            Grid.SetColumn(newCheckboxHeader, 7);
            Grid.SetRow(newCheckboxHeader, 0);

            TextBlock newTextPaymentHeader = new TextBlock();

            newTextPaymentHeader.Text       = "Payment";
            newTextPaymentHeader.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            newTextPaymentHeader.MinWidth   = 30;
            newTextPaymentHeader.Padding    = new Thickness(10, 0, 10, 0);
            newTextPaymentHeader.Background = new SolidColorBrush(Color.FromRgb(41, 53, 65));
            DynamicGrid.Children.Add(newTextPaymentHeader);
            Grid.SetColumn(newTextPaymentHeader, 8);
            Grid.SetRow(newTextPaymentHeader, 0);

            DynamicGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });                                                                              //flag = row number

            Border borderHeader2 = new Border();

            DynamicGrid.Children.Add(borderHeader2);
            Grid.SetRow(borderHeader2, 1);
            Grid.SetColumn(borderHeader2, 0);
            Grid.SetColumnSpan(borderHeader2, 9);
            borderHeader2.Background = new SolidColorBrush(Color.FromRgb(134, 136, 137));


            // <Header/>

            int flag = 2;

            foreach (Depth newDepth in depths)
            {
                DynamicGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });                                                                              //flag = row number
                string nameID = newDepth.DepthID.ToString();



                Border border = new Border();
                DynamicGrid.Children.Add(border);
                Grid.SetRow(border, flag);
                Grid.SetColumn(border, 0);
                Grid.SetColumnSpan(border, 9);
                //border.Padding = new Thickness(4);
                //if (flag % 2 == 1) border.Background = new SolidColorBrush(Color.FromRgb(200, 202, 206));
                //if (flag % 2 == 0) border.Background = new SolidColorBrush(Color.FromRgb(233, 244, 210));
                if (flag % 2 == 1)
                {
                    border.Background         = new SolidColorBrush(Color.FromRgb(128, 0, 0));
                    border.Background.Opacity = 0.5;
                    border.Name = "Bor128" + nameID;
                    RegisterName(border.Name, border);
                    RegisteredNames.Add(border.Name);
                }
                if (flag % 2 == 0)
                {
                    border.Background         = new SolidColorBrush(Color.FromRgb(204, 0, 0));
                    border.Background.Opacity = 0.5;
                    border.Name = "Bor204" + nameID;
                    RegisterName(border.Name, border);
                    RegisteredNames.Add(border.Name);
                }



                //TextBlock newtextboxDepthid = new TextBlock();
                //newtextboxDepthid.Text = newDepth.DepthID.ToString();
                //newtextboxDepthid.MinWidth = 30;
                //newtextboxDepthid.Margin = new Thickness(10, 0, 10, 0);
                //DynamicGrid.Children.Add(newtextboxDepthid);
                //Grid.SetColumn(newtextboxDepthid, 0);
                //Grid.SetRow(newtextboxDepthid, flag);

                //Owner



                // List<Owner> newOwner = await Task.Run(() => sqlexe.SQLGetOwner(Properties.Settings.Default.DBName, tempOwnerID,"none", "none", "none",0,0, "none",0,DateTime.Today, "none",false));
                List <Person> newPerson = new List <Person>();
                newPerson.AddRange(owner.Where(Person => Person.PersonID == newDepth.PersonID));
                newPerson.AddRange(driver.Where(Person => Person.PersonID == newDepth.PersonID));

                TextBlock newtextboxPersonID = new TextBlock();
                foreach (Person oq in newPerson)
                {
                    newtextboxPersonID.Text = oq.FullName;
                }
                newtextboxPersonID.MinWidth = 30;
                newtextboxPersonID.Margin   = new Thickness(10, 0, 10, 0);
                DynamicGrid.Children.Add(newtextboxPersonID);
                Grid.SetColumn(newtextboxPersonID, 1);
                Grid.SetRow(newtextboxPersonID, flag);


                // Taxi

                if (newDepth.TaxiID != 0)
                {
                    //List<Taxi> newTaxi = await Task.Run(() => sqlexe.SQLGetTaxi(Properties.Settings.Default.DBName, tempTaxiID,"none",0m, "none", "none", "none",0, "none", "none",0,DateTime.Today, "none",false));
                    var newTaxi = taxi.Where(Taxi => Taxi.TaxiID == newDepth.TaxiID);

                    TextBlock newtextboxTaxiID = new TextBlock();
                    foreach (Taxi tx in newTaxi)
                    {
                        newtextboxTaxiID.Text = tx.LicensePlate;
                    }
                    newtextboxTaxiID.MinWidth = 30;
                    newtextboxTaxiID.Margin   = new Thickness(10, 0, 10, 0);
                    DynamicGrid.Children.Add(newtextboxTaxiID);
                    Grid.SetColumn(newtextboxTaxiID, 2);
                    Grid.SetRow(newtextboxTaxiID, flag);
                }
                string    tempdate            = newDepth.DepthDate.ToString();
                TextBlock newtextboxDepthDate = new TextBlock();
                newtextboxDepthDate.Text     = tempdate.Substring(0, tempdate.Length - 9);
                newtextboxDepthDate.MinWidth = 30;
                newtextboxDepthDate.Margin   = new Thickness(10, 0, 10, 0);
                DynamicGrid.Children.Add(newtextboxDepthDate);
                Grid.SetColumn(newtextboxDepthDate, 3);
                Grid.SetRow(newtextboxDepthDate, flag);

                TextBlock newTextAmount = new TextBlock();
                newTextAmount.Text     = newDepth.Amount.ToString();
                newTextAmount.MinWidth = 30;
                newTextAmount.Margin   = new Thickness(10, 0, 10, 0);
                DynamicGrid.Children.Add(newTextAmount);
                Grid.SetColumn(newTextAmount, 4);
                Grid.SetRow(newTextAmount, flag);

                TextBlock newTextRepaidAmount = new TextBlock();
                newTextRepaidAmount.Text     = newDepth.RepaidAmount.ToString();
                newTextRepaidAmount.MinWidth = 30;
                newTextRepaidAmount.Name     = "R" + nameID;
                RegisterName(newTextRepaidAmount.Name, newTextRepaidAmount);
                RegisteredNames.Add(newTextRepaidAmount.Name);
                newTextRepaidAmount.Margin = new Thickness(10, 0, 10, 0);
                DynamicGrid.Children.Add(newTextRepaidAmount);
                Grid.SetColumn(newTextRepaidAmount, 5);
                Grid.SetRow(newTextRepaidAmount, flag);


                TextBlock newTextLeftt = new TextBlock();
                newTextLeftt.Text     = (decimal.Parse(newTextAmount.Text) - decimal.Parse(newTextRepaidAmount.Text)).ToString();
                newTextLeftt.MinWidth = 30;
                newTextLeftt.Name     = "D" + nameID;
                RegisterName(newTextLeftt.Name, newTextLeftt);
                RegisteredNames.Add(newTextLeftt.Name);
                newTextLeftt.Margin = new Thickness(10, 0, 10, 0);
                DynamicGrid.Children.Add(newTextLeftt);
                Grid.SetColumn(newTextLeftt, 6);
                Grid.SetRow(newTextLeftt, flag);



                CheckBox newCheckbox = new CheckBox();
                newCheckbox.Name = "C" + nameID;
                RegisterName(newCheckbox.Name, newCheckbox);
                RegisteredNames.Add(newCheckbox.Name);
                if (newDepth.Paid == "")
                {
                    newCheckbox.IsChecked = true;
                }
                newCheckbox.Checked   += CheckBox_Checked;
                newCheckbox.Unchecked += CheckBox_Unchecked;
                DynamicGrid.Children.Add(newCheckbox);
                newCheckbox.Padding           = new Thickness(2, 1, 2, 1);
                newCheckbox.VerticalAlignment = VerticalAlignment.Center;
                Grid.SetColumn(newCheckbox, 7);
                Grid.SetRow(newCheckbox, flag);


                //TextBox newTextPayment = new TextBox();
                //newTextPayment.Name = "TextB" + nameID;
                //newTextPayment.LostFocus += TextBox_Changed;
                //newTextPayment.MinWidth = 30;
                //newTextPayment.TextAlignment = TextAlignment.Center;
                //newTextPayment.Margin = new Thickness(10, 1, 10, 1);
                //DynamicGrid.Children.Add(newTextPayment);
                //Grid.SetColumn(newTextPayment, 8);
                //Grid.SetRow(newTextPayment, flag);

                DecimalUpDown newTextPayment = new DecimalUpDown();
                newTextPayment.Name = "P" + nameID;
                RegisterName(newTextPayment.Name, newTextPayment);
                RegisteredNames.Add(newTextPayment.Name);
                newTextPayment.ClipValueToMinMax = true;
                newTextPayment.Minimum           = 0 - newDepth.Amount - newDepth.RepaidAmount;
                newTextPayment.Maximum           = newDepth.Amount - newDepth.RepaidAmount;
                newTextPayment.MinWidth          = 30;
                newTextPayment.DefaultValue      = 0.0m;
                newTextPayment.Increment         = 0.1m;
                newTextPayment.ValueChanged     += Decimal_Changed;
                //newTextPayment.TextAlignment = TextAlignment.Center;
                newTextPayment.Margin = new Thickness(10, 1, 10, 1);
                DynamicGrid.Children.Add(newTextPayment);
                Grid.SetColumn(newTextPayment, 8);
                Grid.SetRow(newTextPayment, flag);


                flag++;
            }
            DynamicGrid.ApplyTemplate();
            EventHandler = true;
        }