예제 #1
0
        private async void LoginForm_Shown(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            List <string> LoadingMasters()
            {
                using (var context = new ServiceCenterDbContext())
                {
                    var s = new List <string>();
                    foreach (var item in context.MasterPasswords)
                    {
                        s.Add(item.Name);
                    }
                    return(s);
                }
            }

            List <string> result = await Task.Factory.StartNew <List <string> >(() => LoadingMasters());

            var masters = new string[result.Count];

            for (int i = 0; i < result.Count; i++)
            {
                masters[i] = result[i];
            }

            MasterComboBox.Items.AddRange(masters);
            this.Cursor            = Cursors.Default;
            MasterComboBox.Enabled = true;
        }
예제 #2
0
        private async void Form1Show(object sender, EventArgs e)
        {
            string LoadingData()
            {
                using (var context = new ServiceCenterDbContext())
                {
                    var k         = "";
                    var s         = 0;
                    var masterSum = context.MasterReceipts.Where(m => m.MasterName == Master.Name);
                    if (masterSum.Count() == 0)
                    {
                        k = "";
                        s = 0;
                    }
                    else
                    {
                        k = $"{masterSum.Sum(r => r.MyMoney)}";
                        s = masterSum.Count();
                    }
                    return($"Записей: {s}  |  {k} руб.");
                }
            }

            string result = await Task.Factory.StartNew <string>(() => LoadingData());

            toolStripStatusLabel2.Text = result;
            toolStripStatusLabel1.Text = $"{Master.Name}";
        }
예제 #3
0
        private async void Form2_Shown(object sender, EventArgs e)
        {
            string LoadData()
            {
                using (var context = new ServiceCenterDbContext())
                {
                    var s         = "";
                    var masterSum = context.MasterReceipts.Where(m => m.MasterName == Master.Name);
                    s = $"{masterSum.Sum(r => r.MyMoney)} руб.";
                    return(s);
                }
            }

            string result = await Task.Factory.StartNew <string>(() => LoadData());

            label2.Text = result;
        }
예제 #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (var context = new ServiceCenterDbContext())
     {
         foreach (var item in context.MasterPasswords)
         {
             if (PasswordTextBox.Text == item.Password && MasterComboBox.Text == item.Name)
             {
                 var f = new Form1();
                 Master.Name    = MasterComboBox.Text;
                 Master.Percent = item.Percent;
                 f.Show();
                 this.Hide();
                 return;
             }
         }
         MessageBox.Show("Ошибка: Неверный пароль");
     }
 }
예제 #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (var context = new ServiceCenterDbContext())
     {
         if (!String.IsNullOrWhiteSpace(textBox1.Text))
         {
             var debitReceipt = new MasterReceipt(888, "Списание", 0);
             debitReceipt.MyMoney = 0 - Int32.Parse(textBox1.Text);
             context.MasterReceipts.Add(debitReceipt);
             context.SaveChanges();
             textBox1.Text = "";
             var masterSum = context.MasterReceipts.Where(m => m.MasterName == Master.Name);
             label2.Text = $"{masterSum.Sum(r => r.MyMoney)} руб.";
             this.Close();
         }
         else
         {
             MessageBox.Show("Ошибка: введите сумму для списания");
         }
     }
 }
예제 #6
0
        private void AddClick(object sender, EventArgs e)
        {
            using (var context = new ServiceCenterDbContext())
            {
                try
                {
                    var receipt = new MasterReceipt(Int32.Parse(textBox1.Text), textBox2.Text, Int32.Parse(textBox3.Text), checkBox1.Checked);
                    context.MasterReceipts.Add(receipt);
                    context.SaveChanges();

                    foreach (var item in componentList)
                    {
                        item.MasterReceiptID = receipt.ID;
                    }

                    context.Components.AddRange(componentList);
                    context.SaveChanges();

                    var masterSum = context.MasterReceipts.Where(m => m.MasterName == Master.Name);
                    if (masterSum == null)
                    {
                        toolStripStatusLabel2.Text = $"Записей: {0} | {0} руб.";
                    }
                    else
                    {
                        var k = $"{masterSum.Sum(r => r.MyMoney)}";
                        var s = masterSum.Count();

                        toolStripStatusLabel2.Text = $"Записей: {s} | {k} руб.";
                    }
                }
                catch
                {
                    MessageBox.Show("Ошибка: заполните все поля");
                }
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     if (true)
     {
         //TODO: Добавить проверку ввода и редактирование мастеров
         using (var context = new ServiceCenterDbContext())
         {
             var master = new MasterPassword(NameTextBox.Text, PasswordTextBox.Text, double.Parse(PercentTextBox.Text));
             context.MasterPasswords.Add(master);
             try
             {
                 context.SaveChanges();
             }
             catch (DbEntityValidationException ex)
             {
                 MessageBox.Show(ex.Message);
             }
             NameTextBox.Text     = "";
             PasswordTextBox.Text = "";
             PercentTextBox.Text  = "";
             MessageBox.Show("Мастер добавлен");
         }
     }
 }