public bool Write_ToChangeTab(StructDataDeal deal) { bool resalt = true; int id_productName = readDB.GetID_BYNumber(deal.Number); int id_typeCount = readDB.Get_TypeOfCountID_ByName(deal.TypeCount); try { command.CommandType = CommandType.Text; command.CommandText = "INSERT INTO change_t(id_product_name,count_value,id_type_count,price,data_wrote,name_document,number_document,data_document,wherehouser)" + " VALUES('" + id_productName + "','" + deal.Count + "','" + id_typeCount + "','" + deal.Price + "','" + deal.DateWrote + "','" + deal.NameDoc + "','" + deal.NumberDoc + "','" + deal.DateDocCreated + "','" + deal.Warhouser + "')"; connection.Open(); command.ExecuteNonQuery(); } catch (Exception) { resalt = false; } finally { if (connection != null) { connection.Close(); } } return(resalt); }
public bool UpdateCount_ExistPruduct(StructDataDeal deal) { bool resalst = true; try { int newCount = Convert.ToInt32(deal.Count); command.Connection = connection; command.CommandText = "UPDATE product_t SET count_value='" + newCount + "' WHERE id_product=" + deal.ID; command.CommandType = CommandType.Text; connection.Open(); command.ExecuteNonQuery(); } catch { resalst = false; } finally { if (connection != null) { connection.Close(); } } return(resalst); }
public bool ExistInList(List <StructDataDeal> productsList, StructDataDeal lineForInsert) { bool ansver = false; foreach (StructDataDeal deal in productsList) { if (deal.Number == lineForInsert.Number) { ansver = true; } } return(ansver); }
protected void OnBnAddToInsertListClicked(object sender, EventArgs e) { Validation validation = new Validation(); if (!validation.IsEmpty(tb_Name_ForInsert.Text) && !validation.IsEmpty(tb_Code_ForInsert.Text) && !validation.IsEmpty(tb_DocName_ForInsert.Text) && !validation.IsEmpty(tb_DocNumber_ForInsert.Text) && !validation.IsEmpty(tb_DateCreateDoc_ForInsert.Text) && !validation.IsEmpty(tb_Count_ForInsert.Text) && !validation.IsEmpty(tb_TodeyDate_ForInsert.Text) && !validation.IsEmpty(tb_Warehouser_ForInsert.Text)) { StructDataDeal deal = new StructDataDeal(); StructDataDeal deal_new = new StructDataDeal(); deal.Name = tb_Name_ForInsert.Text; deal.Number = tb_Code_ForInsert.Text; deal.NameDoc = tb_DocName_ForInsert.Text; deal.NumberDoc = tb_DocNumber_ForInsert.Text; deal.DateDocCreated = tb_DateCreateDoc_ForInsert.Text; deal.Count = Convert.ToInt32(tb_Count_ForInsert.Text); deal.DateWrote = tb_TodeyDate_ForInsert.Text; deal.TypeCount = _SelectProduct.TypeCount; deal.Warhouser = tb_Warehouser_ForInsert.Text; int price = Convert.ToInt32(deal.Count) * Convert.ToInt32(_SelectProduct.PriceForOne); deal.Price = Convert.ToString(price); if (!validation.ExistInList(_DataForInsert, deal)) { _DataForInsert.Add(deal); Refresh_DataForInsert(); } else { MessageBox.Show("Такая запись уже есть"); } } else { MessageBox.Show("Параметры не заданы или заданы не правильно. "); } }
//CHANGE TABLE private StructDataDeal Get_Deal(int id) { StructDataDeal deal = new StructDataDeal(); int id_product = 0; int id_2 = 0; int id_ = 0; try { command.CommandText = "SELECT *FROM change_t WHERE id_change=" + id + ""; command.CommandType = CommandType.Text; connection.Open(); NpgsqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { id_product = Convert.ToInt32(reader["id_product_name"].ToString()); deal.Count = Convert.ToInt32(reader["count_value"].ToString()); id_2 = Convert.ToInt32(reader["id_type_count"].ToString()); deal.Price = reader["price"].ToString(); deal.DateWrote = reader["data_wrote"].ToString(); deal.NameDoc = reader["name_document"].ToString(); deal.NumberDoc = reader["number_document"].ToString(); deal.DateDocCreated = reader["data_document"].ToString(); deal.Warhouser = reader["wherehouser"].ToString(); } } finally { if (connection != null) { connection.Close(); } } try { command.CommandText = "SELECT * FROM product_t"; command.CommandType = CommandType.Text; connection.Open(); NpgsqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { id_ = Convert.ToInt32(reader["id_product"]); if (id_ == id_product) { deal.Number = reader["code"].ToString(); deal.Name = reader["name_product"].ToString(); break; } } } finally { if (connection != null) { connection.Close(); } } deal.TypeCount = Get_TypeOfCount_ByID(id_2); return(deal); }
private void AddSelectProduct(StructDataDeal deal) { docModel.AppendValues(deal.Number, deal.Name, deal.TypeCount, deal.Count.ToString(), deal.Price); }