Esempio n. 1
0
        private void GetTotalIncome()
        {
            int            round       = 231;
            MagnumEntities db          = new MagnumEntities();
            var            totalIncome = db.Orders.Where(o => o.Round == round).Sum(o => o.Total);

            lblTotalIncome.Text = totalIncome.ToString();
        }
Esempio n. 2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int            id = 1;
            MagnumEntities db = new MagnumEntities();
            User           u  = db.Users.FirstOrDefault(x => x.ID == id);

            db.Users.Remove(u);

            db.SaveChanges();
        }
Esempio n. 3
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            MagnumEntities db = new MagnumEntities();
            User           u  = new User();

            u.Name = TextBox1.Text;

            db.Users.Add(u);
            db.SaveChanges();
        }
Esempio n. 4
0
        private string PickNumber(string number, decimal threshold, string resultType)
        {
            decimal        totalPayoutAmt = 0;
            string         result         = "no";
            MagnumEntities db             = new MagnumEntities();
            var            list           = db.OrderItemSplits.Where(x => x.Number == number).ToList();

            if (list.Count > 0)
            {
                // this random number match the number purchased by customer
                foreach (var data in list)
                {
                    // get the sum of total payout of this number
                    totalPayoutAmt += GetPayoutAmount(data.ID, data.OrderID, data.Number, data.CategoryCode, Convert.ToDecimal(data.Amount), resultType);
                }

                if (totalPayoutAmt > threshold)
                {
                    // NOT ALLOW TO PUBLISH -> the payout of this number is more then threshold.
                    result = "no";
                }
                else
                {
                    // ALLOW TO PUBLISH
                    if (totalPayoutAmt == 0)
                    {
                        // number hit but payout amout is 0
                        result = "not_match";
                    }
                    else
                    {
                        // number hit ->  the payout of this number is less then threshold.
                        result = "hit";
                    }
                }
            }
            else
            {
                // ALLOW PUBLISH, no customer hit this number
                result = "miss";
            }

            if (result != "no")
            {
                DataTable dtResult = (DataTable)ViewState["Result"];
                DataRow   newRow   = dtResult.NewRow();
                newRow["Number"]     = number;
                newRow["ResultType"] = resultType;
                dtResult.Rows.Add(newRow);
            }

            return(result);
        }
Esempio n. 5
0
        protected void btnGet_Click(object sender, EventArgs e)
        {
            MagnumEntities db = new MagnumEntities();

            DataTable dt   = new DataTable();
            var       list = db.Users.Where(x => x.Name == "CH");
            var       pro  = from u in db.Users where u.Name == "CH" select u;

            if (pro != null)
            {
                GridView1.DataSource = list.ToList();
                GridView1.DataBind();
            }
        }
Esempio n. 6
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            int            id = 1;
            MagnumEntities db = new MagnumEntities();
            User           u  = db.Users.Find(id);

            if (u == null)
            {
            }
            else
            {
                u.Name = "KK";
                db.SaveChanges();
            }
        }
Esempio n. 7
0
        private decimal GetPayoutAmount(int id, int?orderID, string number, string code, decimal amount, string resultType)
        {
            bool           proceed      = false;
            decimal        payoutAmount = 0;
            MagnumEntities db           = new MagnumEntities();

            switch (code)
            {
            case "N":
                code    = resultType;
                proceed = true;
                break;

            case "SA1":
                if (resultType == "FP")     // Only 1st Prize
                {
                    proceed = true;
                }
                break;

            case "SA2":
                if (resultType == "SP")     // Only 2nd Prize
                {
                    proceed = true;
                }
                break;

            case "SA3":
                if (resultType == "TP")     // Only 3rd Prize
                {
                    proceed = true;
                }
                break;

            case "SA4":
                if (resultType == "SPP")     // Only Special Prize
                {
                    proceed = true;
                }
                break;

            case "SA5":
                if (resultType == "CP")     // Only Consolation Prize
                {
                    proceed = true;
                }
                break;

            case "SA6":
                if (resultType == "FP" || resultType == "SP" || resultType == "TP")     // Only 1st, 2nd, 3rd Prize (half normal prize)
                {
                    proceed = true;
                }
                break;
            }

            if (proceed)
            {
                var rate = db.setting_CategoryRate.Where(x => x.Code == code).Select(x => x.Rate).FirstOrDefault();

                if (rate != null)
                {
                    payoutAmount = amount * Convert.ToDecimal(rate);
                    MinusMaxLoseThreshold(id, orderID, number, code, amount, rate, payoutAmount);
                }
            }
            else
            {
                payoutAmount = 0;
            }

            return(payoutAmount);
        }