Beispiel #1
0
 private void AttachToAccount()
 {
     if (CreateTable)
     {
         General.CreateTable(LoadString, String.Format("ID int IDENTITY (1, 1) not null, Продукт nchar(25) not null, Цена float not null, Количество float not null, Сумма float not null, Дата nvarchar(15), constraint PK_{0} primary key clustered([ID] ASC)", LoadString));
     }
     if (insertRecords)
     {
         InsertRecords();
     }
     AttachToTable();
 }
Beispiel #2
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            try
            {
                Price       = PriceValue;
                Count       = Count - CountValue;
                Summ        = Summ - SummValue;
                CratesCount = CratesCount - CratesCountBalue;
                Mass        = Mass - MassValue;

                if (!File.Exists(Application.StartupPath + "//Shop.Residue.Data.xml"))
                {
                    General.ShowErrorBox("Список продуктов цеха отсутствует!\nВозможно была потеря данных, обратитесь к администрации программы!");
                }
                else
                {
                    XmlDocument xDoc = new XmlDocument();
                    xDoc.Load(Application.StartupPath + "//Shop.Residue.Data.xml");
                    XmlElement xRoot     = xDoc.DocumentElement;
                    XmlNode    childnode = xRoot.SelectSingleNode(String.Format("ShopResidue[Имя='{0}']", titlebox.Text));
                    if (childnode != null)
                    {
                        XmlNode nameChildNode = childnode.SelectSingleNode("Имя");
                        string  elemNameStr   = "NONE";
                        if (nameChildNode != null)
                        {
                            elemNameStr = nameChildNode.InnerText;
                            XmlNode massElem   = childnode.SelectSingleNode("Масса");
                            XmlNode countElem  = childnode.SelectSingleNode("Количество");
                            XmlNode cratesElem = childnode.SelectSingleNode("КоличествоКаробок");
                            XmlNode pricesElem = childnode.SelectSingleNode("Цена");
                            XmlNode summElem   = childnode.SelectSingleNode("Сумма");

                            if (massElem != null && countElem != null && cratesElem != null && pricesElem != null && summElem != null)
                            {
                                massElem.InnerText   = Mass.ToString();
                                countElem.InnerText  = Count.ToString();
                                cratesElem.InnerText = CratesCount.ToString();
                                pricesElem.InnerText = Price.ToString();
                                summElem.InnerText   = Summ.ToString();
                            }
                        }
                    }
                    xDoc.Save(Application.StartupPath + "//Shop.Residue.Data.xml");
                }

                //General.UpdateCellData("ResidueShopMaterials", "Масса", textBox3.Text, Convert.ToInt32(ID));
                //General.UpdateCellData("ResidueShopMaterials", "Цена", textBox1.Text, Convert.ToInt32(ID));
                //General.UpdateCellData("ResidueShopMaterials", "Количество", textBox2.Text, Convert.ToInt32(ID));
                //General.UpdateCellData("ResidueShopMaterials", "КоличествоКаробок", textBox5.Text, Convert.ToInt32(ID));
                //General.UpdateCellData("ResidueShopMaterials", "Сумма", textBox4.Text, Convert.ToInt32(ID));


                Date = DateControl.Text.ToString();
                if (ProviderTextBox.Text != null)
                {
                    Provider = ProviderTextBox.Text;
                }

                if (RecipientTextBox.Text != null)
                {
                    Recipient = RecipientTextBox.Text;
                }


                SaledShopMaterials RRMF = new SaledShopMaterials();
                RRMF.InsertRecords(titlebox.Text, textBox3.Text, textBox1.Text, textBox2.Text, textBox5.Text, Date, Provider, Recipient);
                RRMF.ShowDialog(this);

                try
                {
                    General.CreateTable(Recipient, String.Format("ID int IDENTITY (1, 1) not null, Продукт nchar(25) not null, Цена float not null, Количество float not null, Сумма float not null, Дата nvarchar(15), constraint PK_{0} primary key clustered([ID] ASC)", Recipient));
                    InsertRecordsToCouterparty(titlebox.Text, PriceValue, CountValue, SummValue, Date);
                }
                catch (Exception)
                {
                    General.Connection.Close();
                }
                this.Close();
            }
            catch (Exception) { }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            ListB.Items.Clear();

            if (TextB.Text != null)
            {
                string       PName   = TextB.Text;
                StreamWriter SWriter = new StreamWriter(FileName, true, Encoding.UTF8);
                SWriter.Write(PName);
                SWriter.WriteLine();
                SWriter.Flush();
                SWriter.Close();

                if (File.Exists(FileName))
                {
                    string[] Data = File.ReadAllLines(FileName);
                    if (Data != null)
                    {
                        ListB.Items.AddRange(Data);
                    }
                }

                if (t_Type == "Shop")
                {
                    try
                    {
                        General.CreateTable(PName, String.Format("ID int IDENTITY (1, 1) not null, Имя nchar(25) not null, Масса float not null, Цена float not null, Количество float not null, КоличествоКаробок float not null, Сумма float not null, Дата nvarchar(25) not null, Поставщик nchar(30) not null, Получатель nchar(30) not null, constraint PK_{0} primary key clustered([ID] ASC)", PName));
                        ProductConculationStep1 P = new ProductConculationStep1(); P.InsertRecords(PName); P.Close();

                        bool isElementExists = false;

                        if (File.Exists(Application.StartupPath + "//Shop.Residue.Data.xml"))
                        {
                            XmlDocument xDoc = new XmlDocument();
                            xDoc.Load(Application.StartupPath + "//Shop.Residue.Data.xml");
                            XmlElement xRoot     = xDoc.DocumentElement;
                            XmlNode    childnode = xRoot.SelectSingleNode(String.Format("ShopResidue[Имя='{0}']", PName));
                            if (childnode != null)
                            {
                                isElementExists = true;
                            }
                        }

                        if (!isElementExists)
                        {
                            General.InsertRowToXMLData(Application.StartupPath + "//Shop.Residue.Data.xml", "ShopResidue", "Имя=" + PName, "Масса=NONE", "Количество=NONE", "КоличествоКаробок=NONE", "Цена=NONE", "Сумма=NONE");
                        }
                    }
                    catch (Exception ex)
                    {
                        General.ShowErrorBox(ex.Message);
                        General.Connection.Close();
                    }
                }


                if (t_Type == "Raw")
                {
                    try
                    {
                        General.CreateTable(PName, String.Format("ID int IDENTITY (1, 1) not null, Имя nchar(25) not null, Масса float not null, Цена float not null, Количество float not null, КоличествоКаробок float not null, Сумма float not null, Дата nvarchar(25) not null, Поставщик nchar(30) not null, Получатель nchar(30) not null, constraint PK_{0} primary key clustered([ID] ASC)", PName));

                        bool isElementExists = false;

                        if (File.Exists(Application.StartupPath + "//Raw.Residue.Data.xml"))
                        {
                            XmlDocument xDoc = new XmlDocument();
                            xDoc.Load(Application.StartupPath + "//Raw.Residue.Data.xml");
                            XmlElement xRoot     = xDoc.DocumentElement;
                            XmlNode    childnode = xRoot.SelectSingleNode(String.Format("RawResidue[Имя='{0}']", PName));
                            if (childnode != null)
                            {
                                isElementExists = true;
                            }
                        }

                        if (!isElementExists)
                        {
                            General.InsertRowToXMLData(Application.StartupPath + "//Raw.Residue.Data.xml", "RawResidue", "Имя=" + PName, "Масса=NONE", "Количество=NONE", "КоличествоКаробок=NONE", "Цена=NONE", "Сумма=NONE");
                        }
                    }
                    catch (Exception ex)
                    {
                        General.ShowErrorBox(ex.Message);
                        General.Connection.Close();
                    }
                }
            }

            TextB.Text = string.Empty;
        }