Ejemplo n.º 1
0
    protected void SaveAttachment()
    {
        EmailAttachment = string.Empty;

        if (fuAttachment.HasFile)
        {
            WebConfig Cfg           = new WebConfig();
            string    AttachmentDir = Cfg.Str("Attachment Dir");

            if (AttachmentDir.Length == 0)
            {
                ErrMsg += "The 'Attachment Dir' value '{0}' is missing in the Web.config file.<br />";
            }
            else if (!Directory.Exists(AttachmentDir))
            {
                ErrMsg += string.Format("The 'Attachment Dir' value '{0}' in the Web.config file points to an invalid directory.<br />", AttachmentDir);
            }
            else
            {
                try
                {
                    string Filename = string.Format(@"{0}\{1} - {2}", AttachmentDir, JobRno, fuAttachment.FileName);
                    if (File.Exists(Filename))
                    {
                        File.Delete(Filename);
                    }
                    fuAttachment.SaveAs(Filename);

                    EmailAttachment = Filename;
                }
                catch (Exception Ex)
                {
                    Err Err = new Err(Ex);
                    Response.Write(Err.Html());
                }
            }
        }
    }
Ejemplo n.º 2
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        int    Rno = Str.Num(hfRno.Value);
        string Sql = String.Format(
            "Select IngredRno From PurchaseDetails Where PurchaseRno = {0}",
            Rno);

        try
        {
            // prep for recalculating the latest price for all the ingredients on this receipt that is being deleted
            DataTable dt = db.DataTable(Sql);

            // delete the receipt
            Sql = String.Format(
                "Delete From PurchaseDetails Where PurchaseRno = {0}; " +
                "Delete From Purchases Where PurchaseRno = {0}; ",
                Rno);
            db.Exec(Sql);

            // now recalc the latest prices
            foreach (DataRow dr in dt.Rows)
            {
                int IngredRno = DB.Int32(dr["IngredRno"]);

                Ingred.UpdateWithLastPrice(IngredRno);
            }

            LoadList();

            ClearData();
            LoadDetails(0);
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Ejemplo n.º 3
0
    private void LoadListSql(string Sql, string NextCurrItem)
    {
        //Response.Write("looking for [" + NextCurrItem + "]<br/>");
        try
        {
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                Int32    Rno     = DB.Int32(dr["IngredRno"]);
                String   Name    = DB.Str(dr["Name"]);
                bool     fHidden = DB.Bool(dr["HideFlg"]);
                ListItem Item    = new ListItem(Name, Rno.ToString());
                if (fHidden)
                {
                    Item.Attributes.Add("class", "Hidden");
                }

                if (Item.Text == NextCurrItem)
                {
                    Item.Selected = true;

                    Rno = Str.Num(Item.Value);
                    GetData(Rno);
                    btnUpdate.Enabled   =
                        btnNext.Enabled = true;
                }

                lstList.Items.Add(Item);
            }

            lblRecCount.Text = Fmt.Num(lstList.Items.Count, true) + " Items";
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Ejemplo n.º 4
0
    protected void Crew()
    {
        string Sql =
            "Select * From mcJobCrew " +
            "Where JobRno = " + JobRno + " " +
            "Order By CrewSeq";

        try
        {
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow r in dt.Rows)
            {
                string Html =
                    "<tr>\n" +
                    "\t<td valign=\"top\" class=\"JobItem\">" + DB.Str(r["CrewMember"]) + "</d>\n" +
                    "\t<td></td>\n" +
                    "\t<td valign=\"top\">" + DB.Str(r["CrewAssignment"]) + "</d>\n" +
                    "\t<td></td>\n" +
                    "\t<td valign=\"top\" align=\"right\">" + Fmt.Tm12Hr(DB.DtTm(r["ReportTime"])) + "</d>\n" +
                    "</tr>\n";

                string Note = DB.Str(r["Note"]);
                if (Note.Length > 0)
                {
                    Html +=
                        "<tr>\n" +
                        "\t<td colspan=\"5\" align=\"left\"><img width=\"20\" height=\"1\" src=\"Images/Space.gif\"><i>" + Note + "</i></td>\n" +
                        "</tr>\n";
                }
                Response.Write(Html);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Ejemplo n.º 5
0
    private void Setup()
    {
        FocusField = "ddlCrewMember";

        String Sql =
            "Select Distinct CrewMember From mcJobCrew " +
            "Where CrewMember Is Not Null Order By CrewMember";

        try
        {
            DataTable dt = db.DataTable(Sql);
            ddlCrewMember.Items.Clear();
            foreach (DataRow dr in dt.Rows)
            {
                string CrewMember = DB.Str(dr["CrewMember"]);
                ddlCrewMember.Items.Add(new ListItem(CrewMember, CrewMember));
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        DateTime Tomorrow = DateTime.Today.AddDays(1);

        txtWeekDate.Text         = Fmt.Dt(Tomorrow);
        txtMonthDate.Text        = Fmt.Dt(Tomorrow.AddDays(1 - Tomorrow.Day).AddMonths(1));
        txtBegDateRange.Text     =
            txtEndDateRange.Text = txtWeekDate.Text;

        ddlCrewMember.Attributes.Add("onChange", "iSetChk('chkCrewMember', true);");
        txtWeekDate.Attributes.Add("onChange", "iSetChk('rdoWeek', true);");
        txtMonthDate.Attributes.Add("onChange", "iSetChk('rdoMonth', true);");
        txtBegDateRange.Attributes.Add("onChange", "iSetChk('rdoRange', true);");
        txtEndDateRange.Attributes.Add("onChange", "iSetChk('rdoRange', true);");
        btnReport.Attributes.Add("OnClick", "return Print();");
    }
Ejemplo n.º 6
0
    private async void Page_Load(object sender, System.EventArgs e)
    {
        db = new DB();

        Pg = new WebPage("Images");
        Pg.CheckLogin(Path.GetFileNameWithoutExtension(Page.AppRelativeVirtualPath));

        // Put user code to initialize the page here
        if (!Page.IsPostBack)
        {
            Session["Menu"] = WebPage.Sling.Title;

            try
            {
                await LoadData();
            }
            catch (Exception Ex)
            {
                Err Err = new Err(Ex);
                Response.Write(Err.Html());
            }
        }
    }
Ejemplo n.º 7
0
    private void Setup()
    {
        string Rno = Parm.Str("Rno");

        if (Rno.Length > 0)
        {
            fStartHere = true;
            string Sql = string.Format("Select Name From Ingredients Where IngredRno = {0}", Rno);
            try
            {
                StartHere = db.SqlStr(Sql);
                //Response.Write("Setup " + StartHere + "<br/>");
            }
            catch (Exception Ex)
            {
                Err Err = new Err(Ex, Sql);
                Response.Write(Err.Html());
            }
        }

        LoadList();
        //LoadConversions();
    }
Ejemplo n.º 8
0
 private void LoadListSql(string Sql, string NextCurrItem)
 {
     //Response.Write("NextCurr [" + NextCurrItem + "]<br/>");
     try
     {
         DataTable dt = db.DataTable(Sql);
         //Response.Write(string.Format("Num Rows {0}<br/>", dt.Rows.Count));
         foreach (DataRow dr in dt.Rows)
         {
             Int32    Rno        = DB.Int32(dr["PurchaseRno"]);
             DateTime dtPurchase = DB.DtTm(dr["PurchaseDt"]);
             String   Vendor     = DB.Str(dr["Vendor"]);
             ListItem Item       = new ListItem(string.Format("{0} - {1}", Fmt.Dt(dtPurchase), Vendor), Rno.ToString());
             Item.Selected = (Item.Value == NextCurrItem);
             lstList.Items.Add(Item);
         }
     }
     catch (Exception Ex)
     {
         Err Err = new Err(Ex, Sql);
         Response.Write(Err.Html());
     }
 }
Ejemplo n.º 9
0
    protected void btnUpdate_Click(object sender, System.EventArgs e)
    {
        Update();

        if (JobRno > 0)
        {
            String Sql = "";
            try
            {
                Sql       = "Select Count(*) From mcJobServices Where JobRno = " + JobRno;
                cServices = db.SqlNum(Sql);
            }
            catch (Exception Ex)
            {
                Err Err = new Err(Ex, Sql);
                Response.Write(Err.Html());
            }
        }
        else
        {
            cServices = 0;
        }
    }
Ejemplo n.º 10
0
    protected async Task <bool> GetAvailability()
    {
        try
        {
            DateTime dtBeg = FindBegDate(DateTime.Parse(txtDate.Text));
            DateTime dtEnd = dtBeg.AddDays(6);

            Sling Sling = new Sling();

            if (await Sling.Login(Sling.Email, Sling.Password))
            {
                await Sling.LoadUsers();
                await ClearAndLoad(Sling, dtBeg, dtEnd);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex);
            Response.Write(Err.Html());
        }

        return(true);
    }
Ejemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        db = new DB();

        Session["Menu"] = WebPage.MenuSetup.Title;
        Pg = new WebPage("Images");
        Pg.CheckLogin(Path.GetFileNameWithoutExtension(Page.AppRelativeVirtualPath));

        // Put user code to initialize the page here
        if (!Page.IsPostBack)
        {
            tblRpt.Visible = false;

            string Sql = "Select QuoteDiffPct From Settings";
            try
            {
                decimal DiffPct = db.SqlDec(Sql);
                if (DiffPct == 0)
                {
                    DiffPct = 15;
                }

                txtDiffPct.Text = Fmt.Num(DiffPct, 0);
            }
            catch (Exception Ex)
            {
                Err Err = new Err(Ex, Sql);
                Response.Write(Err.Html());
            }
        }
        else
        {
            tblRpt.Visible = true;
            fields.Visible = false;
            ProcessReport();
        }
    }
Ejemplo n.º 12
0
    private void Setup()
    {
        rbSortCategory.Checked = true;
        btnUpdate.Enabled      =
            btnNext.Enabled    = true;

        LoadList();

        string Sql = "Select * From mcJobMenuCategories where (HideFlg Is Null Or HideFlg = 0) Order By Category";         // SortOrder";

        try
        {
            DataTable dt = db.DataTable(Sql);
            ddlCategory.DataSource     = dt;
            ddlCategory.DataTextField  = "Category";
            ddlCategory.DataValueField = "Category";
            ddlCategory.DataBind();

            Sql = "Select * From KitchenLocations Order By SortOrder";
            dt  = db.DataTable(Sql);
            ddlLocation.DataSource     = dt;
            ddlLocation.DataTextField  = "Name";
            ddlLocation.DataValueField = "KitchenLocRno";
            ddlLocation.DataBind();

            int Rno = Parm.Int("Rno");
            if (Rno != 0)
            {
                GetData(Rno);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Ejemplo n.º 13
0
    private void LoadListSql(string Sql, string NextCurrItem)
    {
        try
        {
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow r in dt.Rows)
            {
                string   Category = DB.Str(r["Category"]);
                bool     fHidden  = DB.Bool(r["HideFlg"]);
                ListItem Item     = new ListItem(Category);
                if (fHidden)
                {
                    Item.Attributes.Add("class", "Hidden");
                }

                if (Item.Value == NextCurrItem)
                {
                    Item.Selected = true;

                    Category = Item.Value;
                    GetData(Category);
                    //btnUpdate.Enabled =
                    //btnNext.Enabled = true;
                }


                lstList.Items.Add(Item);
            }

            lblRecCount.Text = Fmt.Num(lstList.Items.Count, true) + " Categories";
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Ejemplo n.º 14
0
    private void RemoveEditDishes()
    {
        for (int iDish = 1; iDish <= cDishes; iDish++)
        {
            TableRow tr = tblDishes.Rows[iDish];

            CheckBox chkRemove = (CheckBox)tr.FindControl("chkRemove" + iDish);
            if (chkRemove != null && chkRemove.Checked)
            {
                String Sql = "";
                try
                {
                    Int32 DishSeq = Str.Num(WebPage.FindTextBox(ref tr, "txtDishSeq" + iDish));
                    Sql = "Delete From mcJobDishes Where JobRno = " + JobRno + " And DishSeq = " + DishSeq;
                    db.Exec(Sql);
                }
                catch (Exception Ex)
                {
                    Err Err = new Err(Ex, Sql);
                    Response.Write(Err.Html());
                }
            }
        }
    }
Ejemplo n.º 15
0
    private void RemoveEditServices()
    {
        for (int iService = 1; iService <= cServices; iService++)
        {
            TableRow tr = tblServices.Rows[iService + 1];

            CheckBox chkRemove = (CheckBox)tr.FindControl("chkRemove" + iService);
            if (chkRemove != null && chkRemove.Checked)
            {
                String Sql = "";
                try
                {
                    Int32 ServiceSeq = Str.Num(WebPage.FindTextBox(ref tr, "txtServiceSeq" + iService));
                    Sql = "Delete From mcJobServices Where JobRno = " + JobRno + " And ServiceSeq = " + ServiceSeq;
                    db.Exec(Sql);
                }
                catch (Exception Ex)
                {
                    Err Err = new Err(Ex, Sql);
                    Response.Write(Err.Html());
                }
            }
        }
    }
Ejemplo n.º 16
0
    private void Update()
    {
        bool     fNew = (hfNewRecords.Value == "true");
        DateTime Tm   = DateTime.Now;

        int Count = (int)Str.Int64(hfCount.Value);

        for (int iRow = 1; iRow <= Count; iRow++)
        {
            int    Seq          = Parm.Int("hfSeq" + iRow);
            string sDescription = Parm.Str("hfDescription" + iRow);
            string sCaterer     = Parm.Str("txtCaterer" + iRow);
            string sOther       = Parm.Str("txtOther" + iRow);

            string Sql = string.Format(fNew ?
                                       "Insert Into JobTables (JobRno, Seq, Description, Caterer, Other, CreatedDtTm, CreatedUser) Values ({0}, {1}, {2}, {3}, {4}, {5}, {6})" :
                                       "Update JobTables Set Caterer = {3}, Other = {4}, UpdatedDtTm = {5}, UpdatedUser = {6} Where JobRno = {0} and Seq = {1}",
                                       JobRno,
                                       Seq,
                                       DB.Put(sDescription, 20),
                                       DB.Put(sCaterer, 60),
                                       DB.Put(sOther, 60),
                                       DB.PutDtTm(Tm),
                                       DB.PutStr(g.User));

            try
            {
                db.Exec(Sql);
            }
            catch (Exception Ex)
            {
                Err Err = new Err(Ex, Sql);
                Response.Write(Err.Html());
            }
        }
    }
Ejemplo n.º 17
0
    private void IngredReceipt(int IngredRno)
    {
        string Sql = string.Empty;

        try
        {
            ClearData();

            // find the No Vendor
            Sql = "Select Top 1 VendorRno From Vendors Where Name Like '%No Vendor%'";
            int VendorRno = db.SqlNum(Sql);
            if (VendorRno != 0)
            {
                // find a purchase for the No Vendor today
                Sql = string.Format("Select Top 1 PurchaseRno From Purchases Where VendorRno = {0} And PurchaseDt = {1}", VendorRno, DB.PutDtTm(DateTime.Today));
                int PurchaseRno = db.SqlNum(Sql);
                if (PurchaseRno == 0)
                {
                    // a purchase wasn't found so create one
                    Sql = string.Format(
                        "Insert Into Purchases (VendorRno, PurchaseDt, CreatedDtTm, CreatedUser) Values ({0}, {1}, GetDate(), {2}); Select Scope_Identity();",
                        VendorRno,
                        DB.PutDtTm(DateTime.Today),
                        DB.PutStr(g.User));
                    PurchaseRno = db.SqlNum(Sql);
                }

                GetData(PurchaseRno);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Ejemplo n.º 18
0
    protected void GetData(int Rno)
    {
        string Sql = string.Format("Select * From Settings Where SettingRno = {0}", Rno);

        ClearData();

        try
        {
            DataTable dt = db.DataTable(Sql);
            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];

                hfRno.Value             = Rno.ToString();
                txtBaseCostPct.Text     = Fmt.Num(DB.Dec(dr["BaseCostPct"]), 4);
                txtAsIsBaseCostPct.Text = Fmt.Num(DB.Dec(dr["AsIsBaseCostPct"]), 4);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Ejemplo n.º 19
0
    protected void btnInitialize_Click(object sender, EventArgs e)
    {
        string Sql = "Select IngredRno From Ingredients Order By IngredRno";

        try
        {
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                int IngredRno = DB.Int32(dr["IngredRno"]);

                Ingred.UpdateWithLastPrice(IngredRno);
                Response.Write(IngredRno.ToString() + "<br/>");
            }

            Sql = "Update mcJobMenuItems Set ServingQuote = ServingPrice";
            db.Exec(Sql);
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Ejemplo n.º 20
0
    protected void Supplies()
    {
        string Sql =
            "Select * From mcJobSupplies " +
            "Where JobRno = " + JobRno + " " +
            "Order By SupplySeq";

        try
        {
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow r in dt.Rows)
            {
                string Html =
                    "<tr>\n" +
                    "\t<td valign=\"top\" class=\"JobItem\">" + DB.Str(r["SupplyItem"]) + "</d>\n" +
                    "\t<td></td>\n" +
                    "\t<td valign=\"top\" align=\"right\">" + Fmt.Num(DB.Int32(r["Qty"]), false) + "</d>\n" +
                    "</tr>\n";

                string Note = DB.Str(r["Note"]);
                if (Note.Length > 0)
                {
                    Html +=
                        "<tr>\n" +
                        "\t<td colspan=\"3\" align=\"right\"><i>" + Note + "</i></td>\n" +
                        "</tr>\n";
                }
                Response.Write(Html);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Ejemplo n.º 21
0
    private void RemoveCrew()
    {
        for (int iCrew = 1; iCrew <= cCrew; iCrew++)
        {
            TableRow tr = tblCrew.Rows[iCrew];

            CheckBox chkRemove = (CheckBox)tr.FindControl("chkRemove" + iCrew);
            if (chkRemove != null && chkRemove.Checked)
            {
                String Sql = "";
                try
                {
                    Int32 CrewSeq = Str.Num(WebPage.FindTextBox(ref tr, "txtCrewSeq" + iCrew));
                    Sql = "Delete From mcJobCrew Where JobRno = " + JobRno + " And CrewSeq = " + CrewSeq;
                    db.Exec(Sql);
                }
                catch (Exception Ex)
                {
                    Err Err = new Err(Ex, Sql);
                    Response.Write(Err.Html());
                }
            }
        }
    }
Ejemplo n.º 22
0
    private void ProcessPostBack()
    {
        string id = Request.Params["id"];

        if (id.Length > 0)
        {
            int    JobRno    = 0;
            string FromEmail = string.Empty;

            string Sql = "Select JobRno, Email From mcJobs j Inner Join Contacts c on j.ContactRno = c.ContactRno Where Guid = @Guid";
            try
            {
                DataRow dr = db.DataRow(Sql, "@Guid", id);
                if (dr != null)
                {
                    JobRno    = DB.Int32(dr["JobRno"]);
                    FromEmail = DB.Str(dr["Email"]);
                }
            }
            catch (Exception Ex)
            {
                Err Err = new Err(Ex, Sql);
                Response.Write(Err.Html());
                goto AllDone;
            }

            SectionInfo[] Sections =
            {
                new SectionInfo()
                {
                    id = "Job", Desc = "Job"
                },
                new SectionInfo()
                {
                    id = "Menu", Desc = "Menu"
                },
                new SectionInfo()
                {
                    id = "Prices", Desc = "Prices"
                },
                new SectionInfo()
                {
                    id = "Fees", Desc = "Fees"
                },
                new SectionInfo()
                {
                    id = "Total", Desc = "Total"
                }
            };

            bool fConfirmed = true;
            foreach (SectionInfo section in Sections)
            {
                fConfirmed = fConfirmed && Request.Params["rdo" + section.id + "Confirm"] == "Yes";
            }

            DateTime Tm = DateTime.Now;
            Sql =
                "Update mcJobs Set " +
                "FinishConfirmDtTm = " + DB.Put(Tm) + ", " +
                (fConfirmed ? "ConfirmedDtTm = " + DB.Put(Tm) + ", " : string.Empty) +
                (fConfirmed ? "ConfirmedBy = 'Customer', " : string.Empty) +
                "UpdatedDtTm = " + DB.PutDtTm(Tm) + ", " +
                "UpdatedUser = '******' " +
                "Where Guid = @Guid";
            try
            {
                db.Exec(Sql, "@Guid", id);
            }
            catch (Exception Ex)
            {
                Err Err = new Err(Ex, Sql);
                Response.Write(Err.Html());
                goto AllDone;
            }

            string Subject = string.Format("Event #{0} {1}Confirmed", JobRno, (fConfirmed ? string.Empty : "NOT "));
            string Body    = string.Empty;

            Sql = string.Format(
                "Select JobRno, JobDate, Coalesce(cu.Name, c.Name) as Customer, Location, GuestArrivalTime, MealTime, EndTime, " +
                "NumMenServing, NumWomenServing, NumChildServing, ServicePropDesc, DeliveryPropDesc, " +
                "ChinaPropDesc, AddServicePropDesc, FuelTravelPropDesc, FacilityPropDesc, RentalsPropDesc, " +
                "Adj1PropDesc, Adj2PropDesc, cu.TaxExemptFlg, SubTotTaxPct, EstTotPropDesc, DepositPropDesc, " +
                "ConfirmedDtTm " +
                "From mcJobs j " +
                "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
                "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
                "Where JobRno = {0}", JobRno);
            try
            {
                DataRow dr = db.DataRow(Sql);
                if (dr != null)
                {
                    if (fConfirmed)
                    {
                        Body = string.Format("<h1>Event #{0} Confirmed</h1>", JobRno);
                    }
                    else
                    {
                        Body += string.Format("<h1>Event #{0} Not Confimed</h1>", JobRno);
                    }

                    // info
                    //------------------------------------------------------------
                    DateTime dtJob     = DB.DtTm(dr["JobDate"]);
                    string   Customer  = DB.Str(dr["Customer"]);
                    string   Location  = DB.Str(dr["Location"]);
                    DateTime GuestTime = DB.DtTm(dr["GuestArrivalTime"]);
                    DateTime BegTime   = DB.DtTm(dr["MealTime"]);
                    DateTime EndTime   = DB.DtTm(dr["EndTime"]);

                    if (GuestTime != DateTime.MinValue && GuestTime < BegTime)
                    {
                        BegTime = GuestTime;
                    }

                    string EventTime;
                    if (EndTime == DateTime.MinValue)
                    {
                        EventTime = BegTime.ToString("h:mm tt").ToLower();
                    }
                    else
                    {
                        EventTime = string.Format("{0} - {1}", BegTime.ToString("h:mm tt"), EndTime.ToString("h:mm tt")).ToLower();
                    }

                    int NumServings = DB.Int32(dr["NumMenServing"]) + DB.Int32(dr["NumWomenServing"]) + DB.Int32(dr["NumChildServing"]);

                    string SectionConfirmed = Request.Params["rdoJobConfirm"];
                    Body += string.Format(
                        "<table border=\"0\">" +
                        "<tr><td colspan=\"2\"><h2>Job Information</h2></td></tr>" +
                        "<tr>" +
                        "<td>" +
                        "Event: #{0}<br />" +
                        "Customer: {1}<br />" +
                        "Date: {2}" +
                        "</td>" +
                        "<td>" +
                        "Location: {3}<br />" +
                        "Event Time: {4}<br />" +
                        "Guest Count: {5}" +
                        "</td>" +
                        "</tr></table>" +
                        "<p>Confirm: <b>{6}</b></p>",
                        JobRno,
                        Customer,
                        Fmt.DtNth(dtJob),
                        Location,
                        EventTime,
                        NumServings,
                        SectionConfirmed);
                    if (SectionConfirmed != "Yes")
                    {
                        Body += "<p><b>Notes:</b><br />" + Request.Params["txtJob"].Replace("\r\n\r\n", "</p><p>").Replace("\n\n", "</p><p>") + "</p>";
                    }

                    // menu
                    //------------------------------------------------------------
                    Sql = string.Format(
                        "Select * " +
                        "From mcJobFood " +
                        "Where JobRno = {0} And ProposalHideFlg = 0 " +
                        "Order By ProposalSeq, FoodSeq",
                        JobRno);
                    DataTable dt = db.DataTable(Sql);
                    if (dt.Rows.Count > 0)
                    {
                        Body +=
                            "<table border=\"0\">" +
                            "<tr><td colspan=\"2\"><h2>Food</h2></td></tr>";

                        foreach (DataRow drMenu in dt.Rows)
                        {
                            string ProposalMenuItem = DB.Str(drMenu["ProposalMenuItem"]);
                            bool   fProposalTitle   = DB.Bool(drMenu["ProposalTitleFlg"]);

                            if (fProposalTitle)
                            {
                                Body += string.Format("<tr><td colspan=\"2\"><b>{0}</b></td></tr>", ProposalMenuItem);
                            }
                            else
                            {
                                Body += string.Format("<tr><td width=\"20\">&nbsp;</td><td>{0}</td></tr>", (ProposalMenuItem.Length > 0 ? ProposalMenuItem : "&nbspc;"));
                            }
                        }

                        SectionConfirmed = Request.Params["rdoMenuConfirm"];
                        Body            += string.Format(
                            "</table>" +
                            "<p>Confirm: <b>{0}</b></p>",
                            SectionConfirmed);
                        if (SectionConfirmed != "Yes")
                        {
                            Body += "<p><b>Notes:</b><br />" + Request.Params["txtMenu"].Replace("\r\n\r\n", "</p><p>").Replace("\n\n", "</p><p>") + "</p>";
                        }
                    }

                    // prices
                    //------------------------------------------------------------
                    Sql = string.Format("Select * From JobInvoicePrices Where JobRno = {0} Order By Seq", JobRno);
                    dt  = db.DataTable(Sql);
                    if (dt.Rows.Count > 0)
                    {
                        Body +=
                            "<table border=\"0\">" +
                            "<tr><td><h2>Pricing</h2></td></tr>";
                        foreach (DataRow drPrice in dt.Rows)
                        {
                            string PriceType = DB.Str(drPrice["PriceType"]);
                            string Desc      = string.Empty;

                            switch (PriceType)
                            {
                            case Misc.cnPerPerson:
                                Desc = DB.Str(drPrice["PropPerPersonDesc"]);
                                break;

                            case Misc.cnPerItem:
                                Desc = DB.Str(drPrice["PropPerItemDesc"]);
                                break;

                            case Misc.cnAllIncl:
                                Desc = DB.Str(drPrice["PropAllInclDesc"]);
                                break;
                            }

                            if (Desc.Length > 0)
                            {
                                Body += string.Format("<tr><td>{0}</td></tr>", Desc);
                            }
                        }

                        SectionConfirmed = Request.Params["rdoPricesConfirm"];
                        Body            += string.Format(
                            "</table>" +
                            "<p>Confirm: <b>{0}</b></p>",
                            SectionConfirmed);
                        if (SectionConfirmed != "Yes")
                        {
                            Body += "<p><b>Notes:</b><br />" + Request.Params["txtPrices"].Replace("\r\n\r\n", "</p><p>").Replace("\n\n", "</p><p>") + "</p>";
                        }
                    }

                    // fees
                    //------------------------------------------------------------

                    Body +=
                        "<table border=\"0\">" +
                        "<tr><td><h2>Additional Servics</h2></td></tr>";

                    // services
                    string Fee = DB.Str(dr["ServicePropDesc"]);
                    if (Fee.Length > 0)
                    {
                        Body += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                    }

                    // delivery
                    Fee = DB.Str(dr["DeliveryPropDesc"]);
                    if (Fee.Length > 0)
                    {
                        Body += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                    }

                    // china
                    Fee = DB.Str(dr["ChinaPropDesc"]);
                    if (Fee.Length > 0)
                    {
                        Body += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                    }

                    // additional services
                    Fee = DB.Str(dr["AddServicePropDesc"]);
                    if (Fee.Length > 0)
                    {
                        Body += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                    }

                    // fuel & travel
                    Fee = DB.Str(dr["FuelTravelPropDesc"]);
                    if (Fee.Length > 0)
                    {
                        Body += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                    }

                    // facility
                    Fee = DB.Str(dr["FacilityPropDesc"]);
                    if (Fee.Length > 0)
                    {
                        Body += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                    }

                    // rentals
                    Fee = DB.Str(dr["RentalsPropDesc"]);
                    if (Fee.Length > 0)
                    {
                        Body += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                    }

                    // adjustment 1
                    Fee = DB.Str(dr["Adj1PropDesc"]);
                    if (Fee.Length > 0)
                    {
                        Body += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                    }

                    // adjustment 2
                    Fee = DB.Str(dr["Adj2PropDesc"]);
                    if (Fee.Length > 0)
                    {
                        Body += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                    }

                    SectionConfirmed = Request.Params["rdoFeesConfirm"];
                    Body            += string.Format(
                        "</table>" +
                        "<p>Confirm: <b>{0}</b></p>",
                        SectionConfirmed);
                    if (SectionConfirmed != "Yes")
                    {
                        Body += "<p><b>Notes:</b><br />" + Request.Params["txtFees"].Replace("\r\n\r\n", "</p><p>").Replace("\n\n", "</p><p>") + "</p>";
                    }


                    Body +=
                        "<table border=\"0\">" +
                        "<tr><td><h2>Total</h2></td></tr>";

                    // sales tax
                    //------------------------------------------------------------
                    bool fTaxExempt = DB.Bool(dr["TaxExemptFlg"]);
                    if (!fTaxExempt)
                    {
                        string Tax = string.Format("Utah Food Sales Tax {0:0.00}%", DB.Dec(dr["SubTotTaxPct"]));
                        Body += string.Format("<tr><td>{0}</td></tr>", Tax);
                    }

                    // total
                    //------------------------------------------------------------
                    string TotalDesc = string.Format("\n{0}", DB.Str(dr["EstTotPropDesc"]));
                    Body += string.Format("<tr><td>{0}</td></tr>", TotalDesc);

                    // deposit
                    //------------------------------------------------------------
                    string DepositDesc = DB.Str(dr["DepositPropDesc"]);
                    if (DepositDesc.Length > 0)
                    {
                        Body += string.Format("<tr><td>{0}</td></tr>", DepositDesc);
                    }

                    SectionConfirmed = Request.Params["rdoTotalConfirm"];
                    Body            += string.Format(
                        "</table>" +
                        "<p>Confirm: <b>{0}</b></p>",
                        SectionConfirmed);
                    if (SectionConfirmed != "Yes")
                    {
                        Body += "<p><b>Notes:</b><br />" + Request.Params["txtTotal"].Replace("\r\n\r\n", "</p><p>").Replace("\n\n", "</p><p>") + "</p>";
                    }

                    // tables & linens
                    //------------------------------------------------------------
                    string LinensProvidedBy = Request.Params["ddlLinensProvidedBy"];
                    Body +=
                        "<table border=\"0\">" +
                        "<tr><td colspan=\"2\"><h2>Tables &amp; Linens</h2></td></tr>" +
                        "<tr><td colspan=\"2\">Buffet tables provided by <b>" + Request.Params["ddlTables"] + "</b></td></tr>" +
                        "<tr><td colspan=\"2\">Buffet linen color <b>" + Request.Params["ddlLinenColor"] + "</b></td></tr>" +
                        "<tr><td colspan=\"2\">Linen color for guest tables <b>" + Request.Params["txtGuestTableColor"] + "</b></td></tr>" +
                        "<tr><td colspan=\"2\">Guest linens provided by <b>" + LinensProvidedBy + "</b></td></tr>" +
                        (LinensProvidedBy == Globals.g.Company.Name ?
                         "<tr><td colspan=\"2\">&nbsp;</td></tr>" +
                         "<tr><td align=\"center\"><u>Table Size &amp; Shape</u></td><td align=\"center\"><u>Count</u></td></tr>" +
                         "<tr><td align=\"center\">" + Request.Params["txtTableSizeShape1"] + "</td><td align=\"center\">" + Request.Params["txtTableCount1"] + "</td></tr>" +
                         "<tr><td align=\"center\">" + Request.Params["txtTableSizeShape2"] + "</td><td align=\"center\">" + Request.Params["txtTableCount2"] + "</td></tr>" +
                         "<tr><td align=\"center\">" + Request.Params["txtTableSizeShape3"] + "</td><td align=\"center\">" + Request.Params["txtTableCount3"] + "</td></tr>" +
                         "<tr><td align=\"center\">" + Request.Params["txtTableSizeShape4"] + "</td><td align=\"center\">" + Request.Params["txtTableCount4"] + "</td></tr>"
                        :
                         string.Empty) +
                        "</table>" +
                        "<p><b>Notes:</b><br />" + Request.Params["txtTables"].Replace("\r\n\r\n", "</p><p>").Replace("\n\n", "</p><p>") + "</p>";
                }

                int nTrys = 0;

TryAgain:

                nTrys++;

                try
                {
                    WebConfig   wc  = new WebConfig();
                    MailMessage Msg = new MailMessage(FromEmail, Misc.PrimaryEmailAddress());
                    Msg.CC.Add(wc.Str("Email CC"));
                    Msg.Subject    = Misc.EnvSubject() + Subject;
                    Msg.IsBodyHtml = true;
                    Msg.Body       = Body;

                    SmtpClient Smtp = new SmtpClient();
                    Smtp.Send(Msg);
                }
                catch (Exception Ex)
                {
                    if (nTrys <= 3)
                    {
                        Thread.Sleep(1500);     // 1 1/2 seconds
                        goto TryAgain;
                    }
                    Err Err = new Err(Ex, Sql);
                    Response.Write(Err.Html());
                    goto AllDone;
                }
            }
            catch (Exception Ex)
            {
                Err Err = new Err(Ex, Sql);
                Response.Write(Err.Html());
            }
        }

AllDone:

        return;
    }
Ejemplo n.º 23
0
    private bool FormatJob(string id)
    {
        bool   fOK = true;
        string Sql = string.Format(
            "Select JobRno, JobDate, CancelledDtTm, Coalesce(cu.Name, c.Name) as Customer, Location, " +
            "GuestArrivalTime, MealTime, EndTime, " +
            "NumMenServing, NumWomenServing, NumChildServing, ServicePropDesc, DeliveryPropDesc, " +
            "ChinaPropDesc, AddServicePropDesc, FuelTravelPropDesc, FacilityPropDesc, RentalsPropDesc, " +
            "Adj1PropDesc, Adj2PropDesc, cu.TaxExemptFlg, SubTotTaxPct, EstTotPropDesc, DepositPropDesc, " +
            "FinishConfirmDtTm, ConfirmedDtTm " +
            "From mcJobs  j " +
            "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
            "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
            "Where Guid = {0}", DB.Put(id));

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                int      JobRno            = DB.Int32(dr["JobRno"]);
                DateTime dtFinishedConfirm = DB.DtTm(dr["FinishConfirmDtTm"]);
                DateTime dtConfirmed       = DB.DtTm(dr["ConfirmedDtTm"]);
                if (dtFinishedConfirm == DateTime.MinValue && dtConfirmed == DateTime.MinValue)
                {
                    DateTime dtJob       = DB.DtTm(dr["JobDate"]);
                    DateTime dtCancelled = DB.DtTm(dr["CancelledDtTm"]);
                    if (DateTime.Now <= dtJob && dtCancelled == DateTime.MinValue)
                    {
                        DateTime dtDeadline = Misc.ConfirmationDeadline(dtJob);

                        if (DateTime.Now < dtDeadline)
                        {
                            lblInstructions.Text =
                                "<p>You will see and confirm your event deails in several sections.</p>" +
                                "<p>Please carefully review the information then click <span class=\"success\">Yes</span> " +
                                "if it's all correct or <span class=\"danger\">No</span> to submit changes in the box that will appear. " +
                                "You can click <span class=\"danger\">No</span> on any previous section.</p>" +
                                "<p>" + Globals.g.Company.Name + " will contact you soon if you do not confirm every section.</p>" +
                                "<p>Visit our website <a href=\"" + g.Company.WebsiteUrl + "\">" + g.Company.Website + " </a>.</p>";

                            // info
                            //------------------------------------------------------------
                            string   Customer  = DB.Str(dr["Customer"]);
                            string   Location  = DB.Str(dr["Location"]);
                            DateTime GuestTime = DB.DtTm(dr["GuestArrivalTime"]);
                            DateTime BegTime   = DB.DtTm(dr["MealTime"]);
                            DateTime EndTime   = DB.DtTm(dr["EndTime"]);

                            if (GuestTime != DateTime.MinValue && GuestTime < BegTime)
                            {
                                BegTime = GuestTime;
                            }

                            string EventTime;
                            if (EndTime == DateTime.MinValue)
                            {
                                EventTime = BegTime.ToString("h:mm tt").ToLower();
                            }
                            else
                            {
                                EventTime = string.Format("{0} - {1}", BegTime.ToString("h:mm tt"), EndTime.ToString("h:mm tt")).ToLower();
                            }

                            int NumServings = DB.Int32(dr["NumMenServing"]) + DB.Int32(dr["NumWomenServing"]) + DB.Int32(dr["NumChildServing"]);

                            string Html = string.Format(
                                "<div class=\"Info\">" +
                                "<div class=\"card\">" +
                                "<h3 class=\"card-header\">Job Information</h3>" +
                                "<div class=\"card-body container\">" +
                                "<div class=\"row\">" +
                                "<div class=\"col\">" +
                                "Event: #{0}<br />" +
                                "Customer: {1}<br />" +
                                "Date: {2}" +
                                "</div>" +
                                "<div class=\"col\">" +
                                "Location: {3}<br />" +
                                "Event Time: {4}<br />" +
                                "Guest Count: {5}" +
                                "</div>" +
                                "</div>" +
                                "</div>" +
                                "</div>",
                                JobRno,
                                Customer,
                                Fmt.DtNth(dtJob),
                                Location,
                                EventTime,
                                NumServings) +
                                          ConfirmButtons("Job") +
                                          "</div>";


                            // menu
                            //------------------------------------------------------------
                            Sql = string.Format(
                                "Select * " +
                                "From mcJobFood " +
                                "Where JobRno = {0} And ProposalHideFlg = 0 " +
                                "Order By ProposalSeq, FoodSeq",
                                JobRno);
                            DataTable dt = db.DataTable(Sql);
                            if (dt.Rows.Count > 0)
                            {
                                Html +=
                                    "<div class=\"Menu\">" +
                                    "<div class=\"card\">" +
                                    "<h3 class=\"card-header\">Food</h3>" +
                                    "<div class=\"card-body\">";
                                foreach (DataRow drMenu in dt.Rows)
                                {
                                    string ProposalMenuItem = DB.Str(drMenu["ProposalMenuItem"]);
                                    bool   fProposalTitle   = DB.Bool(drMenu["ProposalTitleFlg"]);

                                    if (fProposalTitle)
                                    {
                                        Html += string.Format("<h4 class=\"card-title\">{0}</h4>", ProposalMenuItem);
                                    }
                                    else
                                    {
                                        Html += string.Format("<div class=\"card-text\">{0}</div>", (ProposalMenuItem.Length > 0 ? ProposalMenuItem : "&nbspc;"));
                                    }
                                }
                                Html +=
                                    "</div>" +
                                    "</div>" +
                                    ConfirmButtons("Menu") +
                                    "</div>";
                            }

                            // prices
                            //------------------------------------------------------------
                            Sql = string.Format("Select * From JobInvoicePrices Where JobRno = {0} Order By Seq", JobRno);
                            dt  = db.DataTable(Sql);
                            if (dt.Rows.Count > 0)
                            {
                                Html +=
                                    "<div class=\"Prices\">" +
                                    "<div class=\"card\">" +
                                    "<h3 class=\"card-header\">Pricing</h3>" +
                                    "<div class=\"card-body\">";
                                foreach (DataRow drPrice in dt.Rows)
                                {
                                    string PriceType = DB.Str(drPrice["PriceType"]);
                                    string Desc      = string.Empty;

                                    switch (PriceType)
                                    {
                                    case Misc.cnPerPerson:
                                        Desc = DB.Str(drPrice["PropPerPersonDesc"]);
                                        break;

                                    case Misc.cnPerItem:
                                        Desc = DB.Str(drPrice["PropPerItemDesc"]);
                                        break;

                                    case Misc.cnAllIncl:
                                        Desc = DB.Str(drPrice["PropAllInclDesc"]);
                                        break;
                                    }

                                    if (Desc.Length > 0)
                                    {
                                        Html += string.Format("<p class=\"card-text\">{0}</p>", Desc);
                                    }
                                }
                                Html +=
                                    "</div>" +
                                    "</div>" +
                                    ConfirmButtons("Prices") +
                                    "</div>";
                            }

                            // fees
                            //------------------------------------------------------------

                            Html +=
                                "<div class=\"Fees\">" +
                                "<div class=\"card\">" +
                                "<h3 class=\"card-header\">Additional Services</h3>" +
                                "<div class=\"card-body\">";
                            // services
                            string Fee = DB.Str(dr["ServicePropDesc"]);
                            if (Fee.Length > 0)
                            {
                                Html += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                            }

                            // delivery
                            Fee = DB.Str(dr["DeliveryPropDesc"]);
                            if (Fee.Length > 0)
                            {
                                Html += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                            }

                            // china
                            Fee = DB.Str(dr["ChinaPropDesc"]);
                            if (Fee.Length > 0)
                            {
                                Html += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                            }

                            // additional services
                            Fee = DB.Str(dr["AddServicePropDesc"]);
                            if (Fee.Length > 0)
                            {
                                Html += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                            }

                            // fuel & travel
                            Fee = DB.Str(dr["FuelTravelPropDesc"]);
                            if (Fee.Length > 0)
                            {
                                Html += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                            }

                            // facility
                            Fee = DB.Str(dr["FacilityPropDesc"]);
                            if (Fee.Length > 0)
                            {
                                Html += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                            }

                            // rentals
                            Fee = DB.Str(dr["RentalsPropDesc"]);
                            if (Fee.Length > 0)
                            {
                                Html += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                            }

                            // adjustment 1
                            Fee = DB.Str(dr["Adj1PropDesc"]);
                            if (Fee.Length > 0)
                            {
                                Html += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                            }

                            // adjustment 2
                            Fee = DB.Str(dr["Adj2PropDesc"]);
                            if (Fee.Length > 0)
                            {
                                Html += string.Format("<p class=\"card-text\">{0}</p>", Fee);
                            }
                            Html +=
                                "</div>" +
                                "</div>" +
                                ConfirmButtons("Fees") +
                                "</div>";


                            Html +=
                                "<div class=\"Total\">" +
                                "<div class=\"card\">" +
                                "<h3 class=\"card-header\">Total</h3>" +
                                "<div class=\"card-body\">";
                            // sales tax
                            //------------------------------------------------------------
                            bool fTaxExempt = DB.Bool(dr["TaxExemptFlg"]);
                            if (!fTaxExempt)
                            {
                                string Tax = string.Format("Utah Food Sales Tax {0:0.00}%", DB.Dec(dr["SubTotTaxPct"]));
                                Html += string.Format("<p class=\"card-text\">{0}</p>", Tax);
                            }

                            // total
                            //------------------------------------------------------------
                            string TotalDesc = string.Format("\n{0}", DB.Str(dr["EstTotPropDesc"]));
                            Html += string.Format("<p class=\"card-text\">{0}</p>", TotalDesc);

                            // deposit
                            //------------------------------------------------------------
                            string DepositDesc = DB.Str(dr["DepositPropDesc"]);
                            if (DepositDesc.Length > 0)
                            {
                                Html += string.Format("<p class=\"card-text\">{0}</p>", DepositDesc);
                            }
                            Html +=
                                "</div>" +
                                "</div>" +
                                ConfirmButtons("Total") +
                                "</div>";

                            // tables & Linens
                            //------------------------------------------------------------
                            Html +=
                                "<div class=\"Tables\">" +
                                "<div class=\"card\">" +
                                "<h3 class=\"card-header\">Tables &amp; Linens</h3>" +
                                "<div class=\"card-body container\">" +
                                "<div class=\"row\">" +
                                "<div class=\"col-11 col-sm-10 col-md-7 col-lg-6 col-xl-5 Buffet\">" +
                                "<div>" +
                                "Buffet tables provided by " +
                                "<select name=ddlTables>" +
                                "<option value=\"" + Globals.g.Company.Name + "\">" + Globals.g.Company.Name + "</option>" +
                                "<option value=\"Venue\">Venue</option>" +
                                "</select>" +
                                "</div>" +
                                "<div>" +
                                "Buffet linen color " +
                                "<select name=\"ddlLinenColor\">" +
                                "<option value=\"White\">White</option>" +
                                "<option value=\"Black\">Black</option>" +
                                "<option value=\"Ivory\">Ivory</option>" +
                                (dtJob.Month == 12 ? "<option value=\"Red\">Red</option>" : string.Empty) +
                                "</select>" +
                                "</div>" +
                                "<div>" +
                                "Linen color for guest tables " +
                                "<input type=text id=\"txtGuestTableColor\" name=\"txtGuestTableColor\" />" +
                                "<div class=\"ColorRequired\">*color is required</div>" +
                                "</div>" +
                                "<div>" +
                                "Guest linens provided by " +
                                "<select id=\"ddlLinensProvidedBy\" name=\"ddlLinensProvidedBy\">" +
                                "<option value=\"" + Globals.g.Company.Name + "\">" + Globals.g.Company.Name + "</option>" +
                                "<option value=\"Customer\">Customer</option>" +
                                "</select>" +
                                "</div>" +
                                "<div class=\"GuestTables\">" +
                                "<div>" +
                                "<div class=\"TableSizeShape\"><u>Table Size &amp; Shape</u></div>" +
                                "<div class=\"TableCount\"><u>Count</u></div>" +
                                "</div>" +
                                "<div>" +
                                "<div class=\"TableSizeShape\"><input type=text id=\"txtTableSizeShape1\" name=\"txtTableSizeShape1\"></div>" +
                                "<div class=\"TableCount\"><input type=text id=\"txtTableCount1\" name=\"txtTableCount1\"></div>" +
                                "</div>" +
                                "<div>" +
                                "<div class=\"TableSizeShape\"><input type=text id=\"txtTableSizeShape2\" name=\"txtTableSizeShape2\"></div>" +
                                "<div class=\"TableCount\"><input type=text id=\"txtTableCount2\" name=\"txtTableCount2\"></div>" +
                                "</div>" +
                                "<div>" +
                                "<div class=\"TableSizeShape\"><input type=text id=\"txtTableSizeShape3\" name=\"txtTableSizeShape3\"></div>" +
                                "<div class=\"TableCount\"><input type=text id=\"txtTableCount3\" name=\"txtTableCount3\"></div>" +
                                "</div>" +
                                "<div>" +
                                "<div class=\"TableSizeShape\"><input type=text id=\"txtTableSizeShape4\" name=\"txtTableSizeShape4\"></div>" +
                                "<div class=\"TableCount\"><input type=text id=\"txtTableCount4\" name=\"txtTableCount4\"></div>" +
                                "</div>" +
                                "</div>" +
                                "</div>" +
                                "</div>" +
                                "</div>" +
                                "</div>" +
                                ConfirmButtons("Tables", true) +
                                "</div>";

                            lblJob.Text = Html;
                        }
                        else
                        {
                            fOK = false;
                            lblInstructions.Text =
                                "<p>Sorry, its is too late to confirm your event online.</p>" +
                                "<p>Please call or <a href=\"mailto: Info(" + g.Company.InfoEmail + ")\">email</a> " + Globals.g.Company.Name + " to confirm or discuss your event.</p>" +
                                "<p>Visit our website <a href=\"" + g.Company.WebsiteUrl + "\">" + g.Company.Website + "</a>.</p>";
                        }
                    }
                    else
                    {
                        fOK = false;
                        lblInstructions.Text = string.Format(
                            "<p>Sorry, that page link is has expired, usually because the event date has past or the event was canceled.</p>" +
                            "<p>If you believe there is a problem, please call or <a href=\"mailto: Info(" + g.Company.InfoEmail + ")\">email</a> " + Globals.g.Company.Name + " to discuss event #{0}.</p>" +
                            "<p>Visit our website <a href=\"" + g.Company.WebsiteUrl + "\">" + g.Company.Website + "</a>.</p>",
                            JobRno);
                    }
                }
                else
                {
                    fOK = false;
                    lblInstructions.Text = string.Format(
                        "<p>Your event has already been confirmed.</p>" +
                        "<p>Please call or <a href=\"mailto: Info(" + g.Company.InfoEmail + ")\">email</a> " + Globals.g.Company.Name + " to discuss event #{0}.</p>" +
                        "<p>Visit our website <a href=\"" + Globals.g.Company.WebsiteUrl + "\">" + Globals.g.Company.Website + "</a>.</p>",
                        JobRno);
                }
            }
            else
            {
                fOK = false;
                lblInstructions.Text =
                    "<p>Sorry, this page link is not valid.</p>" +
                    "<p>Please call or <a href=\"mailto: Info(" + Globals.g.Company.InfoEmail + ")\">email</a> " + Globals.g.Company.Name + " to confirm or discuss your event.</p>" +
                    "<p>Visit our website <a href=\"" + Globals.g.Company.WebsiteUrl + "\">" + Globals.g.Company.Website + "</a>.</p>";
            }
        }
        catch (SqlException)
        {
            fOK = false;
            lblInstructions.Text =
                "<p>Sorry, this page link is not valid.</p>" +
                "<p>Please call or <a href=\"mailto: Info(" + Globals.g.Company.InfoEmail + ")\">email</a> " + Globals.g.Company.Name + " to confirm or discuss your event.</p>" +
                "<p>Visit our website <a href=\"" + Globals.g.Company.WebsiteUrl + "\">" + Globals.g.Company.Website + "</a>.</p>";
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        return(fOK);
    }
Ejemplo n.º 24
0
    public decimal ConversionScaler(int FromUnitRno, int ToUnitRno)
    {
        decimal Scaler   = 0;
        string  FromUnit = string.Empty;
        string  ToUnit   = string.Empty;

        if (IngredConvs == null)
        {
            LoadIngredConversions();
        }

        lstIngredConversions = FindIngredConversions(IngredRno);

        bool   fFound = false;
        string Sql    = string.Empty;

        try
        {
            ShowConversion = string.Empty;
            StepsRemoved   = 0;

            HttpResponse Resp = System.Web.HttpContext.Current.Response;
            if (fShowConv)
            {
                FromUnit = Unit(FromUnitRno);
                ToUnit   = Unit(ToUnitRno);
                Resp.Write(string.Format("------------<br/>{0} -> {1}<br/>", FromUnit, ToUnit));
            }

            if (FromUnitRno == ToUnitRno)
            {
                if (fShowConv)
                {
                    Resp.Write("^^^^^^^^^<br/>");
                }
                Resp.Flush();
                fFound         = true;
                Scaler         = 1;
                ShowConversion = string.Format(" = {0}", ToUnit);
                StepsRemoved   = 0;
            }
            else
            {
                lstIngredConversions = FindIngredConversions(IngredRno);

                fFound = false;

                if (fShowConv)
                {
                    // show the possible conversions
                    Resp.Write("<table>");
                    foreach (IngredConv IngredConv in lstIngredConversions)
                    {
                        Resp.Write(string.Format("<tr><td>{4}{0}</td><td>{1}</td><td>{2}</td><td>{3}</td>", IngredConv.RecipeQty, IngredConv.RecipeUnit, IngredConv.PurchaseQty, IngredConv.PurchaseUnit, (IngredConv.IngredRno == 0 ? string.Empty : "*")));
                    }
                    Resp.Write("</table>"); Resp.Flush();
                }

                // clear visited flags
                // see if the purchase unit is found in the list of conversions
                // see if there is a simple match at the first level
                bool fFoundPurchaseUnit = false;
                foreach (IngredConv IngredConv in lstIngredConversions)
                {
                    IngredConv.fVisited = false;

                    if (IngredConv.PurchaseUnitRno == ToUnitRno)
                    {
                        fFoundPurchaseUnit = true;
                    }

                    if (IngredConv.RecipeUnitRno == FromUnitRno && IngredConv.PurchaseUnitRno == ToUnitRno)
                    {
                        Scaler         = (IngredConv.PurchaseQty / IngredConv.RecipeQty);
                        ShowConversion = string.Format(" * {0} {1} / {2} {3} = {4} {5}", Str.ShowFract(IngredConv.PurchaseQty), IngredConv.PurchaseUnit, Str.ShowFract(IngredConv.RecipeQty), IngredConv.RecipeUnit, Str.ShowFract(Scaler), ToUnit);
                        StepsRemoved   = 1;
                        fFound         = true;
                    }
                }

                if (!fFound && fFoundPurchaseUnit)
                {
                    foreach (IngredConv IngredConv in lstIngredConversions)
                    {
                        if (IngredConv.RecipeUnitRno == FromUnitRno)
                        {
                            IngredConv.fVisited = true;
                            if ((Scaler = NextConversionScaler(1, ToUnitRno, ToUnit, IngredConv, NextLevel)) != 0)
                            {
                                StepsRemoved++;
                                break;
                            }
                        }
                    }
                }
            }
            if (fShowConv)
            {
                Resp.Write(string.Format("Found in {0} steps {1} -> {2} => 1 {3}{4}<br/>", StepsRemoved, FromUnit, ToUnit, FromUnit, ShowConversion));
            }
            Resp.Flush();

            // add a new ingredient conversion if too many steps, next time it will be much shorter
            if (StepsRemoved > 1 && IngredRno != 0)
            {
                Sql = string.Format(
                    "Insert Into IngredConv (IngredRno, PurchaseQty, PurchaseUnitRno, RecipeQty, RecipeUnitRno, CreatedDtTm, CreatedUser) " +
                    "Values ({0}, {1}, {2}, {3}, {4}, GetDate(), {5});" +
                    "Select Scope_Identity()",
                    IngredRno,
                    1,
                    ToUnitRno,
                    1 / Scaler,
                    FromUnitRno,
                    DB.PutStr(g.User));
                int IngredConvRno = DB.DBExec(Sql);

                string PurchaseUnit = DB.DBSqlStr("Select UnitSingle From Units Where UnitRno = " + ToUnitRno);
                string RecipeUnit   = DB.DBSqlStr("Select UnitSingle From Units Where UnitRno = " + FromUnitRno);

                Ingred.AddIngredConv(IngredConvRno, IngredRno, 1, ToUnitRno, PurchaseUnit, 1 / Scaler, FromUnitRno, RecipeUnit);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            System.Web.HttpContext.Current.Response.Write(Err.Html());
        }

        return(Scaler);
    }
Ejemplo n.º 25
0
    protected bool FindConversion()
    {
        bool   fFound = false;
        string Sql    = string.Empty;

        try
        {
            ShowConversion = string.Empty;
            StepsRemoved   = 0;

            //AddNote(string.Format("Recipe {0} {1} -> Purchase {2} {3} {4}<br/>", Str.ShowFract(Qty), UnitSingle, PurchaseQty, PurchaseUnitQty, PurchaseUnitSingle));
            HttpResponse Resp = System.Web.HttpContext.Current.Response;

            if (fShowConv)
            {
                Resp.Write(string.Format("------------<br/>{0} {1} {2} -> {3} {4}<br/>", Name, Str.ShowFract(Qty), UnitSingle, Str.ShowFract(PurchaseQty), PurchaseUnitSingle));
            }

            decimal Scaler = ConversionScaler(UnitRno, PurchaseUnitRno);
            fFound = (Scaler != 0);
            if (PurchaseUnitQty != 0)
            {
                PurchaseQty = Qty * Scaler / PurchaseUnitQty;
            }
            else
            {
                PurchaseQty = Qty * Scaler;
            }
            ShowConversion = string.Format(" = {0} {1} {2}", Str.ShowFract(PurchaseQty), Str.ShowFract(PurchaseUnitQty), PurchaseUnitSingle);


            //	if (UnitRno == PurchaseUnitRno)
            //	{
            //		if (fShowConv) Resp.Write("^^^^^^^^^<br/>"); Resp.Flush();
            //		fFound = true;
            //		PurchaseQty = Qty / PurchaseUnitQty;
            //		ShowConversion = string.Format(" = {0} {1} {2}", Str.ShowFract(PurchaseQty), Str.ShowFract(PurchaseUnitQty), PurchaseUnitSingle);
            //		StepsRemoved = 0;
            //	}
            //	else
            //	{
            //		lstIngredConversions = FindIngredConversions(IngredRno);

            //		fFound = false;

            //		if (fShowConv)
            //		{
            //			// show the possible conversions
            //			Resp.Write("<table>");
            //			foreach (IngredConv IngredConv in lstIngredConversions)
            //			{
            //				Resp.Write(string.Format("<tr><td>{4}{0}</td><td>{1}</td><td>{2}</td><td>{3}</td>", IngredConv.RecipeQty, IngredConv.RecipeUnit, IngredConv.PurchaseQty, IngredConv.PurchaseUnit, (IngredConv.IngredRno == 0 ? string.Empty : "*")));
            //			}
            //			Resp.Write("</table>"); Resp.Flush();
            //		}

            //		// clear visited flags
            //		// see if the purchase unit is found in the list of conversions
            //		// see if there is a simple match at the first level
            //		bool fFoundPurchaseUnit = false;
            //		foreach (IngredConv IngredConv in lstIngredConversions)
            //		{
            //			IngredConv.fVisited = false;

            //			if (IngredConv.PurchaseUnitRno == PurchaseUnitRno)
            //			{
            //				fFoundPurchaseUnit = true;
            //			}

            //			if (IngredConv.RecipeUnitRno == UnitRno && IngredConv.PurchaseUnitRno == PurchaseUnitRno)
            //			{
            //				PurchaseQty = (Qty * IngredConv.PurchaseQty / IngredConv.RecipeQty);
            //				PurchaseQty = PurchaseQty / PurchaseUnitQty;
            //				ShowConversion = string.Format(" * {0} {1} / {2} {3} = {4} {5} {6}", Str.ShowFract(IngredConv.PurchaseQty), IngredConv.PurchaseUnit, Str.ShowFract(IngredConv.RecipeQty), IngredConv.RecipeUnit, Str.ShowFract(PurchaseQty), Str.ShowFract(PurchaseUnitQty), PurchaseUnitSingle);
            //				StepsRemoved = 1;
            //				fFound = true;
            //			}
            //		}

            //		if (!fFound && fFoundPurchaseUnit)
            //		{
            //			for (int i = 0; i < lstIngredConversions.Count; i++)
            //			{
            //				IngredConv IngredConv = lstIngredConversions[i];
            //				if (IngredConv.RecipeUnitRno == UnitRno)
            //				{
            //					IngredConv.fVisited = true;
            //					if (fFound = FindNextConversion(Qty, IngredConv, NextLevel))
            //					{
            //						StepsRemoved++;
            //						break;
            //					}
            //				}
            //			}
            //		}
            //	}
            //	if (fShowConv) Resp.Write(string.Format("Found in {9} steps {0} {1} {2} -> {3} {4} {5} => {6} {7}{8}<br/>", fFound, Str.ShowFract(Qty), UnitSingle, Str.ShowFract(PurchaseQty), Str.ShowFract(PurchaseUnitQty), PurchaseUnitSingle, Str.ShowFract(Qty), UnitSingle, ShowConversion, StepsRemoved)); Resp.Flush();

            //	// add a new ingredient conversion if too many steps, next time it will be much shorter
            //	if (StepsRemoved > 1)
            //	{
            //		Sql = string.Format(
            //			"Insert Into IngredConv (IngredRno, PurchaseQty, PurchaseUnitRno, RecipeQty, RecipeUnitRno, CreatedDtTm, CreatedUser) " +
            //			"Values ({0}, {1}, {2}, {3}, {4}, GetDate(), {5})",
            //			IngredRno,
            //			PurchaseQty * PurchaseUnitQty,
            //			PurchaseUnitRno,
            //			Qty,
            //			UnitRno,
            //			DB.PutStr(g.User));
            //		DB.DBExec(Sql);
            //	}
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            System.Web.HttpContext.Current.Response.Write(Err.Html());
        }

        return(fFound);
    }
Ejemplo n.º 26
0
    // update the ingredients prices in recipies
    private static void UpdatePrices(DB db, int IngredRno, int SubrecipeRno, decimal?Qty, int?UnitRno, decimal?Price)
    {
        string Sql = string.Empty;

        try
        {
            // update price in all recipie ingred xref records
            Sql = string.Format("Select RecipeIngredRno, RecipeRno, UnitQty, UnitRno, BaseCostPrice From RecipeIngredXref Where {0} = {1}", (IngredRno != 0 ? "IngredRno" : "SubrecipeRno"), (IngredRno != 0 ? IngredRno : SubrecipeRno));
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                int     RecipeIngredRno = DB.Int32(dr["RecipeIngredRno"]);
                int     RecipeRno       = DB.Int32(dr["RecipeRno"]);
                decimal RecipeUnitQty   = DB.Dec(dr["UnitQty"]);
                int     RecipeUnitRno   = DB.Int32(dr["UnitRno"]);
                decimal CurrIngredPrice = DB.Dec(dr["BaseCostPrice"]);

                bool fRecalcRecipe = false;

                // if there is a price
                if (Price.HasValue)
                {
                    // calculate the new price
                    Ingred  Ingred      = new Ingred(IngredRno);
                    decimal ConvScaler  = Ingred.ConversionScaler(UnitRno.Value, RecipeUnitRno);
                    decimal IngredPrice = (Qty * ConvScaler == 0 ? 0 : Math.Round(Price.Value / Qty.Value / ConvScaler * RecipeUnitQty, 4));

                    // if price has changed
                    if (IngredPrice != CurrIngredPrice)
                    {
                        // update recipe ingred xref price and recipie cost
                        Sql = string.Format(
                            "Update RecipeIngredXref Set " +
                            "BaseCostPrice = {1}, " +
                            "UpdatedDtTm = GetDate(), " +
                            "UpdatedUser = {2} " +
                            "Where RecipeIngredRno = {0}",
                            RecipeIngredRno,
                            IngredPrice,
                            DB.PutStr(g.User));
                        db.Exec(Sql);

                        fRecalcRecipe = true;
                    }
                }
                else
                {
                    // if there is not a price, remove the price from the recipe ingredient
                    Sql = string.Format(
                        "Update RecipeIngredXref Set " +
                        "BaseCostPrice = Null, " +
                        "UpdatedDtTm = GetDate(), " +
                        "UpdatedUser = {1} " +
                        "Where RecipeIngredRno = {0}",
                        RecipeIngredRno,
                        DB.PutStr(g.User));
                    db.Exec(Sql);

                    fRecalcRecipe = true;
                }

                if (fRecalcRecipe)
                {
                    RecalcRecipePrice(db, RecipeRno);
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            System.Web.HttpContext.Current.Response.Write(Err.Html());
        }
    }
Ejemplo n.º 27
0
    private void LoadLinens()
    {
        if (JobRno > 0)
        {
            String Sql = "";

            while (tblLinens.Rows.Count > 1)
            {
                tblLinens.Rows.RemoveAt(1);
            }

            try
            {
                Sql = String.Format(
                    "Select Seq, Description, Caterer, Color, Ordered, Other " +
                    "From JobLinens " +
                    "Where JobRno = {0} Order By Seq", JobRno);
                DataTable dt = db.DataTable(Sql);
                hfNewRecords.Value = "false";

                if (dt.Rows.Count == 0)
                {
                    Sql = String.Format(
                        "Select Seq, Description, Caterer, Color, Ordered, Other " +
                        "From JobLinens " +
                        "Where JobRno = {0} Order By Seq", 0);
                    dt = db.DataTable(Sql);
                    hfNewRecords.Value = "true";
                }

                int iRow = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    iRow++;

                    Label lbl = new Label()
                    {
                        ID = "lblDescription" + iRow, Text = DB.Str(dr["Description"])
                    };
                    HiddenField hf = new HiddenField()
                    {
                        ID = "hfDescription" + iRow, Value = lbl.Text
                    };
                    TableCell tc = new TableCell()
                    {
                        CssClass = "Field"
                    };
                    tc.Controls.Add(lbl);
                    tc.Controls.Add(hf);
                    TableRow tr = new TableRow();
                    tr.Cells.Add(tc);

                    hf = new HiddenField()
                    {
                        ID = "hfSeq" + iRow, Value = DB.Int32(dr["Seq"]).ToString()
                    };
                    tc = new TableCell();
                    tc.Controls.Add(hf);
                    tr.Cells.Add(tc);

                    TextBox txt = new TextBox()
                    {
                        ID = "txtCaterer" + iRow, CssClass = "Linens", Text = DB.Str(dr["Caterer"])
                    };
                    tc = new TableCell();
                    tc.Controls.Add(txt);
                    tr.Cells.Add(tc);

                    txt = new TextBox()
                    {
                        ID = "txtColor" + iRow, CssClass = "HalfLinens", Text = DB.Str(dr["Color"])
                    };
                    tc = new TableCell();
                    tc.Controls.Add(txt);
                    tr.Cells.Add(tc);

                    txt = new TextBox()
                    {
                        ID = "txtOrdered" + iRow, CssClass = "HalfLinens", Text = DB.Str(dr["Ordered"])
                    };
                    tc = new TableCell();
                    tc.Controls.Add(txt);
                    tr.Cells.Add(tc);

                    txt = new TextBox()
                    {
                        ID = "txtOther" + iRow, CssClass = "Linens", Text = DB.Str(dr["Other"])
                    };
                    tc = new TableCell();
                    tc.Controls.Add(txt);
                    tr.Cells.Add(tc);

                    tblLinens.Rows.Add(tr);
                }
                hfCount.Value = iRow.ToString();
            }
            catch (Exception Ex)
            {
                Err Err = new Err(Ex, Sql);
                Response.Write(Err.Html());
            }
        }
    }
Ejemplo n.º 28
0
    private void AddSubrecipe(int ParentRecipeRno, int SubrecipeRno, decimal Scaler, int JobRno, string Customer, int JobServings, string MenuItem, int RecipeRno, string Recipe, decimal Qty, int UnitRno, string UnitSingle, string UnitPlural, string Subrecipe, List <String> Notes)
    {
        Debug.WriteLine("> AddSubrecipe");
        string Sql = string.Format(
            "Select\n" +
            "r.RecipeRno, r.Name As Subrecipe,\n" +
            "r.NumServings, r.MenServingRatio, r.WomenServingRatio, r.ChildServingRatio,\n" +
            "r.YieldQty, r.YieldUnitRno, (Select UnitPlural From Units Where UnitRno = r.YieldUnitRno) As YieldUnit,\n" +
            "r.PortionQty, r.PortionUnitRno, (Select UnitPlural From Units Where UnitRno = r.PortionUnitRno) As PortionUnit,\n" +
            "x.IngredRno, x.SubrecipeRno, x.UnitQty, x.UnitRno,\n" +
            "(Select UnitSingle From Units Where UnitRno = x.UnitRno) As UnitSingle,\n" +
            "(Select UnitPlural From Units Where UnitRno = x.UnitRno) As UnitPlural,\n" +
            "i.Name, i.PrefVendors, i.StockedFlg,\n" +
            "(Select Name From Recipes Where RecipeRno = {1}) As ParentRecipe,\n" +
            "(Select UnitPlural From Units Where UnitRno = {2}) As ParentUnit\n" +
            "From Recipes r\n" +
            "Inner join RecipeIngredXref x On r.RecipeRno = x.RecipeRno\n" +
            "Left Join Ingredients i On x.IngredRno = i.IngredRno\n" +
            "Where r.RecipeRno = {0}\n" +
            "And IsNull(i.NonPurchaseFlg, 0) = 0",
            SubrecipeRno,
            ParentRecipeRno,
            UnitRno);

        try
        {
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                int     IngredRno     = DB.Int32(dr["IngredRno"]);
                int     xSubrecipeRno = DB.Int32(dr["SubrecipeRno"]);
                decimal YieldQty      = DB.Dec(dr["YieldQty"]);
                int     YieldUnitRno  = DB.Int32(dr["YieldUnitRno"]);

                Ingred  Ingred           = new Ingred(0);
                decimal ConversionScaler = Ingred.ConversionScaler(UnitRno, YieldUnitRno);
                decimal NextScaler       = Scaler * Qty * ConversionScaler;

                if (ConversionScaler == 0)
                {
                    string Note = string.Format("<a href='Recipes.aspx?Rno={0}' target='Fix' tabindex='-1'><i class=\"icon-warning-sign\"></i> <b>{2}'s</b> unit needs to use subrecipe's yield unit ({3}) or a known unit.</a>", ParentRecipeRno, DB.Str(dr["ParentUnit"]), DB.Str(dr["Subrecipe"]), DB.Str(dr["YieldUnit"]));
                    Notes.Add(Note);
                }

                // if an ingredient
                if (IngredRno != 0)
                {
                    AddIngredient(dr);
                    AddServings(IngredRno, NextScaler, JobRno, Customer, JobServings, MenuItem, RecipeRno, Recipe, YieldQty, DB.Dec(dr["UnitQty"]), DB.Int32(dr["UnitRno"]), DB.Str(dr["UnitSingle"]), DB.Str(dr["UnitPlural"]), Subrecipe + " &lt; " + DB.Str(dr["Subrecipe"]), Notes);
                }

                // if a subrecipe
                if (xSubrecipeRno != 0)
                {
                    if (YieldQty == 0)
                    {
                        string Note = string.Format("<a href='Recipes.aspx?Rno={0}' target='_blank' tabindex='-1'><i class=\"icon-warning-sign\"></i> Recipe for <b>{1}</b> is missing the yield quantity.</a>", SubrecipeRno, DB.Str(dr["Subrecipe"]));
                        Notes.Add(Note);
                        YieldQty = 1;
                    }
                    AddSubrecipe(SubrecipeRno, xSubrecipeRno, NextScaler / YieldQty, JobRno, Customer, JobServings, MenuItem, RecipeRno, Recipe, DB.Dec(dr["UnitQty"]), DB.Int32(dr["UnitRno"]), DB.Str(dr["UnitSingle"]), DB.Str(dr["UnitPlural"]), Subrecipe + " &lt; " + DB.Str(dr["Subrecipe"]), Notes);
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
        Debug.WriteLine("< AddSubrecipe");
    }
Ejemplo n.º 29
0
    private void Report()
    {
        Debug.WriteLine("> Report");
        lstIngred = new List <Ingred>();

        hfBegDate.Value = dtBeg.ToString();
        hfEndDate.Value = dtEnd.ToString();

        ltlBegDate.Text = Fmt.Dt(dtBeg);
        ltlEndDate.Text = Fmt.Dt(dtEnd);

        string Sql = string.Format(
            "Select\n" +
            "j.JobRno, Coalesce(cu.Name, c.Name) as Customer, j.NumMenServing, NumWomenServing, NumChildServing, f.Qty, f.MenuItem,\n" +
            "r.RecipeRno, r.Name As Recipe,\n" +
            "r.NumServings, r.MenServingRatio, r.WomenServingRatio, r.ChildServingRatio,\n" +
            "r.YieldQty, r.YieldUnitRno, (Select UnitSingle From Units Where UnitRno = r.YieldUnitRno) As YieldUnit,\n" +
            "r.PortionQty, r.PortionUnitRno, (Select UnitSingle From Units Where UnitRno = r.PortionUnitRno) As PortionUnit,\n" +
            "x.IngredRno, x.SubrecipeRno, x.UnitQty, x.UnitRno,\n" +
            "(Select UnitSingle From Units Where UnitRno = x.UnitRno) As UnitSingle,\n" +
            "(Select UnitPlural From Units Where UnitRno = x.UnitRno) As UnitPlural\n" +
            "From mcJobs j\n" +
            "Inner Join Contacts c On j.ContactRno = c.ContactRno\n" +
            "Left Join Customers cu on c.CustomerRno = cu.CustomerRno\n" +
            "Inner Join mcJobFood f On j.JobRno = f.JobRno\n" +
            "Inner Join mcJobMenuItems m On f.MenuItemRno = m.MenuItemRno\n" +
            "Inner Join Recipes r On m.RecipeRno = r.RecipeRno\n" +
            "Inner join RecipeIngredXref x On r.RecipeRno = x.RecipeRno\n" +
            "Where JobDate Between {0} And {1}\n" +
            "And j.ProposalFlg = 0\n" +
            "And j.CancelledDtTm Is Null\n" +
            "Order By j.JobRno, f.MenuItem\n",
            DB.PutDtTm(dtBeg),
            DB.PutDtTm(dtEnd));

        try
        {
            string Html = string.Empty;
            int    ID   = 0;
            //Response.Write(Sql + "<br/>");
            DataTable dtRecipeIngredXref = db.DataTable(Sql);
            if (dtRecipeIngredXref.Rows.Count > 0)
            {
                Ingred.LoadVendors();
                Ingred.LoadIngredConversions();
                Ingred.LoadIngredPurchases();

                // find the ingredients for the recipes
                Sql = string.Format(
                    "Select IngredRno, Name, StockedFlg, PrefVendors\n" +
                    "From Ingredients i\n" +
                    "Where IsNull(NonPurchaseFlg, 0) = 0\n" +
                    "and IsNull(HideFlg, 0) = 0");
                //IngredRno In ({ 0})\n" +
                //"And
                //Str.Join(DB.StrArray(dtRecipeIngredXref, "IngredRno"), ","));
                DataTable dt = db.DataTable(Sql);
                //Response.Write(Sql + "<br/>");

                // build a collection of ingredients
                foreach (DataRow dr in dt.Rows)
                {
                    AddIngredient(dr);
                }

                // add the number of servings and recipe quantities
                foreach (DataRow dr in dtRecipeIngredXref.Rows)
                {
                    int JobServings = DB.Int32(dr["Qty"]);
                    if (JobServings == 0)
                    {
                        JobServings = DB.Int32(dr["NumMenServing"]) + DB.Int32(dr["NumWomenServing"]) + DB.Int32(dr["NumChildServing"]);
                    }

                    int     IngredRno    = DB.Int32(dr["IngredRno"]);
                    int     SubrecipeRno = DB.Int32(dr["SubrecipeRno"]);
                    decimal NumServings  = DB.Dec(dr["NumServings"]);

                    // if an ingredient
                    if (IngredRno != 0)
                    {
                        AddServings(IngredRno, JobServings, DB.Int32(dr["JobRno"]), DB.Str(dr["Customer"]), JobServings, DB.Str(dr["MenuItem"]), DB.Int32(dr["RecipeRno"]), DB.Str(dr["Recipe"]), NumServings, DB.Dec(dr["UnitQty"]), DB.Int32(dr["UnitRno"]), DB.Str(dr["UnitSingle"]), DB.Str(dr["UnitPlural"]), string.Empty, null);
                    }

                    // if a subrecipe
                    if (SubrecipeRno != 0)
                    {
                        if (NumServings != 0)
                        {
                            int RecipeRno = DB.Int32(dr["RecipeRno"]);
                            AddSubrecipe(RecipeRno, SubrecipeRno, JobServings / NumServings, DB.Int32(dr["JobRno"]), DB.Str(dr["Customer"]), JobServings, DB.Str(dr["MenuItem"]), RecipeRno, DB.Str(dr["Recipe"]), DB.Dec(dr["UnitQty"]), DB.Int32(dr["UnitRno"]), DB.Str(dr["UnitSingle"]), DB.Str(dr["UnitPlural"]), string.Empty, new List <string>());
                        }
                    }
                }

                // sort by vendor, ingredient
                lstIngred.Sort(CompareIngredByName);

                string PrevVendor = string.Empty;

                //Html += ReportHeader();

                foreach (Ingred CurrIngred in lstIngred)
                {
                    ID++;
                    string sID = ID.ToString();

                    CurrIngred.FindPurchaseInfo();
                    CurrIngred.Note = string.Empty;     // remove any "No prior receipt found" note

                    // replace stocked items quantity
                    if (CurrIngred.StockedFlg)
                    {
                        CurrIngred.AdjustStockedItemsQuantity(db);
                    }

                    /*
                     * if (CurrIngred.fFoundConversion)
                     * {
                     *  Html += string.Format(
                     *      "\t\t<tr>\n" +
                     *      "\t\t\t<td><input id='hfIngredRno{0}' type='hidden' value='{1}'/><img src='Images/Box.gif'/></td>\n" +
                     *      "\t\t\t<td class='Qty'>{2}</td>\n" +
                     *      "\t\t\t<td>{3}{4}</td>\n" +
                     *      "\t\t\t<td title='{11}' class='qtp Ingred'><a href='Ingredients.aspx?Rno={1}' target='_blank' tabindex='-1'>{5}</a></td>\n" +
                     *      "\t\t\t<td><input id='txtQty{0}' type=text class='Qty' value='{6}'/></td>\n" +
                     *      "\t\t\t<td><input id='txtUnitQty{0}' type=text class='Qty UnitQty' value='{7}'/></td>\n" +
                     *      "\t\t\t<td><input id='hfUnitRno{0}' type=hidden value='{8}' class='UnitRno'/><input id='txtUnit{0}' type=text class='Unit' value='{9}'/></td>\n" +
                     *      "\t\t\t<td>{10}</td>\n" +
                     *      "\t\t</tr>\n",
                     *      ID,
                     *      CurrIngred.IngredRno,
                     *      Str.ShowFract(CurrIngred.PurchaseQty * CurrIngred.PurchaseUnitQty, 2),
                     *      string.Empty,
                     *      (CurrIngred.PurchaseQty <= 1 ? CurrIngred.PurchaseUnitSingle : CurrIngred.PurchaseUnitPlural),
                     *      5 CurrIngred.Name.Replace("'", "&apos;"),
                     *      Math.Ceiling(CurrIngred.PurchaseQty),
                     *      (CurrIngred.PurchaseUnitQty != 1 ? CurrIngred.PurchaseUnitQty.ToString() : string.Empty),
                     *      CurrIngred.PurchaseUnitRno,
                     *      (CurrIngred.PurchaseQty <= 1 ? CurrIngred.PurchaseUnitSingle : CurrIngred.PurchaseUnitPlural),
                     *      10 CurrIngred.Vendor,
                     *      string.Empty,
                     *      CurrIngred.AddlInfo);
                     * }
                     * else
                     * {
                     *  Html += string.Format(
                     *      "\t\t<tr>\n" +
                     *      "\t\t\t<td><input id='hfIngredRno{0}' type='hidden' value='{1}'/><img src='Images/Box.gif'/></td>\n" +
                     *      "\t\t\t<td class='Qty'>{2}</td>\n" +
                     *      "\t\t\t<td>{3}{4}</td>\n" +
                     *      "\t\t\t<td title='{11}' class='qtp'>{5}</td>\n" +
                     *      "\t\t\t<td><input id='txtQty{0}' type=text class='Qty' value='{6}'/></td>\n" +
                     *      "\t\t\t<td><input id='txtUnitQty{0}' type=text class='Qty UnitQty' value='{7}'/></td>\n" +
                     *      "\t\t\t<td><input id='hfUnitRno{0}' type=hidden value='{8}' class='UnitRno'/><input id='txtUnit{0}' type=text class='Unit' value='{9}'/></td>\n" +
                     *      "\t\t\t<td>{10}</td>\n" +
                     *      "\t\t</tr>\n",
                     *      ID,
                     *      CurrIngred.IngredRno,
                     *      Str.ShowFract(CurrIngred.Qty, 2),
                     *      string.Empty,
                     *      (CurrIngred.Qty <= 1 ? CurrIngred.UnitSingle : CurrIngred.UnitPlural),
                     *      CurrIngred.Name.Replace("'", "&apos;"),
                     *      "?",
                     *      (CurrIngred.PurchaseUnitQty != 1 ? CurrIngred.PurchaseUnitQty + " " : string.Empty),
                     *      CurrIngred.PurchaseUnitRno,
                     *      (CurrIngred.PurchaseQty <= 1 ? CurrIngred.PurchaseUnitSingle : CurrIngred.PurchaseUnitPlural),
                     *      CurrIngred.Vendor,
                     *      string.Empty,
                     *      CurrIngred.AddlInfo);
                     *
                     *  if (CurrIngred.PurchaseUnitRno != 0)
                     *  {
                     *      CurrIngred.AddNote(
                     *          string.Format(
                     *              "<a href='Ingredients.aspx?Rno={2}' target='_blank' tabindex='-1'><i class=\"icon-warning-sign\"></i> Need conversion from {0} to {1}.</a>",
                     *              CurrIngred.UnitPlural,
                     *              CurrIngred.PurchaseUnitPlural,
                     *              CurrIngred.IngredRno));
                     *  }
                     * }
                     *
                     * if (CurrIngred.Note.Length > 0)
                     *                  {
                     *                          Html += string.Format(
                     *                              "<tr><td colspan='9' class='Notes'><ul>{0}</ul></td></tr>\n",
                     *                              CurrIngred.Note);
                     * }
                     */

                    TableRow tr = new TableRow();
                    tblReport.Rows.Add(tr);

                    TableCell tc = new TableCell();
                    tr.Cells.Add(tc);

                    tc.Controls.Add(new HiddenField()
                    {
                        ID = "hfIngredRno" + sID, Value = CurrIngred.IngredRno.ToString()
                    });
                    tc.Controls.Add(new Image()
                    {
                        ImageUrl = "Images/Box.gif"
                    });

                    tr.Cells.Add(new TableCell()
                    {
                        CssClass = "Qty", Text = Str.ShowFract(CurrIngred.PurchaseQty * CurrIngred.PurchaseUnitQty, 2)
                    });
                    tr.Cells.Add(new TableCell()
                    {
                        Text = (CurrIngred.PurchaseQty <= 1 ? CurrIngred.PurchaseUnitSingle : CurrIngred.PurchaseUnitPlural)
                    });

                    string Name = CurrIngred.Name.Replace("'", "&apos;");
                    if (CurrIngred.fFoundConversion)
                    {
                        tc = new TableCell()
                        {
                            ToolTip = CurrIngred.AddlInfo, CssClass = "qtp Ingred"
                        };
                        tr.Cells.Add(tc);
                        tc.Controls.Add(new HyperLink()
                        {
                            NavigateUrl = "Ingredients.aspx?Rno=" + CurrIngred.IngredRno, Target = "_blank", TabIndex = -1, Text = Name
                        });
                    }
                    else
                    {
                        tr.Cells.Add(new TableCell()
                        {
                            ToolTip = CurrIngred.AddlInfo, CssClass = "qtp", Text = Name
                        });
                    }

                    tr.Cells.Add(new TableCell()
                    {
                        CssClass = "Qty", Text = Math.Ceiling(CurrIngred.PurchaseQty).ToString()
                    });
                    tr.Cells.Add(new TableCell()
                    {
                        CssClass = "UnitQty",
                        Text     = string.Format("{0} {1}",
                                                 (CurrIngred.PurchaseUnitQty != 1 ? Math.Ceiling(CurrIngred.PurchaseUnitQty).ToString() : string.Empty),
                                                 (CurrIngred.PurchaseQty <= 1 ? CurrIngred.PurchaseUnitSingle : CurrIngred.PurchaseUnitPlural))
                    });

                    tc = new TableCell();
                    tr.Cells.Add(tc);
                    tc.Controls.Add(new TextBox()
                    {
                        ID = "txtQty" + sID, CssClass = "Qty", Text = (CurrIngred.StockedPurchaseQty != 0 ? Math.Ceiling(CurrIngred.StockedPurchaseQty).ToString() : string.Empty)
                    });

                    if (!CurrIngred.fFoundConversion && CurrIngred.PurchaseUnitRno != 0 && CurrIngred.UnitPlural.Length > 0 && CurrIngred.PurchaseUnitPlural.Length > 0)
                    {
                        CurrIngred.AddNote(
                            string.Format(
                                "<a href='Ingredients.aspx?Rno={2}' target='_blank' tabindex='-1'><i class=\"icon-warning-sign\"></i> Need conversion from {0} to {1}.</a>",
                                CurrIngred.UnitPlural,
                                CurrIngred.PurchaseUnitPlural,
                                CurrIngred.IngredRno));
                    }

                    if (CurrIngred.Note.Length > 0)
                    {
                        //Html += string.Format(
                        //	"<tr><td colspan='9' class='Notes'><ul>{0}</ul></td></tr>\n",
                        //	CurrIngred.Note);
                        tr = new TableRow();
                        tblReport.Rows.Add(tr);
                        tr.Cells.Add(new TableCell()
                        {
                            ColumnSpan = 8, CssClass = "Notes", Text = string.Format("<ul>{0}</ul>", CurrIngred.Note)
                        });
                    }
                }
            }
            //Html += "</table>";
            hfParmCount.Value = ID.ToString();
            //ltlReport.Text = Html;
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
        Debug.WriteLine("< Report");
    }
Ejemplo n.º 30
0
    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());
        }
    }