/* Returns OrderdList given by orderid*/ public List <DeltoneItem> getOrderedList(int OrderID) { List <DeltoneItem> Order_Items = new List <DeltoneItem>(); DeltoneItem OrderedItem; String OutPut = String.Empty; SqlConnection conn = new SqlConnection(); conn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString; String strSqlOrderStmt = "select * from dbo.Ordered_Items where OrderID=" + OrderID; using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = strSqlOrderStmt; cmd.Connection = conn; conn.Open(); using (SqlDataReader sdr = cmd.ExecuteReader()) { while (sdr.Read()) { OrderedItem = new DeltoneItem(); //Instantiate the Deltone Object and Assign values OrderedItem.ItemDescription = sdr["Description"].ToString(); OrderedItem.Qty = Int32.Parse(sdr["Quantity"].ToString()); OrderedItem.UnitPrice = Convert.ToDecimal(sdr["UnitAmount"].ToString()); Order_Items.Add(OrderedItem); // Add it to the Collection } } } conn.Close(); return(Order_Items); }
//Create the List of Creadit Note Items protected List <DeltoneItem> CreateCreaitItems(String strCreditItems) { List <DeltoneItem> CreditItems = new List <DeltoneItem>(); DeltoneItem item; String[] arrcreditItems = strCreditItems.Split('|'); String[] line; for (int i = 0; i < arrcreditItems.Length; i++) { if (!String.IsNullOrEmpty(arrcreditItems[i])) { line = arrcreditItems[i].Split(','); if (line[0].Contains("D/L Handling")) //If this is Delivery Handling Line { item = new DeltoneItem(); item.ItemDescription = line[0].ToString(); item.Qty = 1; item.COG = 0; item.UnitPrice = Convert.ToDecimal(line[4].ToString()); CreditItems.Add(item); } else { item = new DeltoneItem(); item.ItemDescription = line[0].ToString(); item.Qty = Int32.Parse(line[3].ToString()); item.COG = Convert.ToDecimal(line[2].ToString()); item.UnitPrice = Convert.ToDecimal(line[4].ToString()); item.SupplierCode = line[1].ToString(); CreditItems.Add(item); } } } return(CreditItems); }