public bool Delete(machineBLL u) { bool isSucces = false; SqlConnection conn = new SqlConnection(myconnstring); try { string sql = "delete FROM Machine where Id=@Id"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@Id", u.Id); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSucces = true; } else { isSucces = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(isSucces); }
public bool Modifier(machineBLL u) { bool isSucces = false; SqlConnection conn = new SqlConnection(myconnstring); try { string sql = "UPDATE Machine set Ninv=@Ninv,Designation=@Designation,Cfi=@Cfi,Id=@Id where Id=@Id"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@Ninv", u.Ninv); cmd.Parameters.AddWithValue("@Designatoin", u.Designation); cmd.Parameters.AddWithValue("@Cfi", u.Cfi); cmd.Parameters.AddWithValue("@Id", u.Id); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSucces = true; } else { isSucces = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(isSucces); }
public bool Insert(machineBLL u) { bool isSucces = false; SqlConnection conn = new SqlConnection(myconnstring); try { string sql = "INSERT INTO Machine (Ninv,Designation,Cfi,Id) VALUES (@Ninv,@Designation,@Cfi,@Id) "; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@Ninv", u.Ninv); cmd.Parameters.AddWithValue("@Designation", u.Designation); cmd.Parameters.AddWithValue("@Cfi", u.Cfi); cmd.Parameters.AddWithValue("@Id", u.Id); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSucces = true; } else { isSucces = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(isSucces); }