private void button4_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); FileStream f = new FileStream(openFileDialog1.FileName, FileMode.Open); StreamReader rd = new StreamReader(f); string[] str; string inpstr; List<Tovar> tov = new List<Tovar>(); for (int i = 0; i < dataGridView1.Rows.Count; i++) { tov.Add(new Tovar(Convert.ToInt32(dataGridView1[0, i].Value), Convert.ToString(dataGridView1[1, i].Value), Convert.ToDateTime(dataGridView1[2, i].Value), Convert.ToInt32(dataGridView1[3, i].Value), 0)); } while ((inpstr = rd.ReadLine()) != null) { str = inpstr.Split(' '); Tovar t = new Tovar(Convert.ToInt32(str[0]), str[1], Convert.ToDateTime(str[2]), Convert.ToInt32(str[3]), Convert.ToDecimal(str[4])); using (SqlCeConnection conn = new SqlCeConnection(@"Data Source=C:\Users\Андрей свали с компа\Desktop\myDB.sdf")) { conn.Open(); using (SqlCeCommand c = new SqlCeCommand(@"insert into tovar(name, srok, kolvo, price) values('" + t.name + "','"+t.srok.Date+"'," + t.kolvo + "," + t.prise.ToString().Replace(',','.')+")")) { c.Connection = conn; c.ExecuteNonQuery(); } } } rd.Close(); this.tovarTableAdapter.Fill(this.allDataSet.Tovar); tovarTableAdapter.Update(this.allDataSet.Tovar); }
private void FormMain_Load(object sender, EventArgs e) { Organization org = new Organization(); Type type = new Type(); Tovar tovar = new Tovar(); ImportExport impexp = new ImportExport(); TovarInOrganization tovinorg = new TovarInOrganization(); org.Load(); type.Load(); tovar.Load(); impexp.Load(); tovinorg.Load(); }
private void FormMain_FormClosed(object sender, FormClosedEventArgs e) { Organization org = new Organization(); Type type = new Type(); Tovar tovar = new Tovar(); ImportExport impexp = new ImportExport(); TovarInOrganization tovinorg = new TovarInOrganization(); org.Save(); type.Save(); tovar.Save(); impexp.Save(); tovinorg.Save(); }
private void btnAdd_Click(object sender, EventArgs e) { try { if (cbType.Text == "" || tbName.Text == "" || tbWeight.Text == "" || tbPrice.Text == "" || cbOrg.Text == "") throw new Exception(); Tovar tov = new Tovar(tbName.Text, tbWeight.Text, tbPrice.Text,tbNumber.Text,(Type)cbType.SelectedItem); TovarInOrganization tovInOrg = new TovarInOrganization((Organization)cbOrg.SelectedItem, tov); tbName.Text = ""; tbNumber.Text = ""; tbPrice.Text = ""; tbWeight.Text = ""; } catch (Exception) { MessageBox.Show("Коректно заповніть поля!Cтворіть організацію(склад) або новий тип товару!"); } }
public void deleteTovar(Tovar tovar, ref List<Tovar> list) { Console.WriteLine("\n����� "+tovar.name+" ����� �� ��������!\n"); list.Remove(tovar); }