Пример #1
0
        private Dish dishGetFromForm()//при внесении новых блюд изменяем БД
        {
            Dish newDish = new Dish();


            if (string.IsNullOrWhiteSpace(textBoxDishChange.Text) || string.IsNullOrEmpty(textBoxDishChange.Text))
            {
                ErrorlabelCom.Text = "Ошибка:\r\nПоле \"Название блюда\" должно быть обязательно заполнено.";
                throw new System.ArgumentNullException();
            }
            else
            {
                newDish.title = textBoxDishChange.Text;
            }

            if (string.IsNullOrWhiteSpace(textBoxNumDishChange.Text) || string.IsNullOrEmpty(textBoxNumDishChange.Text))
            {
                ErrorlabelCom.Text = "Ошибка:\r\nПоле \"Цена блюда\" должно быть обязательно заполнено.";
                throw new System.ArgumentNullException();
            }
            else
            {
                newDish.quantily = Convert.ToInt32(textBoxNumDishChange.Text);
            }
            newDish.cafe = Cafe.Get(cafeId);
            return(newDish);
        }
Пример #2
0
        private void ButtonChangeAdd_Click(object sender, EventArgs e)
        {
            FormChangeComposition winArray;

            try
            {
                if (menuDGV.SelectedRows.Count > 0)
                {
                    winArray = new FormChangeComposition((int)menuDGV.SelectedRows[0].Cells["Column16"].Value, (int)menuDGV.SelectedRows[0].Cells["cafe_idcafe"].Value);
                    winArray.Show();
                    menuDGV_FirstReload();
                }
                else
                {
                    int k = 0;
                    cafeList = Cafe.Get();
                    while (comboBoxCafe.Text != cafeList[k].address)
                    {
                        ++k;
                    }
                    winArray = new FormChangeComposition(cafeList[k].idcafe);
                    winArray.Show();
                    menuDGV_FirstReload();
                }
            }
            catch
            {
                ErrorlabelMenu.Text = "Ошибка:\r\nВы не выбрали кафе.";
            }
        }
Пример #3
0
        //-------------------------------CAFE TABLE-------------------------------
        private void cafeDGV_FirstReload()
        {
            cafeDGV.Rows.Clear();

            cafeList = Cafe.Get();
            foreach (Cafe cafe in cafeList)
            {
                cafeDGV.Rows.Add(cafe.idcafe, cafe.owner, cafe.title, cafe.address, cafe.phone, cafe.rating);
            }

            for (int i = 0; i < cafeDGV.RowCount; ++i)
            {
                cafeDGV.Rows[i].Selected = false;
            }


            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
            textBox5.Text = "";


            choosenIndexCafe = -1;
        }
Пример #4
0
        public void menuDGV_FirstReload()//заполняем таблицу блюдами
        {
            int k = 0;

            menuDGV.Rows.Clear();
            Cafe tmp = new Cafe();

            dishList = Dish.Get();
            cafeList = Cafe.Get();

            while (comboBoxCafe.Text != cafeList[k].address)
            {
                ++k;
            }
            tmp.idcafe = cafeList[k].idcafe;
            foreach (Dish dish in dishList)
            {
                if (GetCafeDish(tmp, dish) != "0")
                {
                    menuDGV.Rows.Add(dish.iddish, tmp.idcafe, dish.title, dish.quantily);
                }
            }

            for (int i = 0; i < menuDGV.RowCount; ++i)
            {
                menuDGV.Rows[i].Selected = false;
            }
            choosenIndexDish = -1;
        }
