Example #1
0
 protected void btnCardDealRate_Click(object sender, EventArgs e)
 {
     decimal number = -1;
     string num = tbCardDealRate.Text;
     string strcompany = ddCardDealRate.SelectedValue;
     if (!strcompany.Contains("---company"))
     {
         number = Convert.ToDecimal(num);
         if (number >= 0 && number <= 100)
         {
             DataClassesAlbertDataContext db = new DataClassesAlbertDataContext();
             Company qry = (from c in db.Companies where c.Name == strcompany select c).Single();
             //Company qry = qry.Single(); // if we do not insert the fist single
             qry.GCSaleDealRate = number;
             db.SubmitChanges();
             lblDealRate.Text = "OK -> Deal Rate set to " + number.ToString("0.0000") + " % for company " + strcompany;
             tbDealRate.Text = number.ToString("0.0000") + " %";
         }
         else
         {
             lblDealRate.Text = "ERROR -> Entered value must be an integer between 1 and 99 for company " + strcompany;
         }
     }
     else
     {
         lblDealRate.Text = "ERROR -> Entered value must be an integer between 1 and 99 for the selected company" + strcompany;
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     string inGCnum = Request["GC"];
     long GCnum = 0;
     DataClassesAlbertDataContext db = new DataClassesAlbertDataContext();
     GiftCard giftCard = new GiftCard();
     GCnum = Convert.ToInt64(inGCnum.Remove(inGCnum.Length - 1));
     try
     {
         giftCard = (from gc in db.GiftCards where gc.BarCode == GCnum select gc).Single();
         string companyName = "";
         if (giftCard.CompanyID != "00000000-0000-0000-0000-000000000000" && giftCard.CompanyID != "")
         {
             try
             {
                Company comp = (from c in db.Companies where c.UserID.ToString() == giftCard.CompanyID select c).Single();
                companyName = comp.Name;
             }
             catch { }
         }
         GoDineEmails.sendSuccessEmail(giftCard, companyName);
         lblinfo.Text = "Email sent";
     }
     catch
     {
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        ((Site)this.Master).showNavbar = false;

        // Public links will contain an encrypted barcode number, private admin pages will point to the plain number instead
        string encryptedBarcode = Request.QueryString["GC"];

        string barcodeNumber = Request.QueryString["barcodeNumber"];

        if (barcodeNumber == null && encryptedBarcode != null)
            barcodeNumber = SecurityUtils.decrypt(encryptedBarcode);

        if (barcodeNumber != null)
        {
            DataClassesAlbertDataContext db = new DataClassesAlbertDataContext();
            long barcodeNumberL = Convert.ToInt64(barcodeNumber.Remove(barcodeNumber.Length-1));

            try
            {
                GiftCard card = (from gc in db.GiftCards where gc.BarCode == barcodeNumberL select gc).Single();
                string barcodeWithChecksum = UTILITIES.appendChecksum(card.BarCode);

                // populate gift card fields
                message.InnerText = card.GCText;
               if (card.DisplayName == 1)
                {
                   from.InnerText = "From: " + card.NameFrom;
                   to.InnerText = "To: " + card.NameTo;
                }
                value.InnerText = card.Money.ToString("0.00");
                backgroundImage.Src = "/img/GC/" + card.DIRImgGC;
                barcodeImage.Src = "/barcodeStream.aspx?code=" + barcodeWithChecksum;
                barcodeLabel.InnerText = barcodeWithChecksum;

                //populate company name

                try
                {
                    Company gcComp = (from c in db.Companies where c.UserID.ToString() == card.CompanyID select c).Single();
                    String name = gcComp.Name;
                    StoreName1.Text = name;
                    StoreName2.Text = name;
                    StoreName3.Text = name;
                    StoreName4.Text = name;
                }
                catch { }

            }
            catch (Exception ex)
            {
                // Show error - no gift card found
                showErrorMessage("Sorry, we can't find a gift card with that number. Please verify the link and try again.");
                log.Error("Error fetching gift card with number: " + barcodeNumber + ", hash: " + encryptedBarcode, ex);
            }
        }
        else
        {
            // Show error - missing parameter
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         GCready = (UTILITIES.GiftCardReady)Session["GCready"];
         DataClassesAlbertDataContext db = new DataClassesAlbertDataContext();
         GiftCard GCqry = (from gc in db.GiftCards where gc.BarCode == GCready.barcode select gc).Single();
         GoDineEmails.Payment_Fail_Case(GCqry);
     }
     catch
     {
     }
 }
Example #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DataClassesAlbertDataContext db;
            db = new DataClassesAlbertDataContext();
            GoDine a = new GoDine();

            MembershipUser user = Membership.GetUser();
            Guid userID = (Guid)user.ProviderUserKey;
            var company = (from c in db.Companies where c.UserID == userID select c).Single();
            Setup_GiftCardSales(userID.ToString());

            GiftcardSellingMesage.Text = "Here's your gift card link, where your customers can buy gift cards for just your store, any time, even when your store is closed. " + HOST_URL + "/BuyGiftCard.aspx?Company=" + userID.ToString();

            LabelTitle.Text = company.Name;
    }
Example #6
0
    protected void Set_Table_Filtered(string filterSeller)
    {
        GoDine GD = new GoDine();

        DataTable dt;
        DataClassesAlbertDataContext db;

        db = new DataClassesAlbertDataContext();
        dt = new DataTable("Sellers");
        var Sellers = from sl in db.SalesIDs select sl;

        dt.Columns.Add("Email", typeof(string));
        dt.Columns.Add("NumberOfSales", typeof(string));
        dt.Columns.Add("%CurrentDealRate", typeof(string));
        dt.Columns.Add("$TotalOfGiftCardsSold", typeof(string));
        dt.Columns.Add("$TotalIncomeFromSales", typeof(decimal));
        dt.Columns.Add("$WePaidThem", typeof(decimal));
        dt.Columns.Add("CreationDate", typeof(DateTime));
        dt.Columns.Add("SellerID", typeof(string));

        foreach (var seller in Sellers)
        {
            MembershipUser user = Membership.GetUser(seller.UserID);
            String username = user.UserName;
            if (username.Contains(filterSeller))
            {
                SellerStats stats = GD.SellerSts(seller.SellerID);
                DataRow tablerow = dt.NewRow();
                tablerow["Email"] = username;
                tablerow["NumberOfSales"] = stats.numSales.ToString();
                tablerow["%CurrentDealRate"] = seller.DealRate.ToString("0.00");
                tablerow["$TotalOfGiftCardsSold"] =  stats.sold.ToString("0.00");
                tablerow["$TotalIncomeFromSales"] = stats.owed;
                tablerow["$WePaidThem"] = GD.getPaidToSeller(seller.SellerID);
                tablerow["CreationDate"] = user.CreationDate;
                tablerow["SellerID"] = seller.SellerID.ToString();
                dt.Rows.Add(tablerow);
            }
        }

        Session["dt"] = dt;
        GV.DataSource = dt;
        GV.AllowSorting = true;
        GV.AllowPaging = true;
        GV.PageSize = 50;
        //GV.Columns["Money"].ItemStyle.HorizontalAlign = HorizontalAlign.Right;
        GV.DataBind();
    }
    protected void Set_Table_Filtered(string filter)
    {
        DataTable dt;
        DataClassesAlbertDataContext db;

        db = new DataClassesAlbertDataContext();
        dt = new DataTable("Payments");
        //var companies = db.Companies; // THIS IS A FULL TABLE ACQUISITION FROM DATABASE
        var payments = from p in db.Payments select p; // THIS IS A SELECTED TABLE ACQUISITION

        dt.Columns.Add("PaymentID", typeof(int));
        dt.Columns.Add("User", typeof(string));
        dt.Columns.Add("GiftCardID", typeof(int));
        dt.Columns.Add("$Amount", typeof(decimal));
        dt.Columns.Add("$AmountReceived", typeof(decimal));
        dt.Columns.Add("Forced", typeof(bool));
        dt.Columns.Add("Date", typeof(DateTime));
        dt.Columns.Add("Concept", typeof(string));

        foreach (Payment payment in payments)
        {
            string userkey_email = payment.UserID;
            //MembershipUser memberi = Membership.GetUser(userkey_email);
            if (userkey_email.Contains(filter))
            {
                DataRow tablerow = dt.NewRow();
                tablerow["PaymentID"] = payment.PaymentID;
                tablerow["User"] = userkey_email;
                tablerow["GiftCardID"] = payment.GiftCardID;
                tablerow["$Amount"] = Math.Round(payment.Amount,2);
                tablerow["$AmountReceived"] = Math.Round(payment.AmountReceived,2);
                tablerow["Forced"] = payment.Forced == 0 ? false : true;
                tablerow["Date"] = payment.Date.ToString();
                tablerow["Concept"] = payment.Concept;

                dt.Rows.Add(tablerow);
            }
        }
        Session["dt"] = dt;
        GV.DataSource = dt;
        GV.AllowSorting = true;
        GV.AllowPaging = false;
        GV.PageSize = 50;
        //GV.Columns["Money"].ItemStyle.HorizontalAlign = HorizontalAlign.Right;
        GV.DataBind();
    }
    protected void LoadTransactions()
    {
        DataTable dt;
        DataClassesAlbertDataContext db;
        MembershipUser user = Membership.GetUser();
        Guid userID = (Guid)user.ProviderUserKey;

        db = new DataClassesAlbertDataContext();
        dt = new DataTable("Transactions");
        var transactions = from t in db.Transactions select t; // THIS IS A SELECTED TABLE ACQUISITION
        var giftcardIDs = from gc in db.GiftCards where gc.EmailTo == user.UserName select gc.GiftCardID;

        dt.Columns.Add("Gift Card ID", typeof(int));
        dt.Columns.Add("Company", typeof(string));
        dt.Columns.Add("Concept", typeof(string));
        dt.Columns.Add("Value", typeof(string));
        dt.Columns.Add("Date", typeof(DateTime));

        List<TransactionDetails> transactionDetailList = new List<TransactionDetails>();

        foreach (Transaction transaction in transactions)
        {
            bool allow_plot = false;
            foreach (int gcID in giftcardIDs)
            {
                if (transaction.GiftCardID == gcID)
                {
                    allow_plot = true;
                    break;
                }

            }
            if (allow_plot)
            {
                transactionDetailList.Add(new TransactionDetails(transaction.Amount.ToString("C"),
                    transaction.Date.ToShortDateString(),
                    transaction.CUser.Company.Name,
                    transaction.Concept));
            }
        }

        TransactionList.DataSource = transactionDetailList;
        TransactionList.DataBind();
    }
Example #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string filterUser = Request.QueryString["cuser"];

            if (filterUser == null)
            {
                filterUser = "";
            }

            DataClassesAlbertDataContext db;
            db = new DataClassesAlbertDataContext();
            GoDine a = new GoDine();

            MembershipUser user = Membership.GetUser();
            Guid userID = (Guid)user.ProviderUserKey;

        }
    }
