Пример #1
0
 public void SalarySet()
 {
     try {
         if (textBox.Text == "")
             textBox.Text = "0";
         if (textBox1.Text == "")
             textBox1.Text = "0";
         double time = 0;
         double salarys = 0;
         double sum = 0;
         UserContext db = new UserContext();
         List<WorkingTime> WorkTime = db.WorkingTimes.Where(x => x.TimeStart > From.SelectedDate).Where(x => x.TimeEnd < To.SelectedDate).Where(x => x.EmployeesId == EmployeId).ToList();
         foreach (WorkingTime fo in WorkTime)
         {
             time += fo.time;
         }
         time = time / 60.0;
         salarys += time * Convert.ToDouble(textBox.Text);
         List<Check> lstcheck = db.Checks.Where(x => x.Date > From.SelectedDate).Where(x => x.Date < To.SelectedDate).Where(x => x.EmployeesId == EmployeId).ToList();
         foreach (Check ch in lstcheck)
         {
             sum += ch.Sum;
         }
         salarys += sum * Convert.ToDouble(textBox1.Text) / 100.0;
         label_salary.Content = Convert.ToString(salarys);
         if (textBox.Text == "0")
             textBox.Text = "";
         if (textBox1.Text == "0")
             textBox1.Text = "";
     }
     catch
     {
         MessageBox.Show("Error");
     }
 }
Пример #2
0
 public OrderEdit()
 {
     InitializeComponent();
     UserContext db = new UserContext();
     var q = db.Goodss.Include("Weapon");
     dataGrid.ItemsSource = GoodsViewMode(q.Include("Accessories").ToList());
     GoodsGrid.Visibility = Visibility.Hidden;
     CountPriceGrid.Visibility = Visibility.Hidden;
 }
Пример #3
0
 public WorkerMain()
 {
     UserContext db = new UserContext();
     InitializeComponent();
     //Запоняем таблицу для нового чека
     dataGridCheck.ItemsSource = checks;
     //Запоняем таблицу для покупателей
     dataGridCustomer.ItemsSource = db.Customers.ToList();
     //Запоняем таблицу для Товаров
     var s = db.Goodss.Include("Weapon");
     dataGridGoods.ItemsSource = GoodsViewMode(s.Include("Accessories").ToList());
     AddGoodsGrid.Visibility = Visibility.Hidden;
 }
Пример #4
0
        public DeliveryEdit()
        {
            InitializeComponent();
            UserContext db = new UserContext();

            var q = db.Goodss.Include("Weapon");
            dataGrid.ItemsSource = GoodsViewMode(q.Include("Accessories").ToList());

            GoodsGrid.Visibility = Visibility.Hidden;
            CountPriceGrid.Visibility = Visibility.Hidden;
            List<string> combobox = new List<string>() { "Наличная", "Безналичная", "Неоплачена" };
            comboBox_TypePayment.ItemsSource = combobox;
        }
Пример #5
0
 private void SubmitBorder_MouseDown(object sender, MouseButtonEventArgs e)
 {
     try {
         Customer cust = new Customer();
         cust.FullName = textBox_surname.Text + " " + textBox_name.Text + " " + textBox_fathername.Text;
         cust.PassportNumber = textBox_Passport.Text;
         cust.PermitWeapon = textBox_Weapon.Text;
         cust.ValidFrom = Convert.ToDateTime(textBox_validfrom.Text);
         cust.ValidTo = Convert.ToDateTime(textBox_validto.Text);
         UserContext db = new UserContext();
         db.Customers.Add(cust);
         db.SaveChanges();
         this.Close();
     }
     catch
     {
         MessageBox.Show("Error");
     }
 }
Пример #6
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            UserContext db = new UserContext();
            if (delinfo == null)
            {

                OrderViewModel edit = dataGridGoods.SelectedItem as OrderViewModel;
                OrderViewModel f = lst.FirstOrDefault(x => x == edit);
                f.Price = Convert.ToDouble(textBLock_Price.Text);
                f.Count = Convert.ToInt32(textBox_Count.Text);
                dataGridGoods.ItemsSource = null;
            }
            else
            {
                delinfo.Price = Convert.ToDouble(textBLock_Price.Text);
                delinfo.Count = Convert.ToInt32(textBox_Count.Text);
                lst.Add(delinfo);
                dataGridGoods.ItemsSource = null;
                delinfo = null;
            }
            db.SaveChanges();

            button1_Click(null, null);
        }