Пример #5
0
        private Serve serveGetFromForm()
        {
            int   i        = 0;
            Serve newServe = new Serve();

            if (string.IsNullOrWhiteSpace(textBoxName.Text) || string.IsNullOrEmpty(textBoxName.Text))
            {
                ErrorlabelServe.Text = "Ошибка:\r\nПоле \"ФИО сотрудника\" должно быть обязательно заполнено.";
                throw new System.ArgumentNullException();
            }
            else
            {
                newServe.name = textBoxName.Text;
            }

            if (string.IsNullOrWhiteSpace(textBoxPassport.Text) || string.IsNullOrEmpty(textBoxPassport.Text))
            {
                ErrorlabelServe.Text = "Ошибка:\r\nПоле \"Паспортные данные\" должно быть обязательно заполнено.";
                throw new System.ArgumentNullException();
            }
            else
            {
                newServe.passport = Convert.ToInt32(textBoxPassport.Text);
            }

            newServe.education = textBoxEducation.Text;

            if (string.IsNullOrWhiteSpace(textBoxExperience.Text) || string.IsNullOrEmpty(textBoxExperience.Text))
            {
                ErrorlabelServe.Text = "Ошибка:\r\nПоле \"Опыт работы\" должно быть обязательно заполнено.";
                throw new System.ArgumentNullException();
            }
            else
            {
                newServe.experience = Convert.ToInt32(textBoxExperience.Text);
            }
            if (string.IsNullOrWhiteSpace(comboBoxServeCafe.Text) || string.IsNullOrEmpty(comboBoxServeCafe.Text))
            {
                ErrorlabelServe.Text = "Ошибка:\r\nПоле \"Адрес кофейни\" должно быть обязательно заполнено.";
                throw new System.ArgumentNullException();
            }
            else
            {
                while (comboBoxServeCafe.Text != cafeList[i].address)
                {
                    ++i;
                }
                newServe.cafe = Cafe.Get(cafeList[i].idcafe);
            }

            return(newServe);
        }
Пример #6
0
        private void DGVCount_FirstReload()
        {
            DGVCount.Rows.Clear();
            cafeList = Cafe.Get();

            foreach (Cafe cafe in cafeList)
            {
                if (GetCafeServ(cafe) == true)
                {
                    DGVCount.Rows.Add(cafe.idcafe, cafe.address, Cafe.GetCountServe(cafe.idcafe), Cafe.GetPostCafe(cafe.idcafe));
                }
            }

            for (int i = 0; i < DGVCount.RowCount; ++i)
            {
                DGVCount.Rows[i].Selected = false;
            }
            choosenIndexCafe = -1;
        }
Пример #7
0
        private void supDGV_FirstReload()
        {
            supDGV.Rows.Clear();

            cafeList = Cafe.Get();
            supList  = Supplier.Get();
            comboBoxSupCafe.Items.Clear();


            foreach (Supplier supplier in supList)
            {
                foreach (Cafe cafe in cafeList)
                {
                    if (GetCafeSup(cafe, supplier) != "0")
                    {
                        supDGV.Rows.Add(supplier.idsupplier, supplier.title, supplier.product, supplier.FrequencyOfDeliveries, supplier.VolumeOfDeliveries, cafe.address);
                    }
                }
            }

            for (int i = 0; i < supDGV.RowCount; ++i)
            {
                supDGV.Rows[i].Selected = false;
            }
            foreach (Cafe cafe in cafeList)
            {
                comboBoxSupCafe.Items.Add(cafe.address);
            }
            comboBoxSupCafe.SelectedIndex = -1;



            textBoxSupTitle.Text   = "";
            textBoxSupProduct.Text = "";
            textBoxSupFOD.Text     = "";
            textBoxSupVOD.Text     = "";
            comboBoxSupCafe.Text   = null;

            choosenIndexSupplier = -1;
        }