Example #10
0
    ///////////////////////////////////////////////////////////// PAYMENT SUCCESS
    public static void Payment_Success_Case_Global_MoneyAndSend(GiftCard giftCard, decimal fee)
    {
        log.Debug("Processing successful payment for GiftCard " + giftCard.GiftCardID);
        log.Debug("Value=" + giftCard.GCValue + ", fee=" + fee + ", barcode=" + giftCard.BarCode);
        DataClassesAlbertDataContext db = new DataClassesAlbertDataContext();

        string companyName = "";
        if (giftCard.CompanyID != "00000000-0000-0000-0000-000000000000" && giftCard.CompanyID != "")
        {
            try
            {
                companyName = (from c in db.Companies where c.UserID == new Guid(giftCard.CompanyID) select c).Single().Name;
            }
            catch { }
        }

        GoDine a = new GoDine();
        a.Insert_Money_2_GiftCard(giftCard.GCValue, giftCard.GCValue - fee, giftCard.BarCode, "Payment by credit card/paypal: " + giftCard.EmailFrom, 0); //IT IS NOT FORCED
        sendSuccessEmail(giftCard, companyName);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        DataClassesAlbertDataContext db;
        db = new DataClassesAlbertDataContext();
        GoDine a = new GoDine();
        MembershipUser user = Membership.GetUser();
        Guid userID = (Guid)user.ProviderUserKey;
        var company = (from c in db.Companies where c.UserID == userID select c).Single();
        LabelTitle.Text = company.Name;

        DataTable dt;
        dt = new DataTable("Company Payments");

        var Payments = from pmt in db.CompanyPayHists
                       where pmt.CompanyID == company.CompanyID
                       where pmt.IsACompany == true
                     select pmt;

        dt.Columns.Add("Context", typeof(string));
        dt.Columns.Add("Amount($)", typeof(decimal));
        dt.Columns.Add("Date of Payment", typeof(DateTime));

        foreach (var pmt in Payments)
        {
            DataRow tablerow = dt.NewRow();

            tablerow["Context"] = pmt.Concept;
            tablerow["Amount($)"] = pmt.Amount.ToString("0.00");
            tablerow["Date of Payment"] = pmt.Date;
            dt.Rows.Add(tablerow);
        }

        Session["dt"] = dt;
        GV.DataSource = dt;
        GV.AllowSorting = true;
        GV.AllowPaging = true;
        GV.PageSize = 50;
        GV.DataBind();
    }
