Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Section tmpSec = new Section();
            ((Form1)this.Owner).TmpGood.Status = false;
            if (DataBase.GetSqlConnection().State == ConnectionState.Open)
            {
                string query = string.Format("update Goods set Stat = {0} where GoodID = {1}", 0, good.GoodID);
                SqlCommand command = new SqlCommand(query, DataBase.Sql);
                command.ExecuteNonQuery();

                foreach(Section section in SectionsManager.Sections)
                {
                    if(section.SectionID == good.SectionID)
                    {
                        //((Form1)this.Owner).DictKvp.Remove(section);
                        tmpSec = section;
                        break;
                    }
                }
                tmpSec.ExclusiveOrList(good.BoolenLocation);
                double loc = SectionsManager.ToDouble(tmpSec.BoolenTopography);
                query = string.Format("update Sections set Topography = {0} where SectionID = {1}", loc, tmpSec.SectionID);
                command = new SqlCommand(query, DataBase.Sql);
                command.ExecuteNonQuery();
            }
            ((Form1)this.Owner).DictButGood.Remove(((Form1)this.Owner).TmpButton);
            ((Form1)this.Owner).TmpButton.Parent.Controls.Remove(((Form1)this.Owner).TmpButton);

            this.Close();
        }
        public static void LoadSections(SqlDataReader reader)
        {
            while (reader.Read())
            {
                Section section = new Section();

                section.SectionID = (int)reader["SectionID"];
                //section.Topography = (double)reader["Topography"];
                decimal topography = (decimal)reader["Topography"];
                while (topography != 0)
                {
                    if (topography % 2 == 1)
                    {
                        section.BoolenTopography.Add(true);
                        topography = (topography - 1) / 2;
                    }
                    else
                    {
                        section.BoolenTopography.Add(false);
                        topography = topography / 2;
                    }
                    
                }

                int c = section.BoolenTopography.Count;
                for (int i = 48 - c; i > 0; i--)
                {
                    section.BoolenTopography.Add(false);
                }

                section.IsChanged = false;
                sections.Add(section);
            }
        }
        public static void UpdateSections()
        {
            string query1 = string.Empty;
            string query2 = string.Empty;
            Section tmpSection = new Section();
            SqlCommand command;
            SqlDataReader reader;
            List<int> changedData;

            query1 = "select * from Sections";
            command = new SqlCommand(query1, DataBase.Sql);
            reader = command.ExecuteReader();

            changedData = new List<int>();

            foreach (Section section in SectionsManager.Sections)
            {
                if (section.IsChanged) changedData.Add(section.SectionID);
            }

            List<string> querys = new List<string>();
            while (reader.Read())
            {
                //if (changedData.Contains((int)reader["SectionID"]))
                //{
                    foreach (Section section in SectionsManager.Sections)
                    {
                        if (section.SectionID == ((int)reader["SectionID"]))
                        {
                            tmpSection = section;
                            break;
                        }
                    }
                    querys.Add(string.Format("update Sections set Topography = '{0}' where SectionID = {1}", ToDouble(tmpSection.BoolenTopography), tmpSection.SectionID));
                    //query2 = string.Format("update Sections set Topography = '{0}' where SectionID = {1}", ToDouble(tmpSection.BoolenTopography), tmpSection.SectionID);
                    //(new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery();

                    tmpSection.IsChanged = false;
                //}
            }

            reader.Close();

            foreach(string str in querys)
            {
                (new SqlCommand(str, DataBase.Sql)).ExecuteNonQuery();
            }

            DataBase.Sql.Close();
        }
Ejemplo n.º 4
0
        void Choice_Good(object sender, MouseEventArgs e)
        {
            if (shiftBtn != null)
            {
                foreach (Section section in SectionsManager.Sections)
                    dictGraph[dictKvp[section]].Clear(((Button)sender).Parent.BackColor);
                shiftBtn.Show();
            }
            shiftBtn = (Button)sender;
            tmpGood = dictButGood[(Button)sender];
            ((Button)sender).Hide();
            dictTemp.Clear();
            dictTemp = fillDictTemp();
            int n, m;
            n = tmpGood.Height / 25;
            m = tmpGood.Width / 25;

            foreach (Section section in SectionsManager.Sections)
            {
                if (dictKvp[section] == (Panel)(((Button)sender).Parent))
                {
                    sectionTmp = section;
                    for (int i = 0; i < 4; i++)
                    {
                        for (int j = 0; j < 12; j++)
                        {
                            dictTemp[section][i, j] = dictTemp[section][i, j] ^ tmpGood.BoolenLocation[i * 12 + j];//копать тут
                        }
                    }
                    break;
                }
            }

            bool yes = false;
            dictGraph.Clear();
            foreach (Section section in SectionsManager.Sections)
            {
                dictGraph.Add(dictKvp[section], dictKvp[section].CreateGraphics());
            }
            foreach (Section section in SectionsManager.Sections)
            {
                for (int k = 0; k < 4; k++)
                {
                    for (int l = 0; l < 12; l++)
                    {
                        if (OffSet(k, l, m - 1, n - 1, dictTemp[section]))
                        {
                            yes = true;
                            dictGraph[dictKvp[section]].DrawLine(new Pen(Color.Red), l * 25, k * 25, l * 25 + 13, k * 25);
                            dictGraph[dictKvp[section]].DrawLine(new Pen(Color.Red), l * 25, k * 25, l * 25, k * 25 + 13);
                        }
                        else
                        {
                            if (OffSet(k, l, n - 1, m - 1, dictTemp[section]))
                            {
                                yes = true;
                                dictGraph[dictKvp[section]].DrawLine(new Pen(Color.Red), l * 25, k * 25, l * 25 + 13, k * 25);
                                dictGraph[dictKvp[section]].DrawLine(new Pen(Color.Red), l * 25, k * 25, l * 25, k * 25 + 13);
                            }
                        }
                    }
                }
            }

            if (yes)
            {
                foreach (Section section in SectionsManager.Sections)
                {
                    dictKvp[section].MouseClick += Choice_MouseClick1;
                }
            }
        }
Ejemplo n.º 5
0
        private void labelTmp_Click(object sender, EventArgs e)
        {
            changeStat = false;
            controlLabel.Parent.Controls.Remove(controlLabel);
            foreach (Section section in SectionsManager.Sections)
            {
                dictKvp[section].MouseClick -= Choice_MouseClick;
                dictKvp[section].MouseClick -= Choice_MouseClick1;
            }
            Dictionary<Button, Good>.KeyCollection kC = dictButGood.Keys;
            for (int i = 0; i < kC.Count; i++)
            {
                kC.ElementAt(i).MouseClick -= Choice_Good;
            }
            if (shiftBtn != null)
                shiftBtn.Show();

            for (int i = 0; i < this.Controls.Count; i++)
            {
                this.Controls[i].Show();
            }
            dictTemp.Clear();
            if (GoodFromNG != null)
                GoodFromNG.Close();

            if (sectionTmp != null)
                sectionTmp = null;

            for (int i = 0; i < panel1.Controls.Count; i++)
            {
                if (panel1.Controls[i] is Panel)
                {
                    dictGraph[(Panel)panel1.Controls[i]].Clear(this.BackColor);
                }
            }
            ColorButton();
        }