Пример #8
0
        private void servDGV_FirstReload()
        {
            servDGV.Rows.Clear();
            cafeList  = Cafe.Get();
            serveList = Serve.Get();

            comboBoxServeCafe.Items.Clear();
            foreach (Serve serve in serveList)
            {
                foreach (Cafe cafe in cafeList)
                {
                    if (GetCafeServe(cafe, serve) != "0")
                    {
                        servDGV.Rows.Add(serve.idserve, serve.name, serve.passport, serve.education, serve.experience, cafe.address);
                    }
                }
            }

            for (int i = 0; i < servDGV.RowCount; ++i)
            {
                servDGV.Rows[i].Selected = false;
            }
            foreach (Cafe cafe in cafeList)
            {
                comboBoxServeCafe.Items.Add(cafe.address);
            }
            comboBoxServeCafe.SelectedIndex = -1;

            textBoxName.Text       = "";
            textBoxPassport.Text   = "";
            textBoxEducation.Text  = "";
            textBoxExperience.Text = "";
            comboBoxServeCafe.Text = null;

            choosenIndexServe = -1;
        }
Пример #9
0
        private Supplier supGetFromForm()
        {
            int      i           = 0;
            Supplier newSupplier = new Supplier();

            if (string.IsNullOrWhiteSpace(textBoxSupTitle.Text) || string.IsNullOrEmpty(textBoxSupTitle.Text))
            {
                ErrorlabelSup.Text = "Ошибка:\r\nПоле \"Название фирмы\" должно быть обязательно заполнено.";
                throw new System.ArgumentNullException();
            }
            else
            {
                newSupplier.title = textBoxSupTitle.Text;
            }

            if (string.IsNullOrWhiteSpace(textBoxSupProduct.Text) || string.IsNullOrEmpty(textBoxSupProduct.Text))
            {
                ErrorlabelSup.Text = "Ошибка:\r\nПоле \"Поставляемая продукция\" должно быть обязательно заполнено.";
                throw new System.ArgumentNullException();
            }
            else
            {
                newSupplier.product = textBoxSupProduct.Text;
            }

            newSupplier.FrequencyOfDeliveries = Convert.ToInt32(textBoxSupFOD.Text);
            newSupplier.VolumeOfDeliveries    = Convert.ToInt32(textBoxSupVOD.Text);

            while (comboBoxSupCafe.Text != cafeList[i].address)
            {
                ++i;
            }
            newSupplier.cafe = Cafe.Get(cafeList[i].idcafe);

            return(newSupplier);
        }