Example #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string filterUser = Request.QueryString["cuser"];

            if (filterUser == null)
            {
                filterUser = "";
            }

            DataClassesAlbertDataContext db;
            db = new DataClassesAlbertDataContext();
            GoDine a = new GoDine();

            MembershipUser user = Membership.GetUser();
            Guid userID = (Guid)user.ProviderUserKey;
            var company = (from c in db.Companies where c.UserID == userID select c).Single();

            LabelTitle.Text = company.Name;
        }
    }
    protected void btnDownAll_Click(object sender, EventArgs e)
    {
        DataClassesAlbertDataContext db = new DataClassesAlbertDataContext();
        var allGC = db.GiftCards; // THIS IS A FULL TABLE ACQUISITION FROM DATABASE
        string filename = "Giftcards_DB_All_" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".csv";
        string attachment = "attachment; filename=" + filename;
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.ClearHeaders();
        HttpContext.Current.Response.ClearContent();
        HttpContext.Current.Response.AddHeader("content-disposition", attachment);
        HttpContext.Current.Response.ContentType = "text/csv";
        HttpContext.Current.Response.AddHeader("Pragma", "public");

        var sb = new StringBuilder();
        sb.AppendLine(TransformDataLineIntoCsv_Header());
        foreach (GiftCard gcrow in allGC)
        {
            sb.AppendLine(TransformDataLineIntoCsv(gcrow));
        }
        HttpContext.Current.Response.Write(sb.ToString());
        HttpContext.Current.Response.End();
    }
Example #14
0
    protected void Setup_Sales(Guid user)
    {
        DataTable dt;
        DataClassesAlbertDataContext db;

        db = new DataClassesAlbertDataContext();
        var salesID = (from sid in db.SalesIDs where sid.UserID == user select sid).Single();
        Guid sellerID = salesID.SellerID;
        dt = new DataTable("Sales");
        var sales = from gc in db.GiftCards where gc.SellerID == sellerID.ToString() where gc.TotalIn != 0 select gc;

        dt.Columns.Add("$Amount", typeof(string));
        dt.Columns.Add("%DealRate", typeof(string));
        dt.Columns.Add("Income", typeof(string));
        dt.Columns.Add("Date", typeof(DateTime));

        foreach (GiftCard sale in sales)
        {

                DataRow tablerow = dt.NewRow();

                tablerow["$Amount"] = sale.TotalIn.ToString("0.00");
                tablerow["%DealRate"] = sale.SalesDealRate.ToString("0.00");
                tablerow["Income"] = Math.Round(sale.TotalIn * sale.SalesDealRate / 100,2).ToString("0.00");
                tablerow["Date"] = sale.Date;

                dt.Rows.Add(tablerow);
        }

        Session["dt"] = dt;
        GV.DataSource = dt;
        GV.AllowSorting = true;
        GV.AllowPaging = true;
        GV.PageSize = 50;
        //GV.Columns["Money"].ItemStyle.HorizontalAlign = HorizontalAlign.Right;
        GV.DataBind();
    }
