/// <summary> /// Get a Sales Forms information by it's ID /// </summary> /// <param name="id"></param> /// <returns></returns> public static SalesForm GetSalesForm(int id) { SalesForm retSalesForm = null; SqlConnection conn = new SqlConnection(); conn.ConnectionString = _ReadConnectionString; try { conn.Open(); SqlCommand command = new SqlCommand("sprocSalesFormGet", conn); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue($"@{SalesForm.db_ID}", id); SqlDataReader dr = command.ExecuteReader(); SalesForm sf = new SalesForm(); while (dr.Read()) { sf.Fill(dr); } retSalesForm = sf; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); //throw; } finally { conn.Close(); } return(retSalesForm); }
/// <summary> /// Get all the Sales form information from the database /// </summary> public static void GetAllSalesForms() { SqlConnection conn = new SqlConnection(); conn.ConnectionString = _ReadConnectionString; try { conn.Open(); SqlCommand command = new SqlCommand("sprocSalesFormsGetALL", conn); command.CommandType = System.Data.CommandType.StoredProcedure; SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { SalesForm sf = new SalesForm(); sf.Fill(dr); SalesForms.SalesFormList.Add(sf); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); //throw; } finally { conn.Close(); } }