Exemplo n.º 1
0
        public clsOrder GetOrder(int OrderNo)// Get
        {
            Dictionary <string, object> par = new Dictionary <string, object>(1);

            par.Add("OrderNo", OrderNo);
            DataTable lcResult = clsDbConnection.GetDataTable("SELECT * FROM [Order] WHERE OrderNo = @OrderNo", par);

            if (lcResult.Rows.Count > 0)
            {
                DataRow  dr      = lcResult.Rows[0];
                clsOrder lcOrder = dataRow2Order(dr);
                lcOrder.OrderItem = GetItem(lcOrder.ItemID);
                return(lcOrder);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
 public string PostOrder(clsOrder prOrder) // Insert
 {
     try
     {
         int lcRecCount = clsDbConnection.Execute("INSERT INTO [Order] "
                                                  + "(Qnty, PricePerItem, CustName, CustPh, TimeOrdered, ItemID) "
                                                  + "VALUES (@Qnty, @PricePerItem, @CustName, @CustPh, @TimeOrdered, @ItemID)"
                                                  , prepareOrderParameters(prOrder));
         if (lcRecCount == 1)
         {
             clsMQTTClient.Instance.MqttPublish("DBChange");
             return("One order inserted");
         }
         else
         {
             return("Unexpected order insert count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }
Exemplo n.º 3
0
 public string DeleteOrder(clsOrder prOrder) // Delete
 {                                           // delete
     try
     {
         int lcRecCount = clsDbConnection.Execute(
             "DELETE FROM [Order] " +
             "WHERE OrderNo = @OrderNo",
             prepareOrderParameters(prOrder));
         if (lcRecCount == 1)
         {
             clsMQTTClient.Instance.MqttPublish("DBChange");
             return("One order deleted");
         }
         else
         {
             return("Unexpected order delete count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }