/*
         #####################################################################
         # Q10
         #              itemInclude._Item._NAME
         #              itemInclude._Quantity
         #              itemInclude._Item._PRICE
         #              itemInclude._Total
         #####################################################################
         */
        public static List <Item_Include> GetItemDeatils(int transactionCode)
        {
            string Q10Query = " select it.NAME, i.QUANTITY, it.PRICE,(i.QUANTITY * it.PRICE) as total " +
                              " from INCLUDES i " +
                              " inner join item it " +
                              " on i.ITEMCODE= it.ITEMCODE " +
                              " Where i.TRANSACTIONCODE = 1 " +
                              " order by it.name asc ";
            List <Item_Include> itemsIncludes = new List <Item_Include>();

            //Item_Include itemInclude;
            if (Connect())
            {
                //we are going to call query called Q10
                using (SqlCommand sqlCommand = new SqlCommand())
                {
                    sqlCommand.CommandType = CommandType.Text;
                    sqlCommand.CommandText = Q10Query;
                    sqlCommand.Connection  = _Connection;
                    SqlDataReader reader;
                    try
                    {
                        reader = sqlCommand.ExecuteReader();
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                    //Converting query results to PersonPhoneAddress objects
                    while (reader.Read())
                    {
                        Item_Include itemInclude = new Item_Include();
                        itemInclude._Item._NAME  = Convert.ToString(reader[0]);
                        itemInclude._Quantity    = Convert.ToInt32(reader[1]);
                        itemInclude._Item._PRICE = Convert.ToInt32(reader[2]);
                        itemInclude._Total       = Convert.ToInt32(reader[3]);
                        itemsIncludes.Add(itemInclude);
                    }
                    reader.Close();
                }
            }
            return(itemsIncludes);
        }
Example #2
0
        /*
         #####################################################################
         # Q10
         #              itemInclude._Item._NAME
         #              itemInclude._Quantity
         #              itemInclude._Item._PRICE
         #              itemInclude._Total
         #####################################################################
         */
        public static List <Item_Include> GetItemDeatils(int transactionCode)
        {
            List <Item_Include> itemsIncludes = new List <Item_Include>();
            Item_Include        itemInclude;

            if (Connect())
            {
                using (SqlCommand sqlCommand = new SqlCommand("Q10", _Connection))
                {
                    sqlCommand.CommandType = CommandType.StoredProcedure;
                    sqlCommand.CommandText = "sp_GetItemDeatils";
                    sqlCommand.Parameters.Add("@transactioncode", SqlDbType.VarChar).Value = transactionCode;
                    SqlDataReader reader;
                    try
                    {
                        reader = sqlCommand.ExecuteReader();
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                    while (reader.Read())
                    {
                        itemInclude              = new Item_Include();
                        itemInclude._Item._NAME  = Convert.ToString(reader[0]);
                        itemInclude._Quantity    = Convert.ToInt32(reader[1]);
                        itemInclude._Item._PRICE = Convert.ToInt32(reader[2]);
                        itemInclude._Total       = Convert.ToInt32(reader[3]);
                        itemsIncludes.Add(itemInclude);
                    }
                    reader.Close();
                }
            }

            return(itemsIncludes);
        }