Example #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DataClassesAlbertDataContext db;
        db = new DataClassesAlbertDataContext();
        GoDine a = new GoDine();

        MembershipUser user = Membership.GetUser();
        Guid userID = (Guid)user.ProviderUserKey;
        var salesID = (from sid in db.SalesIDs where sid.UserID == userID select sid).Single();
        decimal dealRate = a.getDealRateForSellerID(salesID.SellerID);
        SellerStats table = a.SellerSts(salesID.SellerID);
        decimal paid = a.Paid_FromSalesPaymentHist(salesID.SellerID);

        LabelTitle.Text = "Your Sales Progress";
        lbldealrate.Text = dealRate.ToString("0.00") + "%";
        lblincome.Text = "$" + table.owed.ToString("0.00");
        lblnumsales.Text = table.numSales.ToString();
        lblpaid.Text = "$" + paid.ToString("0.00");
        lbltopay.Text = "$" + (table.owed - paid).ToString("0.00");

        String salesUrl = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "BuyGiftCard.aspx?Sale=" + salesID.SellerID.ToString();

        UrlBlurb.Text = "Your sales url: " + salesUrl + "</br> (refer people here when you're selling in order to get credit for your sales)";
    }
    private CUser getDefaultCompanyUser()
    {
        DataClassesAlbertDataContext db;
        db = new DataClassesAlbertDataContext();

        MembershipUser user = Membership.GetUser();
        Guid userID = (Guid)user.ProviderUserKey;

         return (from c in db.CUsers where c.Company.UserID == userID orderby c.CUserID select c).First();
    }
    protected void Set_Table_Filtered(string filter)
    {
        DataTable dt;
        DataClassesAlbertDataContext db;

        db = new DataClassesAlbertDataContext();
        dt = new DataTable("Customers");
        //var companies = db.Companies; // THIS IS A FULL TABLE ACQUISITION FROM DATABASE
        var companies = from c in db.Companies where c.Name.Contains(filter) select c; // THIS IS A SELECTED TABLE ACQUISITION
        MembershipUserCollection allUsers = Membership.GetAllUsers();

        dt.Columns.Add("UserName", typeof(string));
        //dt.Columns.Add("UserEmail", typeof(string));
        dt.Columns.Add("GiftCards", typeof(int));
        dt.Columns.Add("Payments", typeof(int));
        dt.Columns.Add("Transactions", typeof(string));
        dt.Columns.Add("Created", typeof(DateTime));
        dt.Columns.Add("LastAccess", typeof(DateTime));

        foreach (MembershipUser user in allUsers)
        {
            //Guid userkey = (Guid) user.ProviderUserKey;
            string userkey_Email = user.UserName;
            string email = user.Email;
            string name = user.UserName;
            DateTime created = user.CreationDate;
            DateTime lastaccess = user.LastLoginDate;
            bool isCustomer = Roles.IsUserInRole(name,"customer");
            if (isCustomer && (email.Contains(filter) || name.Contains(filter)))
            {
                var giftcards = from gc in db.GiftCards where gc.EmailTo == userkey_Email select gc;
                var payments = from pm in db.Payments where pm.UserID == userkey_Email select pm;
                var transactions = from ts in db.Transactions where false select ts;
                int gcnum = 0;
                int pmnum = 0;
                int tsnum = 0;
                foreach (GiftCard gc in giftcards){
                    gcnum++;
                }
                foreach (Payment pm in payments){
                    pmnum++;
                }
                foreach (Transaction ts in transactions){
                    tsnum++;
                }

                DataRow tablerow = dt.NewRow();
                tablerow["UserName"] = name;
                tablerow["Created"] = created;
                tablerow["LastAccess"] = lastaccess;
                //tablerow["UserEmail"] = email;
                tablerow["GiftCards"] = gcnum;
                tablerow["Payments"] = pmnum;
                tablerow["Transactions"] = tsnum;

                dt.Rows.Add(tablerow);
            }
        }

        Session["dt"] = dt;
        GV.DataSource = dt;
        GV.AllowSorting = true;
        GV.AllowPaging = true;
        GV.PageSize = 50;
        //GV.Columns["Money"].ItemStyle.HorizontalAlign = HorizontalAlign.Right;
        GV.DataBind();
    }
    protected Decimal2_int1 Set_Table_Filtered_by_CUsers(int companyID, string filterUser)
    {
        DataTable dt;
        DataClassesAlbertDataContext db;

        db = new DataClassesAlbertDataContext();
        dt = new DataTable("Company Users");

        GoDine CS = new GoDine();
        CompanyStatus this_company_status = CS.CompanyStatus_from_CompanyID(companyID);

        decimal expensesTOT = this_company_status.TotalIn;
        decimal expensesTOTafterdisc = this_company_status.TotalInDiscounted;

        //var companies = db.Companies; // THIS IS A FULL TABLE ACQUISITION FROM DATABASE
        var Cusers = from cu in db.CUsers
                     where cu.CompanyID == companyID && cu.UserCode.Contains(filterUser)
                     select cu;
        ; // THIS IS A SELECTED TABLE ACQUISITION

        dt.Columns.Add("Employee Name", typeof(string));
        dt.Columns.Add("Total Gift $ Redeemed", typeof(decimal));
        dt.Columns.Add("Date Employee Added", typeof(DateTime));

        int numusers = 0;

        foreach (var cuser in Cusers)
        {
            DataRow tablerow = dt.NewRow();

            tablerow["Employee Name"] = cuser.UserCode;
            tablerow["Total Gift $ Redeemed"] = CS.Cuser_TotalIn_CuserID(cuser.CUserID).ToString("0.00");
            tablerow["Date Employee Added"] = cuser.Date;
            dt.Rows.Add(tablerow);
            numusers = numusers + 1;
        }

        Session["dt"] = dt;
        GV.DataSource = dt;
        GV.AllowSorting = true;
        GV.AllowPaging = true;
        GV.PageSize = 50;
        //GV.Columns["Money"].ItemStyle.HorizontalAlign = HorizontalAlign.Right;
        GV.DataBind();

        Company company = (from c in db.Companies where c.CompanyID == companyID select c).Single();
        compname.Text = company.Name;
        var giftcards = (from g in db.GiftCards where g.CompanyID == company.UserID.ToString() select g);
        decimal totalGiftcardSales = 0;
        decimal totalGiftcardSalesAfterComish = 0;
        foreach (var card in giftcards)
        {
            totalGiftcardSales += card.TotalIn;
            totalGiftcardSalesAfterComish += Math.Round((card.TotalIn * ((100 - card.SalesDealRate) / 100)),2);
        }

        Decimal2_int1 toreturn = new Decimal2_int1();
        toreturn.dec1 = expensesTOT;
        toreturn.dec2 = expensesTOTafterdisc;
        toreturn.num = numusers;
        toreturn.gcsalesDealRate = company.GCSaleDealRate;
        toreturn.giftcardSales = totalGiftcardSales;
        toreturn.giftcardSalesAfterComish = totalGiftcardSalesAfterComish;
        return toreturn;
    }
Example #19
0
 /////////////////////////////////////////////////////////////////////////// FOR COMPANY DEAL RATE
 protected void ddDealRate_SelectedIndexChanged(object sender, EventArgs e)
 {
     DataClassesAlbertDataContext db = new DataClassesAlbertDataContext();
     string strcompany = ddDealRate.Text;
     try {
         Company qry = (from c in db.Companies where c.Name == strcompany select c).Single();
         tbDealRate.Text = qry.DealRate.ToString("0.0000");
     }catch{
         tbDealRate.Text = "";
     }
 }