Пример #7
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            try {
                if (textBox_Count.Text != "" && textBox_Count.Text != "0" && textBox_PurchasePrice.Text != "" && textBox_PurchasePrice.Text != "0" && textBox_SellPrice.Text != "" && textBox_SellPrice.Text != "0")
                {
                    UserContext db = new UserContext();
                    if (delinfo == null)
                    {

                        DeliveryViewModel edit = dataGridGoods.SelectedItem as DeliveryViewModel;
                        DeliveryViewModel f = lst.FirstOrDefault(x => x == edit);
                        db.Goodss.FirstOrDefault(x => x.Id == f.GoodsId).Balance -= f.Count;
                        f.Price = Convert.ToDouble(textBox_PurchasePrice.Text);
                        f.Count = Convert.ToInt32(textBox_Count.Text);
                        db.Goodss.Find(edit.GoodsId).SellPrice = Convert.ToDouble(textBox_SellPrice.Text);
                        db.Goodss.Find(f.GoodsId).PricePurchase = Convert.ToDouble(textBox_PurchasePrice.Text);
                        db.Goodss.FirstOrDefault(x => x.Id == f.GoodsId).Balance += f.Count;
                        dataGridGoods.ItemsSource = null;
                    }
                    else
                    {
                        delinfo.Price = Convert.ToDouble(textBox_PurchasePrice.Text);
                        delinfo.Count = Convert.ToInt32(textBox_Count.Text);
                        db.Goodss.Find(delinfo.GoodsId).SellPrice = Convert.ToDouble(textBox_SellPrice.Text);
                        db.Goodss.Find(delinfo.GoodsId).PricePurchase = Convert.ToDouble(textBox_PurchasePrice.Text);
                        lst.Add(delinfo);
                        db.Goodss.FirstOrDefault(x => x.Id == delinfo.GoodsId).Balance += delinfo.Count;
                        dataGridGoods.ItemsSource = null;
                        delinfo = null;
                    }
                    db.SaveChanges();

                    button1_Click(null, null);
                }
                else
                {
                    MessageBox.Show("Неправильный ввод");
                }
            }
            catch
            {
                MessageBox.Show("Error");
            }
        }
Пример #8
0
 private void textBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     UserContext db = new UserContext();
     var s = db.Goodss.Include("Weapon");
     List<GoodsViewModel> list = GoodsViewMode(s.Include("Accessories").ToList());
     dataGrid.ItemsSource = list.Where(x => x.Name.ToUpper().Contains(textBox.Text.ToUpper()));
 }
Пример #9
0
 private void Lol_Loaded(object sender, RoutedEventArgs e)
 {
     UserContext db = new UserContext();
     if (IdDelivery != -1)
     {
         DeliveryNote deliver = db.DeliveryNotes.FirstOrDefault(x => x.Id == IdDelivery);
         label4.Content = deliver.Employees.Surname + "  " + deliver.Employees.Name;
         foreach (DeliveryInfo s in deliver.DeliveryInfos)
         {
             lst.Add(new DeliveryViewModel(s, s.Id));
         }
     }
     else
     {
         Employee emp = db.Emloyees.FirstOrDefault(x => x.Id == EmployeeId);
         label4.Content = emp.Surname + "  " + emp.Name;
     }
     if (lst.Count != 0)
     {
         i = lst[lst.Count - 1].Id + 1;
     }
     dataGridGoods.ItemsSource = lst;
     SetSumma();
 }
