internal DataTable addNewItem(Regitermekek regitermek) { ops = new DBOperation(); ops.addNewOldItem(regitermek); oldProductsList.Add(regitermek); return(getToDataTable()); }
private void button1_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 1) { dataGridView1.ClearSelection(); return; } bool teg = false; if (dataGridView1.SelectedRows[0].Cells[8].Value.ToString() == "True") { teg = true; } Regitermekek oldOne = new Regitermekek( Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()) , dataGridView1.SelectedRows[0].Cells[1].Value.ToString() , Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[2].Value.ToString()) , Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[3].Value.ToString()) , dataGridView1.SelectedRows[0].Cells[4].Value.ToString() , Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[5].Value.ToString()) , Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[6].Value.ToString()) , Convert.ToDateTime(dataGridView1.SelectedRows[0].Cells[7].Value.ToString()) , teg); dataGridView1.DataSource = OPS.restore(oldOne); }
private void fillProductListFromDataTable() { ops = new DBOperation(); Adatbazis a = new Adatbazis(); MySQLDatabaseInterface mdi = a.kapcsolodas(); mdi.open(); string query = "SELECT * FROM regitermekek "; DataTable dtCustomer = mdi.getToDataTable(query); mdi.close(); foreach (DataRow row in dtCustomer.Rows) { int Tkod = Convert.ToInt32(row["Tkod"].ToString()); string Tnev = row["Tnev"].ToString(); int Tar = Convert.ToInt32(row["Tar"].ToString()); int Tkeszl = Convert.ToInt32(row["Tkeszl"].ToString()); string Tmert = row["Tmert"].ToString(); int Tkatkod = Convert.ToInt32(row["Tkatkod"].ToString()); int Tvonkod = Convert.ToInt32(row["Tvonkod"].ToString()); DateTime Tszavido = Convert.ToDateTime(row["Tszavido"].ToString()); bool Tegalizalte = Convert.ToBoolean(row["Tegalizalte"].ToString()); Regitermekek c = new Regitermekek(Tkod, Tnev, Tar, Tkeszl, Tmert, Tkatkod, Tvonkod, Tszavido, Tegalizalte); oldProductsList.Add(c); } }
internal void addNewOldItem(Regitermekek regitermek) { DateTime dt = regitermek.Tszavido; string uj = dt.toMysqlFormat(); string query = "INSERT INTO `regitermekek` ( `Tnev`, `Tar`, `Tkeszl`, `Tmert`, `Tkatkod`, `Tvonkod`, `Tszavido`, `Tegalizalte`) VALUES (" + regitermek.Tnev + "', '" + regitermek.Tar + "', '" + regitermek.Tkeszl + "', '" + regitermek.Tmert + "', '" + regitermek.Tkatkod + "', '" + regitermek.Tvonkod + "', '" + uj + "', '" + regitermek.Tegalizalte + "')"; MySqlConnection connect = new MySqlConnection(conG); connect.Open(); try { MySqlCommand cm = new MySqlCommand(query, connect); cm.ExecuteNonQuery(); } catch (Exception e) { Debug.WriteLine(e.Message); } }
internal DataTable restore(Regitermekek oldOne) { ops = new DBOperation(); int i = 0; while (i < oldProductsList.Count) { if (oldProductsList[i].Tkod == oldOne.Tkod) { oldProductsList.RemoveAt(i); } i++; } ops.moveFromOld(oldOne); return(getToDataTable()); }
internal void moveFromOld(Regitermekek oldOne) { string query = "delete from regitermekek where Tkod=" + oldOne.Tkod + ""; MySqlConnection con = new MySqlConnection(conG); con.Open(); MySqlCommand cmd = new MySqlCommand(query, con); cmd.ExecuteNonQuery(); string uj = oldOne.Tszavido.toMysqlFormat(); query = "INSERT INTO `termekek` ( `Tnev`, `Tar`, `Tkeszl`, `Tmert`, `Tkatkod`, `Tvonkod`, `Tszavido`, `Tegalizalte`) VALUES (" + oldOne.Tnev + "', '" + oldOne.Tar + "', '" + oldOne.Tkeszl + "', '" + oldOne.Tmert + "', '" + oldOne.Tkatkod + "', '" + oldOne.Tvonkod + "', '" + uj + "', '" + oldOne.Tegalizalte + "')"; cmd = new MySqlCommand(query, con); cmd.ExecuteNonQuery(); }
internal void AddNew(Regitermekek regitermek) { dataGridView1.DataSource = OPS.addNewItem(regitermek); }
internal DataTable restore(Regitermekek oldOne) { return(OPR.restore(oldOne)); }
internal DataTable addNewItem(Regitermekek regitermek) { return(OPR.addNewItem(regitermek)); }