public int SaveSupplier(Supplier supplier) { SupplierDL supplierDL = new SupplierDL(); if (supplier.SupplierID > 0) return supplierDL.UpdateSupplier(supplier); else return supplierDL.SaveSupplier(supplier); }
public int SaveSupplier(Supplier supplier) { int status = 0; using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString)) { using (SqlCommand objComm = new SqlCommand("saveSupplier", objConn)) { objConn.Open(); objComm.CommandType = CommandType.StoredProcedure; objComm.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = supplier.Name; SqlParameter supplierID = new SqlParameter("@supplierID", SqlDbType.Int); supplierID.Direction = ParameterDirection.Output; objComm.Parameters.Add(supplierID); status = objComm.ExecuteNonQuery(); supplier.SupplierID = int.Parse(objComm.Parameters["@supplierID"].Value.ToString()); } } return supplier.SupplierID; }
public int UpdateSupplier(Supplier supplier) { int status = 0; using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString)) { using (SqlCommand objComm = new SqlCommand("updateSupplier", objConn)) { objComm.CommandType = CommandType.StoredProcedure; objComm.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = supplier.Name; status = objComm.ExecuteNonQuery(); } } return status; }