Ejemplo n.º 1
0
        public static int UpdatePurchaseDetail(PurchaseDetail purchaseDetail)
        {
            const string Query =
                "update PurchaseDetail set Quantity = @Quantity, Total = @Total where PurchaseDetail_ID = @PurchaseDetail_ID";
            Provider p  = new Provider();
            int      id = -1;

            try
            {
                DataTable dt;
                p.Connect();
                dt = p.ExcecuteQuery(CommandType.Text, Query,
                                     new SqlParameter {
                    ParameterName = "@PurchaseDetail_ID", Value = purchaseDetail.PurchaseDetail_ID
                },
                                     new SqlParameter {
                    ParameterName = "@Quantity", Value = purchaseDetail.Quantity
                },
                                     new SqlParameter {
                    ParameterName = "@Total", Value = purchaseDetail.Total
                }
                                     );

                return(id);
            }
            catch (Exception eSql)
            {
                Debug.WriteLine("Exception: " + eSql.Message);
            }
            finally
            {
                p.DisConnect();
            }
            return(0);
        }
Ejemplo n.º 2
0
 public static void UpdateListPurchaseDetail(ObservableCollection <object> list_Update)
 {
     for (int i = 0; i < list_Update.Count; i++)
     {
         dynamic p             = list_Update[i];
         Type    typeOfDynamic = p.GetType();
         bool    exist         = typeOfDynamic.GetProperties().Where(x => x.Name.Equals("PurchaseDetail_ID")).Any();
         if (exist)
         {
             var update_item = new PurchaseDetail
             {
                 Total             = p.Quantity * p.Unit_Price,
                 Quantity          = p.Quantity,
                 PurchaseDetail_ID = p.PurchaseDetail_ID
             };
             UpdatePurchaseDetail(update_item);
         }
     }
 }
Ejemplo n.º 3
0
        public static int InsertPurchaseDetail(PurchaseDetail purchaseDetail)
        {
            const string Query = "insert into PurchaseDetail(Purchase_ID,Product_ID,Price,Quantity,Total) " +
                                 "values(@Purchase_ID, @Product_ID, @Price, @Quantity, @Total)";
            Provider p  = new Provider();
            int      id = -1;

            try
            {
                DataTable dt;
                p.Connect();
                dt = p.ExcecuteQuery(CommandType.Text, Query,
                                     new SqlParameter {
                    ParameterName = "@Purchase_ID", Value = purchaseDetail.Purchase_ID
                },
                                     new SqlParameter {
                    ParameterName = "@Product_ID", Value = purchaseDetail.Product_ID
                },
                                     new SqlParameter {
                    ParameterName = "@Price", Value = purchaseDetail.Price
                },
                                     new SqlParameter {
                    ParameterName = "@Quantity", Value = purchaseDetail.Quantity
                },
                                     new SqlParameter {
                    ParameterName = "@Total", Value = purchaseDetail.Total
                }
                                     );

                return(id);
            }
            catch (Exception eSql)
            {
                Debug.WriteLine("Exception: " + eSql.Message);
            }
            finally
            {
                p.DisConnect();
            }
            return(0);
        }
Ejemplo n.º 4
0
 public static void InsertListPurchaseDetail(ObservableCollection <object> list_New, int current_id = 1)
 {
     //List<PurchaseDetail> listPurchaseDetails = new List<PurchaseDetail>();
     for (int i = 0; i < list_New.Count; i++)
     {
         dynamic p             = list_New[i];
         Type    typeOfDynamic = p.GetType();
         bool    exist         = typeOfDynamic.GetProperties().Where(x => x.Name.Equals("PurchaseDetail_ID")).Any();
         if (!exist)
         {
             var new_item = new PurchaseDetail
             {
                 Purchase_ID = current_id,
                 Total       = p.SubTotal,
                 Quantity    = p.Quantity,
                 Product_ID  = p.Product_ID,
                 Price       = p.Unit_Price
             };
             InsertPurchaseDetail(new_item);
         }
     }
 }