Example #1
0
        public Items GetTemplateItems(string templateID, string pricelevel
            , string currency, string uOFm)
        {
            Items items = new Items();
            try
            {
                using (SqlConnection conn = new SqlConnection(connString))
                using (SqlCommand comm = new SqlCommand("usp_GetTemplateItems", conn))
                {
                    comm.CommandType = CommandType.StoredProcedure;

                    comm.Parameters.Clear();
                    comm.Parameters.Add(new SqlParameter("@TemplateID", templateID));

                    conn.Open();

                    using (SqlDataReader dr = comm.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            Item i = null;
                            decimal qty;

                            i = ItemData.Instance.GetItem(pricelevel, currency
                                , dr["Item no"].ToString(), uOFm);

                            qty = Convert.ToDecimal(dr["Qty"]);

                            if (i != null)
                            {
                                if (qty > 0)
                                {
                                    i.Qty = qty;
                                }

                                if (items != null)
                                {
                                    items.Add(i);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
            return items;
        }
Example #2
0
        public Items GetKitComponents(string kitItemNo)
        {
            Items items = new Items();
            try
            {
                using (SqlConnection conn = new SqlConnection(connString))
                using (SqlCommand comm = new SqlCommand("usp_GetKitComponents", conn))
                {
                    comm.CommandType = CommandType.StoredProcedure;

                    comm.Parameters.Clear();
                    comm.Parameters.Add(new SqlParameter("@Kit", kitItemNo));

                    conn.Open();

                    using (SqlDataReader dr = comm.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            if (dr.HasRows)
                            {
                                Item item = new Item();
                                item.ItemNo = dr["Component Item No"].ToString();
                                item.Uofm = dr["U of M"].ToString();
                                item.Qty = Convert.ToDecimal(dr["Qty"].ToString());
                                item.ItemType = (ItemType)Convert.ToInt32(dr["Item Type"]);
                                items.Add(item);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
            return items;
        }
Example #3
0
        public Items GetAssessmentItems(string assessmentNo
            , Transaction_Type sopType)
        {
            Items items = new Items();
            try
            {
                using (SqlConnection conn = new SqlConnection(connString))
                using (SqlCommand comm = new SqlCommand("usp_GetAssessmentItems", conn))
                {
                    comm.CommandType = CommandType.StoredProcedure;

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

                    conn.Open();

                    using (SqlDataReader dr = comm.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            Item i = new Item();
                            i.ItemNo = dr["Item Number"].ToString();
                            i.ItemDescription = dr["Item Description"].ToString();
                            i.Qty = Convert.ToDecimal(dr["Quantity"].ToString());
                            i.Unitprice = Convert.ToDecimal(dr["Unit Price"].ToString());
                            i.ItemClass = dr["Item Class"].ToString();
                            i.Uofm = dr["U of M"].ToString();
                            i.MarkDown = Convert.ToDecimal(dr["Markdown"]);

                            items.Add(i);
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
            return items;
        }
Example #4
0
        public Items GetItems(string level, string currency
            , string uOfM)
        {
            Items items = new Items();
            try
            {
                using (SqlConnection conn = new SqlConnection(connString))

                using (SqlCommand comm = new SqlCommand("usp_GetItemsByLevel", conn))
                {
                    comm.CommandType = CommandType.StoredProcedure;

                    comm.Parameters.Clear();
                    comm.Parameters.Add(new SqlParameter("@UofM", uOfM));
                    comm.Parameters.Add(new SqlParameter("@Currency", currency));
                    comm.Parameters.Add(new SqlParameter("@Level", level));

                    conn.Open();

                    using (SqlDataReader dr = comm.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            Item item = new Item();

                            item.ItemNo = dr["Item Number"].ToString();
                            item.ItemDescription = dr["Item Description"].ToString();
                            item.ItemClass = dr["Item Class Code"].ToString();
                            item.Uofm = dr["U of M"].ToString();
                            item.Unitprice = Convert.ToDecimal(dr["Unit Price"].ToString());
                            item.ItemType = (ItemType)Convert.ToInt32(dr["Item Type"].ToString());

                            items.Add(item);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }

            return items;
        }
Example #5
0
        private Items getKitComponents(Item itemKit)
        {
            Items items = new Items();
            Items pricedItems = new Items();

            if (transaction != null)
            {
                if (itemKit.ItemType == ItemType.Kit)
                {
                    items = ItemAdapter.Instance.GetKitComponents(itemKit.ItemNo);

                    foreach (Item item in items)
                    {
                        Item pricedItem;
                        pricedItem = ItemAdapter.Instance.GetItem
                            (transaction.PriceLevel, transaction.CurrencyID
                            , item.ItemNo, item.Uofm);

                        if (pricedItem != null)
                        {
                            //set qty equals qty of the component
                            //in the kit multiplied by the qty of the kit
                            pricedItem.Qty = item.Qty * itemKit.Qty;
                            pricedItem.ComponentOf = itemKit.ItemNo;
                            pricedItems.Add(pricedItem);
                        }
                    }
                }
            }
            return pricedItems;
        }