Beispiel #1
0
    protected void GetData()
    {
        string Sql = string.Format("Select * From SysParms Where SysParmName = {0}", DB.PutStr(Misc.cnSlingUserEmail));

        ClearData();

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                hfEmailRno.Value    = DB.Int32(dr["SysParmRno"]).ToString();
                txtUser.Text        = DB.Str(dr["SysParmValue"]);
                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 * From SysParms Where SysParmName = {0}", DB.PutStr(Misc.cnSlingUserPassword));
            dr  = db.DataRow(Sql);
            if (dr != null)
            {
                hfPasswordRno.Value = DB.Int32(dr["SysParmRno"]).ToString();
                txtPassword.Text    = DB.Str(dr["SysParmValue"]);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Beispiel #2
0
    protected void GetData(int Rno)
    {
        string Sql = string.Format(
            "Select * " +
            "From Vendors " +
            "Where VendorRno = {0}",
            Rno);

        ClearData();

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                hfRno.Value         = Rno.ToString();
                txtName.Text        = DB.Str(dr["Name"]);
                chkHide.Checked     = DB.Bool(dr["HideFlg"]);
                txtPhone.Text       = DB.Str(dr["Phone"]);
                txtContact.Text     = DB.Str(dr["Contact"]);
                txtEmail.Text       = DB.Str(dr["Email"]);
                txtWebsite.Text     = DB.Str(dr["Website"]);
                txtNote.Text        = DB.Str(dr["Note"]);
                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 Purchases Where VendorRno = {0}", Rno);
                int Count = db.SqlNum(Sql);

                if (Count > 0)
                {
                    btnDelete.Enabled = false;
                    btnDelete.ToolTip = string.Format("Vendor for {0} receipts", Count);
                }
                else
                {
                    btnDelete.Enabled = true;
                    btnDelete.ToolTip = "Not a vendor for any receipts";
                }

                FocusField = "txtName";
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Beispiel #3
0
    protected void GetData(string userNameLabel)
    {
        string userName = getUserNameFromListFormatStyle(userNameLabel);
        string Sql      = string.Format("Select * From Users Where UserName = {0}", DB.PutStr(userName));

        ClearData();

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                txtCurrUser.Value      = listFormatStyle(DB.Str(dr["UserCommonName"]), DB.Str(dr["UserName"]));
                txtUserCommonName.Text = DB.Str(dr["UserCommonName"]);
                txtUserName.Text       = DB.Str(dr["UserName"]);
                PageAccess.AccessLevels AccessLevel = (PageAccess.AccessLevels)DB.Int32(dr["AccessLevel"]);
                switch (AccessLevel)
                {
                case PageAccess.AccessLevels.General:
                    rdoGeneral.Checked = true;
                    break;

                case PageAccess.AccessLevels.OfficeStaff:
                    rdoOfficeStaff.Checked = true;
                    break;

                case PageAccess.AccessLevels.Everything:
                    rdoEverything.Checked = true;
                    break;

                case PageAccess.AccessLevels.Admin:
                    rdoAdmin.Checked = true;
                    break;
                }
                chkDisabled.Checked = DB.Bool(dr["DisabledFlg"]);
                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"]);
            }

            btnDelete.Enabled = true;
            btnDelete.ToolTip = "";
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Beispiel #4
0
    protected void GetData(int Rno)
    {
        string Sql = string.Format(
            "Select * " +
            "From Purchases p Inner Join Vendors v On p.VendorRno = v.VendorRno " +
            "Where PurchaseRno = {0}",
            Rno);

        ClearData();

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                hfRno.Value           = Rno.ToString();
                txtPurchaseDate.Text  = Fmt.Dt(DB.DtTm(dr["PurchaseDt"]));
                hfVendorRno.Value     = DB.Int32(dr["VendorRno"]).ToString();
                txtVendor.Text        = DB.Str(dr["Name"]);
                txtOrderNum.Text      = DB.Str(dr["PurchaseOrdNum"]);
                txtVendorInvoice.Text = DB.Str(dr["VendorInvNum"]);
                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"]);

                btnDelete.Enabled = true;

                FocusField = "txtPurchaseDate";

                LoadDetails(Rno);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
    protected void GetData(string Category)
    {
        string Sql = string.Format("Select * From mcJobMenuCategories Where Category = {0}", DB.PutStr(Category));

        ClearData();

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                txtCurrCategory.Value  =
                    txtCategory.Text   = DB.Str(dr["Category"]);
                chkMultiSelect.Checked = DB.Bool(dr["MultSelFlg"]);
                chkHide.Checked        = DB.Bool(dr["HideFlg"]);
                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 * From mcJobMenuItems Where Category = {0} And (HideFlg = 0 Or HideFlg Is Null) Order By CategorySortOrder, MenuItem", DB.PutStr(txtCategory.Text));
            DataTable dt = db.DataTable(Sql);
            int       i  = 0;
            foreach (DataRow drMenuItem in dt.Rows)
            {
                HtmlGenericControl li = new HtmlGenericControl("li");

                HtmlGenericControl sp = new HtmlGenericControl("span");
                sp.Attributes.Add("class", "ui-icon ui-icon-arrowthick-2-n-s");
                li.Controls.Add(sp);

                HtmlInputHidden hf = new HtmlInputHidden();
                hf.ID    = string.Format("hfMenuItem{0}", i);
                hf.Value = DB.Int32(drMenuItem["MenuItemRno"]).ToString();
                li.Controls.Add(hf);

                hf       = new HtmlInputHidden();
                hf.ID    = string.Format("hfSortOrder{0}", i);
                hf.Value = DB.Int32(drMenuItem["CategorySortOrder"]).ToString();
                hf.Attributes.Add("class", "SortOrder");
                li.Controls.Add(hf);

                HtmlGenericControl lbl = new HtmlGenericControl("label");
                lbl.InnerText = DB.Str(drMenuItem["MenuItem"]);
                li.Controls.Add(lbl);

                ulItems.Controls.Add(li);

                i++;
            }
            NumMenuItems = i;

            Sql = string.Format("Select Count(*) From mcJobFood Where Category = {0}", DB.PutStr(txtCategory.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";
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Beispiel #6
0
    private void Page_PreRender(object sender, System.EventArgs e)
    {
        Misc.DefaultProposalMenu(JobRno);
        string Sql = string.Format(
            "Select * " +
            "From mcJobFood " +
            //"Where JobRno = {0} And (MenuItem <> '' Or MenuItem Is Null) " +
            "Where JobRno = {0} " +
            "Order By IsNull(ProposalSeq, 0), IsNull(FoodSeq, 0)",
            JobRno);

        try
        {
            DB db = new DB();
            Misc.DefaultInvoicePrice(db, JobRno);

            DataTable dt    = db.DataTable(Sql, 300);
            int       cLine = 0;

            if (FirstTime(dt))
            {
                //ulMenu.Controls.Add(EditLine(cLine++, 0, true, NewTitle));
            }

            foreach (DataRow dr in dt.Rows)
            {
                string MenuItem         = DB.Str(dr["MenuItem"]);
                string ProposalMenuItem = DB.Str(dr["ProposalMenuItem"]);
                bool   fTitleLine       = DB.Bool(dr["ProposalTitleFlg"]);
                ulMenu.Controls.Add(EditLine(cLine++, DB.Int32(dr["JobFoodRno"]), fTitleLine, (ProposalMenuItem.Length > 0 ? ProposalMenuItem : MenuItem), DB.Str(dr["Category"]), DB.Str(dr["MenuItem"]), DB.Bool(dr["ProposalHideFlg"])));
            }
            hfNumLines.Value = cLine.ToString();

            NewTitleHtml = Misc.ToString(EditLine("xxxx", 0, true, NewTitle));
            NewItemHtml  = Misc.ToString(EditLine("xxxx", 0, false, NewItem));

            {
                Sql = "Select 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;
                DataRow dr = db.DataRow(Sql);
                if (dr != null)
                {
                    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"]);

                    hfJobRno.Value            = JobRno.ToString();
                    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());
        }
    }
Beispiel #7
0
    protected void GetData(int Rno)
    {
        string Sql = string.Format(
            "Select * " +
            "From Customers " +
            "Where CustomerRno = {0}",
            Rno);

        ClearData();

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                hfRno.Value                      = Rno.ToString();
                txtName.Text                     = DB.Str(dr["Name"]);
                chkHide.Checked                  = (DB.DtTm(dr["InactiveDtTm"]) != DateTime.MinValue);
                chkCompany.Checked               = DB.Bool(dr["CompanyFlg"]);
                chkTaxExempt.Checked             = DB.Bool(dr["TaxExemptFlg"]);
                chkOnlineOrders.Checked          = DB.Bool(dr["OnlineOrderFlg"]);
                chkEmailConfirmations.Checked    = DB.Bool(dr["EmailConfirmationsFlg"]);
                txtAnnualContractSignedName.Text = DB.Str(dr["AnnualContractSignedName"]);
                txtAnnualContractSignedDate.Text = Fmt.Dt(DB.DtTm(dr["AnnualContractSignedDtTm"]));
                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 Contacts Where CustomerRno = {0}", Rno);
                int Count = db.SqlNum(Sql);

                if (Count > 0)
                {
                    btnDelete.Enabled = false;
                    btnDelete.ToolTip = string.Format("Customer for {0} contacts", Count);
                }
                else
                {
                    btnDelete.Enabled = true;
                    btnDelete.ToolTip = "Not a customer for any contacts";
                }

                FocusField = "txtName";

                // contacts
                Sql = string.Format("Select ContactRno, Name From Contacts Where CustomerRno = {0} Order By Name", Rno);
                DataTable dt = db.DataTable(Sql);
                foreach (DataRow drContact in dt.Rows)
                {
                    int ContactRno        = DB.Int32(drContact["ContactRno"]);
                    HtmlGenericControl li = new HtmlGenericControl("li");
                    HtmlAnchor         a  = new HtmlAnchor()
                    {
                        InnerText = DB.Str(drContact["Name"]),
                        HRef      = Page.ResolveUrl(string.Format("{0}?ContactRno={1}", @"~\Contacts.aspx", DB.Int32(drContact["ContactRno"]))),
                        Target    = "Contact"
                    };
                    li.Controls.Add(a);
                    phContacts.Controls.Add(li);
                }

                // jobs
                Sql = string.Format("Select JobRno, JobDesc, JobDate From mcJobs Where ContactRno In (Select ContactRno From Contacts Where CustomerRno = {0}) Order By JobDate Desc", Rno);
                dt  = db.DataTable(Sql);
                foreach (DataRow drJobs in dt.Rows)
                {
                    int JobRno            = DB.Int32(drJobs["JobRno"]);
                    HtmlGenericControl li = new HtmlGenericControl("li");
                    HtmlAnchor         a  = new HtmlAnchor()
                    {
                        InnerText = string.Format("{0} {1}", JobRno, DB.Str(drJobs["JobDesc"])),
                        HRef      = Page.ResolveUrl(string.Format("{0}?JobRno={1}", @"~\Job.aspx", JobRno)), Target = "Job"
                    };
                    HtmlGenericControl div = new HtmlGenericControl("div")
                    {
                        InnerText = Fmt.Dt(DB.DtTm(drJobs["JobDate"]))
                    };
                    div.Attributes.Add("class", "Date");
                    li.Controls.Add(div);
                    li.Controls.Add(a);
                    phJobs.Controls.Add(li);
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Beispiel #8
0
    protected void GetData(int Rno)
    {
        string Sql = string.Format(
            "Select i.*, u.UnitSingle, u.UnitPlural From " +
            "(Select i.*, (Select Top 1 PurchaseUnitRno From PurchaseDetails Where IngredRno = i.IngredRno Order By CreatedDtTm Desc) PurchaseUnitRno From Ingredients i Where IngredRno = {0}) " +
            "i Left Join Units u on i.PurchaseUnitRno = u.UnitRno",
            Rno);

        ClearData();

        try
        {
            DataTable dt = db.DataTable(Sql);
            if (dt.Rows.Count > 0)
            {
                DataRow dr        = dt.Rows[0];
                int     IngredRno = DB.Int32(dr["IngredRno"]);
                txtRno.Value           = IngredRno.ToString();
                txtName.Text           = DB.Str(dr["Name"]);
                chkHide.Checked        = DB.Bool(dr["HideFlg"]);
                chkStocked.Checked     = DB.Bool(dr["StockedFlg"]);
                chkNonPurchase.Checked = DB.Bool(dr["NonPurchaseFlg"]);
                string DryLiquid = DB.Str(dr["DryLiquid"]);
                //rbDry.Checked = DryLiquid == Dry;
                //rbLiquid.Checked = DryLiquid == Liquid;
                decimal Qty = DB.Dec(dr["StockedPurchaseQty"]);
                txtStockedPurchaseQty.Text = Str.ShowFract(Qty);
                hfPrefVendors.Value        = DB.Str(dr["PrefVendors"]);
                hfRejVendors.Value         = DB.Str(dr["RejVendors"]);
                txtPrefBrands.Text         = DB.Str(dr["PrefBrands"]);
                txtRejBrands.Text          = DB.Str(dr["RejBrands"]);
                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 RecipeIngredXref Where IngredRno = {0}", IngredRno);
                int Count = db.SqlNum(Sql);

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

                FindRecipes(IngredRno);
                LoadConversions(IngredRno);
                PriceHistory(IngredRno);

                FocusField = "txtName";
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Beispiel #9
0
    protected void GetData(int Rno)
    {
        string Sql = string.Format(
            "Select * " +
            "From Units " +
            "Where UnitRno = {0}",
            Rno);

        ClearData();

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                hfRno.Value         = Rno.ToString();
                txtSingle.Text      = DB.Str(dr["UnitSingle"]);
                txtPlural.Text      = DB.Str(dr["UnitPlural"]);
                chkHide.Checked     = DB.Bool(dr["HideFlg"]);
                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 RecipeIngredXref Where UnitRno = {0}", Rno);
                int NumRecipes = db.SqlNum(Sql);
                int Count      = NumRecipes;
                if (NumRecipes > 0)
                {
                    Sql = string.Format("Select Name, RecipeRno From Recipes Where RecipeRno In (Select RecipeRno From RecipeIngredXref Where UnitRno = {0}) Order By Name", Rno);
                    DataTable dtRecipes = db.DataTable(Sql);
                    foreach (DataRow drRecipe in dtRecipes.Rows)
                    {
                        HtmlGenericControl li = new HtmlGenericControl("li");
                        HtmlAnchor         a  = new HtmlAnchor();
                        a.InnerText = DB.Str(drRecipe["Name"]);
                        a.HRef      = string.Format("Recipes.aspx?Rno={0}", DB.Int32(drRecipe["RecipeRno"]));
                        a.Target    = "UnitUsed";
                        li.Controls.Add(a);
                        ulRecipes.Controls.Add(li);
                    }
                }

                //Sql = string.Format("Select Count(*) From VendorIngredXref Where PurchaseUnitRno = {0}", Rno);
                //            int NumIngreds = db.SqlNum(Sql);
                //            Count += NumIngreds;
                //if (NumIngreds > 0)
                //{
                //    Sql = string.Format("Select Name From Ingredients Where IngredRno In (Select IngredRno From VendorIngredXref Where PurchaseUnitRno = {0}) Order By Name", Rno);
                //    DataTable dtIngreds = db.DataTable(Sql);
                //    foreach (DataRow drIngred in dtIngreds.Rows)
                //    {
                //        HtmlGenericControl li = new HtmlGenericControl("li");
                //        HtmlAnchor a = new HtmlAnchor();
                //        a.InnerText = DB.Str(drIngred["Name"]);
                //        a.HRef = string.Format("Recipes.aspx?Rno={0}", DB.Int32(drRecipe["RecipeRno"]));
                //        a.Target = "UnitUsed";
                //        li.Controls.Add(a);
                //        ulVendorIngred.Controls.Add(li);

                //        HtmlGenericControl li = new HtmlGenericControl("li");
                //        HtmlAnchor a = new HtmlAnchor();
                //        a.InnerText = DB.Str(drRecipe["Name"]);
                //        a.HRef = string.Format("Recipes.aspx?Rno={0}", DB.Int32(drRecipe["RecipeRno"]));
                //        a.Target = "UnitUsed";
                //        li.Controls.Add(a);
                //        ulRecipes.Controls.Add(li);

                //    }
                //}

                Sql = string.Format("Select Count(*) From IngredConv Where PurchaseUnitRno = {0} Or RecipeUnitRno = {0}", Rno);
                int NumIngreds = db.SqlNum(Sql);
                Count += NumIngreds;
                if (NumIngreds > 0)
                {
                    Sql = string.Format("Select Name, IngredRno From Ingredients Where IngredRno In (Select IngredRno From IngredConv Where PurchaseUnitRno = {0} Or RecipeUnitRno = {0}) Order By Name", Rno);
                    DataTable dtIngreds = db.DataTable(Sql);
                    foreach (DataRow drIngred in dtIngreds.Rows)
                    {
                        HtmlGenericControl li = new HtmlGenericControl("li");
                        HtmlAnchor         a  = new HtmlAnchor();
                        a.InnerText = DB.Str(drIngred["Name"]);
                        a.HRef      = string.Format("Ingredients.aspx?Rno={0}", DB.Int32(drIngred["IngredRno"]));
                        a.Target    = "UnitUsed";
                        li.Controls.Add(a);
                        ulIngredConv.Controls.Add(li);
                    }
                }

                if (Count > 0)
                {
                    btnDelete.Enabled = false;
                    btnDelete.ToolTip = string.Format("Units for {0} recipe ingredients & ingredient conversions", Count);
                }
                else
                {
                    btnDelete.Enabled = true;
                    btnDelete.ToolTip = "Not used by any recipe ingredients & ingredient conversions";
                }

                FocusField = "txtSingle";

                Sql = string.Format(
                    "Select c.*, up.UnitSingle As PurchaseUnitSingle, up.UnitPlural As PurchaseUnitPlural, " +
                    "ur.UnitSingle As RecipeUnitSingle, ur.UnitPlural As RecipeUnitPlural " +
                    "From IngredConv c " +
                    "Inner Join Units up On c.PurchaseUnitRno = up.UnitRno " +
                    "Inner Join Units ur On c.RecipeUnitRno = ur.UnitRno " +
                    "Where IngredRno = 0 And (PurchaseUnitRno = {0} Or RecipeUnitRno = {0}) Order By PurchaseQty Desc, RecipeQty", Rno);
                DataTable dt = db.DataTable(Sql);
                foreach (DataRow drConv in dt.Rows)
                {
                    decimal   PurchaseQty = DB.Dec(drConv["PurchaseQty"]);
                    decimal   RecipeQty   = DB.Dec(drConv["RecipeQty"]);
                    TableRow  tr          = new TableRow();
                    TableCell td;

                    td          = new TableCell();
                    td.Text     = Str.ShowFract(RecipeQty);
                    td.CssClass = "Qty";
                    tr.Controls.Add(td);

                    td      = new TableCell();
                    td.Text = DB.Str(drConv["Recipe" + (RecipeQty <= 1 ? "UnitSingle" : "UnitPlural")]);
                    if (DB.Int32(drConv["RecipeUnitRno"]) == Rno)
                    {
                        td.CssClass = "Unit";
                    }
                    tr.Controls.Add(td);

                    td          = new TableCell();
                    td.Text     = Str.ShowFract(PurchaseQty);
                    td.CssClass = "Qty";
                    tr.Controls.Add(td);

                    td      = new TableCell();
                    td.Text = DB.Str(drConv["Purchase" + (PurchaseQty <= 1 ? "UnitSingle" : "UnitPlural")]);
                    if (DB.Int32(drConv["PurchaseUnitRno"]) == Rno)
                    {
                        td.CssClass = "Unit";
                    }
                    tr.Controls.Add(td);

                    tblConv.Controls.Add(tr);
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Beispiel #10
0
    protected void GetData(int Rno)
    {
        string Sql = string.Format(
            "Select * " +
            "From Contacts " +
            "Where ContactRno = {0}",
            Rno);

        ClearData();

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                hfRno.Value = Rno.ToString();
                int CustomerRno = DB.Int32(dr["CustomerRno"]);
                ddlCustomer.ClearSelection();
                ListItem Item = ddlCustomer.Items.FindByValue(CustomerRno == 0 ? "" : CustomerRno.ToString());
                if (Item != null)
                {
                    Item.Selected = true;
                }

                txtName.Text        = DB.Str(dr["Name"]);
                chkHide.Checked     = (DB.DtTm(dr["InactiveDtTm"]) != DateTime.MinValue);
                txtPhone.Text       = DB.Str(dr["Phone"]);
                txtCell.Text        = DB.Str(dr["Cell"]);
                txtFax.Text         = DB.Str(dr["Fax"]);
                txtEmail.Text       = DB.Str(dr["Email"]);
                txtTitle.Text       = DB.Str(dr["Title"]);
                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 mcJobs Where ContactRno = {0}", Rno);
                int Count = db.SqlNum(Sql);

                if (Count > 0)
                {
                    btnDelete.Enabled = false;
                    btnDelete.ToolTip = string.Format("Contact for {0} jobs", Count);
                }
                else
                {
                    btnDelete.Enabled = true;
                    btnDelete.ToolTip = "Not a contact for any jobs";
                }

                FocusField = "txtName";

                // jobs
                Sql = string.Format("Select JobRno, JobDesc, JobDate From mcJobs Where ContactRno = {0} Order By JobDate Desc", Rno);
                DataTable dt = db.DataTable(Sql);
                foreach (DataRow drJobs in dt.Rows)
                {
                    int JobRno            = DB.Int32(drJobs["JobRno"]);
                    HtmlGenericControl li = new HtmlGenericControl("li");
                    HtmlAnchor         a  = new HtmlAnchor()
                    {
                        InnerText = string.Format("{0} {1}", JobRno, DB.Str(drJobs["JobDesc"])),
                        HRef      = Page.ResolveUrl(string.Format("{0}?JobRno={1}", @"~\Job.aspx", JobRno)), Target = "Job"
                    };
                    HtmlGenericControl div = new HtmlGenericControl("div")
                    {
                        InnerText = Fmt.Dt(DB.DtTm(drJobs["JobDate"]))
                    };
                    div.Attributes.Add("class", "Date");
                    li.Controls.Add(div);
                    li.Controls.Add(a);
                    phJobs.Controls.Add(li);
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Beispiel #11
0
    protected void GetData(int Rno, int iCol)
    {
        string Sql = string.Format(
            "Select c.*, cu.Name as CustomerName " +
            "From Contacts c " +
            "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
            "Where ContactRno = {0}",
            Rno);

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                switch (iCol)
                {
                case 1:
                    hfRno1.Value         = Rno.ToString();
                    lblRno1.Text         = Rno.ToString();
                    rdoName1.Text        = DB.Str(dr["Name"]);
                    rdoPhone1.Text       = DB.Str(dr["Phone"]);
                    rdoCell1.Text        = DB.Str(dr["Cell"]);
                    rdoFax1.Text         = DB.Str(dr["Fax"]);
                    rdoEmail1.Text       = DB.Str(dr["Email"]);
                    rdoTitle1.Text       = DB.Str(dr["Title"]);
                    rdoCustomer1.Text    = DB.Str(dr["CustomerName"]);
                    txtCreatedDt1.Text   = Fmt.DtTm(DB.DtTm(dr["CreatedDtTm"]));
                    txtCreatedUser1.Text = DB.Str(dr["CreatedUser"]);
                    txtUpdatedDt1.Text   = Fmt.DtTm(DB.DtTm(dr["UpdatedDtTm"]));
                    txtUpdatedUser1.Text = DB.Str(dr["UpdatedUser"]);

                    rdoName1.Checked                             =
                        rdoPhone1.Checked                        =
                            rdoCell1.Checked                     =
                                rdoFax1.Checked                  =
                                    rdoEmail1.Checked            =
                                        rdoTitle1.Checked        =
                                            rdoCustomer1.Checked = true;

                    FocusField = "rdoName1";
                    break;

                case 2:
                    if (Rno.ToString() != lblRno1.Text)
                    {
                        hfRno2.Value         = Rno.ToString();
                        lblRno2.Text         = Rno.ToString();
                        rdoName2.Text        = DB.Str(dr["Name"]);
                        rdoPhone2.Text       = DB.Str(dr["Phone"]);
                        rdoCell2.Text        = DB.Str(dr["Cell"]);
                        rdoFax2.Text         = DB.Str(dr["Fax"]);
                        rdoEmail2.Text       = DB.Str(dr["Email"]);
                        rdoTitle2.Text       = DB.Str(dr["Title"]);
                        rdoCustomer2.Text    = DB.Str(dr["CustomerName"]);
                        txtCreatedDt2.Text   = Fmt.DtTm(DB.DtTm(dr["CreatedDtTm"]));
                        txtCreatedUser2.Text = DB.Str(dr["CreatedUser"]);
                        txtUpdatedDt2.Text   = Fmt.DtTm(DB.DtTm(dr["UpdatedDtTm"]));
                        txtUpdatedUser2.Text = DB.Str(dr["UpdatedUser"]);

                        if (rdoName1.Text.Length == 0 && rdoName2.Text.Length > 0)
                        {
                            rdoName2.Checked = true;
                        }
                        if (rdoPhone1.Text.Length == 0 && rdoPhone2.Text.Length > 0)
                        {
                            rdoPhone2.Checked = true;
                        }
                        if (rdoCell1.Text.Length == 0 && rdoCell2.Text.Length > 0)
                        {
                            rdoCell2.Checked = true;
                        }
                        if (rdoFax1.Text.Length == 0 && rdoFax2.Text.Length > 0)
                        {
                            rdoFax1.Checked = true;
                        }
                        if (rdoEmail1.Text.Length == 0 && rdoEmail2.Text.Length > 0)
                        {
                            rdoEmail2.Checked = true;
                        }
                        if (rdoTitle1.Text.Length == 0 && rdoTitle2.Text.Length > 0)
                        {
                            rdoTitle2.Checked = true;
                        }
                        if (rdoCustomer1.Text.Length == 0 && rdoCustomer2.Text.Length > 0)
                        {
                            rdoCustomer2.Checked = true;
                        }

                        FocusField = "rdoName2";
                    }
                    break;
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Beispiel #12
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);
    }
Beispiel #13
0
    protected void GetData(int Rno, int iCol)
    {
        string Sql = string.Format(
            "Select c.* " +
            "From Customers c " +
            "Where CustomerRno = {0}",
            Rno);

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                switch (iCol)
                {
                case 1:
                    hfRno1.Value         = Rno.ToString();
                    lblRno1.Text         = Rno.ToString();
                    rdoName1.Text        = DB.Str(dr["Name"]);
                    rdoTaxExempt1.Text   = Fmt.YesNo(DB.Bool(dr["TaxExemptFlg"]));
                    rdoCompany1.Text     = Fmt.YesNo(DB.Bool(dr["CompanyFlg"]));
                    rdoOnlineOrder1.Text = Fmt.YesNo(DB.Bool(dr["OnlineOrderFlg"]));
                    rdoEmailConf1.Text   = Fmt.YesNo(DB.Bool(dr["EmailConfirmationsFlg"]));
                    rdoSignedBy1.Text    = Fmt.YesNo(DB.Bool(dr["AnnualContractSignedName"]));
                    rdoSigned1.Text      = Fmt.YesNo(DB.Bool(dr["AnnualContractSignedDtTm"]));
                    txtCreatedDt1.Text   = Fmt.DtTm(DB.DtTm(dr["CreatedDtTm"]));
                    txtCreatedUser1.Text = DB.Str(dr["CreatedUser"]);
                    txtUpdatedDt1.Text   = Fmt.DtTm(DB.DtTm(dr["UpdatedDtTm"]));
                    txtUpdatedUser1.Text = DB.Str(dr["UpdatedUser"]);

                    rdoName1.Checked                           =
                        rdoTaxExempt1.Checked                  =
                            rdoCompany1.Checked                =
                                rdoOnlineOrder1.Checked        =
                                    rdoEmailConf1.Checked      =
                                        rdoSignedBy1.Checked   =
                                            rdoSigned1.Checked = true;

                    FocusField = "rdoName1";
                    break;

                case 2:
                    if (Rno.ToString() != lblRno1.Text)
                    {
                        hfRno2.Value         = Rno.ToString();
                        lblRno2.Text         = Rno.ToString();
                        rdoName2.Text        = DB.Str(dr["Name"]);
                        rdoTaxExempt1.Text   = Fmt.YesNo(DB.Bool(dr["TaxExemptFlg"]));
                        rdoCompany1.Text     = Fmt.YesNo(DB.Bool(dr["CompanyFlg"]));
                        rdoOnlineOrder1.Text = Fmt.YesNo(DB.Bool(dr["OnlineOrderFlg"]));
                        rdoEmailConf1.Text   = Fmt.YesNo(DB.Bool(dr["EmailConfirmationsFlg"]));
                        rdoSignedBy1.Text    = Fmt.YesNo(DB.Bool(dr["AnnualContractSignedName"]));
                        rdoSigned1.Text      = Fmt.YesNo(DB.Bool(dr["AnnualContractSignedDtTm"]));
                        txtCreatedDt2.Text   = Fmt.DtTm(DB.DtTm(dr["CreatedDtTm"]));
                        txtCreatedUser2.Text = DB.Str(dr["CreatedUser"]);
                        txtUpdatedDt2.Text   = Fmt.DtTm(DB.DtTm(dr["UpdatedDtTm"]));
                        txtUpdatedUser2.Text = DB.Str(dr["UpdatedUser"]);

                        if (rdoName1.Text.Length == 0 && rdoName2.Text.Length > 0)
                        {
                            rdoName2.Checked = true;
                        }
                        if (rdoTaxExempt1.Text.Length == 0 && rdoTaxExempt2.Text.Length > 0)
                        {
                            rdoTaxExempt2.Checked = true;
                        }
                        if (rdoCompany1.Text.Length == 0 && rdoCompany2.Text.Length > 0)
                        {
                            rdoCompany2.Checked = true;
                        }
                        if (rdoOnlineOrder1.Text.Length == 0 && rdoOnlineOrder2.Text.Length > 0)
                        {
                            rdoOnlineOrder1.Checked = true;
                        }
                        if (rdoEmailConf1.Text.Length == 0 && rdoEmailConf2.Text.Length > 0)
                        {
                            rdoEmailConf2.Checked = true;
                        }
                        if (rdoSignedBy1.Text.Length == 0 && rdoSignedBy2.Text.Length > 0)
                        {
                            rdoSignedBy2.Checked = true;
                        }
                        if (rdoSigned1.Text.Length == 0 && rdoSigned2.Text.Length > 0)
                        {
                            rdoSigned2.Checked = true;
                        }

                        FocusField = "rdoName2";
                    }
                    break;
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Beispiel #14
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());
        }
    }
Beispiel #15
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());
        }
    }