示例#1
0
    protected string CCPayments(Int32 JobRno)
    {
        string Html = string.Empty;
        string Sql  = string.Format("Select * From Payments Where JobRno = {0} Order By Seq", JobRno);

        try
        {
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                string CCNum   = DB.Str(dr["CCNum"]);
                string SecCode = DB.Str(dr["CCSecCode"]);

                try
                {
                    CCNum = Crypt.Decrypt(CCNum, Misc.Password);
                }
                catch (Exception)
                {
                }

                try
                {
                    SecCode = Crypt.Decrypt(SecCode, Misc.Password);
                }
                catch (Exception)
                {
                }

                if (CCNum.Length > 0)
                {
                    string CardInfo = string.Format(
                        "<dl>\n" +
                        "<dt>Amount</dt><dd class=\"mid\">{1}</dd>\n" +
                        "<dt>Card Type</dt><dd>{0}</dd>\n" +
                        "</dl>",
                        DB.Str(dr["CCType"]),
                        Fmt.Dollar(DB.Dec(dr["Amount"])));
                    Html += string.Format(
                        "<tr><td colspan=\"11\" class=\"nil\" /></tr>\n" +
                        "<tr>\n" +
                        "<td colspan=\"2\" />\n" +
                        "<td colspan=\"7\">{0}</td>\n" +
                        "</tr>\n",
                        CardInfo);
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex);
            Response.Write(Err.Html());
        }

        return(Html);
    }
