Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            ShopItems form = new ShopItems();

            this.Hide();
            form.ShowDialog();
        }
Esempio n. 2
0
        private void create_Click(object sender, EventArgs e)
        {
            string Item = "Files/ID.dat";

            using (BinaryReader reader = new BinaryReader(File.Open(Item, FileMode.Open)))
            {
                ItemsSHP item = new ItemsSHP();
                while (reader.PeekChar() > -1)
                {
                    string ids = reader.ReadString();
                    item.shopIdIT = ids;
                }
                reader.Close();

                string id = item.idIT;
                item.nameIT  = nameItem.Text;
                item.desIT   = descriptionItem.Text;
                item.namerIT = numeric.Text;
                try
                {
                    item.priceIT = Convert.ToString(int.Parse(price.Text));
                }
                catch { MessageBox.Show("Для ціни можна використовувати лише цифри", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Error); }
                item.pictureName = "Pictures/" + id + ".bmp";

                string shops = "Files/Items.dat";
                try
                {
                    using (BinaryWriter writer = new BinaryWriter(File.Open(shops, FileMode.Append)))
                    {
                        if (item.pictureName == "" || item.nameIT == "" || item.desIT == "" || item.namerIT == "" || item.priceIT == "" || item.pictureName == "" || item.idIT == "" || item.shopIdIT == "")
                        {
                            MessageBox.Show("Не всі поля заповнені", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            pictureItem.Image.Save(item.pictureName);
                            writer.Write(item.nameIT);
                            writer.Write(item.desIT);
                            writer.Write(item.namerIT);
                            writer.Write(item.priceIT);
                            writer.Write(item.pictureName);
                            writer.Write(item.idIT);
                            writer.Write(item.shopIdIT);
                            writer.Close();
                            this.Hide();
                            ShopItems form = new ShopItems();
                            form.Show();
                        }
                    }
                }
                catch { }
            }
        }
Esempio n. 3
0
        private void saveIt_Click(object sender, EventArgs e)
        {
            ItemsSHP[] it = new ItemsSHP[1];

            string Item  = "Files/IDS.dat";
            string Items = "Files/Items.dat";

            string[] nameIT      = new string[100];
            string[] namerIT     = new string[100];
            string[] desIT       = new string[100];
            string[] priceIT     = new string[100];
            string[] pictureName = new string[100];
            string[] idIT        = new string[100];
            string[] shopIdIT    = new string[100];

            using (BinaryReader reader = new BinaryReader(File.Open(Item, FileMode.Open)))
            {
                int dis = 0;
                using (BinaryReader reader2 = new BinaryReader(File.Open(Items, FileMode.Open)))
                {
                    while (reader.PeekChar() > -1)
                    {
                        string id = reader.ReadString();



                        for (int i = 0; reader2.PeekChar() > -1; i++)
                        {
                            nameIT[i]      = reader2.ReadString();
                            desIT[i]       = reader2.ReadString();
                            namerIT[i]     = reader2.ReadString();
                            priceIT[i]     = reader2.ReadString();
                            pictureName[i] = reader2.ReadString();
                            idIT[i]        = reader2.ReadString();
                            shopIdIT[i]    = reader2.ReadString();

                            if (idIT[i] == id)
                            {
                                nameIT[i]  = rewname.Text;
                                priceIT[i] = rewprice.Text;
                                desIT[i]   = richTextBox1.Text;
                                namerIT[i] = numeric.Text;
                            }
                            dis++;
                        }
                        reader2.Close();
                    }
                }
                using (BinaryWriter writer = new BinaryWriter(File.Open(Items, FileMode.Create)))
                {
                    for (int i = 0; i < dis; i++)
                    {
                        writer.Write(nameIT[i]);
                        writer.Write(desIT[i]);
                        writer.Write(namerIT[i]);
                        writer.Write(priceIT[i]);
                        writer.Write(pictureName[i]);
                        writer.Write(idIT[i]);
                        writer.Write(shopIdIT[i]);
                    }
                    writer.Close();
                }
                reader.Close();
                ShopItems form = new ShopItems();
                this.Hide();
                form.ShowDialog();
            }
        }
Esempio n. 4
0
        private void delate_Click(object sender, EventArgs e)
        {
            ItemsSHP[] it = new ItemsSHP[1];

            string Item  = "Files/IDS.dat";
            string Items = "Files/Items.dat";

            string[] nameIT      = new string[100];
            string[] namerIT     = new string[100];
            string[] desIT       = new string[100];
            string[] priceIT     = new string[100];
            string[] pictureName = new string[100];
            string[] idIT        = new string[100];
            string[] shopIdIT    = new string[100];

            using (BinaryReader reader = new BinaryReader(File.Open(Item, FileMode.Open)))
            {
                int dis = 0;
                using (BinaryReader reader2 = new BinaryReader(File.Open(Items, FileMode.Open)))
                {
                    while (reader.PeekChar() > -1)
                    {
                        string id = reader.ReadString();



                        for (int i = 0; reader2.PeekChar() > -1; i++)
                        {
                            nameIT[i]      = reader2.ReadString();
                            desIT[i]       = reader2.ReadString();
                            namerIT[i]     = reader2.ReadString();
                            priceIT[i]     = reader2.ReadString();
                            pictureName[i] = reader2.ReadString();
                            idIT[i]        = reader2.ReadString();
                            shopIdIT[i]    = reader2.ReadString();


                            dis++;
                        }
                        {
                            for (int i = 0; i < dis; i++)
                            {
                                if (idIT[i] == id)
                                {
                                    try
                                    { for (int j = i; j < dis; j++)
                                      {
                                          nameIT[j]      = nameIT[j + 1];
                                          priceIT[j]     = priceIT[j + 1];
                                          desIT[j]       = desIT[j + 1];
                                          namerIT[j]     = namerIT[j + 1];
                                          pictureName[j] = pictureName[j + 1];
                                          idIT[j]        = idIT[j + 1];
                                          shopIdIT[j]    = shopIdIT[j + 1];
                                      }
                                      dis--; }
                                    catch { dis--; }
                                }
                            }
                        }
                        reader2.Close();
                    }
                }
                using (BinaryWriter writer = new BinaryWriter(File.Open(Items, FileMode.Create)))
                {
                    for (int i = 0; i < dis; i++)
                    {
                        writer.Write(nameIT[i]);
                        writer.Write(desIT[i]);
                        writer.Write(namerIT[i]);
                        writer.Write(priceIT[i]);
                        writer.Write(pictureName[i]);
                        writer.Write(idIT[i]);
                        writer.Write(shopIdIT[i]);
                    }
                    writer.Close();
                }
                reader.Close();
                ShopItems form = new ShopItems();
                this.Hide();
                form.ShowDialog();
            }
        }
Esempio n. 5
0
        private void saveme_Click(object sender, EventArgs e)
        {
            Shop   shop = new Shop();
            string IDD  = "Files/ID.dat";
            string Shop = "Files/Shop.dat";

            string[] name    = new string[100];
            string[] adres   = new string[100];
            string[] type    = new string[100];
            string[] idd     = new string[100];
            string[] picture = new string[100];


            using (BinaryReader reader = new BinaryReader(File.Open(IDD, FileMode.Open)))
            {
                int dis = 0;
                using (BinaryReader reader2 = new BinaryReader(File.Open(Shop, FileMode.Open)))
                {
                    while (reader.PeekChar() > -1)
                    {
                        string id = reader.ReadString();



                        for (int i = 0; reader2.PeekChar() > -1; i++)
                        {
                            name[i]    = reader2.ReadString();
                            type[i]    = reader2.ReadString();
                            adres[i]   = reader2.ReadString();
                            idd[i]     = reader2.ReadString();
                            picture[i] = reader2.ReadString();

                            if (idd[i] == id)
                            {
                                name[i]  = rewname.Text;
                                adres[i] = rewadress.Text;
                                type[i]  = comboBox1.Text;
                            }
                            dis++;
                        }
                        reader2.Close();
                    }
                }
                using (BinaryWriter writer = new BinaryWriter(File.Open(Shop, FileMode.Create)))
                {
                    for (int i = 0; i < dis; i++)
                    {
                        writer.Write(name[i]);
                        writer.Write(type[i]);
                        writer.Write(adres[i]);
                        writer.Write(idd[i]);
                        writer.Write(picture[i]);
                    }
                    writer.Close();
                }
                reader.Close();
                ShopItems form = new ShopItems();
                this.Hide();
                form.ShowDialog();
            }
        }