public bool AddMagazin(DTO_Magazin mag) { try { _conn.Open(); string sql = ""; if (kindMagazin == "tblMagazin") { sql = string.Format("INSERT INTO tblMagazin(ID, Name, Adress) VALUES ('{0}', '{1}', '{2}')", mag.MAGAZIN_ID, mag.MAGAZIN_NAME, mag.MAGAZIN_ADRESS); } else { sql = string.Format("INSERT INTO {0}(ID, Name, Cost, Stock) VALUES ('{1}', '{2}', '{3}', '{4}')", kindMagazin, mag.ITEM_ID, mag.ITEM_NAME, mag.ITEM_COST, mag.ITEM_STOCK); } cmd = new SqlCommand(sql, _conn); if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception e) { } finally { _conn.Close(); } return(false); }
public bool EditMagazin(DTO_Magazin mag) { try { _conn.Open(); string sql = string.Format("UPDATE {0} SET ID={1}, Name={2}, Cost={3}, Stock={4}", kindMagazin, mag.ITEM_ID, mag.ITEM_NAME, mag.ITEM_COST, mag.ITEM_STOCK); cmd = new SqlCommand(sql, _conn); if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception ex) { } finally { _conn.Close(); } return(false); }
private void Addbox_Click(object sender, EventArgs e) { if (IDBox.Text != "" && NameBox.Text != "" && AdressBox.Text != "") { DTO_Magazin mag = new DTO_Magazin(IDBox.Text, NameBox.Text, AdressBox.Text); if (busMag.AddMagazin(mag)) { MessageBox.Show("was successful!"); dataMagazin.DataSource = busMag.getMagazin(s, 0); dataMagazin.Refresh(); } else { MessageBox.Show("was't successful"); } } }
private void buttonEdit_Click(object sender, EventArgs e) { if (IDBox.Text != "" && NameBox.Text != "" && CostBox.Text != "" && StockBox.Text != "") { DTO_Magazin mag = new DTO_Magazin(IDBox.Text, NameBox.Text, CostBox.Text, Convert.ToInt32(StockBox.Text)); if (busMag.EditMagazin(mag)) { MessageBox.Show("was successful!"); dataPere.DataSource = busMag.getMagazin(s, 2); dataPere.Refresh(); } else { MessageBox.Show("was't successful"); } } }
public bool EditMagazin(DTO_Magazin mag) { return(dalMagazin.EditMagazin(mag)); }
public bool AddMagazin(DTO_Magazin mag) { return(dalMagazin.AddMagazin(mag)); }