예제 #1
0
 private void SaveNewOrderItemOptions(uint mySqlId, OrderItems item)
 {
     using (var conn = new MySqlConnection(ConnString))
     {
         foreach (ItemOptions iOption in item.OptionsList)
         {
             MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
             cmd.Connection  = conn;
             cmd.CommandText = "INSERT INTO orderitemoptions(OrdItmOpt_OrdHdrId,OrdItmOpt_OptCode,OrdItmOpt_Description," +
                               "OrdItmOpt_Quant,OrdItmOpt_Price)" +
                               "Values(?OrdHdrId,?OptCode,?Description,?Quant,?Price)";
             iOption.MySqlOrderId = mySqlId;
             cmd.Parameters.AddWithValue("?OrdHdrId", mySqlId);
             cmd.Parameters.AddWithValue("?OptCode", Convert.ToString(iOption.OptCode));
             cmd.Parameters.AddWithValue("?Description", Convert.ToString(iOption.Description));
             cmd.Parameters.AddWithValue("?Quant", Convert.ToInt32(iOption.Quant));
             cmd.Parameters.AddWithValue("?Price", Convert.ToDecimal(iOption.Price));
             conn.Open();
             cmd.ExecuteNonQuery();
             conn.Close();
         }
     }
 }
예제 #2
0
        private List <OrderItems> fillOrderItems()
        {
            OrderItems item           = new OrderItems();
            var        itemList       = new List <OrderItems>();
            var        itemOptionList = new List <ItemOptions>();

            while (FileLineList[i] != "</OrderItems>")
            {
                i++;
                if (FileLineList[i] == "</OrderItemInfo>")
                {
                    item.OptionsList = itemOptionList;
                    itemList.Add(item);
                    item           = new OrderItems();
                    itemOptionList = new List <ItemOptions>();
                }
                var aLineSplit = FileLineList[i].Split('=');
                switch (aLineSplit[0])
                {
                case "Item Product Code":
                    item.ItemCode = aLineSplit[1];
                    break;

                case "Item Product Description":
                    item.Description = aLineSplit[1];
                    break;

                case "Item Quantity Each":
                    if (int.TryParse(aLineSplit[1], out int value))
                    {
                        item.Quant = value;
                    }
                    break;

                case "Item Price":
                    var temp = aLineSplit[1].Remove(0, 1);
                    if (decimal.TryParse(aLineSplit[1].Remove(0, 1), out Decimal value1))
                    {
                        item.Price = value1;
                    }
                    break;

                case "Item Total Price":
                    if (Decimal.TryParse(aLineSplit[1], out decimal value2))
                    {
                        item.LineTotal = value2;
                    }
                    break;

                case "<OrderItemOption>":
                    var itemOpt = fillItemOptions();
                    item.Description = item.Description + "-" + itemOpt.Description;
                    itemOptionList.Add(itemOpt);
                    break;

                default:
                    break;
                }
            }
            return(itemList);
        }