示例#1
0
        public MainForm()
        {
            InitializeComponent();

            this.Opacity = 0;

            LogInForm logform = new LogInForm();

LogInForm:
            if (logform.ShowDialog() == DialogResult.OK)
            {
                if (logform.txtPassword.Text == "1234" && logform.txtUsername.Text == "admin")
                {
                    logform.Close();
                    this.Opacity = 100;
                }
                else
                {
                    MessageBox.Show("Неверный пароль!");
                    goto LogInForm;
                }
            }

            dataGridView.MultiSelect = false;

            using (PharmacyEntities db = new PharmacyEntities())
            {
                foreach (var item in db.PointsOfSale)
                {
                    toolStripComboBox1.Items.Add(item.AddressOfPoint);
                }
            }
        }
        private void AddButton_Click(object sender, EventArgs e)
        {
            using (PharmacyEntities db = new PharmacyEntities())
            {
                Manufactures buff = new Manufactures();

                try
                {
                    buff.id = Convert.ToInt32(idTextBox.Text);
                    buff.NameManufacture = nameTextBox.Text;
                }
                catch (FormatException)
                {
                    MessageBox.Show("Неверно введённые данные!");
                    return;
                }

                db.Manufactures.Add(buff);

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    MessageBox.Show("ID не должен повторяться!");
                    return;
                }
            }

            this.Close();
        }
示例#3
0
 public Form1(Form form, int userId)
 {
     _userId = userId;
     _login  = form;
     _db     = new PharmacyEntities();
     InitializeComponent();
 }
示例#4
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            using (PharmacyEntities db = new PharmacyEntities())
            {
                db.ProductList.RemoveRange(db.ProductList.Where(items => items.shelfLife < DateTime.Now));
                db.SaveChanges();

                InitializeRows();
            }
        }
示例#5
0
        private void InitializeRows()
        {
            dataGridView.DataSource = null;
            dataGridView.Rows.Clear();
            dataGridView.Columns.Clear();

            using (PharmacyEntities db = new PharmacyEntities())
            {
                switch (tablesToolStripComboBox.SelectedIndex)
                {
                case 0:
                    db.Manufactures.Load();
                    dataGridView.DataSource = db.Manufactures.Local;

                    dataGridView.Columns[0].HeaderText = "ID Производителя";
                    dataGridView.Columns[0].Width      = 125;
                    dataGridView.Columns[1].HeaderText = "Производитель";
                    dataGridView.Columns[2].Visible    = false;
                    break;

                case 1:
                    db.MedicalPreparations.Load();
                    dataGridView.DataSource = db.MedicalPreparations.Local;

                    dataGridView.Columns[0].HeaderText = "ID препарата";
                    dataGridView.Columns[0].Width      = 125;
                    dataGridView.Columns[1].HeaderText = "Препарат";
                    dataGridView.Columns[2].HeaderText = "Производитель";
                    dataGridView.Columns[3].HeaderText = "Цена";
                    dataGridView.Columns[4].HeaderText = "Штук в упаковке";
                    dataGridView.Columns[4].Width      = 125;
                    dataGridView.Columns[5].Visible    = false;
                    dataGridView.Columns[6].Visible    = false;
                    break;

                case 2:
                    db.PointsOfSale.Load();
                    dataGridView.DataSource         = db.PointsOfSale.Local;
                    dataGridView.Columns[2].Visible = false;
                    break;

                case 3:
                    db.ProductList.Load();
                    dataGridView.DataSource         = db.ProductList.Local;
                    dataGridView.Columns[4].Visible = false;
                    dataGridView.Columns[5].Visible = false;
                    break;
                }
            }
        }
示例#6
0
        private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (PharmacyEntities db = new PharmacyEntities())
            {
                foreach (var item in db.ProductList)
                {
                    if (toolStripComboBox1.Text.ToString() == item.PointsOfSale.AddressOfPoint)
                    {
                        db.ProductList.Load();
                        dataGridView.DataSource = db.ProductList.Local.Where(items => items.PointOfSaleID == item.PointsOfSale.id).ToList();

                        dataGridView.Columns[4].Visible = false;
                        dataGridView.Columns[5].Visible = false;
                    }
                }
            }
        }