Example #20
0
    protected void Set_Table_Filtered(string filter)
    {
        DataClassesAlbertDataContext db;

        db = new DataClassesAlbertDataContext();

        /////////////////  FOR COMPANY DEAL RATES  AND  PAY AMOUNT
        var companies = from c in db.Companies where c.Name.Contains(filter) select c; // THIS IS A SELECTED TABLE ACQUISITION
        ddDealRate.Items.Clear();
        ddSalesDealRate.Items.Clear();
        ddPaidAmount.Items.Clear();
        ddcreategc.Items.Clear();
        ddpaymentUsr.Items.Clear();
        ddSalesPpl.Items.Clear();
        ddtransactionUsr.Items.Clear();
        ddDealRate.Items.Add("---company---");
        ddPaidAmount.Items.Add("---company---");
        ddCardDealRate.Items.Add("---company---");
        foreach (Company company in companies)
        {
            ddDealRate.Items.Add(company.Name);
            ddPaidAmount.Items.Add(company.Name);
            ddCardDealRate.Items.Add(company.Name);
        }

        /////////////////// Sellers

        var sellers = from sl in db.SalesIDs select sl;
        ddSalesPpl.Items.Add("---sellers---");
        ddSalesDealRate.Items.Add("---sellers---");
        foreach (SalesID slid in sellers){
            String username = Membership.GetUser(slid.UserID).UserName;
            ddSalesPpl.Items.Add(username);
            ddSalesDealRate.Items.Add(username);
        }

        /////////////////// USERS
        //var customerlist = Roles.GetUsersInRole("customer");
        var customerlist = from gc in db.GiftCards where gc.EmailTo.Contains(filter) select gc.EmailTo;
        ddcreategc.Items.Add("---unknown---");
        ddpaymentUsr.Items.Add("---unknown---");
        ddtransactionUsr.Items.Add("---unknown---");
        foreach (string username in customerlist) {
            if (username.Contains("@")) {
                ddcreategc.Items.Add(username);
                ddpaymentUsr.Items.Add(username);
                ddtransactionUsr.Items.Add(username);
            }
        }

        ////////////////// Company Users
        ddtransactionCUser.Items.Clear();
        ddtransactionCUser.Items.Add("--- company user ---");
        var cusercodelist = from cu in db.CUsers where cu.UserCode.Contains(filter) select cu.UserCode;
        foreach (string cusercode in cusercodelist) {
            ddtransactionCUser.Items.Add(cusercode);
        }
        /////////////////// Gift cards
        try // used to supress leading zeros on the left
        {
            long filternum = Convert.ToInt64(filter);
            filter = filternum.ToString();
        }
        catch {
        }
        ddpaymentID.Items.Clear();
        ddtransactionID.Items.Clear();
        var barcodelist = from gc in db.GiftCards where gc.BarCode.ToString().Contains(filter) select gc.BarCode;
        foreach (long barcode in barcodelist)
        {
            string gcstr;
            gcstr = UTILITIES.appendChecksum(barcode);
            ddpaymentID.Items.Add(gcstr);
            ddtransactionID.Items.Add(gcstr);
        }
    }
    protected void Load_Presets_From_GC(long GCnum)
    {
        DataClassesAlbertDataContext db = new DataClassesAlbertDataContext();
        try
        {
            GiftCard GCqry = (from gc in db.GiftCards where gc.BarCode == GCnum && gc.TotalIn == 0 select gc).Single();
            fromName.Text = GCqry.NameFrom;
            fromEmail.Text = GCqry.EmailFrom;
            confirmFromEmail.Text = GCqry.EmailFrom;
            toName.Text = GCqry.NameTo;
            toEmail.Text = GCqry.EmailTo;
            confirmToEmail.Text = GCqry.EmailTo;
            char[] removechars = new char[2] { ' ', '$' };
            value.Text = GCqry.GCValue.ToString("0.00");
            message.Value = GCqry.GCText;
            //cbDisplayNames.Checked = true;
            if (GCqry.DisplayName == 1)
            {
                cbDisplayNames.Checked = true;
            }
            else
            {
                cbDisplayNames.Checked = false;
            }

            if (GCqry.MODE.Contains("EMAIL"))
            {
                rbChoice.SelectedIndex = 0;
            }
            else if (GCqry.MODE.Contains("PRINT"))
            {
                rbChoice.SelectedIndex = 1;
                toEmail.Enabled = false;
                confirmToEmail.Enabled = false;
                disableFrom.Style["block"] = "none";
                disableFrom.Style["display"] = "none";
            }

            verifyAll();
        }
        catch(Exception e)
        {
            log.Error("Error loading Gift Card details on BuyGiftCard", e);
        }
    }
Example #22
0
 protected void btnPaidSalesAmount_Click(object sender, EventArgs e)
 {
     DataClassesAlbertDataContext db = new DataClassesAlbertDataContext();
     GoDine a = new GoDine();
     try
     {
         decimal amount = Convert.ToDecimal(tbPaidSalesAmount.Text);
         Guid userId = a.UserName_2_Guid(ddSalesPpl.SelectedValue);
         SalesID seller = (from s in db.SalesIDs where s.UserID == userId select s).Single();
         string concept = tbPaidSalesAmountConcept.Text;
         if (a.Pay_Amount_to_Seller(amount, seller.SellerID, concept) == 0)
         {
             lblPaidSalesAmount.Text = "OK -> Seller " + ddSalesPpl.SelectedValue + " received " + amount.ToString();
             tbPaidSalesAmount.Text = "";
         }
         else
         {
             lblPaidSalesAmount.Text = "Error -> Seller " + ddSalesPpl.SelectedValue + " did not 'get paid' Have Lana Check the logs for details :P";
         };
     }
     catch
     {
         lblPaidSalesAmount.Text = "Error -> Input value must be a number.";
     }
 }
Example #23
0
 protected void ddtransactionID_SelectedIndexChanged(object sender, EventArgs e)
 {
     DataClassesAlbertDataContext db = new DataClassesAlbertDataContext();
     long barcode = Convert.ToInt64(ddtransactionID.SelectedValue);
     barcode = UTILITIES.removeCheckSum(barcode);
     decimal moneyLeft = (from gc in db.GiftCards where gc.BarCode == barcode select gc.Money).Single();
     lbltransaction.Text = "The selected gift card has " + moneyLeft.ToString() + " dollars left";
 }
