Esempio n. 1
0
        public Discounts GetCustomerDiscounts(string customerNo)
        {
            Discounts discounts = new Discounts();
            try
            {
                using (SqlConnection conn = new SqlConnection(connString))
                using (SqlCommand comm = new SqlCommand("usp_GetCustomerDiscounts", conn))
                {
                    comm.CommandType = CommandType.StoredProcedure;

                    comm.Parameters.Clear();
                    comm.Parameters.Add(new SqlParameter("@Customer_ID", customerNo));

                    conn.Open();

                    using (SqlDataReader dr = comm.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            Discount d = new Discount();
                            d.DiscountID = dr["Discount ID"].ToString();
                            d.DiscountDescription = dr["Discount Description"].ToString();
                            d.Percent = decimal.Round(Convert.ToDecimal(dr["Discount Percentage"].ToString()), 2);
                            d.DiscountType = (Discount_Type)Convert.ToInt32(dr["Discount Type"].ToString());
                            d.Computed = false;

                            discounts.Add(d);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
            return discounts;
        }
Esempio n. 2
0
        public Discounts GetAssessmentDiscountsByDocID(string transactionNo, Transaction_Type type)
        {
            Discounts discounts = new Discounts();
            try
            {
                using (SqlConnection conn = new SqlConnection(connString))
                using (SqlCommand comm = new SqlCommand("usp_GetAssessmentDiscountsByDocID", conn))
                {
                    comm.CommandType = CommandType.StoredProcedure;

                    comm.Parameters.Clear();
                    comm.Parameters.Add(new SqlParameter("@Assessment_No", transactionNo));
                    comm.Parameters.Add(new SqlParameter("@SOPType", (int)type));

                    conn.Open();

                    using (SqlDataReader dr = comm.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            Discount d = new Discount();
                            d.DiscountID = dr["Discount ID"].ToString();
                            d.DiscountDescription = dr["Discount Description"].ToString();
                            d.Percent = decimal.Round(Convert.ToDecimal((dr["Percent"]).ToString()), 2);
                            d.DiscountType = (Discount_Type)Convert.ToInt32(dr["Discount Type"].ToString());
                            d.Amount = decimal.Round(Convert.ToDecimal((dr["Discount Amount"]).ToString()), 2);
                            d.ItemAppliedTo = dr["Applied To"].ToString();
                            d.Computed = true;

                            discounts.Add(d);

                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
            return discounts;
        }