Пример #10
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     if (dataGridGoods.SelectedItem != null)
     {
         MainGrid.IsEnabled = false;
         UserContext db = new UserContext();
         CountPriceGrid.Visibility = Visibility.Visible;
         DeliveryViewModel edit = dataGridGoods.SelectedItem as DeliveryViewModel;
         textBox_Count.Text = Convert.ToString(edit.Count);
         textBox_PurchasePrice.Text = Convert.ToString(edit.Price);
         textBox_SellPrice.Text = Convert.ToString(db.Goodss.Find(edit.GoodsId).SellPrice);
     }
     else
     {
         MessageBox.Show("Вы ничего не выбрали!", "Ошибка");
     }
     SetSumma();
 }
Пример #11
0
        private void button7_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                UserContext db = new UserContext();
                if (IdDelivery == -1)
                {
                    Order delnew = new Order();
                    delnew.Employees = db.Emloyees.FirstOrDefault(x => x.Id == EmployeeId);
                    delnew.Date = DateTime.Now;
                    if (checkBox.IsChecked == true)
                        delnew.Status = true;
                    else
                        delnew.Status = false;

                    foreach (OrderViewModel delvm in lst)
                    {
                        OrderInfo delinfo = new OrderInfo();
                        delinfo.Count = delvm.Count;
                        delinfo.Goods = db.Goodss.Find(delvm.GoodsId);
                        delnew.OrderInfos.Add(delinfo);
                    }
                    db.Orders.Add(delnew);
                    delnew.SavePDF();
                }
                else
                {
                    Order delnew = db.Orders.Include("OrderInfos").FirstOrDefault(x => x.Id == IdDelivery);
                    delnew.Employees = db.Emloyees.FirstOrDefault(x => x.Id == EmployeeId);
                    delnew.OrderInfos.Clear();
                    delnew.Date = DateTime.Now;
                    if (checkBox.IsChecked == true)
                        delnew.Status = true;
                    else
                        delnew.Status = false;
                    delnew.OrderInfos.Clear();
                    foreach (OrderViewModel delvm in lst)
                    {
                        OrderInfo delinfo = new OrderInfo();
                        delinfo.Count = delvm.Count;
                        delinfo.Goods = db.Goodss.Find(delvm.GoodsId);
                        delnew.OrderInfos.Add(delinfo);
                    }
                    delnew.SavePDF();
                }

                foreach (OrderInfo s in db.OrderInfos.ToList())
                {
                    if (s.GoodsId == null)
                        db.OrderInfos.Remove(s);
                }

                db.SaveChanges();
                Close();
            }
            catch
            {
                MessageBox.Show("Error");
            }
        }
Пример #12
0
 private void button6_Click(object sender, RoutedEventArgs e)
 {
     if (dataGridGoods.SelectedItem !=null)
     {
         UserContext db = new UserContext();
         DeliveryViewModel del = dataGridGoods.SelectedItem as DeliveryViewModel;
         db.Goodss.FirstOrDefault(x => x.Id == del.GoodsId).Balance -= del.Count;
         lst.Remove(lst.FirstOrDefault(x => x == del));
         dataGridGoods.ItemsSource = null;
         dataGridGoods.ItemsSource = lst;
     }
     else
     {
         MessageBox.Show("Вы ничего не выбрали!", "Ошибка");
     }
     SetSumma();
 }
Пример #13
0
 private void button3_Click(object sender, RoutedEventArgs e)
 {
     if (dataGrid.SelectedItem != null)
     {
         delinfo = new DeliveryViewModel();
         UserContext db = new UserContext();
         var q = db.Goodss.Include("Weapon");
         GoodsViewModel per = dataGrid.SelectedItem as GoodsViewModel;
         Goodss f = q.Include("Accessories").FirstOrDefault(x => x.Id == per.Id);
         delinfo.GoodsId = f.Id;
         delinfo.Id = i;
         if (f.Accessories == null)
         {
             delinfo.Name = f.Weapon.CodeName;
         }
         else
         {
             delinfo.Name = f.Accessories.Name;
         }
         CountPriceGrid.Visibility = Visibility.Visible;
     }
     else
     {
         MessageBox.Show("Вы ничего не выбрали!", "Ошибка");
     }
 }