Example #24
0
 /////////////////////////////////////////////////////////////////////////// FOR SELLER DEAL RATE
 protected void ddSalesDealRate_SelectedIndexChanged(object sender, EventArgs e)
 {
     DataClassesAlbertDataContext db = new DataClassesAlbertDataContext();
     string Seller = ddSalesDealRate.Text;
     GoDine a = new GoDine();
     if (!(ddSalesDealRate.SelectedValue.Contains("---sellers---")))
     {
         Guid UserID = a.UserName_2_Guid(ddSalesDealRate.SelectedValue);
         Guid SellerID = a.getSellerFromUser(UserID).SellerID;
         decimal rate = a.getDealRateForSellerID(SellerID);
         tbSalesDealRate.Text = rate.ToString("0.00");
     }
     else
     {
         tbSalesDealRate.Text = "";
     }
 }
    protected void Set_Transactions_Filtered_by_CUsers(int companyID, string filterUser)
    {
        DataTable dt;
        DataClassesAlbertDataContext db;

        db = new DataClassesAlbertDataContext();
        dt = new DataTable("Transactions");
        //var companies = db.Companies; // THIS IS A FULL TABLE ACQUISITION FROM DATABASE
        var transactions = from t in db.Transactions select t; // THIS IS A SELECTED TABLE ACQUISITION
        var cusers = from cu in db.CUsers where cu.CompanyID == companyID && cu.UserCode.Contains(filterUser) select cu.CUserID;

        //dt.Columns.Add("CUserID", typeof(int));
        dt.Columns.Add("CUserCode", typeof(string));
        dt.Columns.Add("$Amount", typeof(string));
        //dt.Columns.Add("%DealRate", typeof(decimal));
        dt.Columns.Add("Notes", typeof(string));
        dt.Columns.Add("Date", typeof(DateTime));

        foreach (Transaction transaction in transactions)
        {
            bool allow_plot = false;
            foreach (int cuserID in cusers) {
                if (transaction.CUserID == cuserID){
                    allow_plot = true;
                    break;
                }

            }
            if (allow_plot)
            {
                DataRow tablerow = dt.NewRow();
                tablerow["CUserCode"] = transaction.CUser.UserCode;
                tablerow["$Amount"] = transaction.Amount.ToString("0.00");
                //tablerow["%DealRate"] = transaction.DealRate;
                tablerow["Notes"] = transaction.Concept;
                tablerow["Date"] = transaction.Date;

                dt.Rows.Add(tablerow);
            }
        }

        Session["dt"] = dt;
        GV.DataSource = dt;
        GV.AllowSorting = true;
        GV.AllowPaging = true;
        GV.PageSize = 50;
        //GV.Columns["Money"].ItemStyle.HorizontalAlign = HorizontalAlign.Right;
        GV.DataBind();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //Response.Redirect("google.ca");
            /*string filterCompany = Request.QueryString["Company"];
            string filterUser = Request.QueryString["CUser"];

            if (filterCompany == null)
            {
                filterCompany = "";
            }
            if (filterUser == null)
            {
                filterUser = "";
            }
            TextBox1.Text = filterUser;*/
            DataClassesAlbertDataContext db;
            db = new DataClassesAlbertDataContext();
            GoDine a = new GoDine();

            MembershipUser user = Membership.GetUser();
            Guid userID = (Guid) user.ProviderUserKey;
            var company = (from c in db.Companies where c.UserID == userID select c).Single();
            Decimal2_int1 info = Set_Table_Filtered_by_CUsers(company.CompanyID, "");
            decimal paid = a.Paid_FromCompanyPaymentHist(company.CompanyID);

            LabelTitle.Text = company.Name;
            lblincome.Text = "$" + info.dec1.ToString("0.00");
            lblgcincome.Text = "$" + info.giftcardSales.ToString("0.00");
            lblincomeafter.Text = "$" + info.dec2.ToString("0.00");
            lblgcincomeafter.Text = "$" + info.giftcardSalesAfterComish.ToString("0.00");
            lbldealrate.Text = "% " + company.DealRate.ToString("G29");
            lblgcdealrate.Text = "%" + info.gcsalesDealRate.ToString("G29");
            lblalreadypaid.Text = "$" + paid.ToString("0.00");
            lbltopay.Text = "$" + (info.dec2 + info.giftcardSalesAfterComish - paid).ToString("0.00");
            lblnumusers.Text = info.num.ToString();

        }
    }
