Exemplo n.º 1
0
        private void btnsell_Click(object sender, EventArgs e)
        {
            string  buyMedText = "";
            decimal totalPrice = 0;

            for (int i = chkList.Items.Count - 1; i >= 0; i--)
            {
                string   buyMedName  = chkList.Items[i].ToString();
                int      medCount    = Convert.ToInt32(buyMedName.Substring(buyMedName.LastIndexOf(",") + 1));
                string   medName     = buyMedName.Substring(0, buyMedName.LastIndexOf(","));
                Medicine selectedMed = db.Medicines.First(m => m.Name == medName);
                db.Orders.Add(new Order()
                {
                    WorkerID     = 1,
                    Amount       = medCount,
                    MedicineID   = selectedMed.Id,
                    PurchaseDate = DateTime.Now,
                });
                db.SaveChanges();
                selectedMed.Quantity -= medCount;
                db.SaveChanges();
                buyMedText += string.Format($"{medName} count: {medCount}, price: {selectedMed.Price} Azn\n");
                totalPrice += selectedMed.Price * medCount;
            }
            MessageBox.Show(buyMedText + $"\n Total price: {totalPrice}\nBuy succesfully", "BUY", MessageBoxButtons.OK, MessageBoxIcon.Information);
            FillDataGridMedicine();
        }
Exemplo n.º 2
0
        public ActionResult Details(int?id, string Status)
        {
            var stock = db.Stocks.Find(id);

            stock.Status = Status;
            db.SaveChanges();
            return(RedirectToAction("Index", "Stocks"));
        }
Exemplo n.º 3
0
        public ActionResult Create([Bind(Include = "ID,CateName,CateCode")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "ID,Firstname,Lastname,Gender,BirthDay,Weight,Height,Description")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
Exemplo n.º 5
0
        public ActionResult Create([Bind(Include = "ID,CateID,ProductName,Buy,Size,Code,Ingredients,ImagePath,Description,Unit,Barcode,Sale")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CateID = new SelectList(db.Categories, "ID", "CateName", product.CateID);
            return(View(product));
        }
Exemplo n.º 6
0
        public ActionResult Create(Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();

                return(Json("Success", JsonRequestBehavior.AllowGet));
            }
            ViewBag.Category = new SelectList(db.ProductCategories, "ProductTypeCode", "ProductType", product.ProductTypeCode);


            return(View(product));
        }
Exemplo n.º 7
0
        private void addButton_Click_1(object sender, EventArgs e)
        {
            using (PharmacyEntities db = new PharmacyEntities())
            {
                PointsOfSale buff = new PointsOfSale();

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

                buff.AddressOfPoint = adressTexBox.Text;
                db.PointsOfSale.Add(buff);

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    MessageBox.Show("ID не должен повторяться!");
                    return;
                }
            }
            Close();
        }
Exemplo n.º 8
0
        public int HaveFirms(string frm)
        {
            Firm hasFirm = db.Firms.FirstOrDefault(x => x.Name == frm);

            if (hasFirm == null)
            {
                Firm newFirm = new Firm()
                {
                    Name = frm
                };
                db.Firms.Add(newFirm);
                db.SaveChanges();
                return(newFirm.ID);
            }
            return(hasFirm.ID);
        }
Exemplo n.º 9
0
        public ActionResult Deletes(int id)
        {
            PurchaseItem purchaseitem = db.PurchaseItems.Find(id);

            db.PurchaseItems.Remove(purchaseitem);
            db.SaveChanges();
            return(Json("Success", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 10
0
 public ActionResult Create(CreateClientModel model)
 {
     if (ModelState.IsValid)
     {
         PharmacyEntities entities = new PharmacyEntities();
         entities.MainClientDatas.Add(model.MainData);
         entities.SaveChanges();
         int mainDataId = entities.MainClientDatas.First(x => x.Email == model.MainData.Email).id;
         model.OtherData.ClientId = mainDataId;
         model.EyeData.ClientId   = mainDataId;
         entities.OtherClientDatas.Add(model.OtherData);
         entities.EyeClientDatas.Add(model.EyeData);
         entities.SaveChanges();
         return(RedirectToAction("FindClient"));
     }
     else
     {
         return(View(model));
     }
 }
Exemplo n.º 11
0
        private void addButton_Click(object sender, EventArgs e)
        {
            using (PharmacyEntities db = new PharmacyEntities())
            {
                ProductList buff = new ProductList();

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

                foreach (var item in db.MedicalPreparations)
                {
                    if (medicalPreparationsComboBox.Text == item.NamePreparation)
                    {
                        buff.ProductID = item.id;
                        break;
                    }
                }

                foreach (var item in db.PointsOfSale)
                {
                    if (pointsOfSaleComboBox.Text == item.AddressOfPoint)
                    {
                        buff.PointOfSaleID = item.id;
                        break;
                    }
                }

                buff.shelfLife = dateTimePicker1.Value;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    MessageBox.Show("ID не должен повторяться!");
                    return;
                }
            }
        }
Exemplo n.º 12
0
 private void editButton_Click(object sender, EventArgs e)
 {
     using (PharmacyEntities db = new PharmacyEntities())
     {
         db.PointsOfSale.Find(id).AddressOfPoint = adressTexBox.Text;
         try
         {
             db.SaveChanges();
         }
         catch (DbUpdateException)
         {
             MessageBox.Show("Ошибка!");
             return;
         }
         Close();
     }
 }
Exemplo n.º 13
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            using (PharmacyEntities db = new PharmacyEntities())
            {
                MedicalPreparations buff = new MedicalPreparations();

                try
                {
                    buff.id = Convert.ToInt32(idTextBox.Text);
                    buff.NamePreparation = nameTextBox.Text;

                    foreach (var item in db.Manufactures)
                    {
                        if (manufacturesComboBox.Text == item.NameManufacture)
                        {
                            buff.ManufactureID = item.id;
                            break;
                        }
                    }

                    buff.Price          = Convert.ToDouble(priceTextBox.Text);
                    buff.CountInPackage = Convert.ToInt32(countTextBox.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("Неверно введенные данные!");
                    return;
                }

                db.MedicalPreparations.Add(buff);

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

            this.Close();
        }
Exemplo n.º 14
0
        private void editButton_Click(object sender, EventArgs e)
        {
            using (PharmacyEntities db = new PharmacyEntities())
            {
                try
                {
                    db.ProductList.Find(id).id = Convert.ToInt32(idTextBox.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("Неверно введенные данные!");
                    return;
                }

                foreach (var item in db.MedicalPreparations)
                {
                    if (medicalPreparationsComboBox.Text == item.NamePreparation)
                    {
                        db.ProductList.Find(id).ProductID = item.id;
                    }
                }

                foreach (var item in db.PointsOfSale)
                {
                    if (pointsOfSaleComboBox.Text == item.AddressOfPoint)
                    {
                        db.ProductList.Find(id).PointOfSaleID = item.id;
                    }
                }

                db.ProductList.Find(id).shelfLife = dateTimePicker.Value;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    MessageBox.Show("Ошибка");
                    return;
                }
            }
            Close();
        }
Exemplo n.º 15
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            using (PharmacyEntities db = new PharmacyEntities())
            {
                db.Manufactures.Find(this.id).NameManufacture = nameTextBox.Text;

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


            this.Close();
        }