Пример #10
0
        public static bool export(string f_name)
        {
            XmlDocument    doc = new XmlDocument();
            XmlElement     cafeElement, SupElemnt, root;
            XmlDeclaration declaration;
            XmlAttribute   attribute;

            doc.Schemas.Add(targetNamespace, xds);
            declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
            root        = doc.CreateElement("BDCafe");

            doc.AppendChild(root);
            List <Cafe> cafeList;

            cafeList = Cafe.Get();

            List <Supplier> supList;

            supList = Supplier.Get();

            foreach (Cafe cafe in cafeList)
            {
                cafeElement = doc.CreateElement("Cafe");

                //attribute = doc.CreateAttribute("idcafe");
                //attribute.Value = cafe.idcafe.ToString();
                //cafeElement.Attributes.Append(attribute);

                attribute       = doc.CreateAttribute("owner");
                attribute.Value = cafe.owner;
                cafeElement.Attributes.Append(attribute);

                attribute       = doc.CreateAttribute("title");
                attribute.Value = cafe.title;
                cafeElement.Attributes.Append(attribute);

                attribute       = doc.CreateAttribute("address");
                attribute.Value = cafe.address;
                cafeElement.Attributes.Append(attribute);

                attribute       = doc.CreateAttribute("phone");
                attribute.Value = cafe.phone.ToString();
                cafeElement.Attributes.Append(attribute);

                attribute       = doc.CreateAttribute("rating");
                attribute.Value = cafe.rating.ToString();
                cafeElement.Attributes.Append(attribute);

                foreach (Supplier supplier in supList)
                {
                    if (GetCafeSup(cafe, supplier) == true)
                    {
                        SupElemnt = doc.CreateElement("Supplier");

                        //attribute = doc.CreateAttribute("idsupplier");
                        //attribute.Value = supplier.idsupplier.ToString();
                        //SupElemnt.Attributes.Append(attribute);

                        attribute       = doc.CreateAttribute("title");
                        attribute.Value = supplier.title;
                        SupElemnt.Attributes.Append(attribute);

                        attribute       = doc.CreateAttribute("product");
                        attribute.Value = supplier.product;
                        SupElemnt.Attributes.Append(attribute);

                        attribute       = doc.CreateAttribute("Frequencyofdeliveries");
                        attribute.Value = supplier.FrequencyOfDeliveries.ToString();
                        SupElemnt.Attributes.Append(attribute);

                        attribute       = doc.CreateAttribute("Volumeofdeliveries");
                        attribute.Value = supplier.VolumeOfDeliveries.ToString();
                        SupElemnt.Attributes.Append(attribute);


                        attribute       = doc.CreateAttribute("cafeAddress");
                        attribute.Value = supplier.cafe.address; //ID
                        SupElemnt.Attributes.Append(attribute);

                        cafeElement.AppendChild(SupElemnt);
                    }
                }
                root.AppendChild(cafeElement);
            }
            doc.Save(f_name);
            try
            {
                doc.DocumentElement.SetAttribute("xmlns", targetNamespace);
                doc.Validate(null);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #11
0
        static public void import(string f_name)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(f_name);
            XmlElement root = doc.DocumentElement;

            doc.Schemas.Add(targetNamespace, xds);
            if (string.IsNullOrEmpty(doc.DocumentElement.NamespaceURI))
            {
                doc.DocumentElement.SetAttribute("xmlns", targetNamespace);
                doc.LoadXml(doc.InnerXml);
            }
            //try
            //{
            //    doc.DocumentElement.SetAttribute("xmlns", targetNamespace);
            //    doc.Validate(null);
            //}
            //catch
            //{
            //    MessageBox.Show("Документ не соответсвует схеме", "Информация", MessageBoxButtons.OKCancel);
            //    return;
            //}

            foreach (XmlNode n in root)
            {
                Cafe        c = new Cafe();
                List <Cafe> cafeList;
                cafeList = Cafe.Get();

                //c.idcafe = Int32.Parse(n.Attributes["idcafe"].Value);
                c.owner   = n.Attributes["owner"].Value;
                c.title   = n.Attributes["title"].Value;
                c.address = n.Attributes["address"].Value;
                c.phone   = Int32.Parse(n.Attributes["phone"].Value);
                c.rating  = Int32.Parse(n.Attributes["rating"].Value);

                Cafe np = new Cafe();
                np = np.search(c.address);
                if (np == null)
                {
                    c.add(c);
                    cafeList = Cafe.Get();
                    c.idcafe = cafeList.LastOrDefault().idcafe;
                }
                else
                {
                    c.change(np.idcafe, c);//обновляет
                    c.idcafe = np.idcafe;
                }

                foreach (XmlNode t in n)
                {
                    Supplier s = new Supplier();
                    if (t.Attributes["cafeAddress"].Value != c.address)
                    {
                        break;
                    }
                    //s.idsupplier = Int32.Parse(t.Attributes["idsupplier"].Value);
                    s.title   = t.Attributes["title"].Value;
                    s.product = t.Attributes["product"].Value;
                    s.FrequencyOfDeliveries = Int32.Parse(t.Attributes["Frequencyofdeliveries"].Value);
                    s.VolumeOfDeliveries    = Int32.Parse(t.Attributes["Volumeofdeliveries"].Value);
                    s.cafe = Cafe.Get(c.idcafe);

                    Supplier sp = new Supplier();
                    sp = sp.search(s.title);
                    if (sp == null)
                    {
                        s.add(s);
                    }
                    else
                    {
                        s.change(sp.idsupplier, s);
                    }
                }
            }
        }