Example #27
0
    protected void ExecuteCalculs()
    {
        DataTable dt;
        DataClassesAlbertDataContext db;

        db = new DataClassesAlbertDataContext();
        var companies = db.Companies;
        var CUsers = db.CUsers;
        var giftcards = db.GiftCards;
        var payments = db.Payments;
        var transactions = db.Transactions;

        var totalpaidtocompanies = from c in db.CompanyPayHists where c.IsACompany == true select c.Amount;
        var totalspentbyCustomersB = from tr in db.Transactions
                                     join gc in db.GiftCards on tr.GiftCardID equals gc.GiftCardID
                                     where (gc.CompanyID == "00000000-0000-0000-0000-000000000000" || gc.CompanyID == "")
                                     select tr.Amount;
        var totalspentbyCustomersAfterDiscountB = from t in db.Transactions
                                                  join gc in db.GiftCards on t.GiftCardID equals gc.GiftCardID
                                                  where (gc.CompanyID == "00000000-0000-0000-0000-000000000000" || gc.CompanyID == "")
                                                  where gc.CompanyID != ""
                                                  select Math.Round((t.Amount * (1-t.DealRate/100)),2, MidpointRounding.ToEven);

        var totalLeftOngiftcards = from gc in db.GiftCards
                                   where (gc.CompanyID == "00000000-0000-0000-0000-000000000000" || gc.CompanyID == "")
                                   where gc.TotalIn != 0
                                   where gc.CompanyID != "" select gc.Money ;

        var totalPaidbyCustomersA = from p in db.Payments
                                    join gc in db.GiftCards on p.GiftCardID equals gc.GiftCardID
                                    where (gc.CompanyID == "00000000-0000-0000-0000-000000000000" || gc.CompanyID == "")
                                    where gc.TotalIn != 0
                                    where gc.MODE != "IT TYPE" select p.Amount;

        var totalPaidbyCustomersB = from p in db.Payments
                                    join gc in db.GiftCards on p.GiftCardID equals gc.GiftCardID
                                    where (gc.CompanyID == "00000000-0000-0000-0000-000000000000" || gc.CompanyID == "")
                                    where gc.TotalIn != 0
                                    where gc.MODE != "IT TYPE"
                                    select p.AmountReceived;

        var totalPutOnCompanyCards = from g in db.GiftCards
                                     where g.CompanyID != "00000000-0000-0000-0000-000000000000"
                                     where g.CompanyID != ""
                                     where g.TotalIn != 0
                                     where g.SalesDealRate != 0
                                     select g.TotalIn;

        var totalMadeOffCompanyCards = from g in db.GiftCards
                                       where g.CompanyID != "00000000-0000-0000-0000-000000000000"
                                       where g.CompanyID != ""
                                       where g.TotalIn != 0
                                       where g.SalesDealRate != 0
                                       select Math.Round((g.TotalIn * (g.SalesDealRate/100)),2,MidpointRounding.ToEven);

        var paypallTakenFromCompanyCards = from p in db.Payments
                                           join gc in db.GiftCards on p.GiftCardID equals gc.GiftCardID
                                           where gc.CompanyID != "00000000-0000-0000-0000-000000000000"
                                           where gc.CompanyID != ""
                                           where gc.TotalIn != 0
                                           where gc.SalesDealRate != 0
                                           select (p.Amount - p.AmountReceived);

        var totalOwedFromCompanyCards = from g in db.GiftCards
                                       where g.CompanyID != "00000000-0000-0000-0000-000000000000"
                                       where g.CompanyID != ""
                                       where g.TotalIn != 0
                                       where g.SalesDealRate != 0
                                       select Math.Round((g.TotalIn * ((100 - g.SalesDealRate)/100)),2,MidpointRounding.ToEven);

        decimal CreditCard_Rate = 3;

        decimal totaltopaytocompany;
        decimal totalbenefits;
        decimal totalnotbelongingtogodine;
        try { totaltopaytocompany = (decimal)totalspentbyCustomersAfterDiscountB.Sum() - (decimal)totalpaidtocompanies.Sum(); }
        catch { totaltopaytocompany = 0; }

        try { totalbenefits = (decimal) totalspentbyCustomersB.Sum() * (1 - CreditCard_Rate / 100) - (decimal) totalspentbyCustomersAfterDiscountB.Sum();}
        catch { totalbenefits = 0; }

        dt = new DataTable("Companies");

        dt.Columns.Add("ID", typeof(string));
        dt.Columns.Add("Description", typeof(string));
        dt.Columns.Add("Amount", typeof(string));

        DataRow tablerow;

        try
        {
            tablerow = dt.NewRow();
            tablerow["ID"] = "A";
            tablerow["Description"] = "Total money spent by customers (transactions)";
            try
            {
                tablerow["Amount"] = Math.Round(totalspentbyCustomersB.Sum(), 2) + "(Only from AT giftcards)";
            }catch
            {
                tablerow["Amount"] = "0.00";
            }
            dt.Rows.Add(tablerow);
            tablerow = dt.NewRow();
            tablerow["ID"] = "B";
            tablerow["Description"] = "Total money remaining on AT gift cards";
            try{
                tablerow["Amount"] = Math.Round(totalLeftOngiftcards.Sum(),2) + "(includes IT types)";
            }catch
            {
                tablerow["Amount"] ="0.00";
            }

            dt.Rows.Add(tablerow);
            tablerow = dt.NewRow();
            tablerow["ID"] = "C";
            tablerow["Description"] = "Total monney put on AT giftcards.";
            try{
                tablerow["Amount"] = Math.Round(totalPaidbyCustomersA.Sum(), 2) + "(" + Math.Round(totalPaidbyCustomersB.Sum(), 2) + " after paypall fees, neither include IT types)";
            }catch
            {
                tablerow["Amount"] ="0.00";
            }

            dt.Rows.Add(tablerow);
            tablerow = dt.NewRow();
            tablerow["ID"] = "D";
            tablerow["Description"] = "Total money Put Onto Company Cards";
            try{
                tablerow["Amount"] = Math.Round(totalPutOnCompanyCards.Sum(), 2);
            }catch
            {
                tablerow["Amount"] ="0.00";
            }

            dt.Rows.Add(tablerow);
            tablerow = dt.NewRow();
            tablerow["ID"] = "E";
            tablerow["Description"] = "Total money Made off of Company Cards";
            try
            {
                tablerow["Amount"] = Math.Round(totalMadeOffCompanyCards.Sum() - paypallTakenFromCompanyCards.Sum(), 2) + "(Commision - Paypall fees)";
            }
            catch
            {
                tablerow["Amount"] = "0.00";
            }

            dt.Rows.Add(tablerow);
            tablerow = dt.NewRow();
            tablerow["ID"] = "";
            tablerow["Description"] = "F + G - H = I";
            tablerow["Amount"] = "";
            dt.Rows.Add(tablerow);
        }
        catch(Exception e) {
            Label2.Text = e.Message;
        }

        try
        {
            tablerow = dt.NewRow();
            tablerow["ID"] = "F";
            tablerow["Description"] = "Total made by companies from AT redemptions.";
            tablerow["Amount"] = Math.Round(totalspentbyCustomersAfterDiscountB.Sum(), 2);
            dt.Rows.Add(tablerow);
        }catch{}
        try{
            tablerow = dt.NewRow();
            tablerow["ID"] = "G";
            tablerow["Description"] = "Total made by companies for company GC";
            tablerow["Amount"] = Math.Round(totalOwedFromCompanyCards.Sum(),2);
            dt.Rows.Add(tablerow);
        }
        catch {
        }
        try{
            tablerow = dt.NewRow();
            tablerow["ID"] = "H";
            tablerow["Description"] = "Total money paid to companies";
            tablerow["Amount"] = Math.Round(totalpaidtocompanies.Sum(),2);
            dt.Rows.Add(tablerow);
        }
        catch{
        }
        try
        {
            tablerow = dt.NewRow();
            tablerow["ID"] = "I";
            tablerow["Description"] = "Remaining to pay companies";
            tablerow["Amount"] = (Math.Round(totalspentbyCustomersAfterDiscountB.Sum(), 2) + Math.Round(totalOwedFromCompanyCards.Sum(), 2) - Math.Round(totalpaidtocompanies.Sum(),2));
            dt.Rows.Add(tablerow);
        }
        catch
        {
        }

        ////////////////////
        Label1.Text = "Current number of users online " + Membership.GetNumberOfUsersOnline().ToString();

        Session["dt"] = dt;
        GV.DataSource = dt;
        GV.AllowSorting = false;
        GV.AllowPaging = false;
        //GV.PageSize = 50;
        //GV.Columns["Money"].ItemStyle.HorizontalAlign = HorizontalAlign.Right;
        GV.DataBind();
    }
    protected void Set_Table_Filtered(string filter, string filterIDstr)
    {
        DataTable dt;
        DataClassesAlbertDataContext db;
        GoDine a;

        db = new DataClassesAlbertDataContext();
        dt = new DataTable("GiftCards");
        a = new GoDine();

        dt.Columns.Add("BarCode", typeof(string));
        dt.Columns.Add("UserName", typeof(string));
        dt.Columns.Add("$TotalIn", typeof(decimal));
        dt.Columns.Add("$MoneyLeft", typeof(decimal));
        dt.Columns.Add("%SaleDealRate", typeof(decimal));
        dt.Columns.Add("Company", typeof(string));
        dt.Columns.Add("Seller", typeof(string));
        dt.Columns.Add("Forced", typeof(bool));
        dt.Columns.Add("CreationDate", typeof(DateTime));
        dt.Columns.Add("Mode", typeof(string));
        dt.Columns.Add("EmailFrom", typeof(string));

        if (filterIDstr == "It's a sales filter" || filterIDstr == "It's a company filter")
        {
            var giftcards = from c in db.GiftCards select c;
            if (filterIDstr == "It's a company filter")
            {
                giftcards = from c in db.GiftCards where c.CompanyID == filter select c; // THIS IS A SELECTED TABLE ACQUISITION
            }
            else
            {
                giftcards = from c in db.GiftCards where c.SellerID == filter select c; // THIS IS A SELECTED TABLE ACQUISITION
            }

            foreach (GiftCard giftcard in giftcards)
            {
                GiftCardExtras extra = a.getExtraFieldsFor(giftcard);
                string giftcard_userkey = giftcard.EmailTo;
                    DataRow tablerow = dt.NewRow();
                    tablerow["UserName"] = giftcard_userkey;
                    tablerow["$TotalIn"] = giftcard.TotalIn;
                    tablerow["$MoneyLeft"] = giftcard.Money;
                    tablerow["%SaleDealRate"] = giftcard.SalesDealRate;
                    tablerow["Company"] = extra.compName;
                    tablerow["Seller"] = extra.salesPerson;
                    tablerow["BarCode"] = UTILITIES.appendChecksum(giftcard.BarCode);
                    tablerow["Forced"] = giftcard.Forced;
                    tablerow["CreationDate"] = giftcard.Date;
                    tablerow["Mode"] = giftcard.MODE;
                    tablerow["EmailFrom"] = giftcard.EmailFrom;
                    dt.Rows.Add(tablerow);
            }
        }
        else
        {
            var giftcards = from c in db.GiftCards select c; // THIS IS A SELECTED TABLE ACQUISITION
            foreach (GiftCard giftcard in giftcards)
            {
                GiftCardExtras extra = a.getExtraFieldsFor(giftcard);
                string giftcard_userkey = giftcard.EmailTo;
                //MembershipUser memberi = Membership.GetUser(userkey_email);
                if (((filterIDstr == null) && (giftcard_userkey.Contains(filter) || giftcard_userkey.Contains(filter))) || filterIDstr == giftcard.GiftCardID.ToString())
                {
                    DataRow tablerow = dt.NewRow();
                    tablerow["UserName"] = giftcard_userkey;
                    tablerow["$TotalIn"] = giftcard.TotalIn;
                    tablerow["$MoneyLeft"] = giftcard.Money;
                    tablerow["%SaleDealRate"] = giftcard.SalesDealRate;
                    tablerow["Company"] = extra.compName;
                    tablerow["Seller"] = extra.salesPerson;
                    tablerow["BarCode"] = UTILITIES.appendChecksum(giftcard.BarCode);
                    tablerow["Forced"] = giftcard.Forced;
                    tablerow["CreationDate"] = giftcard.Date;
                    tablerow["Mode"] = giftcard.MODE;
                    tablerow["EmailFrom"] = giftcard.EmailFrom;
                    dt.Rows.Add(tablerow);
                }
            }
        }

        Session["dt"] = dt;
        GV.DataSource = dt;
        GV.AllowSorting = true;
        GV.AllowPaging = true;
        GV.PageSize = 1000000;
        //GV.Columns["Money"].ItemStyle.HorizontalAlign = HorizontalAlign.Right;
        GV.DataBind();
    }
