public bool delete(lobsterClass c) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstring); try { string sql = "DELETE FROM [حصر الاستاكوزا] WHERE [رقم المطالبة]=@id;"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@id", c.id); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { } finally { conn.Close(); } return(isSuccess); }
public bool insert(lobsterClass c) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstring); try { string sql = "INSERT INTO [حصر الاستاكوزا] VALUES(@companyName, @quantity, @price, @id, @date, @country); "; SqlCommand cmd = new SqlCommand(sql, conn); SqlDataAdapter adapter = new SqlDataAdapter(cmd); cmd.Parameters.AddWithValue("@companyName", c.companyName); cmd.Parameters.AddWithValue("@quantity", c.quantity); cmd.Parameters.AddWithValue("@price", c.price); cmd.Parameters.AddWithValue("@id", c.id); cmd.Parameters.AddWithValue("@date", c.date); cmd.Parameters.AddWithValue("@country", c.country); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { } finally { conn.Close(); } return(isSuccess); }
public bool update(lobsterClass c) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstring); try { string sql = "UPDATE [حصر الاستاكوزا] SET [اسم الشركة]=@companyName, [الكمية بالكيلو]=@quantity, المبلغ=@price, [رقم المطالبة]=@id, التاريخ=@date, الدولة=@country WHERE [رقم المطالبة]=@id;"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@companyName", c.companyName); cmd.Parameters.AddWithValue("@quantity", c.quantity); cmd.Parameters.AddWithValue("@price", c.price); cmd.Parameters.AddWithValue("@id", c.id); cmd.Parameters.AddWithValue("@date", c.date); cmd.Parameters.AddWithValue("@country", c.country); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { } finally { conn.Close(); } return(isSuccess); }