示例#2
0
    private void PriceHistory(int IngredRno)
    {
        string Sql = string.Format(
            "Select Top 15 p.PurchaseRno, d.PurchaseDetailRno, p.PurchaseDt, v.Name, d.PurchaseQty, d.PurchaseUnitQty, u.UnitSingle, u.UnitPlural, Price\n " +
            "From PurchaseDetails d\n " +
            "Inner Join Purchases p On p.PurchaseRno = d.PurchaseRno\n " +
            "Inner Join Vendors v On v.VendorRno = p.VendorRno\n " +
            "Inner Join Units u On u.UnitRno = d.PurchaseUnitRno\n " +
            "Where IngredRno = {0}\n " +
            "Order By PurchaseDt Desc",
            IngredRno);

        try
        {
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                decimal  PurchaseQty     = DB.Dec(dr["PurchaseQty"]);
                decimal  PurchaseUnitQty = DB.Dec(dr["PurchaseUnitQty"]);
                decimal  Price           = DB.Dec(dr["Price"]);
                TableRow tr = new TableRow();
                tr.Cells.Add(new TableCell());
                tr.Cells.Add(new TableCell()
                {
                    Text = Fmt.Dt(DB.DtTm(dr["PurchaseDt"]))
                });
                tr.Cells.Add(new TableCell()
                {
                    Text = DB.Str(dr["Name"])
                });
                tr.Cells.Add(new TableCell()
                {
                    Text = Str.ShowFract(PurchaseQty), CssClass = "Qty"
                });
                tr.Cells.Add(new TableCell()
                {
                    Text = string.Format("{0} {1}", Str.ShowFract(PurchaseUnitQty), DB.Str(dr[PurchaseUnitQty <= 1 ? "UnitSingle" : "UnitPlural"]))
                });
                tr.Cells.Add(new TableCell()
                {
                    Text = Fmt.Dollar(Price), CssClass = "Price"
                });
                tr.Cells.Add(new TableCell()
                {
                    Text = Fmt.Dollar(Math.Round((PurchaseQty != 0 ? Price / PurchaseQty : 0), 2)), CssClass = "Price"
                });
                tblPrices.Rows.Add(tr);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
示例#3
0
    private void JobInfo()
    {
        string Sql =
            "Select j.NumMenServing, j.NumWomenServing, j.NumChildServing, j.Status, j.EventType, j.ServiceType, j.Location, " +
            "j.PrintDirectionsFlg, j.LocationDirections, j.JobDate, j.MealTime, j.ArrivalTime, j.DepartureTime, j.PricePerPerson, " +
            "j.JobNotes, j." +
            "cu.Name as Customer, c.Name, c.Phone, c.Cell, c.Fax, c.Email, " +
            "From mcJobs j " +
            "Left Join Contacts c on j.ContactRno = c.ContactRno " +
            "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
            "Where JobRno = " + JobRno;

        try
        {
            DataTable dt = db.DataTable(Sql);
            DataRow   r  = dt.Rows[0];

            Int32 cMen   = DB.Int32(r["NumMenServing"]);
            Int32 cWomen = DB.Int32(r["NumWomenServing"]);
            Int32 cChild = DB.Int32(r["NumChildServing"]);

            lblPrinted.Text   = String.Format("{0}", DateTime.Now);
            lblJobRno.Text    = JobRno.ToString();
            lblStatus.Text    = DB.Str(r["Status"]);
            lblCustomer.Text  = DB.Str(r["Customer"]);
            lblName.Text      = DB.Str(r["Name"]);
            lblPhone.Text     = DB.Str(r["Phone"]);
            lblCell.Text      = DB.Str(r["Cell"]);
            lblFax.Text       = DB.Str(r["Fax"]);
            lblEmail.Text     = DB.Str(r["Email"]);
            lblEventType.Text = DB.Str(r["EventType"]);
            lblServType.Text  = DB.Str(r["ServiceType"]);
            lblLocation.Text  = DB.Str(r["Location"]);
            if (DB.Bool(r["PrintDirectionsFlg"]))
            {
                lblDirections.Text = DB.Str(r["LocationDirections"]).Replace("\n", "<br>");
            }
            lblJobDate.Text         = Fmt.Dt(DB.DtTm(r["JobDate"]));
            lblMealTime.Text        = Fmt.Tm12Hr(DB.DtTm(r["MealTime"]));
            lblArrivalTime.Text     = Fmt.Tm12Hr(DB.DtTm(r["ArrivalTime"]));
            lblDepartureTime.Text   = Fmt.Tm12Hr(DB.DtTm(r["DepartureTime"]));
            lblNumServing.Text      = Fmt.Num(cMen + cWomen + cChild);
            lblNumMenServing.Text   = Fmt.Num(cMen);
            lblNumWomenServing.Text = Fmt.Num(cWomen);
            lblNumChildServing.Text = Fmt.Num(cChild);
            lblPricePerPerson.Text  = Fmt.Dollar(DB.Dec(r["PricePerPerson"]), false);
            lblJobNotes.Text        = DB.Str(r["JobNotes"]);
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
示例#4
0
    //protected string CCPayment(DataRow dr, string PmtNum)
    protected string CCPayment(DataRow dr)
    {
        string Html = string.Empty;

        try
        {
            string CCNum   = DB.Str(dr["CCNum"]);     // + PmtNum]);
            string SecCode = DB.Str(dr["CCSecCode"]); // + PmtNum]);

            try
            {
                CCNum = Crypt.Decrypt(CCNum, Misc.Password);
            }
            catch (Exception)
            {
            }

            try
            {
                SecCode = Crypt.Decrypt(SecCode, Misc.Password);
            }
            catch (Exception)
            {
            }

            if (CCNum.Length > 0)
            {
                string CardInfo = string.Format(
                    "<dl>\n" +
                    "<dt>Amount</dt><dd class=\"mid\">{1}</dd>\n" +
                    "<dt>Card Type</dt><dd>{0}</dd>\n" +
                    "</dl>",
                    DB.Str(dr["CCType"]),
                    Fmt.Dollar(DB.Dec(dr["Amount"])));
                Html += string.Format(
                    "<tr><td colspan=\"11\" class=\"nil\" /></tr>\n" +
                    "<tr>\n" +
                    "<td colspan=\"2\" />\n" +
                    "<td colspan=\"7\">{0}</td>\n" +
                    "</tr>\n",
                    CardInfo);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex);
            Response.Write(Err.Html());
        }

        return(Html);
    }
示例#5
0
    protected string Jobs()
    {
        string Html = string.Empty;
        string Sql  = string.Empty;

        try
        {
            decimal RptTotal        = 0;
            decimal RptTotalBalance = 0;

            int iRow = 0;

            DateTime PrevDay   = DateTime.MinValue;
            bool     fFirstDay = true;

            string Where = "JobDate <= GetDate() and InvBalAmt > 0 and PaidInFullDtTm is null and IsNull(ProposalFlg, 0) = 0 and CancelledDtTm is null";
            Sql = "Select *, Coalesce(cu.Name, c.Name) as Customer " +
                  "From mcJobs j " +
                  "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
                  "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
                  "Where " + Where + " " +
                  "Order By JobDate, JobRno";
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                InvoiceAmounts(dr);

                DateTime JobDate       = DB.DtTm(dr["JobDate"]);
                string   Customer      = DB.Str(dr["Customer"]);
                DateTime?Final         = DB.DtTm(dr["FinalDtTm"]);
                DateTime?Processed     = DB.DtTm(dr["ProcessedDtTm"]);
                DateTime?EditProcessed = DB.DtTm(dr["EditProcessedDtTm"]);
                DateTime?Updated       = DB.DtTm(dr["InvUpdatedDtTm"]);

                if (Updated.HasValue && Updated.Value == DateTime.MinValue)
                {
                    Updated = null;
                }

                bool   fUpdated = false;
                string Title    = string.Empty;

                if (JobDate != PrevDay)
                {
                    if (!fFirstDay)
                    {
                        //Html += "\t\t</tbody>\n\t</table>\n";
                        Html += "\t\t</tbody>\n";
                    }
                    Html += string.Format(
                        //"<div class=\"FeatureSub\">{0:M/d/yyyy}</div>\n" +
                        //"\t<table class=\"Acct\">\n" +
                        "\t\t<thead>\n" +
                        "\t\t\t<tr><td colspan=\"10\"><div class=\"FeatureSub\">{0:M/d/yyyy}</div></td></tr>\n" +
                        "\t\t\t<tr>\n" +
                        "\t\t\t\t<th>Paid</th>\n" +
                        "\t\t\t\t<th style=\"white-space: nowrap;\">Inv #</th>\n" +
                        "\t\t\t\t<th>Name</th>\n" +
                        "\t\t\t\t<th>Date</th>\n" +
                        "\t\t\t\t<th>Location</th>\n" +
                        "\t\t\t\t<th>Subtotal</th>\n" +
                        "\t\t\t\t<th>Other</th>\n" +
                        "\t\t\t\t<th>Tax</th>\n" +
                        "\t\t\t\t<th>Total</th>\n" +
                        "\t\t\t\t<th>Balance</th>\n" +
                        "\t\t\t</tr>\n" +
                        "\t\t</thead>\n" +
                        "\t\t</tbody>\n",
                        JobDate
                        );
                    PrevDay   = JobDate;
                    fFirstDay = false;
                }

                Html += string.Format(
                    "<tr class=\"{12}\">\n" +
                    "<td class=\"Center\"><input type=\"checkbox\" name=\"chkProc{0}\" value=\"{2}\" /></td>\n" +
                    "<td class=\"Right\" title=\"{13}\">{11}<a href=\"Invoice.aspx?JobRno={2}\" target=\"invoice\">{2}</a></td>\n" +
                    "<td>{3}</td>\n" +
                    "<td class=\"Center\">{4}</td>\n" +
                    "<td>{5}</td>\n" +
                    "<td class=\"Right\">{6}</td>\n" +
                    "<td class=\"Right\">{7}</td>\n" +
                    "<td class=\"Right\">{8}</td>\n" +
                    "<td class=\"Right\">{9}</td>\n" +
                    "<td class=\"Right\">{10}</td>\n" +
                    "</tr>\n",
                    ++iRow,
                    "",
                    DB.Int32(dr["JobRno"]),
                    DB.Str(dr["Customer"]),
                    Fmt.Dt(DB.DtTm(dr["JobDate"])),
                    DB.Str(dr["Location"]),
                    Fmt.Dollar(Subtotal),
                    Fmt.Dollar(OtherTotal),
                    Fmt.Dollar(SalesTaxTotal),
                    Fmt.Dollar(Total),
                    Fmt.Dollar(Balance),
                    (fUpdated ? "*" : ""),
                    (fUpdated ? "Updated" : ""),
                    Title);
                RptTotal        += Math.Round(Total, 2);
                RptTotalBalance += Math.Round(Balance, 2);
            }

            Html += string.Format(
                "<tr>\n" +
                "<td><input type=\"hidden\" name=\"{0}Count\" value=\"{1}\"/></td>\n" +
                //"<td colspan=\"2\"><span style='color: Red;'>*</span><span style='font-size: 80%'>Updated</span></td>\n" +
                "<td colspan=\"2\"></td>\n" +
                "<td colspan=\"2\"></td>\n" +
                "<td align=\"right\"><b>Count</b></td>\n" +
                "<td align=\"right\"><b>{2}</b></td>\n" +
                "<td align=\"right\"><b>Total</b></td>\n" +
                "<td align=\"right\"><b>{3}</b></td>\n" +
                "<td align=\"right\"><b>{4}</b></td>\n" +
                "</tr>\n",
                "",
                iRow,
                dt.Rows.Count,
                Fmt.Dollar(RptTotal),
                Fmt.Dollar(RptTotalBalance));
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        return(Html);
    }
示例#6
0
    private void ProcessReport()
    {
        decimal DiffPct = Str.Dec(txtDiffPct.Text);

        string Sql = "Update Settings Set QuoteDiffPct = " + DiffPct.ToString();

        try
        {
            db.Exec(Sql);

            Sql =
                "Select m.MenuItemRno, m.Category, m.MenuItem, m.ServingQuote, m.ServingPrice, m.InaccuratePriceFlg " +
                "From mcJobMenuItems m " +
                "Inner Join mcJobMenuCategories c On m.Category = c.Category " +
                "Where IsNull(m.HideFlg, 0) = 0 " +
                "And IsNull(c.HideFlg, 0) = 0 " +
                "And (IsNull(m.ServingQuote, 0) = 0 Or IsNull(m.ServingPrice, 0) <> 0) " +
                "And MenuItem <> '' " +
                "Order By m.Category, m.MenuItem ";

            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                decimal Quote = Math.Round(DB.Dec(dr["ServingQuote"]), 2);
                decimal Price = Math.Round(DB.Dec(dr["ServingPrice"]), 2);
                decimal Diff  = (Price != 0 ? (Quote - Price) / Price * 100M : 0);

                if (Quote == 0 || Diff > DiffPct || -Diff > DiffPct)
                {
                    HtmlTableRow tr = new HtmlTableRow();

                    HtmlTableCell td = new HtmlTableCell();
                    td.InnerText = DB.Str(dr["Category"]);
                    tr.Controls.Add(td);

                    td = new HtmlTableCell();
                    HtmlAnchor a = new HtmlAnchor();
                    a.InnerText = DB.Str(dr["MenuItem"]);
                    a.HRef      = string.Format("SetupMenuItems.aspx?Rno={0}", DB.Int32(dr["MenuItemRno"]));
                    a.Target    = "Fix";
                    td.Controls.Add(a);
                    tr.Controls.Add(td);

                    td           = new HtmlTableCell();
                    td.InnerText = Fmt.Dollar(DB.Dec(dr["ServingQuote"]));
                    td.Attributes.Add("class", "amt quote");
                    tr.Controls.Add(td);

                    td           = new HtmlTableCell();
                    td.InnerText = Fmt.Dollar(DB.Dec(dr["ServingPrice"]));
                    td.Attributes.Add("class", "amt price");
                    tr.Controls.Add(td);

                    td = new HtmlTableCell();
                    if (DB.Bool(dr["InaccuratePriceFlg"]))
                    {
                        HtmlGenericControl i = new HtmlGenericControl("i");
                        i.Attributes.Add("class", "icon-dollar");
                        i.Attributes.Add("title", "Cost and Price are inaccurate because there are ingredients with no price from receipts.");
                        td.Controls.Add(i);
                    }
                    tr.Controls.Add(td);

                    td           = new HtmlTableCell();
                    td.InnerText = string.Format("{0:0}% {1}", Math.Abs(Diff), (Diff < 0 ? "under" : "over"));
                    tr.Controls.Add(td);

                    tblRpt.Rows.Add(tr);
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
示例#7
0
    private string FinalizedJobs(StatusType Type)
    {
        string Html = string.Empty;
        string Sql  = string.Empty;

        try
        {
            decimal RptTotal = 0;

            int iRow = 0;

            string sType = (Type == StatusType.RecentlyEdited ? "Re" : string.Empty);
            string Where = string.Empty;

            switch (Type)
            {
            case StatusType.RecentlyEdited:
                Where = "FinalDtTm Is Not Null And ProcessedDtTm Is Not Null And EditProcessedDtTm Is Not Null";
                break;

            case StatusType.Finalized:
                Where = "FinalDtTm Is Not Null And ProcessedDtTm Is Null";
                break;

            case StatusType.NotFinalized:
                Where = "FinalDtTm Is Null And ProcessedDtTm Is Null And InvCreatedDtTm Is Not Null";
                break;
            }

            Sql =
                "Select Coalesce(cu.Name, c.Name) as Customer, * " +
                "From mcJobs j " +
                "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
                "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
                "Where " + Where + " Order By JobRno";

            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                InvoiceAmounts(dr);

                string   Customer      = DB.Str(dr["Customer"]);
                DateTime?Final         = DB.DtTm(dr["FinalDtTm"]);
                DateTime?Processed     = DB.DtTm(dr["ProcessedDtTm"]);
                DateTime?EditProcessed = DB.DtTm(dr["EditProcessedDtTm"]);
                DateTime?Updated       = DB.DtTm(dr["InvUpdatedDtTm"]);

                if (Updated.HasValue && Updated.Value == DateTime.MinValue)
                {
                    Updated = null;
                }

                bool   fUpdated = false;
                string Title    = string.Empty;
                if (Updated.HasValue)
                {
                    DateTime dtUpdated = Updated.Value.AddMinutes(-5);
                    switch (Type)
                    {
                    case StatusType.RecentlyEdited:
                        fUpdated = (dtUpdated > EditProcessed);
                        if (fUpdated)
                        {
                            Title = string.Format("Invoice was saved final on {0}\nand then updated again on {1}.", Fmt.DtTm(EditProcessed.Value), Fmt.DtTm(Updated.Value));
                        }
                        break;

                    case StatusType.Finalized:
                        fUpdated = (dtUpdated > Final);
                        if (fUpdated)
                        {
                            Title = string.Format("Invoice was saved final on {0}\nand then updated again on {1}.", Fmt.DtTm(Final.Value), Fmt.DtTm(Updated.Value));
                        }
                        break;
                    }
                }

                Int32 JobRno = DB.Int32(dr["JobRno"]);


                Html += string.Format(
                    "<tr class=\"{11}\">\n" +
                    "<td class=\"Center\"><input type=\"checkbox\" name=\"chk{1}Proc{0}\" value=\"{2}\" /></td>\n" +
                    "<td class=\"Right\" title=\"{12}\">{10}<a href=\"Invoice.aspx?JobRno={2}\" target=\"invoice\">{2}</a></td>\n" +
                    "<td>{3}</td>\n" +
                    "<td class=\"Center\">{4}</td>\n" +
                    "<td>{5}</td>\n" +
                    "<td class=\"Right\">{6}</td>\n" +
                    "<td class=\"Right\">{7}</td>\n" +
                    "<td class=\"Right\">{8}</td>\n" +
                    "<td class=\"Right\">{9}</td>\n" +
                    "</tr>\n",
                    ++iRow,
                    sType,
                    JobRno,
                    DB.Str(dr["Customer"]),
                    Fmt.Dt(DB.DtTm(dr["JobDate"])),
                    DB.Str(dr["Location"]),
                    Fmt.Dollar(Subtotal),
                    Fmt.Dollar(OtherTotal),
                    Fmt.Dollar(SalesTaxTotal),
                    Fmt.Dollar(Total),
                    (fUpdated ? "*" : ""),
                    (fUpdated ? "Updated" : ""),
                    Title);
                RptTotal += Math.Round(Total, 2);

                string PmtSql = string.Format("Select * from Payments where JobRno = {0} Order by Seq", JobRno);
                try
                {
                    DataTable dtPmt = db.DataTable(PmtSql);
                    foreach (DataRow drPmt in dtPmt.Rows)
                    {
                        Html += CCPayment(drPmt);
                    }
                }
                catch (Exception Ex)
                {
                    Err Err = new Err(Ex, Sql);
                    Response.Write(Err.Html());
                }

                //            Html += CCPayment(dr, "1");
                //Html += CCPayment(dr, "2");
                //Html += CCPayment(dr, "3");
            }

            Html += string.Format(
                "<tr>\n" +
                "<td><input type=\"hidden\" name=\"{0}Count\" value=\"{1}\"/></td>\n" +
                "<td colspan=\"2\"><span style='color: Red;'>*</span><span style='font-size: 80%'>Updated</span></td>\n" +
                "<td colspan=\"2\"></td>\n" +
                "<td align=\"right\"><b>Count</b></td>\n" +
                "<td align=\"right\"><b>{2}</b></td>\n" +
                "<td align=\"right\"><b>Total</b></td>\n" +
                "<td align=\"right\"><b>{3}</b></td>\n" +
                "</tr>\n",
                sType,
                iRow,
                dt.Rows.Count,
                Fmt.Dollar(RptTotal));
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        return(Html);
    }
示例#8
0
    // populate the list control from the category/item data returned from the SQL
    private void LoadListSql(string Sql, string CurrItem)
    {
        try
        {
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow r in dt.Rows)
            {
                int     MenuItemRno      = DB.Int32(r["MenuItemRno"]);
                string  Category         = DB.Str(r["Category"]);
                bool    fCatMultiSelect  = DB.Bool(r["CatMultSelFlg"]);
                int     SortOrder        = DB.Int32(r["SortOrder"]);
                string  MenuItem         = DB.Str(r["MenuItem"]);
                bool    fMultiSelect     = DB.Bool(r["MultSelFlg"]);
                string  MultItems        = DB.Str(r["MultItems"]);
                bool    fIngredSelect    = DB.Bool(r["IngredSelFlg"]);
                int     RecipeRno        = DB.Int32(r["RecipeRno"]);
                int     ItemSortOrder    = DB.Int32(r["ItemSortOrder"]);
                decimal Quote            = DB.Dec(r["ServingQuote"]);
                decimal Price            = DB.Dec(r["ServingPrice"]);
                bool    fInaccuratePrice = DB.Bool(r["InaccuratePriceFlg"]);
                bool    fGlutenFree      = DB.Bool(r["GlutenFreeFlg"]);
                bool    fVegan           = DB.Bool(r["VeganFlg"]);
                bool    fVegetarian      = DB.Bool(r["VegetarianFlg"]);
                bool    fDairyFree       = DB.Bool(r["DairyFreeFlg"]);
                bool    fNuts            = DB.Bool(r["NutsFlg"]);

                ListItem Item = new ListItem(Category + " - " + MenuItem);
                Item.Selected = (Item.Value == CurrItem);
                Item.Attributes.Add("Rno", MenuItemRno.ToString());
                Item.Attributes.Add("Category", Category);
                if (fCatMultiSelect)
                {
                    Item.Attributes.Add("CatMultSel", "true");
                }
                Item.Attributes.Add("SortOrder", SortOrder.ToString("000"));
                if (fMultiSelect)
                {
                    Item.Attributes.Add("MultItems", MultItems);
                }
                if (fIngredSelect && RecipeRno > 0)
                {
                    Sql = string.Format(
                        "Select x.RecipeIngredRno, Coalesce(i.Name, r.Name) as Name, r.GlutenFreeFlg, r.VeganFlg, r.VegetarianFlg, r.DairyFreeFlg, r.NutsFlg " +
                        "From RecipeIngredXref x " +
                        "Left Join Ingredients i On i.IngredRno = x.IngredRno " +
                        "Left Join Recipes r on r.RecipeRno = x.SubrecipeRno " +
                        "Where x.RecipeRno = {0} " +
                        "Order By Name",
                        RecipeRno);
                    string    Ingred   = string.Empty;
                    DataTable dtIngred = db.DataTable(Sql);
                    foreach (DataRow drIngred in dtIngred.Rows)
                    {
                        Ingred += string.Format(
                            "{0}|{1}|{2}|{3}|{4}|{5}|{6}~",
                            DB.Int32(drIngred["RecipeIngredRno"]),
                            DB.Str(drIngred["Name"]),
                            DB.Int32(drIngred["GlutenFreeFlg"]),
                            DB.Int32(drIngred["VeganFlg"]),
                            DB.Int32(drIngred["VegetarianFlg"]),
                            DB.Int32(drIngred["DairyFreeFlg"]),
                            DB.Int32(drIngred["NutsFlg"]));
                    }
                    if (Ingred.Length > 0)
                    {
                        Ingred = Ingred.Substring(0, Ingred.Length - 1);
                        Item.Attributes.Add("Ingred", Ingred);
                    }
                }
                Item.Attributes.Add("MenuItem", MenuItem);
                Item.Attributes.Add("ItemSortOrder", ItemSortOrder.ToString("000"));
                Item.Attributes.Add("title", Item.Text);
                Item.Attributes.Add("Quote", Fmt.Dollar(Quote));
                Item.Attributes.Add("Price", Fmt.Dollar(Price));
                Item.Attributes.Add("InaccuratePrice", (fInaccuratePrice ? "true" : "false"));
                if (fGlutenFree)
                {
                    Item.Attributes.Add("GlutenFree", "1");
                }
                if (fVegan)
                {
                    Item.Attributes.Add("Vegan", "1");
                }
                if (fVegetarian)
                {
                    Item.Attributes.Add("Vegetarian", "1");
                }
                if (fDairyFree)
                {
                    Item.Attributes.Add("DairyFree", "1");
                }
                if (fNuts)
                {
                    Item.Attributes.Add("Nuts", "1");
                }
                lstList.Items.Add(Item);
            }

            Sql =
                "Select Distinct c.Category, i.MenuItem " +
                "From mcJobMenuItems i Inner Join mcJobMenuCategories c On i.Category = c.Category " +
                "Order By c.Category, i.MenuItem";
            dt = db.DataTable(Sql);

            StringBuilder sbData       = new StringBuilder();
            string        PrevCategory = null;

            foreach (DataRow dr in dt.Rows)
            {
                string Category = DB.Str(dr["Category"]);
                string MenuItem = DB.Str(dr["MenuItem"]);

                if (Category != PrevCategory)
                {
                    if (sbData.Length > 0)
                    {
                        sbData.Append("]},\n\t");
                    }
                    sbData.AppendFormat("{{cat:\"{0}\",items:[", Category.Replace("\"", "\\\""));
                    PrevCategory = Category;
                }
                sbData.AppendFormat("\"{0}\",", MenuItem.Replace("\"", "\\\""));
            }
            sbData.Append("]}");

            CatInfo = sbData.ToString();
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
示例#9
0
    private void Scale()
    {
        string Sql = string.Empty;

        try
        {
            Sql = string.Format(
                "Select r.*, " +
                "(Select UnitSingle From Units Where UnitRno = r.YieldUnitRno) As YieldUnitSingle, " +
                "(Select UnitPlural From Units Where UnitRno = r.YieldUnitRno) As YieldUnitPlural, " +
                "(Select UnitSingle From Units Where UnitRno = r.PortionUnitRno) As PortionUnitSingle, " +
                "(Select UnitPlural From Units Where UnitRno = r.PortionUnitRno) As PortionUnitPlural, " +
                "(Select Top 1 BaseCostPct From Settings) As DefaultBaseCostPct " +
                "From Recipes r Where RecipeRno = {0}",
                RecipeRno);
            DataRow drRecipe = db.DataRow(Sql);
            if (drRecipe != null)
            {
                decimal RecipeServings = DB.Dec(drRecipe["NumServings"]);
                decimal ScaleServings  = Str.Dec(txtServings.Text);
                decimal Multiplier     = Str.Dec(txtMultiplier.Text);
                if (ScaleServings == 0)
                {
                    ScaleServings = RecipeServings;
                }
                if (Multiplier == 0)
                {
                    Multiplier = 1;
                }

                decimal Scaler                 = (RecipeServings != 0 ? ScaleServings / RecipeServings : Multiplier);
                decimal Yield                  = DB.Dec(drRecipe["YieldQty"]);
                decimal ServingSize            = DB.Dec(drRecipe["PortionQty"]);
                decimal BaseCostPrice          = DB.Dec(drRecipe["BaseCostPrice"]);
                decimal BaseCostPct            = DB.Dec(drRecipe["BaseCostPct"]);
                bool    fUseDefaultBaseCostPct = (drRecipe["BaseCostPct"] == DBNull.Value);
                decimal DefaultBaseCostPct     = DB.Dec(drRecipe["DefaultBaseCostPct"]);
                if (fUseDefaultBaseCostPct)
                {
                    BaseCostPct = DefaultBaseCostPct;
                }

                lblPrmRecipeName.Text   =
                    lblRecipeName.Text  = DB.Str(drRecipe["Name"]);
                txtServings.Text        = Fmt.Num(Scaler * RecipeServings, 3);
                txtMultiplier.Text      = Fmt.Num(Scaler, 3);
                hfOrigServings.Value    = RecipeServings.ToString();
                tdServings.Text         = Str.ShowFract(Scaler * RecipeServings);
                tdPrmYield.Text         =
                    tdYield.Text        = Str.ShowFract(Scaler * Yield);
                tdPrmYieldUnit.Text     =
                    tdYieldUnit.Text    = (Scaler * Yield <= 1 ? DB.Str(drRecipe["YieldUnitSingle"]) : DB.Str(drRecipe["YieldUnitPlural"]));
                tdPrmSize.Text          =
                    tdSize.Text         = Str.ShowFract(ServingSize);
                tdPrmSizeUnit.Text      =
                    tdSizeUnit.Text     = (ServingSize <= 1 ? DB.Str(drRecipe["PortionUnitSingle"]) : DB.Str(drRecipe["PortionUnitPlural"]));
                tdPrmServingCost.Text   =
                    tdServingCost.Text  = Fmt.Dollar(RecipeServings != 0 ? BaseCostPrice / RecipeServings : 0);
                tdPrmRecipeCost.Text    =
                    tdRecipeCost.Text   = Fmt.Dollar(Scaler * BaseCostPrice);
                tdPrmServingPrice.Text  =
                    tdServingPrice.Text = Fmt.Dollar(RecipeServings != 0 ? BaseCostPrice / RecipeServings : 0);
                tdPrmServingPrice.Text  =
                    tdServingPrice.Text = Fmt.Dollar(RecipeServings != 0 ? BaseCostPrice / RecipeServings / (BaseCostPct / 100) : 0);
                tdPrmRecipePrice.Text   =
                    tdRecipePrice.Text  = Fmt.Dollar(Scaler * BaseCostPrice / (BaseCostPct / 100));

                ltlDirections.Text = DB.Str(drRecipe["Instructions"]);     liDirections.Visible = (ltlDirections.Text.Length > 0);
                ltlNotes.Text      = DB.Str(drRecipe["IntNote"]);          liNotes.Visible = (ltlNotes.Text.Length > 0);
                ltlSource.Text     = DB.Str(drRecipe["Source"]);           liSource.Visible = (ltlSource.Text.Length > 0);

                Sql = string.Format(
                    "Select x.*, IsNull(i.Name, sr.Name) as Name, " +
                    "(Select UnitSingle From Units Where UnitRno = x.UnitRno) As UnitSingle, " +
                    "(Select UnitPlural From Units Where UnitRno = x.UnitRno) As UnitPlural " +
                    "From RecipeIngredXref x Left Join Ingredients i On i.IngredRno = x.IngredRno " +
                    "Left Join Recipes sr on sr.RecipeRno = x.SubrecipeRno " +
                    "Where x.RecipeRno = {0} " +
                    "Order By RecipeSeq",
                    RecipeRno);
                DataTable dt = db.DataTable(Sql);
                foreach (DataRow dr in dt.Rows)
                {
                    string   Title = DB.Str(dr["Title"]);
                    decimal  Qty   = Scaler * DB.Dec(dr["UnitQty"]);
                    TableRow tr    = new TableRow();
                    if (Title.Length > 0)
                    {
                        tr.Cells.Add(new TableCell()
                        {
                            Text = string.Format("<span class='Title'>{0}</span>", Title), ColumnSpan = 4
                        });
                    }
                    else
                    {
                        tr.Cells.Add(new TableCell()
                        {
                            Text = Str.ShowFract(Qty)
                        });
                        tr.Cells.Add(new TableCell()
                        {
                            Text = DB.Str(dr["Unit" + (Qty <= 1 ? "Single" : "Plural")])
                        });
                        string note = DB.Str(dr["Note"]);
                        tr.Cells.Add(new TableCell()
                        {
                            Text = DB.Str(dr["Name"]) + (note.Length > 0 ? " - " + note : "")
                        });
                    }
                    tblIngredients.Rows.Add(tr);
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
示例#10
0
    public string FindPayment()
    {
        string Html = string.Empty;
        string Sql  = string.Empty;

        try
        {
            if (txtPaymentAmt.Text.Length > 0)
            {
                decimal RptTotal = 0;

                Sql = string.Format(
                    "Select Coalesce(cu.Name, c.Name) as Customer, *, 1 as Section " +
                    "From mcJobs j " +
                    "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
                    "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
                    "Where {0} = j.InvBalAmt And j.InvCreatedDtTm Is Not Null And j.JobDate >= DateAdd(day, -90, GetDate())\n" +
                    "union\n" +
                    "Select Coalesce(cu.Name, c.Name) as Customer, *, 2 as Section " +
                    "From mcJobs j " +
                    "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
                    "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
                    "Where {0} Between j.InvBalAmt And j.InvBalAmt + 0.25 * j.SubTotAmt And j.InvBalAmt > 0 And j.InvCreatedDtTm Is Not Null And j.JobDate >= DateAdd(day, -90, GetDate())\n" +
                    "Order by Section, JobDate",
                    Str.Dec(txtPaymentAmt.Text));
                DataTable dt = db.DataTable(Sql);
                foreach (DataRow dr in dt.Rows)
                {
                    InvoiceAmounts(dr);

                    string Customer = DB.Str(dr["Customer"]);

                    Html += string.Format(
                        "<tr>\n" +
                        "<td class=\"Right\"><a href=\"Invoice.aspx?JobRno={0}\" target=\"invoice\">{0}</a></td>\n" +
                        "<td>{1}</td>\n" +
                        "<td class=\"Center\">{2}</td>\n" +
                        "<td>{3}</td>\n" +
                        "<td class=\"Right\">{4}</td>\n" +
                        "<td class=\"Right\">{5}</td>\n" +
                        "<td class=\"Right\">{6}</td>\n" +
                        "<td class=\"Right\">{7}</td>\n" +
                        "<td class=\"Right\">{8}</td>\n" +
                        "</tr>\n",
                        DB.Int32(dr["JobRno"]),
                        DB.Str(dr["Customer"]),
                        Fmt.Dt(DB.DtTm(dr["JobDate"])),
                        DB.Str(dr["Location"]),
                        Fmt.Dollar(Subtotal),
                        Fmt.Dollar(OtherTotal),
                        Fmt.Dollar(SalesTaxTotal),
                        Fmt.Dollar(Total),
                        Fmt.Dollar(Balance));
                    RptTotal += Math.Round(Total, 2);

                    Html += CCPayments(DB.Int32(dr["JobRno"]));
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        return(Html);
    }
示例#11
0
    private void LoadDetails(int Rno)
    {
        //Response.Write(string.Format("LoadDetails Rno {0}<br/>", Rno));
        if (Rno > 0)
        {
            String Sql = "";

            try
            {
                Sql = string.Format(
                    "Select d1.PurchaseDetailRno " +
                    "From PurchaseDetails d1 Inner Join PurchaseDetails d2 " +
                    "On d1.PurchaseRno = d2.PurchaseRno And d1.PurchaseDetailRno <> d2.PurchaseDetailRno " +
                    "Where d1.PurchaseRno = {0} " +
                    "And d1.PurchaseDetailRno = d2.PurchaseDetailRno",
                    Rno);
                DupSeq Dups = new DupSeq(db, Sql);

                Sql = string.Format(
                    "Select d.*, i.Name, i.MenuItemAsIsFlg, u.UnitSingle, u.UnitPlural " +
                    "From PurchaseDetails d " +
                    "Inner Join Ingredients i On d.IngredRno = i.IngredRno " +
                    "Inner Join Units u On d.PurchaseUnitRno = u.UnitRno " +
                    "Where PurchaseRno = {0} Order By PurchaseDetailRno", Rno);
                DataTable dt = db.DataTable(Sql);
                cDetails = dt.Rows.Count + 1;
                //Response.Write(string.Format("dt rows {0} cDetails {1}<br/>", dt.Rows.Count, cDetails));
                //Response.Write(Sql + "<br/>");
                AddLines();

                int iRow = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    iRow++;
                    TableRow tr = tblDetails.Rows[iRow];

                    int  PurchaseDetailRno = DB.Int32(dr["PurchaseDetailRno"]);
                    bool fDup = Dups.In(PurchaseDetailRno);

                    HtmlInputHidden hfPurchaseDetailRno = (HtmlInputHidden)tr.FindControl("hfPurchaseDetailRno" + iRow);
                    HtmlInputHidden hfOrigIngredRno     = (HtmlInputHidden)tr.FindControl("hfOrigIngredRno" + iRow);
                    HtmlInputHidden hfIngredRno         = (HtmlInputHidden)tr.FindControl("hfIngredRno" + iRow);
                    TextBox         txtIngredient       = (TextBox)tr.FindControl("txtIngredient" + iRow);
                    TextBox         txtPurchaseQty      = (TextBox)tr.FindControl("txtPurchaseQty" + iRow);
                    TextBox         txtUnitQty          = (TextBox)tr.FindControl("txtUnitQty" + iRow);
                    HtmlInputHidden hfUnitRno           = (HtmlInputHidden)tr.FindControl("hfUnitRno" + iRow);
                    TextBox         txtUnit             = (TextBox)tr.FindControl("txtUnit" + iRow);
                    TextBox         txtPrice            = (TextBox)tr.FindControl("txtPrice" + iRow);
                    CheckBox        chkRemove           = (CheckBox)tr.FindControl("chkRemove" + iRow);

                    hfPurchaseDetailRno.Value = PurchaseDetailRno.ToString();
                    hfOrigIngredRno.Value     =
                        hfIngredRno.Value     = DB.Int32(dr["IngredRno"]).ToString();
                    txtIngredient.Text        = DB.Str(dr["Name"]);
                    decimal Qty = DB.Dec(dr["PurchaseQty"]);
                    txtPurchaseQty.Text = Str.ShowFract(Qty);
                    txtUnitQty.Text     = Str.ShowFract(DB.Dec(dr["PurchaseUnitQty"]));
                    hfUnitRno.Value     = DB.Int32(dr["PurchaseUnitRno"]).ToString();
                    txtUnit.Text        = DB.Str(dr[Qty <= 1 ? "UnitSingle" : "UnitPlural"]);
                    if (DB.Bool(dr["MenuItemAsIsFlg"]))
                    {
                        txtUnit.Attributes.Add("disabled", "true");
                    }
                    txtPrice.Text     = Fmt.Dollar(DB.Dec(dr["Price"]));
                    chkRemove.Checked = false;
                }

                hfNumDetails.Value = cDetails.ToString();
            }
            catch (Exception Ex)
            {
                Err Err = new Err(Ex, Sql);
                Response.Write(Err.Html());
            }
        }
        else
        {
            cDetails = 1;
            AddLines();
        }
    }
示例#12
0
    protected void ReadValues()
    {
        ClearValues();

        String Sql =
            "Select j.SubTotTaxPct, j.Adj1Desc, j.Adj2Desc, j.ServiceAmt, j.DeliveryAmt, j.ChinaAmt, j.AddServiceAmt, j.FuelTravelAmt, " +
            "j.FacilityAmt, j.RentalsAmt, j.Adj1Amt, j.Adj2Amt, j.DepositAmt, j.ServiceTaxPct, j.DeliveryTaxPct, j.ChinaTaxPct, " +
            "j.AddServiceTaxPct, j.FuelTravelTaxPct, j.FacilityTaxPct, j.RentalsTaxPct, j.Adj1TaxPct, j.Adj2TaxPct, j.ServicePropDesc, " +
            "j.DeliveryPropDesc, j.ChinaPropDesc, j.AddServicePropDesc, j.FuelTravelPropDesc, j.FacilityPropDesc, j.RentalsPropDesc, " +
            "j.Adj1PropDesc, j.Adj2PropDesc, j.EstTotPropDesc, j.DepositPropDesc, j.SalesTaxTotAmt, j.InvTotAmt, j.InvBalAmt, j.ServicePropDescCustFlg, " +
            "j.DeliveryPropDescCustFlg, j.ChinaPropDescCustFlg, j.AddServicePropDescCustFlg, j.FuelTravelPropDescCustFlg, " +
            "j.FacilityPropDescCustFlg, j.RentalsPropDescCustFlg, j.EstTotPropDescCustFlg, j.DepositPropDescCustFlg, j.ServicePropOptions, " +
            "j.DeliveryPropOptions, j.ChinaPropOptions, j.AddServicePropOptions, j.FuelTravelPropOptions, j.FacilityPropOptions, " +
            "j.RentalsPropOptions, j.EstTotPropOptions, j.DepositPropOptions, j.NumMenServing, j.NumWomenServing, j.NumChildServing, " +
            "j.ProposalFlg, j.PropCreatedDtTm, j.PropEmailedDtTm, j.ConfirmEmailedDtTm, j.JobType, c.Email, j.PropCreatedUser, " +
            "j.PropUpdatedDtTm, j.PropUpdatedUser, j.PropGeneratedDtTm, j.PropGeneratedUser, j.PropEmailedUser, j.ConfirmEmailedUser " +
            "From mcJobs j " +
            "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
            "Where JobRno = " + JobRno;

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                //decimal SalesTax = 0;
                //decimal Total = 0;
                string Default = string.Empty;
                string Zero    = Fmt.Dollar(0);

                decimal SubTotTaxPct = DB.Dec(dr["SubTotTaxPct"]);

                // prices
                Sql = string.Format("Select * From JobInvoicePrices Where JobRno = {0} Order By Seq", JobRno);
                DataTable dtPrices = db.DataTable(Sql);
                foreach (DataRow drPrice in dtPrices.Rows)
                {
                    int    Rno       = DB.Int32(drPrice["Rno"]);
                    string PriceType = DB.Str(drPrice["PriceType"]);
                    //string PriceDesc = string.Empty;
                    int     Count    = 0;
                    decimal Price    = 0;
                    decimal ExtPrice = 0;
                    string  FmtPrice = string.Empty;
                    //string Desc = string.Empty;
                    string PropDesc    = string.Empty;
                    bool   fCustomized = false;
                    Default = string.Empty;
                    string Options = string.Empty;

                    switch (PriceType)
                    {
                    case Misc.cnPerPerson:
                        Count = DB.Int32(drPrice["InvPerPersonCount"]);
                        Price = DB.Dec(drPrice["InvPerPersonPrice"]);
                        //ExtPrice = Count * Price;
                        ExtPrice = DB.Dec(drPrice["InvPerPersonExtPrice"]);
                        FmtPrice = Fmt.Dollar(Price);
                        //Desc = DB.Str(drPrice["InvPerPersonDesc"]);
                        //PriceDesc = string.Format("Price per person: {0}", FmtPrice);
                        PropDesc    = DB.Str(drPrice["PropPerPersonDesc"]);
                        fCustomized = DB.Bool(drPrice["PropPerPersonDescCustFlg"]);
                        Options     = DB.Str(drPrice["PropPerPersonOptions"]);
                        Default     = string.Format("Price per person: {0}", FmtPrice);
                        if (!fCustomized && PropDesc.Length > 0 && FmtPrice != Zero)
                        {
                            PropDesc = Default;
                        }
                        break;

                    case Misc.cnPerItem:
                        Count = DB.Int32(drPrice["InvPerItemCount"]);
                        Price = DB.Dec(drPrice["InvPerItemPrice"]);
                        //ExtPrice = Count * Price;
                        ExtPrice = DB.Dec(drPrice["InvPerItemExtPrice"]);
                        FmtPrice = Fmt.Dollar(Count * Price);
                        //Desc = DB.Str(drPrice["InvPerItemDesc"]);
                        //PriceDesc = string.Format("{0} {1} @ {2} per item",
                        //	Fmt.Num(Count),
                        //	Desc,
                        //	Fmt.Dollar(Price));
                        PropDesc    = DB.Str(drPrice["PropPerItemDesc"]);
                        fCustomized = DB.Bool(drPrice["PropPerItemDescCustFlg"]);
                        PriceType   = string.Format("{0} {1}", Count, DB.Str(drPrice["InvPerItemDesc"]));
                        Default     = string.Format("{0}: {1}", PriceType, FmtPrice);
                        if (!fCustomized && PropDesc.Length > 0 && FmtPrice != Zero)
                        {
                            PropDesc = Default;
                        }
                        break;

                    case Misc.cnAllIncl:
                        Count = 1;
                        Price = DB.Dec(drPrice["InvAllInclPrice"]);
                        //ExtPrice = Price - (Price * (1 - 1 / (1 + SubTotTaxPct / 100)));
                        ExtPrice = DB.Dec(drPrice["InvAllInclExtPrice"]);
                        FmtPrice = Fmt.Dollar(Price);
                        //Desc = DB.Str(drPrice["InvAllInclDesc"]);
                        //PriceDesc = string.Format("All inclusive {0} @ {1}",
                        //	Desc,
                        //	Fmt.Dollar(Price));
                        PropDesc    = DB.Str(drPrice["PropAllInclDesc"]);
                        fCustomized = DB.Bool(drPrice["PropAllInclDescCustFlg"]);
                        PriceType   = DB.Str(drPrice["InvAllInclDesc"]);
                        Default     = string.Format("{0}: {1}", PriceType, FmtPrice);
                        if (!fCustomized && PropDesc.Length > 0 && FmtPrice != Zero)
                        {
                            PropDesc = Default;
                        }
                        break;
                    }

                    //if (PropDesc.Length > 0)
                    {
                        HtmlGenericControl tr = new HtmlGenericControl("tr");

                        HtmlGenericControl td = new HtmlGenericControl("td");
                        td.Attributes.Add("align", "right");
                        td.InnerHtml = string.Format("{0} (<span class=\"Amt\">{1}</span>)", PriceType, FmtPrice);
                        tr.Controls.Add(td);

                        td = new HtmlGenericControl("td");

                        HtmlTextArea txt = new HtmlTextArea();
                        txt.ID = string.Format("txtPrice_{0}", Rno);
                        txt.Attributes.Add("class", "FeeDesc");
                        txt.Attributes.Add("data-default", Default);
                        txt.Value = PropDesc;
                        td.Controls.Add(txt);

                        HtmlInputHidden hf = new HtmlInputHidden();
                        hf.ID    = string.Format("hfPriceCustomized_{0}", Rno);
                        hf.Value = Customized(fCustomized);
                        td.Controls.Add(hf);

                        HtmlGenericControl ul = new HtmlGenericControl("ul");
                        ul.ID = string.Format("ulPrice_{0}", Rno);
                        ul.Attributes.Add("class", "Options");
                        td.Controls.Add(ul);

                        RenderOptions(ul, PerPerson, Options);

                        tr.Controls.Add(td);
                        td = new HtmlGenericControl("td");

                        HtmlGenericControl lbl = new HtmlGenericControl("label");
                        lbl.Attributes.Add("class", "Reset");
                        lbl.Attributes.Add("title", "Click to reset the description and show all the options.");
                        lbl.InnerText = "Undo Custom";
                        td.Controls.Add(lbl);

                        lbl = new HtmlGenericControl("label");
                        lbl.Attributes.Add("class", "SeeOptions");
                        lbl.InnerText = "click Undo Custom to see available options";
                        td.Controls.Add(lbl);

                        tr.Controls.Add(td);
                        phPrices.Controls.Add(tr);
                    }

                    //Total += ExtPrice;
                }

                //SalesTax += Math.Round(Total * SubTotTaxPct / 100, 2);

                lblAdj1Desc.Text = DB.Str(dr["Adj1Desc"]);
                lblAdj2Desc.Text = DB.Str(dr["Adj2Desc"]);

                decimal ServiceAmt    = DB.Dec(dr["ServiceAmt"]);
                decimal DeliveryAmt   = DB.Dec(dr["DeliveryAmt"]);
                decimal ChinaAmt      = DB.Dec(dr["ChinaAmt"]);
                decimal AddServiceAmt = DB.Dec(dr["AddServiceAmt"]);
                decimal FuelTravelAmt = DB.Dec(dr["FuelTravelAmt"]);
                decimal FacilityAmt   = DB.Dec(dr["FacilityAmt"]);
                decimal RentalsAmt    = DB.Dec(dr["RentalsAmt"]);
                decimal Adj1Amt       = DB.Dec(dr["Adj1Amt"]);
                decimal Adj2Amt       = DB.Dec(dr["Adj2Amt"]);
                decimal DepositAmt    = DB.Dec(dr["DepositAmt"]);

                decimal ServicePct    = DB.Dec(dr["ServiceTaxPct"]);
                decimal DeliveryPct   = DB.Dec(dr["DeliveryTaxPct"]);
                decimal ChinaPct      = DB.Dec(dr["ChinaTaxPct"]);
                decimal AddServicePct = DB.Dec(dr["AddServiceTaxPct"]);
                decimal FuelTravelPct = DB.Dec(dr["FuelTravelTaxPct"]);
                decimal FacilityPct   = DB.Dec(dr["FacilityTaxPct"]);
                decimal RentalsPct    = DB.Dec(dr["RentalsTaxPct"]);
                decimal Adj1Pct       = DB.Dec(dr["Adj1TaxPct"]);
                decimal Adj2Pct       = DB.Dec(dr["Adj2TaxPct"]);

                lblServiceAmt.Text    = Fmt.Dollar(ServiceAmt);
                lblDeliveryAmt.Text   = Fmt.Dollar(DeliveryAmt);
                lblChinaAmt.Text      = Fmt.Dollar(ChinaAmt);
                lblAddServiceAmt.Text = Fmt.Dollar(AddServiceAmt);
                lblFuelTravelAmt.Text = Fmt.Dollar(FuelTravelAmt);
                lblFacilityAmt.Text   = Fmt.Dollar(FacilityAmt);
                lblRentalsAmt.Text    = Fmt.Dollar(RentalsAmt);
                lblAdj1Amt.Text       = Fmt.Dollar(Adj1Amt);
                lblAdj2Amt.Text       = Fmt.Dollar(Adj2Amt);
                lblDepositAmt.Text    = Fmt.Dollar(DepositAmt);

                txtServiceDesc.Text    = DB.Str(dr["ServicePropDesc"]);
                txtDeliveryDesc.Text   = DB.Str(dr["DeliveryPropDesc"]);
                txtChinaDesc.Text      = DB.Str(dr["ChinaPropDesc"]);
                txtAddServiceDesc.Text = DB.Str(dr["AddServicePropDesc"]);
                txtFuelTravelDesc.Text = DB.Str(dr["FuelTravelPropDesc"]);
                txtFacilityDesc.Text   = DB.Str(dr["FacilityPropDesc"]);
                txtRentalsDesc.Text    = DB.Str(dr["RentalsPropDesc"]);
                txtAdj1Desc.Text       = DB.Str(dr["Adj1PropDesc"]);
                txtAdj2Desc.Text       = DB.Str(dr["Adj2PropDesc"]);
                txtTotalDesc.Text      = DB.Str(dr["EstTotPropDesc"]);
                txtDepositDesc.Text    = DB.Str(dr["DepositPropDesc"]);

                //SalesTax +=
                //	Math.Round(ServiceAmt		* ServicePct	/ 100, 2) +
                //	Math.Round(DeliveryAmt		* DeliveryPct	/ 100, 2) +
                //	Math.Round(ChinaAmt			* ChinaPct		/ 100, 2) +
                //	Math.Round(AddServiceAmt	* AddServicePct / 100, 2) +
                //	Math.Round(FuelTravelAmt	* FuelTravelPct / 100, 2) +
                //	Math.Round(FacilityAmt		* FacilityPct	/ 100, 2) +
                //	Math.Round(RentalsAmt		* RentalsPct	/ 100, 2) +
                //	Math.Round(Adj1Amt			* Adj1Pct		/ 100, 2) +
                //	Math.Round(Adj2Amt			* Adj2Pct		/ 100, 2);

                //Total +=
                //	ServiceAmt +
                //	DeliveryAmt +
                //	ChinaAmt +
                //	AddServiceAmt +
                //	FuelTravelAmt +
                //	FacilityAmt +
                //	RentalsAmt +
                //	Adj1Amt +
                //	Adj2Amt;

                //bool fTaxExempt = DB.Bool(dr["TaxExemptFlg"]);
                //if (!fTaxExempt)
                //{
                //	Total += SalesTax;
                //}

                //bool fCreditCardPaymentFee = DB.Bool(dr["CCPmtFeeFlg"]);
                //if (fCreditCardPaymentFee)
                //{
                //	decimal CreditCardFeePct = DB.Dec(dr["CCFeePct"]);
                //	decimal CreditCardFeeAmt = Math.Round(Total * CreditCardFeePct / 100, 2);
                //	decimal CreditCardFeeTaxPct = DB.Dec(dr["CCFeeTaxPct"]);
                //	decimal CreditCardFeeTaxAmt = 0;
                //	if (!fTaxExempt)
                //	{
                //		CreditCardFeeTaxAmt = Math.Round(CreditCardFeeAmt * CreditCardFeeTaxPct / 100, 2);
                //	}

                //	SalesTax += CreditCardFeeTaxAmt;
                //	Total += CreditCardFeeAmt + CreditCardFeeTaxAmt;
                //}

                decimal SalesTax = DB.Dec(dr["SalesTaxTotAmt"]);
                decimal Total    = DB.Dec(dr["InvTotAmt"]);
                decimal Balance  = Total - DepositAmt; // DB.Dec(dr["InvBalAmt"]);

                bool fServiceCustomized    = DB.Bool(dr["ServicePropDescCustFlg"]);
                bool fDeliveryCustomized   = DB.Bool(dr["DeliveryPropDescCustFlg"]);
                bool fChinaCustomized      = DB.Bool(dr["ChinaPropDescCustFlg"]);
                bool fAddServiceCustomized = DB.Bool(dr["AddServicePropDescCustFlg"]);
                bool fFuelTravelCustomized = DB.Bool(dr["FuelTravelPropDescCustFlg"]);
                bool fFacilityCustomized   = DB.Bool(dr["FacilityPropDescCustFlg"]);
                bool fRentalsCustomized    = DB.Bool(dr["RentalsPropDescCustFlg"]);
                bool fTotalCustomized      = DB.Bool(dr["EstTotPropDescCustFlg"]);
                bool fDepositCustomized    = DB.Bool(dr["DepositPropDescCustFlg"]);

                string ServiceOptions    = DB.Str(dr["ServicePropOptions"]);
                string DeliveryOptions   = DB.Str(dr["DeliveryPropOptions"]);
                string ChinaOptions      = DB.Str(dr["ChinaPropOptions"]);
                string AddServiceOptions = DB.Str(dr["AddServicePropOptions"]);
                string FuelTravelOptions = DB.Str(dr["FuelTravelPropOptions"]);
                string FacilityOptions   = DB.Str(dr["FacilityPropOptions"]);
                string RentalsOptions    = DB.Str(dr["RentalsPropOptions"]);
                string TotalOptions      = DB.Str(dr["EstTotPropOptions"]);
                string DepositOptions    = DB.Str(dr["DepositPropOptions"]);

                hfServiceCustomized.Value    = Customized(fServiceCustomized);
                hfDeliveryCustomized.Value   = Customized(fDeliveryCustomized);
                hfChinaCustomized.Value      = Customized(fChinaCustomized);
                hfAddServiceCustomized.Value = Customized(fAddServiceCustomized);
                hfFuelTravelCustomized.Value = Customized(fFuelTravelCustomized);
                hfFacilityCustomized.Value   = Customized(fFacilityCustomized);
                hfRentalsCustomized.Value    = Customized(fRentalsCustomized);
                hfTotalCustomized.Value      = Customized(fTotalCustomized);
                hfDepositCustomized.Value    = Customized(fDepositCustomized);

                //trAdj1.Visible = (lblAdj1Desc.Text.Length > 0);
                //trAdj2.Visible = (lblAdj2Desc.Text.Length > 0);

                RenderOptions(ulService, Service, ServiceOptions);
                RenderOptions(ulDelivery, Delivery, DeliveryOptions);
                RenderOptions(ulChina, China, ChinaOptions);
                RenderOptions(ulAddService, AddService, AddServiceOptions);
                RenderOptions(ulFuelTravel, FuelTravel, FuelTravelOptions);
                RenderOptions(ulFacility, Facility, FacilityOptions);
                RenderOptions(ulRentals, Rentals, RentalsOptions);

                Default = (lblServiceAmt.Text != Zero ? string.Format("{0}: {1}", DefaultService + " (gratuity not included)", lblServiceAmt.Text) : string.Empty);
                txtServiceDesc.Attributes.Add("data-default", Default);
                if (!fServiceCustomized && lblServiceAmt.Text != Zero)
                {
                    txtServiceDesc.Text = Default;
                }

                Default = (lblDeliveryAmt.Text != Zero ? string.Format("{0}: {1}", DefaultDelivery, lblDeliveryAmt.Text) : string.Empty);
                txtDeliveryDesc.Attributes.Add("data-default", Default);
                if (!fDeliveryCustomized && lblDeliveryAmt.Text != Zero)
                {
                    txtDeliveryDesc.Text = Default;
                }

                Default = (lblChinaAmt.Text != Zero ? string.Format("{0}: {1}", DefaultChina, lblChinaAmt.Text) : string.Empty);
                txtChinaDesc.Attributes.Add("data-default", Default);
                if (!fChinaCustomized && lblChinaAmt.Text != Zero)
                {
                    txtChinaDesc.Text = Default;
                }

                Default = (lblAddServiceAmt.Text != Zero ? string.Format("{0}: {1}", DefaultAddService, lblAddServiceAmt.Text) : string.Empty);
                txtAddServiceDesc.Attributes.Add("data-default", Default);
                if (!fAddServiceCustomized && lblAddServiceAmt.Text != Zero)
                {
                    txtAddServiceDesc.Text = Default;
                }

                Default = (lblFuelTravelAmt.Text != Zero ? string.Format("{0}: {1}", DefaultFuelTravel, lblFuelTravelAmt.Text) : string.Empty);
                txtFuelTravelDesc.Attributes.Add("data-default", Default);
                if (!fFuelTravelCustomized && lblFuelTravelAmt.Text != Zero)
                {
                    txtFuelTravelDesc.Text = Default;
                }

                Default = (lblFacilityAmt.Text != Zero ? string.Format("{0}: {1}", DefaultFacility, lblFacilityAmt.Text) : string.Empty);
                txtFacilityDesc.Attributes.Add("data-default", Default);
                if (!fFacilityCustomized && lblFacilityAmt.Text != Zero)
                {
                    txtFacilityDesc.Text = Default;
                }

                Default = (lblRentalsAmt.Text != Zero ? string.Format("{0}: {1}", DefaultRentals, lblRentalsAmt.Text) : string.Empty);
                txtRentalsDesc.Attributes.Add("data-default", Default);
                if (!fRentalsCustomized && lblRentalsAmt.Text != Zero)
                {
                    txtRentalsDesc.Text = Default;
                }

                Default = (lblAdj1Amt.Text != Zero ? string.Format("{0}: {1}", lblAdj1Desc.Text, lblAdj1Amt.Text) : string.Empty);
                txtAdj1Desc.Attributes.Add("data-default", Default);
                if (txtAdj1Desc.Text.Length == 0 && lblAdj1Amt.Text != Zero)
                {
                    txtAdj1Desc.Text = Default;
                }

                Default = (lblAdj2Amt.Text != Zero ? string.Format("{0}: {1}", lblAdj2Desc.Text, lblAdj2Amt.Text) : string.Empty);
                txtAdj2Desc.Attributes.Add("data-default", Default);
                if (txtAdj2Desc.Text.Length == 0 && lblAdj2Amt.Text != Zero)
                {
                    txtAdj2Desc.Text = Default;
                }

                int NumServings = DB.Int32(dr["NumMenServing"]) + DB.Int32(dr["NumWomenServing"]) + DB.Int32(dr["NumChildServing"]);
                lblTotalAmt.Text = Fmt.Dollar(Total);
                Default          = string.Format("Estimated Total: {0} - Based on {1} guests. Price per person and on-site service are subject to change as guest count changes.", Fmt.Dollar(Total), Fmt.Num(NumServings));
                txtTotalDesc.Attributes.Add("data-default", Default);
                if (!fTotalCustomized)
                {
                    txtTotalDesc.Text = Default;
                }

                Default = (lblDepositAmt.Text != Zero ? string.Format("{0}: {1}, remaining Invoice Balance: {2}", DefaultDeposit, lblDepositAmt.Text, Fmt.Dollar(Balance)) : string.Empty);
                txtDepositDesc.Attributes.Add("data-default", Default);
                if (txtDepositDesc.Text.Length == 0 && lblDepositAmt.Text != Zero)
                {
                    txtDepositDesc.Text = Default;
                }

                bool     fProposal        = DB.Bool(dr["ProposalFlg"]);
                DateTime dtPropCreated    = DB.DtTm(dr["PropCreatedDtTm"]);
                DateTime dtPropEmailed    = DB.DtTm(dr["PropEmailedDtTm"]);
                DateTime dtConfirmEmailed = DB.DtTm(dr["ConfirmEmailedDtTm"]);
                string   JobType          = DB.Str(dr["JobType"]);

                EmailType                 = (fProposal ? "Proposal" : (JobType == "Private" ? "Private Confirmation" : "Corporate Confirmation"));
                txtEmail.Text             = DB.Str(dr["Email"]);
                txtSubject.Text           = (fProposal ? (dtPropEmailed == DateTime.MinValue ? string.Empty : "Revised ") + "Proposal" : (dtConfirmEmailed == DateTime.MinValue ? string.Empty : "Revised ") + "Confirmation") + " from " + Globals.g.Company.Name;
                txtMessage.Text           = (fProposal ? "Attached is your " + (dtPropEmailed == DateTime.MinValue ? string.Empty : "revised ") + "proposal from " + Globals.g.Company.Name + ".\n\nWe appreciate your business." : (dtConfirmEmailed == DateTime.MinValue ? string.Empty : "Attached is your revised confirmation from " + Globals.g.Company.Name + ".\n\nWe appreciate your business."));
                chkTermsOfService.Checked = (JobType == "Private");

                btnEmail.Visible        = fProposal;
                btnEmailConfirm.Visible = !fProposal;

                if (dtPropCreated == DateTime.MinValue)
                {
                    btnEmail.Attributes.Add("disabled", "disabled");
                    btnEmail.Attributes.Add("title", "Save Client Pricing and then email.");
                    btnEmailConfirm.Attributes.Add("disabled", "disabled");
                    btnEmailConfirm.Attributes.Add("title", "Save Client Pricing and then email.");
                }

                if (dtPropEmailed != DateTime.MinValue)
                {
                    btnEmail.Value = "Re-Email Proposal";
                }
                if (dtConfirmEmailed != DateTime.MinValue)
                {
                    btnEmailConfirm.Value = "Re-Email Confirm";
                }

                txtCreatedDt.Text          = Fmt.DtTm(dtPropCreated);
                txtCreatedUser.Text        = DB.Str(dr["PropCreatedUser"]);
                txtUpdatedDt.Text          = Fmt.DtTm(DB.DtTm(dr["PropUpdatedDtTm"]));
                txtUpdatedUser.Text        = DB.Str(dr["PropUpdatedUser"]);
                txtGeneratedDt.Text        = Fmt.DtTm(DB.DtTm(dr["PropGeneratedDtTm"]));
                txtGeneratedUser.Text      = DB.Str(dr["PropGeneratedUser"]);
                txtPropEmailedDt.Text      = Fmt.DtTm(dtPropEmailed);
                txtPropEmailedUser.Text    = DB.Str(dr["PropEmailedUser"]);
                txtConfirmEmailedDt.Text   = Fmt.DtTm(dtConfirmEmailed);
                txtConfirmEmailedUser.Text = DB.Str(dr["ConfirmEmailedUser"]);
                pnlPreview.ToolTip         = string.Format("{0} Preview", (fProposal ? "Proposal" : "Confirmation"));
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
示例#13
0
    protected void GetData(int Rno)
    {
        string Sql = string.Format("Select *, (Select Name From Recipes Where RecipeRno = i.RecipeRno) As Name From mcJobMenuItems i Where MenuItemRno = {0}", Rno);

        ClearData();

        try
        {
            DataTable dt = db.DataTable(Sql);
            if (dt.Rows.Count > 0)
            {
                DataRow dr            = dt.Rows[0];
                int     KitchenLocRno = DB.Int32(dr["KitchenLocRno"]);
                if (KitchenLocRno == 0)
                {
                    Sql           = "Select KitchenLocRno From KitchenLocations Where DefaultFlg = 1";
                    KitchenLocRno = db.SqlNum(Sql);
                }

                txtRno.Value          = DB.Int32(dr["MenuItemRno"]).ToString();
                txtCurrCategory.Value =
                    ddlCategory.Text  = DB.Str(dr["Category"]);
                txtCurrMenuItem.Value =
                    txtMenuItem.Text  = DB.Str(dr["MenuItem"]);
                txtProposal.Text      = DB.Str(dr["ProposalMenuItem"]);
                txtServingQuote.Text  = Fmt.Dollar(DB.Dec(dr["ServingQuote"]));
                txtServingPrice.Text  = Fmt.Dollar(DB.Dec(dr["ServingPrice"]));
                if (DB.Bool(dr["InaccuratePriceFlg"]))
                {
                    HtmlGenericControl i = new HtmlGenericControl("i");
                    i.Attributes.Add("class", "icon-dollar");
                    i.Attributes.Add("title", "Cost and Price are inaccurate because there are ingredients with no price from receipts.");
                    lblInaccuratePrice.Controls.Add(i);
                }
                bool fAsIs     = DB.Bool(dr["AsIsFlg"]);
                int  RecipeRno = 0;

                if (fAsIs)
                {
                    ltlRecipe.Text = "none";
                }
                else
                {
                    RecipeRno = DB.Int32(dr["RecipeRno"]);
                    if (RecipeRno == 0)
                    {
                        ltlRecipe.Text  = "none";
                        chkAsIs.Enabled = true;
                        chkAsIs.ToolTip = "";
                    }
                    else
                    {
                        lnkRecipe.Text        = DB.Str(dr["Name"]);
                        lnkRecipe.NavigateUrl = string.Format("Recipes.aspx?Rno={0}", RecipeRno);
                        chkAsIs.Enabled       = false;
                        chkAsIs.ToolTip       = "As Is items cannot have a recipe. Remove this item from its recipe first.";
                    }
                }
                ddlLocation.SelectedValue = KitchenLocRno.ToString();
                chkAsIs.Checked           = fAsIs;
                chkMultiSelect.Checked    = DB.Bool(dr["MultSelFlg"]);
                chkIngredSelect.Checked   = DB.Bool(dr["IngredSelFlg"]);
                chkIngredSelect.Enabled   = (RecipeRno != 0);
                chkHide.Checked           = DB.Bool(dr["HideFlg"]);
                txtMultItems.Value        = DB.Str(dr["MultItems"]);
                string[] MultiItems = txtMultItems.Value.Split(',');
                chkMultiSelect.Text = string.Format((txtMultItems.Value.Length > 0 && MultiItems.Length > 0 ? " {0} ({1} items)" : " {0}"), "Multi-Select", MultiItems.Length);
                txtCreatedDt.Text   = Fmt.DtTm(DB.DtTm(dr["CreatedDtTm"]));
                txtCreatedUser.Text = DB.Str(dr["CreatedUser"]);
                txtUpdatedDt.Text   = Fmt.DtTm(DB.DtTm(dr["UpdatedDtTm"]));
                txtUpdatedUser.Text = DB.Str(dr["UpdatedUser"]);

                Sql = string.Format("Select Count(*) From mcJobFood Where Category = {0} And MenuItem = {1}", DB.PutStr(ddlCategory.Text), DB.PutStr(txtMenuItem.Text));
                int NumJobs = db.SqlNum(Sql);

                if (NumJobs > 0)
                {
                    btnDelete.Enabled = false;
                    btnDelete.ToolTip = string.Format("Used in {0} Jobs", NumJobs);
                }
                else
                {
                    btnDelete.Enabled = true;
                    btnDelete.ToolTip = "Not used in any Jobs";
                }

                Sql = string.Format(
                    "Select MenuItemRno, Category, RecipeRno " +
                    "From mcJobMenuItems Where MenuItem In " +
                    "(Select MenuItem From mcJobMenuItems Where MenuItemRno = {0}) And MenuItemRno <> {0} " +
                    "And IsNull(HideFlg, 0) = 0 " +
                    "And Category In (Select Category From mcJobMenuCategories Where IsNull(HideFlg, 0) = 0) " +
                    "Order By Category",
                    Rno);
                DataTable dtSimlar = db.DataTable(Sql);
                if (dtSimlar.Rows.Count == 0)
                {
                    lblSimilar.Visible = false;
                }
                else
                {
                    lblSimilar.Visible = true;
                    lblSimilar.Text    = string.Format("{0} more categories", dtSimlar.Rows.Count);

                    string Tip = string.Empty;
                    ulSimilar.Controls.Clear();
                    foreach (DataRow drSimilar in dtSimlar.Rows)
                    {
                        string Category = DB.Str(drSimilar["Category"]);
                        Tip += string.Format("<li>{0}</li>\n", Category);

                        HtmlAnchor a = new HtmlAnchor();
                        a.HRef      = string.Format("SetupMenuItems.aspx?Rno={0}", DB.Int32(drSimilar["MenuItemRno"]));
                        a.InnerText = Category;
                        HtmlGenericControl li = new HtmlGenericControl("li");
                        li.Controls.Add(a);
                        ulSimilar.Controls.Add(li);

                        if (DB.Int32(drSimilar["RecipeRno"]) > 0)
                        {
                            fSimilarMenuItemsWithRecipe = true;
                        }
                    }
                    lblSimilar.ToolTip = string.Format("<ul>{0}</ul>", Tip);
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
示例#14
0
    protected string CCPayment(DataRow dr, string PmtNum)
    {
        string Html = string.Empty;

        try
        {
            string CCNum   = DB.Str(dr["CCNum" + PmtNum]);
            string SecCode = DB.Str(dr["CCSecCode" + PmtNum]);

            try
            {
                CCNum = Crypt.Decrypt(CCNum, Misc.Password);
            }
            catch (Exception)
            {
            }

            try
            {
                SecCode = Crypt.Decrypt(SecCode, Misc.Password);
            }
            catch (Exception)
            {
            }

            if (CCNum.Length > 0)
            {
                string CardInfo = string.Format(
                    "<dl>\n" +
                    "<dt>Amount</dt><dd class=\"mid\">{7}</dd>\n" +
                    "<dt>Card Type</dt><dd>{0}</dd>\n" +
                    "<dt>Exp Date</dt><dd class=\"short\">{2}</dd>\n" +
                    "<dt>Name</dt><dd class=\"long\">{4}</dd>\n" +
                    "<dt></dt><dd class=\"mid\"></dd>\n" +
                    "<dt>Card Num</dt><dd>{1}</dd>\n" +
                    "<dt>Sec Code</dt><dd class=\"short\">{3}</dd>\n" +
                    "<dt>Addr / Zip</dt><dd class=\"long\">{5} / {6}</dd>\n" +
                    "</dl>",
                    DB.Str(dr["CCType" + PmtNum]),
                    CCNum,
                    DB.Str(dr["CCExpDt" + PmtNum]),
                    SecCode,
                    DB.Str(dr["CCName" + PmtNum]),
                    DB.Str(dr["CCAddr" + PmtNum]),
                    DB.Str(dr["CCZip" + PmtNum]),
                    Fmt.Dollar(DB.Dec(dr["PmtAmt" + PmtNum])));
                Html += string.Format(
                    "<tr><td colspan=\"11\" class=\"nil\" /></tr>\n" +
                    "<tr>\n" +
                    "<td colspan=\"2\" />\n" +
                    "<td colspan=\"7\">{0}</td>\n" +
                    "</tr>\n",
                    CardInfo);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex);
            Response.Write(Err.Html());
        }

        return(Html);
    }
示例#15
0
    // find the given text box in the given row of the food menu table
    //private String FindTextBox(ref TableRow tr, String ID)
    //{
    //	String Text = "";

    //	try
    //	{
    //		Control Ctrl = tr.FindControl(ID);
    //		if (Ctrl != null)
    //		{
    //			TextBox txtBox = new TextBox();
    //			HtmlInputHidden txtHidden = new HtmlInputHidden();

    //			if (Ctrl.GetType() == txtBox.GetType())
    //			{
    //				txtBox = (TextBox)Ctrl;
    //				Text = txtBox.Text.Trim();
    //			}
    //			else
    //				if (Ctrl.GetType() == txtHidden.GetType())
    //				{
    //					txtHidden = (HtmlInputHidden)Ctrl;
    //					Text = txtHidden.Value.Trim();
    //				}
    //		}
    //	}
    //	catch (Exception Ex)
    //	{
    //		Err Err = new Err(Ex);
    //		Response.Write(Err.Html());
    //	}

    //	return Text;
    //}

    // retrieve the food menu items for the job and present them as rows in the menu table
    private void LoadFood()
    {
        if (JobRno > 0)
        {
            String Sql = "";

            try
            {
                // look for duplicates
                Sql =
                    "Select f1.FoodSeq " +
                    "From mcJobFood f1 Inner Join mcJobFood f2 " +
                    "On f1.JobRno = f2.JobRno And f1.FoodSeq <> f2.FoodSeq " +
                    "And f1.Category = f2.Category And f1.MenuItem = f2.MenuItem " +
                    "Where f1.JobRno = " + JobRno;
                DupSeq Dups = new DupSeq(db, Sql);

                Sql =
                    "Select f.*, i.ServingQuote, i.ServingPrice, i.InaccuratePriceFlg, i.RecipeRno " +
                    "From mcJobFood f Left Join mcJobMenuItems i on f.MenuItemRno = i.MenuItemRno " +
                    "Where JobRno = " + JobRno + " And FoodSeq Is Not Null " +
                    "Order By FoodSeq";
                DataTable dt = db.DataTable(Sql, 300);
                //cItems = dt.Rows.Count + 1;
                cItems = dt.Rows.Count;
                AddLines();

                int iRow = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    iRow++;
                    TableRow tr = tblFood.Rows[iRow];

                    bool fDup = Dups.In(DB.Int32(dr["FoodSeq"]));

                    HtmlInputHidden txtFoodSeq = (HtmlInputHidden)tr.FindControl("txtFoodSeq" + iRow);
                    txtFoodSeq.Value = DB.Str(dr["FoodSeq"]);

                    HtmlInputHidden hfJobFoodRno = (HtmlInputHidden)tr.FindControl("hfJobFoodRno" + iRow);
                    hfJobFoodRno.Value = DB.Str(dr["JobFoodRno"]);

                    HtmlInputHidden hfProposal = (HtmlInputHidden)tr.FindControl("hfProposal" + iRow);
                    hfProposal.Value = DB.Str(dr["ProposalMenuItem"]);

                    HtmlInputHidden hfIngredSelFlg     = (HtmlInputHidden)tr.FindControl("hfIngredSelFlg" + iRow);
                    HtmlInputHidden hfOrigIngredSelFlg = (HtmlInputHidden)tr.FindControl("hfOrigIngredSelFlg" + iRow);
                    bool            fIngredSel         = DB.Bool(dr["IngredSelFlg"]);
                    hfIngredSelFlg.Value         =
                        hfOrigIngredSelFlg.Value = fIngredSel.ToString();

                    HtmlInputHidden hfIngredSel     = (HtmlInputHidden)tr.FindControl("hfIngredSel" + iRow);
                    HtmlInputHidden hfOrigIngredSel = (HtmlInputHidden)tr.FindControl("hfOrigIngredSel" + iRow);
                    hfIngredSel.Value         =
                        hfOrigIngredSel.Value = DB.Str(dr["IngredSel"]);

                    HtmlInputHidden hfIngredSelAutoPop = (HtmlInputHidden)tr.FindControl("hfIngredSelAutoPop" + iRow);
                    hfIngredSelAutoPop.Value = false.ToString();

                    TextBox         txtCategory    = (TextBox)tr.FindControl("txtCategory" + iRow);
                    HtmlInputHidden hfOrigCategory = (HtmlInputHidden)tr.FindControl("hfOrigCategory" + iRow);
                    txtCategory.Text         =
                        hfOrigCategory.Value = DB.Str(dr["Category"]);
                    txtCategory.CssClass     = (fDup ? "DupFoodCategory " : "") + "FoodCategory";

                    TextBox         txtMenuItem    = (TextBox)tr.FindControl("txtMenuItem" + iRow);
                    HtmlInputHidden hfOrigMenuItem = (HtmlInputHidden)tr.FindControl("hfOrigMenuItem" + iRow);
                    txtMenuItem.Text         =
                        hfOrigMenuItem.Value = DB.Str(dr["MenuItem"]);
                    txtMenuItem.CssClass     = (fDup ? "DupMenuItem " : "") + "MenuItem";

                    SelectList slMenuItem = SelectList.Find("MenuItem" + iRow);
                    if (slMenuItem != null)
                    {
                        Sql = "Select Distinct MenuItem From mcJobMenuItems Where Category = " + DB.PutStr(txtCategory.Text) + " And HideFlg != 1 Order By MenuItem";
                        slMenuItem.ClearValues();
                        slMenuItem.AddDBValues(db, Sql);
                    }

                    Label lblIngredSel = (Label)tr.FindControl("lblIngredSel" + iRow);
                    if (fIngredSel)
                    {
                        string ToolTip = "<div class='IngredSelQtip'>Selected Ingredients</div>";
                        Sql = string.Format(
                            "Select Coalesce(i.Name, r.Name) as Name, " +
                            "r.GlutenFreeFlg, r.VeganFlg, r.VegetarianFlg, r.DairyFreeFlg, r.NutsFlg " +
                            "From RecipeIngredXref x " +
                            "Left Join Ingredients i On i.IngredRno = x.IngredRno " +
                            "Left Join Recipes r on r.RecipeRno = x.SubrecipeRno " +
                            "Where x.RecipeRno = {0} " +
                            "And RecipeIngredRno In ({1}) " +
                            "Order By x.RecipeSeq",
                            DB.Int32(dr["RecipeRno"]),
                            (hfIngredSel.Value != string.Empty ? hfIngredSel.Value : "null"));
                        DataTable dtXref = db.DataTable(Sql);
                        foreach (DataRow drXref in dtXref.Rows)
                        {
                            ToolTip += DB.Str(drXref["Name"]) +
                                       (DB.Bool(drXref["GlutenFreeFlg"]) ? " [GF]"  : string.Empty) +
                                       (DB.Bool(drXref["VeganFlg"])      ? " [V]"   : string.Empty) +
                                       (DB.Bool(drXref["VegetarianFlg"]) ? " [Veg]" : string.Empty) +
                                       (DB.Bool(drXref["DairyFreeFlg"])  ? " [DF]"  : string.Empty) +
                                       (DB.Bool(drXref["NutsFlg"])       ? " [N]"   : string.Empty) +
                                       "<br/>";
                        }

                        lblIngredSel.ToolTip = ToolTip;
                        lblIngredSel.Attributes.Add("style", "display: inline;");
                    }
                    else
                    {
                        lblIngredSel.ToolTip             = "Select ingredients for the menu item.";
                        lblIngredSel.Attributes["style"] = string.Empty;
                    }

                    //TextBox txtQtyNote = (TextBox)tr.FindControl("txtQtyNote" + iRow);
                    //TextBox txtOrigQtyNote = (TextBox)tr.FindControl("txtOrigQtyNote" + iRow);
                    //txtQtyNote.Text =
                    //txtOrigQtyNote.Text = DB.Str(dr["QtyNote"]);

                    TextBox txtQty     = (TextBox)tr.FindControl("txtQty" + iRow);
                    TextBox txtOrigQty = (TextBox)tr.FindControl("txtOrigQty" + iRow);
                    txtQty.Text         =
                        txtOrigQty.Text = DB.Int32(dr["Qty"]).ToString("##,###");

                    TextBox txtServiceNote     = (TextBox)tr.FindControl("txtServiceNote" + iRow);
                    TextBox txtOrigServiceNote = (TextBox)tr.FindControl("txtOrigServiceNote" + iRow);
                    txtServiceNote.Text         =
                        txtOrigServiceNote.Text = DB.Str(dr["ServiceNote"]);

                    decimal ServingQuote = DB.Dec(dr["ServingQuote"]);
                    Label   lblQuote     = (Label)tr.FindControl("lblQuote" + iRow);
                    lblQuote.Text = Fmt.Dollar(ServingQuote);

                    decimal ServingPrice = DB.Dec(dr["ServingPrice"]);
                    Label   lblPrice     = (Label)tr.FindControl("lblPrice" + iRow);
                    lblPrice.Text = Fmt.Dollar(ServingPrice);

                    bool  fInaccuratePrice   = DB.Bool(dr["InaccuratePriceFlg"]);
                    Label lblInaccuratePrice = (Label)tr.FindControl("lblInaccuratePrice" + iRow);
                    if (fInaccuratePrice)
                    {
                        lblInaccuratePrice.CssClass = "icon-dollar";
                        lblInaccuratePrice.ToolTip  = "Cost and Price are inaccurate because there are ingredients with no price from receipts.";
                    }
                }
            }
            catch (Exception Ex)
            {
                Err Err = new Err(Ex, Sql);
                Response.Write(Err.Html());
            }
        }
        else
        {
            cItems = 1;
            AddLines();
        }

        //if (FocusField.Length == 0) { FocusField = "txtCategory" + cItems; }
    }
示例#16
0
    public string FindCheckNum()
    {
        string Html = string.Empty;
        string Sql  = string.Empty;

        try
        {
            if (txtCheckNum.Text.Length > 0)
            {
                decimal RptTotal = 0;

                Sql = string.Format(
                    "Select p.JobRno, p.Seq, p.Reference, Coalesce(cu.Name, c.Name) as Customer, " +
                    "j.JobDate, j.SubTotAmt, j.PreTaxSubTotAmt, j.SalesTaxTotAmt, j.InvTotAmt, j.InvBalAmt " +
                    "From Payments p " +
                    "Inner Join mcJobs j on p.JobRno = j.JobRno " +
                    "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
                    "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
                    "Where Method = 'Check' And Reference Like '%{0}%' " +
                    "Order By p.JobRno, p.Seq",
                    txtCheckNum.Text);
                DataTable dt = db.DataTable(Sql);
                foreach (DataRow dr in dt.Rows)
                {
                    string  Customer      = DB.Str(dr["Customer"]);
                    string  Ref           = string.Format("Payment #{0} - {1}", DB.Int32(dr["Seq"]), DB.Str(dr["Reference"]));
                    decimal Subtotal      = DB.Dec(dr["SubTotAmt"]);
                    decimal OtherTotal    = DB.Dec(dr["PreTaxSubTotAmt"]) - Subtotal;
                    decimal SalesTaxTotal = DB.Dec(dr["SalesTaxTotAmt"]);
                    decimal Total         = DB.Dec(dr["InvTotAmt"]);
                    decimal Balance       = DB.Dec(dr["InvBalAmt"]);

                    Html += string.Format(
                        "<tr>\n" +
                        "<td class=\"Right\"><a href=\"Invoice.aspx?JobRno={0}\" target=\"invoice\">{0}</a></td>\n" +
                        "<td>{1}</td>\n" +
                        "<td class=\"Center\">{2}</td>\n" +
                        "<td>{3}</td>\n" +
                        "<td class=\"Right\">{4}</td>\n" +
                        "<td class=\"Right\">{5}</td>\n" +
                        "<td class=\"Right\">{6}</td>\n" +
                        "<td class=\"Right\">{7}</td>\n" +
                        "</tr>\n",
                        DB.Int32(dr["JobRno"]),
                        DB.Str(dr["Customer"]),
                        Fmt.Dt(DB.DtTm(dr["JobDate"])),
                        Ref,
                        Fmt.Dollar(Subtotal),
                        Fmt.Dollar(OtherTotal),
                        Fmt.Dollar(SalesTaxTotal),
                        Fmt.Dollar(Total));
                    RptTotal += Math.Round(Total, 2);

                    //Html += CCPayment(dr, "1");
                    //Html += CCPayment(dr, "2");
                    //Html += CCPayment(dr, "3");
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        return(Html);
    }
示例#17
0
    protected string CCPayments()
    {
        string Html = string.Empty;
        string Sql  = string.Empty;

        try
        {
            decimal RptTotal   = 0;
            decimal DailyTotal = 0;
            int     DailyCount = 0;

            DateTime PrevDay   = DateTime.MinValue;
            bool     fFirstDay = true;

            Sql = string.Format(
                "Select Cast(p.PaymentDt as Date) as PaymentDt, p.Amount, p.Type, p.Reference, p.CCStatus, p.CCResult, " +
                "p.CCPmtDtTm, p.CCPmtUser, p.CCPrintDtTm, p.CCPrintUser, p.JobRno, p.Seq, " +
                "Coalesce(cu.Name, c.Name) as Customer, j.JobDate, j.Location, j.InvTotAmt " +
                "From Payments p " +
                "Inner Join mcJobs j on p.JobRno = j.JobRno " +
                "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
                "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
                "Where PaymentDt Between {0} And GetDate() And Method = 'CreditCard' " +
                "Order By Cast(p.PaymentDt as Date), p.JobRno, p.Seq",
                DB.PutDtTm(Str.DtTm(txtStartDate.Text)));

            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                DateTime PmtDate     = DB.DtTm(dr["PaymentDt"]);
                decimal  PmtAmt      = DB.Dec(dr["Amount"]);
                string   sPmtAmt     = Fmt.Dollar(PmtAmt);
                string   PmtType     = DB.Str(dr["Type"]);
                string   PmtRef      = DB.Str(dr["Reference"]);
                string   CCStatus    = DB.Str(dr["CCStatus"]);
                string   CCResult    = DB.Str(dr["CCResult"]);
                DateTime CCPmtDtTm   = DB.DtTm(dr["CCPmtDtTm"]);
                string   CCPmtUser   = DB.Str(dr["CCPmtUser"]);
                DateTime CCPrintDtTm = DB.DtTm(dr["CCPrintDtTm"]);
                String   CCPrintUser = DB.Str(dr["CCPrintUser"]);
                Int32    JobRno      = DB.Int32(dr["JobRno"]);
                string   Customer    = DB.Str(dr["Customer"]);
                DateTime JobDate     = DB.DtTm(dr["JobDate"]);
                string   Location    = DB.Str(dr["Location"]);
                decimal  Total       = DB.Dec(dr["InvTotAmt"]);
                bool     fDeclined   = (CCStatus.ToLower() == "declined");

                if (fDeclined)
                {
                    sPmtAmt  = "** " + sPmtAmt;
                    CCStatus = "<b>" + CCStatus + "</b>";
                }

                if (PmtDate != PrevDay)
                {
                    if (!fFirstDay)
                    {
                        //Html += "\t\t</tbody>\n\t</table>\n";
                        Html += string.Format(
                            "<tr>\n" +
                            "<td align=\"right\"><b>{0}</b></td>\n" +
                            "<td><b>Total</b></td>\n" +
                            "<td align=\"right\"><b>{1}</b></td>\n" +
                            "<td><b>Count</b></td>\n" +
                            "<td colspan=\"7\"></td>\n" +
                            "</tr>\n",
                            Fmt.Dollar(DailyTotal),
                            DailyCount);
                        Html      += "\t\t</tbody>\n";
                        DailyCount = 0;
                        DailyTotal = 0;
                    }
                    Html += string.Format(
                        //"<div class=\"FeatureSub\">{0:M/d/yyyy}</div>\n" +
                        //"\t<table class=\"Acct\">\n" +
                        "\t\t<thead>\n" +
                        "\t\t\t<tr><td colspan=\"11\"><div class=\"FeatureSub\">{0:M/d/yyyy}</div></td></tr>\n" +
                        "\t\t\t<tr>\n" +
                        "\t\t\t\t<th>Amount</th>\n" +
                        "\t\t\t\t<th>Type</th>\n" +
                        "\t\t\t\t<th>Reference</th>\n" +
                        "\t\t\t\t<th>Status</th>\n" +
                        "\t\t\t\t<th>Paid</th>\n" +
                        "\t\t\t\t<th>Printed</th>\n" +
                        "\t\t\t\t<th style=\"white-space: nowrap;\">Inv #</th>\n" +
                        "\t\t\t\t<th>Name</th>\n" +
                        "\t\t\t\t<th>Job Date</th>\n" +
                        "\t\t\t\t<th>Location</th>\n" +
                        "\t\t\t\t<th>Total</th>\n" +
                        "\t\t\t</tr>\n" +
                        "\t\t</thead>\n" +
                        "\t\t</tbody>\n",
                        PmtDate
                        );
                    PrevDay   = PmtDate;
                    fFirstDay = false;
                }

                Html += string.Format(
                    "<tr class=\"{9}\">\n" +
                    "<td class=\"Right\">{0}</td>\n" +
                    "<td>{1}</td>\n" +
                    "<td>{2}</td>\n" +
                    "<td>{3}</td>\n" +
                    "<td>{4}</td>\n" +
                    "<td>{5}</td>\n" +
                    "<td class=\"Right\"><a href=\"Invoice.aspx?JobRno={6}\" target=\"invoice\">{6}</a></td>\n" +
                    "<td>{7}</td>\n" +
                    "<td class=\"Center\">{8}</td>\n" +
                    "<td>{9}</td>\n" +
                    "<td class=\"Right\">{10}</td>\n" +
                    "</tr>\n",
                    sPmtAmt,
                    PmtType,
                    PmtRef,
                    CCStatus,
                    string.Format("{0} - {1}", Fmt.Tm(CCPmtDtTm), CCPmtUser),
                    string.Format("{0} - {1}", Fmt.Tm(CCPrintDtTm), CCPrintUser),
                    JobRno,
                    Customer,
                    Fmt.Dt(JobDate),
                    Location,
                    Fmt.Dollar(Total),
                    (fDeclined ? "Declined" : string.Empty));

                DailyCount++;
                DailyTotal += Math.Round(PmtAmt, 2);
                RptTotal   += Math.Round(PmtAmt, 2);
            }

            Html += string.Format(
                "<tr>\n" +
                "<td align=\"right\"><b>{0}</b></td>\n" +
                "<td><b>Total</b></td>\n" +
                "<td align=\"right\"><b>{1}</b></td>\n" +
                "<td><b>Count</b></td>\n" +
                "<td colspan=\"7\"></td>\n" +
                "</tr>\n",
                Fmt.Dollar(DailyTotal),
                DailyCount);
            Html += "\t\t</tbody>\n";

            Html += string.Format(
                "<tr><td colspan=\"11\">&nbsp;</td></tr>\n" +
                "<tr>\n" +
                "<td align=\"right\"><b>{0}</b></td>\n" +
                "<td><b>Total</b></td>\n" +
                "<td align=\"right\"><b>{1}</b></td>\n" +
                "<td><b>Count&nbsp;&nbsp;Report Totals</b></td>\n" +
                "<td colspan=\"7\"></td>\n" +
                "</tr>\n",
                Fmt.Dollar(RptTotal),
                dt.Rows.Count);
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        return(Html);
    }