Example #29
0
 ////////////////////////////////////////////////////////////////////////////////////////////  TRANSACTION
 protected void ddtransactionUsr_SelectedIndexChanged(object sender, EventArgs e)
 {
     ddtransactionID.Items.Clear();
     DataClassesAlbertDataContext db = new DataClassesAlbertDataContext();
     GoDine a = new GoDine();
     //Guid idCustomer = a.UserName_2_Guid(ddtransactionUsr.SelectedValue);
     if (!ddtransactionUsr.SelectedValue.Contains("---"))
     {
         string idCustomer_email = ddtransactionUsr.SelectedValue;
         var barcodes = from gc in db.GiftCards where gc.EmailTo == idCustomer_email select gc.BarCode;
         int number_of_gc = 0;
         foreach (long barcode in barcodes)
         {
             ddtransactionID.Items.Add(UTILITIES.appendChecksum(barcode));
             number_of_gc = number_of_gc + 1;
         }
         if (number_of_gc > 0)
         {
             ddtransactionID_SelectedIndexChanged(null, null);
         }
         else
         {
             lbltransaction.Text = "This user has not any gift card";
         }
     }
     else
     {
         string idCustomer_email = ddtransactionUsr.SelectedValue;
         var barcodes = from gc in db.GiftCards select gc.BarCode;
         int number_of_gc = 0;
         foreach (long barcode in barcodes)
         {
             ddtransactionID.Items.Add(UTILITIES.appendChecksum(barcode));
             number_of_gc = number_of_gc + 1;
         }
         if (number_of_gc > 0)
         {
             ddtransactionID_SelectedIndexChanged(null, null);
         }
     }
 }
Example #30
0
 protected void btnSalesDealRate_Click(object sender, EventArgs e)
 {
     decimal number = -1;
     string num = tbSalesDealRate.Text;
     GoDine a = new GoDine();
     string username = ddSalesDealRate.SelectedValue;
     if (!username.Contains("---sellers---"))
     {
         number = Convert.ToDecimal(num);
         if (number >= 0 && number <= 100)
         {
             DataClassesAlbertDataContext db = new DataClassesAlbertDataContext();
             SalesID qry = (from s in db.SalesIDs where s.UserID == a.UserName_2_Guid(username) select s).Single();
             //Company qry = qry.Single(); // if we do not insert the fist single
             qry.DealRate = number;
             db.SubmitChanges();
             lblSalesDealRate.Text = "OK -> Deal Rate set to " + number.ToString() + " % for seller " + username;
             tbSalesDealRate.Text = number.ToString();
         }
         else
         {
             lblSalesDealRate.Text = "ERROR -> Entered value must be an integer between 1 and 99 for company " + username;
         }
     }
     else
     {
         lblSalesDealRate.Text = "Please select a seller.";
     }
 }