示例#7
0
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            {
                using (PharmacyEntities db = new PharmacyEntities())
                {
                    db.MedicalPreparations.Load();
                    dataGridView.DataSource = db.MedicalPreparations.Local.Where(items => items.CountInPackage >= 100).ToList();

                    dataGridView.Columns[0].HeaderText = "ID препарата";
                    dataGridView.Columns[0].Width      = 125;
                    dataGridView.Columns[1].HeaderText = "Препарат";
                    dataGridView.Columns[2].HeaderText = "Производитель";
                    dataGridView.Columns[3].HeaderText = "Цена";
                    dataGridView.Columns[4].HeaderText = "Штук в упаковке";
                    dataGridView.Columns[4].Width      = 125;
                    dataGridView.Columns[5].Visible    = false;
                    dataGridView.Columns[6].Visible    = false;
                }
            }
        }
示例#8
0
        private void DeleteToolStripButton_Click(object sender, EventArgs e)
        {
            switch (tablesToolStripComboBox.SelectedIndex)
            {
            case 0:
                foreach (var item in dataGridView.Rows)
                {
                    if ((item as DataGridViewRow).Selected)
                    {
                        using (PharmacyEntities db = new PharmacyEntities())
                        {
                            var buff = db.Manufactures.Find((int)(item as DataGridViewRow).Cells[0].Value);
                            db.Manufactures.Remove(buff);

                            try
                            {
                                db.SaveChanges();
                            }
                            catch (DbUpdateException)
                            {
                                MessageBox.Show("Ошибка");
                                return;
                            }
                        }

                        break;
                    }
                }

                InitializeRows();
                break;

            case 1:
                foreach (var item in dataGridView.Rows)
                {
                    if ((item as DataGridViewRow).Selected)
                    {
                        using (PharmacyEntities db = new PharmacyEntities())
                        {
                            var buff = db.MedicalPreparations.Find((int)(item as DataGridViewRow).Cells[0].Value);
                            db.MedicalPreparations.Remove(buff);

                            try
                            {
                                db.SaveChanges();
                            }
                            catch (DbUpdateException)
                            {
                                MessageBox.Show("Ошибка");
                                return;
                            }
                        }

                        break;
                    }
                }

                InitializeRows();
                break;

            case 2:
                foreach (var item in dataGridView.Rows)
                {
                    if ((item as DataGridViewRow).Selected)
                    {
                        using (PharmacyEntities db = new PharmacyEntities())
                        {
                            var buff = db.PointsOfSale.Find((int)(item as DataGridViewRow).Cells[0].Value);
                            db.PointsOfSale.Remove(buff);

                            try
                            {
                                db.SaveChanges();
                            }
                            catch (DbUpdateException)
                            {
                                MessageBox.Show("Ошибка");
                                return;
                            }
                        }

                        break;
                    }
                }

                InitializeRows();
                break;

            case 3:
                foreach (var item in dataGridView.Rows)
                {
                    if ((item as DataGridViewRow).Selected)
                    {
                        using (PharmacyEntities db = new PharmacyEntities())
                        {
                            var buff = db.ProductList.Find((int)(item as DataGridViewRow).Cells[0].Value);
                            db.ProductList.Remove(buff);

                            try
                            {
                                db.SaveChanges();
                            }
                            catch (DbUpdateException)
                            {
                                MessageBox.Show("Ошибка");
                                return;
                            }
                        }

                        break;
                    }
                }

                InitializeRows();
                break;
            }
        }
示例#9
0
 public CreateType(ComboBox cmb)
 {
     _cmb = cmb;
     _db  = new PharmacyEntities();
     InitializeComponent();
 }
示例#10
0
 public Register(Form form)
 {
     _db    = new PharmacyEntities();
     _login = form;
     InitializeComponent();
 }
示例#11
0
 public Login()
 {
     _db = new PharmacyEntities();
     InitializeComponent();
 }
示例#12
0
 public Report()
 {
     _db = new PharmacyEntities();
     InitializeComponent();
 }
示例#13
0
 public Admin(Form form)
 {
     _login = form;
     _db    = new PharmacyEntities();
     InitializeComponent();
 }