public static void LoadGoods(SqlDataReader reader) { while (reader.Read()) { Good good = new Good(); good.GoodID = (int)reader["GoodID"]; good.Title = reader["Title"].ToString(); good.SectionID = (int)reader["SectionID"]; good.Height = (int)reader["Height"]; good.Width = (int)reader["Width"]; good.ClientID = (int)reader["ClientID"]; good.DateStart = (DateTime)reader["DateStart"]; good.DateFinish = (DateTime)reader["DateFinish"]; good.Cost = (int)reader["Cost"]; good.Fine = (int)reader["Fine"]; good.Status = (bool)reader["Stat"]; decimal locationD = (decimal)reader["Location"]; double location = (double)locationD; while (location >= 1) { if (location % 2 == 1) { good.BoolenLocation.Add(true); location = (location - 1) / 2; } else { good.BoolenLocation.Add(false); location = location/ 2; } } int c = good.BoolenLocation.Count; for (int i = 48 - c; i > 0; i--) { good.BoolenLocation.Insert(48 - i, false); } good.IsChanged = false; goods.Add(good); } }
private void GoodInfo_Shown(object sender, EventArgs e) { good = ((Form1)this.Owner).TmpGood; textBox1.Text = good.GoodID.ToString(); textBox2.Text = good.ClientID.ToString(); textBox3.Text = good.SectionID.ToString(); textBox4.Text = good.Cost.ToString(); textBox5.Text = good.Fine.ToString(); textBox6.Text = good.Status.ToString(); textBox7.Text = good.Height.ToString(); textBox8.Text = good.Width.ToString(); label1.Text = good.Title; dateTimePicker1.Value = good.DateStart; dateTimePicker2.Value = good.DateFinish; dateTimePicker1.MinDate = good.DateStart; dateTimePicker1.MaxDate = good.DateStart; dateTimePicker2.MinDate = good.DateFinish; if(good.Fine > 0) dateTimePicker2.MaxDate = good.DateFinish; }
public static void UpdateGoods() { string query1 = string.Empty; string query2 = string.Empty; Good tmpGood = new Good(); SqlCommand command; SqlDataReader reader; List <int> changedData; query1 = "select * from Goods"; command = new SqlCommand(query1, DataBase.Sql); reader = command.ExecuteReader(); changedData = new List <int>(); foreach (Good good in Goodsmanager.Goods) { if (good.IsChanged) { changedData.Add(good.GoodID); } } while (reader.Read()) { if (changedData.Contains((int)reader["GoodID"])) { foreach (Good good in Goodsmanager.Goods) { if (good.GoodID == ((int)reader["GoodID"])) { tmpGood = good; break; } } query2 = string.Format("update Goods set Title = '{0}' where GoodID = {1}", tmpGood.Title, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Goods set Height = {0} where GoodID = {1}", tmpGood.Height, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Goods set Width = {0} where GoodID = {1}", tmpGood.Width, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set SectionID = {0} where GoodID = {1}", tmpGood.SectionID, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set Location = '{0}' where GoodID = {1}", ToDouble(tmpGood.BoolenLocation), tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set ClientID = {0} where GoodID = {1}", tmpGood.ClientID, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set DateStart = '{0}' where GoodID = {1}", tmpGood.DateStart.ToString(), tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set DateFinish = '{0}' where GoodID = {1}", tmpGood.DateFinish.ToString(), tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set Cost = {0} where GoodID = {1}", tmpGood.Cost, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set Fine = {0} where GoodID = {1}", tmpGood.Fine, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set Status = {0} where GoodID = {1}", tmpGood.Status, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); tmpGood.IsChanged = false; } } reader.Close(); }
public GoodForClientInf(Good gd) { goodFromList = gd; title = gd.Title; }
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; } } }
void button_MouseClick(object sender, MouseEventArgs e) { if (!changeStat) { tmpGood = dictButGood[(Button)sender]; tmpButton = (Button)sender; GoodInfo goodInfo = new GoodInfo(); goodInfo.Show(this); } }
public static void UpdateGoods() { string query1 = string.Empty; string query2 = string.Empty; Good tmpGood = new Good(); SqlCommand command; SqlDataReader reader; List<int> changedData; query1 = "select * from Goods"; command = new SqlCommand(query1, DataBase.Sql); reader = command.ExecuteReader(); changedData = new List<int>(); foreach (Good good in Goodsmanager.Goods) { if (good.IsChanged) changedData.Add(good.GoodID); } while (reader.Read()) { if (changedData.Contains((int)reader["GoodID"])) { foreach (Good good in Goodsmanager.Goods) { if (good.GoodID == ((int)reader["GoodID"])) { tmpGood = good; break; } } query2 = string.Format("update Goods set Title = '{0}' where GoodID = {1}", tmpGood.Title, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Goods set Height = {0} where GoodID = {1}", tmpGood.Height, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Goods set Width = {0} where GoodID = {1}", tmpGood.Width, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set SectionID = {0} where GoodID = {1}", tmpGood.SectionID, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set Location = '{0}' where GoodID = {1}", ToDouble(tmpGood.BoolenLocation), tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set ClientID = {0} where GoodID = {1}", tmpGood.ClientID, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set DateStart = '{0}' where GoodID = {1}", tmpGood.DateStart.ToString(), tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set DateFinish = '{0}' where GoodID = {1}", tmpGood.DateFinish.ToString(), tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set Cost = {0} where GoodID = {1}", tmpGood.Cost, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set Fine = {0} where GoodID = {1}", tmpGood.Fine, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); query2 = string.Format("update Offers set Status = {0} where GoodID = {1}", tmpGood.Status, tmpGood.GoodID); (new SqlCommand(query2, DataBase.Sql)).ExecuteNonQuery(); tmpGood.IsChanged = false; } } reader.Close(); }