Example #1
0
        public void GeneratePerformanceLog(ForSaleTable ActItem)
        {
            var PerfQuery = from u in DataContextInv.PerformanceTables
                            where u.ItemName == ActItem.ItemName
                            select u;

            if (PerfQuery.Count() == 0) // then a perf record for the item doesnt exist
            {
                PerformanceTable PerformanceLog = new PerformanceTable();
                PerformanceLog.ItemName  = ActItem.ItemName;
                PerformanceLog.January   = 0;
                PerformanceLog.February  = 0;
                PerformanceLog.March     = 0;
                PerformanceLog.April     = 0;
                PerformanceLog.May       = 0;
                PerformanceLog.June      = 0;
                PerformanceLog.July      = 0;
                PerformanceLog.August    = 0;
                PerformanceLog.September = 0;
                PerformanceLog.October   = 0;
                PerformanceLog.November  = 0;
                PerformanceLog.December  = 0;
                //returns the current month , e.g. January
                string currentMonth = DateTime.Now.ToString("MMMM");

                Console.WriteLine("The quantity is " + ActItem.Quantity);

                if (currentMonth == "January")
                {
                    PerformanceLog.January += ActItem.Quantity.Value;
                }
                if (currentMonth == "February")
                {
                    PerformanceLog.February = ActItem.Quantity.Value;
                }
                if (currentMonth == "March")
                {
                    PerformanceLog.March = ActItem.Quantity.Value;
                }
                if (currentMonth == "April")
                {
                    PerformanceLog.April = ActItem.Quantity.Value;
                }
                if (currentMonth == "May")
                {
                    PerformanceLog.May = ActItem.Quantity.Value;
                }
                if (currentMonth == "June")
                {
                    PerformanceLog.June = ActItem.Quantity.Value;
                }
                if (currentMonth == "July ")
                {
                    PerformanceLog.July = ActItem.Quantity.Value;
                }
                if (currentMonth == "August")
                {
                    PerformanceLog.August = ActItem.Quantity.Value;
                }
                if (currentMonth == "September")
                {
                    PerformanceLog.September = ActItem.Quantity.Value;
                }
                if (currentMonth == "October")
                {
                    PerformanceLog.October = ActItem.Quantity.Value;
                }
                if (currentMonth == "November")
                {
                    PerformanceLog.November = ActItem.Quantity.Value;
                }
                if (currentMonth == "December")
                {
                    PerformanceLog.December = ActItem.Quantity.Value;
                }
                DataContextInv.PerformanceTables.InsertOnSubmit(PerformanceLog);
                DataContextInv.SubmitChanges();
            }
            else
            {
                //get the actual record in the performance table
                var    PerfData     = DataContextInv.PerformanceTables.Single(x => x.ItemName == ActItem.ItemName);
                string currentMonth = DateTime.Now.ToString("MMMM");
                if (currentMonth == "January")
                {
                    //increment the value by the quantity of item
                    PerfData.January += ActItem.Quantity.Value;
                }
                if (currentMonth == "February")
                {
                    PerfData.February += ActItem.Quantity.Value;
                }
                if (currentMonth == "March")
                {
                    PerfData.March += ActItem.Quantity.Value;
                }
                if (currentMonth == "April")
                {
                    PerfData.April += ActItem.Quantity.Value;
                }
                if (currentMonth == "May")
                {
                    PerfData.May += ActItem.Quantity.Value;
                }
                if (currentMonth == "June")
                {
                    PerfData.June += ActItem.Quantity.Value;
                }
                if (currentMonth == "July ")
                {
                    PerfData.July += ActItem.Quantity.Value;
                }
                if (currentMonth == "August")
                {
                    PerfData.August += ActItem.Quantity.Value;
                }
                if (currentMonth == "September")
                {
                    PerfData.September += ActItem.Quantity.Value;
                }
                if (currentMonth == "October")
                {
                    PerfData.October += ActItem.Quantity.Value;
                }
                if (currentMonth == "November")
                {
                    PerfData.November += ActItem.Quantity.Value;
                }
                if (currentMonth == "December")
                {
                    PerfData.December += ActItem.Quantity.Value;
                }
                DataContextInv.SubmitChanges();
            }
        }
 partial void DeleteForSaleTable(ForSaleTable instance);
 partial void UpdateForSaleTable(ForSaleTable instance);
 private void detach_ForSaleTables(ForSaleTable entity)
 {
     this.SendPropertyChanging();
     entity.CategoryTable = null;
 }
 partial void InsertForSaleTable(ForSaleTable instance);