Esempio n. 1
0
        public master_luckyballs_sale alter_master_luckyballs_sale()
        {
            try
            {
                master_luckyballs_sale prev_master_luckyballs_sale = db.master_luckyballs_sales.SingleOrDefault(a => a.id == master_luckyballs_sale.id);

                prev_master_luckyballs_sale.balance     = master_luckyballs_sale.balance;
                prev_master_luckyballs_sale.cancelled   = master_luckyballs_sale.cancelled;
                prev_master_luckyballs_sale.commision   = master_luckyballs_sale.commision;
                prev_master_luckyballs_sale.date        = master_luckyballs_sale.date;
                prev_master_luckyballs_sale.date_posted = master_luckyballs_sale.date_posted;
                prev_master_luckyballs_sale.islocked    = master_luckyballs_sale.islocked;
                prev_master_luckyballs_sale.isverified  = master_luckyballs_sale.isverified;
                prev_master_luckyballs_sale.net_balance = master_luckyballs_sale.net_balance;
                prev_master_luckyballs_sale.posted_by   = master_luckyballs_sale.posted_by;
                prev_master_luckyballs_sale.sales       = master_luckyballs_sale.sales;
                prev_master_luckyballs_sale.shop        = master_luckyballs_sale.shop;
                prev_master_luckyballs_sale.stake       = master_luckyballs_sale.stake;
                prev_master_luckyballs_sale.winnings    = master_luckyballs_sale.winnings;
                db.SubmitChanges();
                return(master_luckyballs_sale);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 2
0
 public master_luckyballs_sale find_master_luckyballs_sale_By_AppId(string Appid)
 {
     try
     {
         master_luckyballs_sale = db.master_luckyballs_sales.SingleOrDefault(a => a.app_id == Appid);
         return(master_luckyballs_sale);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 3
0
 public master_luckyballs_sale find_master_luckyballs_sale_By_ID(int id)
 {
     try
     {
         master_luckyballs_sale = db.master_luckyballs_sales.SingleOrDefault(a => a.id == id);
         return(master_luckyballs_sale);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 4
0
 public master_luckyballs_sale delete_master_luckyballs_sale()
 {
     try
     {
         master_luckyballs_sale prev_master_luckyballs_sale = db.master_luckyballs_sales.SingleOrDefault(a => a.id == master_luckyballs_sale.id);
         db.master_luckyballs_sales.DeleteOnSubmit(prev_master_luckyballs_sale);
         return(master_luckyballs_sale);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 5
0
 public saleshelper(master_luckyballs_sale sales)
 {
     this.shopcode_         = (sales.shop1 != null) ? sales.shop1.shop_code : "ERROR SHOP";
     this.stake             = sales.stake.Value;
     this.cancelled         = sales.cancelled.Value;
     this.single_sales      = sales.single_stake_sales != null ? sales.single_stake_sales.Value : Decimal.Zero;
     this.single_comm       = sales.single_stake_commision != null ? sales.single_stake_commision.Value : Decimal.Zero;;
     this.multi_sales       = sales.sales.Value - this.single_sales;
     this.multi_comm        = sales.commision.Value - this.single_comm;
     this.single_stake_perc = sales.single_stake_percent.ToString() + "%";
     this.total_sales       = sales.sales.Value;
     this.total_comm        = sales.commision.Value;
     this.total_winnings    = sales.winnings.Value;
     this.NetBalance_       = sales.sales.Value - sales.winnings.Value - sales.commision.Value;
 }
Esempio n. 6
0
        //public master_luckyballs_sales_crud(master_luckyballs_sale master_luckyballs_sale_, List<transaction_category> trancategory,List<master_balance_sheet> sheets)
        //{
        //    this.trancategory = trancategory;
        //    this.master_luckyballs_sale_ = master_luckyballs_sale_;
        //    this.sheets = sheets;
        //}

        public master_luckyballs_sales_crud(master_luckyballs_sale master_luckyballs_sale)
        {
            this.master_luckyballs_sale_ = master_luckyballs_sale;
        }
        public void computeSales()
        {
            if (hasMasterSale())
            {
                mstake          = (decimal)mastersales.Sum(a => a.stake);
                msales          = (decimal)mastersales.Sum(a => a.sales);
                mwinnings       = (decimal)mastersales.Sum(a => a.winnings);
                mcancelled      = (decimal)mastersales.Sum(a => a.cancelled);
                mbalance        = (decimal)mastersales.Sum(a => a.balance);
                mcommision      = (decimal)mastersales.Sum(a => a.commision);
                mnetbalance     = (decimal)mastersales.Sum(a => a.net_balance);
                msingle_sales   = (decimal)mastersales.Sum(a => a.single_stake_sales);
                msingle_comm    = (decimal)mastersales.Sum(a => a.single_stake_commision);
                mmulti_sales    = msales - msingle_sales;
                mmulti_comm     = mcommision - msingle_comm;
                msingle_percent = (decimal)mastersales.Average(a => a.single_stake_percent);
            }
            else
            {
                msales = mwinnings = mcancelled = mbalance = mcommision = mnetbalance = mstake = Decimal.Zero;
            }
            if (hasShopSale())
            {
                sstake      = (decimal)shopsales.Sum(a => a.stake);
                ssales      = (decimal)shopsales.Sum(a => a.sales);
                swinnings   = (decimal)shopsales.Sum(a => a.winnings);
                scancelled  = (decimal)shopsales.Sum(a => a.cancelled);
                sbalance    = (decimal)shopsales.Sum(a => a.balance);
                scommision  = (decimal)shopsales.Sum(a => a.commision);
                snetbalance = (decimal)shopsales.Sum(a => a.net_balance);
            }
            else
            {
                ssales = swinnings = scancelled = sbalance = scommision = snetbalance = sstake = Decimal.Zero;
            }

            _combinedshopsales = new shop_daily_sale
            {
                stake       = sstake,
                sales       = ssales,
                winnings    = swinnings,
                cancelled   = scancelled,
                balance     = sbalance,
                commision   = scommision,
                net_balance = snetbalance,
                shop1       = shop
            };

            _combinedmastersales = new master_luckyballs_sale
            {
                stake                  = mstake,
                sales                  = msales,
                winnings               = mwinnings,
                cancelled              = mcancelled,
                balance                = mbalance,
                commision              = mcommision,
                net_balance            = mnetbalance,
                shop1                  = shop,
                single_stake_commision = msingle_comm,
                single_stake_percent   = msingle_percent,
                single_stake_sales     = msingle_sales
            };

            cstake      = Decimal.Subtract(mstake, sstake);
            csales      = Decimal.Subtract(msales, ssales);
            cwinnings   = Decimal.Subtract(mwinnings, swinnings);
            ccancelled  = Decimal.Subtract(mcancelled, scancelled);
            cbalance    = Decimal.Subtract(mbalance, sbalance);
            ccommision  = Decimal.Subtract(mcommision, scommision);
            cnetbalance = Decimal.Subtract(mnetbalance, snetbalance);


            _combinedsale = new master_luckyballs_sale
            {
                stake                  = cstake,
                sales                  = csales,
                winnings               = cwinnings,
                cancelled              = ccancelled,
                balance                = cbalance,
                commision              = ccommision,
                net_balance            = cnetbalance,
                shop1                  = _shop,
                single_stake_commision = msingle_comm,
                single_stake_percent   = msingle_percent,
                single_stake_sales     = msingle_sales
            };
            //_combinedmastersales.shop1.shop_code
        }
Esempio n. 8
0
        //Adjust accordingly to Lucky Balls Excel format
        public List <master_luckyballs_sale> fillLuckyBallsDataToList(DateTime date)

        {
            List <shop> shops = new CRUD.shop_crud().getallShop().ToList <shop>();

            if (dtExcelRecords == null)
            {
                return(null);
            }
            else
            {
                List <master_luckyballs_sale> sales = new List <master_luckyballs_sale>();

                shop_crud shophelper = new shop_crud();
                //shop shoped;
                foreach (DataRow row in dtExcelRecords.Rows)
                {
                    int rowindex = dtExcelRecords.Rows.IndexOf(row);
                    //if(dtExcelRecords.Rows.IndexOf(row) == 0)
                    //    continue;
                    if (dtExcelRecords.Rows.IndexOf(row) == dtExcelRecords.Rows.Count - 1)
                    {
                        break;
                    }
                    //
                    var values = row.ItemArray;
                    master_luckyballs_sale sale;
                    string excelshopcode       = (string)values[0];
                    string excelshopcodeINT    = excelshopcode.Substring(0, excelshopcode.IndexOf('-')).ToString().Trim();
                    string excelshopcodeString = excelshopcode.Substring(excelshopcode.IndexOf('-') + 1).ToString().Trim();
                    int    errorcount          = -1;
                    try
                    {
                        int  excelshopid = int.Parse(excelshopcodeINT.ToString());
                        shop shoped      = shops.SingleOrDefault(a => a.id == excelshopid && a.shop_code == excelshopcodeString);// new shop_crud().find_shop_By_Code((string)values[1]) != null ? shophelper.find_shop_By_Code((string)values[1]) : new shop {id=-1, shop_code=(string) values[1]};


                        sale = new master_luckyballs_sale
                        {
                            // shop1 = (shop_ != null) ? shop_ : null,
                            //((shophelper.find_shop_By_Code((string)values[1])) != null) ? shophelper.find_shop_By_Code((string)values[1]) : null,
                            //(string)values[1]) != null) ? shophelper.find_shop_By_Code((string)values[1]) : null,
                            shop1 = (shoped != null) ? shoped : new shop {
                                shop_code = values[1].ToString(), app_id = values[1].ToString()
                            },
                            // shop = shoped.id,//shoped.id,
                            //app_id = values[1].ToString(),//temp string used to display shop in list view
                            date               = date,
                            stake              = Decimal.Parse(values[3].ToString()),
                            winnings           = Decimal.Parse(values[5].ToString()),
                            cancelled          = Decimal.Zero,
                            single_stake_sales = Decimal.Zero,
                            isverified         = false,
                            islocked           = false,
                            date_posted        = DateTime.Today,
                        };

                        // sale.shop1 = ((shophelper.find_shop_By_Code((string)values[1])) != null) ? shophelper.find_shop_By_Code((string)values[1]) : null;

                        sale.sales   = Decimal.Subtract((Decimal)sale.stake, (Decimal)sale.cancelled);
                        sale.balance = Decimal.Subtract((Decimal)sale.sales, (Decimal)sale.winnings);
                        sale.other_stake_commision  = 0; //Decimal.Multiply((Decimal)(sale.sales - sale.single_stake_sales), (shoped.commission != null) ? shoped.commission.Value / 100 : Utilities.COMMISSION.COMMISSION_CONSTANT / 100);
                        sale.single_stake_commision = 0; //Decimal.Multiply((Decimal)sale.single_stake_sales, Utilities.COMMISSION.SINGLE_COMMISION_CONSTANT / 100);
                        sale.commision = sale.single_stake_commision + sale.other_stake_commision;
                        //sale.commision = Decimal.Multiply((Decimal)sale.sales, (shoped.commission != null) ? shoped.commission.Value / 100 : Utilities.COMMISSION.COMMISSION_CONSTANT / 100);
                        sale.net_balance          = Decimal.Subtract((Decimal)sale.balance, (Decimal)sale.commision);
                        sale.single_stake_percent = sale.sales != 0 ? (sale.single_stake_sales / sale.sales) * 100 : 0;
                        //   sale = new master_luckyballs_sales_crud(sale).insert_master_luckyballs_sale();
                        if (sale == null)
                        {
                            sale = new master_luckyballs_sale();
                        }
                        sales.Add(sale);
                        //   sale = new master_luckyballs_sales_crud(sale).insert_master_luckyballs_sale();
                    }


                    catch (Exception)
                    {
                        sale = new master_luckyballs_sale();
                        // sale.shop1 = new shop {id = errorcount, shop_code = excelshopcode, app_id = excelshopcode};
                        //  errorcount--;
                        sale.app_id = excelshopcode;
                        sales.Add(sale);
                    }
                }

                return(sales);
            }
        }