Пример #14
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     UserContext db = new UserContext();
     if (IdDelivery != -1)
     {
         Order deliver = db.Orders.Include("OrderInfos").FirstOrDefault(x => x.Id == IdDelivery);
         label4.Content = deliver.Employees.Surname + "  " + deliver.Employees.Name;
         foreach (OrderInfo s in deliver.OrderInfos)
         {
             lst.Add(new OrderViewModel(s, s.Id));
         }
     }
     else
     {
         Employee emp = db.Emloyees.FirstOrDefault(x => x.Id == EmployeeId);
         label4.Content = emp.Surname + "  " + emp.Name;
     }
     if (lst.Count != 0)
     {
         i = lst[lst.Count - 1].Id + 1;
     }
     dataGridGoods.ItemsSource = lst;
 }
Пример #15
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     if (dataGridGoods.SelectedItem != null)
     {
         MainGrid.IsEnabled = false;
         UserContext db = new UserContext();
         CountPriceGrid.Visibility = Visibility.Visible;
         OrderViewModel edit = dataGridGoods.SelectedItem as OrderViewModel;
         textBox_Count.Text = Convert.ToString(edit.Count);
         textBLock_Price.Text = Convert.ToString(edit.Price);
     }
     else
     {
         MessageBox.Show("Вы ничего не выбрали!", "Ошибка");
     }
 }
Пример #16
0
 void AddCustomer_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     UserContext db = new UserContext();
     dataGridCustomer.ItemsSource = db.Customers.ToList();
 }
Пример #17
0
        private void button7_Click(object sender, RoutedEventArgs e)
        {
            try {
                UserContext db = new UserContext();
                if (IdDelivery == -1)
                {

                    DeliveryNote delnew = new DeliveryNote();
                    delnew.Employees = db.Emloyees.FirstOrDefault(x => x.Id == EmployeeId);
                    delnew.TypePayment = comboBox_TypePayment.SelectedItem as string;
                    delnew.Sum = 0;
                    delnew.Date = DateTime.Now;

                    foreach (DeliveryViewModel delvm in lst)
                    {
                        DeliveryInfo delinfo = new DeliveryInfo();
                        delinfo.Count = delvm.Count;
                        delinfo.Price = delvm.Price;
                        delinfo.Goods = db.Goodss.Find(delvm.GoodsId);
                        delnew.Sum += delvm.Summa;
                        delnew.DeliveryInfos.Add(delinfo);

                    }
                    delnew.SavePDF();
                    db.DeliveryNotes.Add(delnew);
                }
                else
                {
                    DeliveryNote delnew = db.DeliveryNotes.FirstOrDefault(x => x.Id == IdDelivery);
                    delnew.Employees = db.Emloyees.FirstOrDefault(x => x.Id == EmployeeId);
                    delnew.TypePayment = comboBox_TypePayment.SelectedItem as string;
                    delnew.Sum = 0;
                    delnew.Date = DateTime.Now;
                    delnew.DeliveryInfos.Clear();
                    foreach (DeliveryViewModel delvm in lst)
                    {
                        DeliveryInfo delinfo = new DeliveryInfo();
                        delinfo.Count = delvm.Count;
                        delinfo.Price = delvm.Price;
                        delinfo.Goods = db.Goodss.Find(delvm.GoodsId);
                        delnew.Sum += delvm.Summa;
                        delnew.DeliveryInfos.Add(delinfo);
                    }
                    delnew.SavePDF();
                }
                db.SaveChanges();
                Close();
            }
            catch
            {
                MessageBox.Show("Error");
            }
        }
Пример #18
0
 private void button6_Click(object sender, RoutedEventArgs e)
 {
     if (dataGridGoods.SelectedItem != null)
     {
         UserContext db = new UserContext();
         OrderViewModel del = dataGridGoods.SelectedItem as OrderViewModel;
         lst.Remove(lst.FirstOrDefault(x => x == del));
         dataGridGoods.ItemsSource = null;
         dataGridGoods.ItemsSource = lst;
     }
     else
     {
         MessageBox.Show("Вы ничего не выбрали!", "Ошибка");
     }
 }