// find the given text box in the given row of the food menu table //private String FindTextBox(ref TableRow tr, String ID) //{ // String Text = ""; // try // { // Control Ctrl = tr.FindControl(ID); // if (Ctrl != null) // { // TextBox txtBox = new TextBox(); // HtmlInputHidden txtHidden = new HtmlInputHidden(); // if (Ctrl.GetType() == txtBox.GetType()) // { // txtBox = (TextBox)Ctrl; // Text = txtBox.Text.Trim(); // } // else // if (Ctrl.GetType() == txtHidden.GetType()) // { // txtHidden = (HtmlInputHidden)Ctrl; // Text = txtHidden.Value.Trim(); // } // } // } // catch (Exception Ex) // { // Err Err = new Err(Ex); // Response.Write(Err.Html()); // } // return Text; //} // retrieve the food menu items for the job and present them as rows in the menu table private void LoadFood() { if (JobRno > 0) { String Sql = ""; try { // look for duplicates Sql = "Select f1.FoodSeq " + "From mcJobFood f1 Inner Join mcJobFood f2 " + "On f1.JobRno = f2.JobRno And f1.FoodSeq <> f2.FoodSeq " + "And f1.Category = f2.Category And f1.MenuItem = f2.MenuItem " + "Where f1.JobRno = " + JobRno; DupSeq Dups = new DupSeq(db, Sql); Sql = "Select f.*, i.ServingQuote, i.ServingPrice, i.InaccuratePriceFlg, i.RecipeRno " + "From mcJobFood f Left Join mcJobMenuItems i on f.MenuItemRno = i.MenuItemRno " + "Where JobRno = " + JobRno + " And FoodSeq Is Not Null " + "Order By FoodSeq"; DataTable dt = db.DataTable(Sql, 300); //cItems = dt.Rows.Count + 1; cItems = dt.Rows.Count; AddLines(); int iRow = 0; foreach (DataRow dr in dt.Rows) { iRow++; TableRow tr = tblFood.Rows[iRow]; bool fDup = Dups.In(DB.Int32(dr["FoodSeq"])); HtmlInputHidden txtFoodSeq = (HtmlInputHidden)tr.FindControl("txtFoodSeq" + iRow); txtFoodSeq.Value = DB.Str(dr["FoodSeq"]); HtmlInputHidden hfJobFoodRno = (HtmlInputHidden)tr.FindControl("hfJobFoodRno" + iRow); hfJobFoodRno.Value = DB.Str(dr["JobFoodRno"]); HtmlInputHidden hfProposal = (HtmlInputHidden)tr.FindControl("hfProposal" + iRow); hfProposal.Value = DB.Str(dr["ProposalMenuItem"]); HtmlInputHidden hfIngredSelFlg = (HtmlInputHidden)tr.FindControl("hfIngredSelFlg" + iRow); HtmlInputHidden hfOrigIngredSelFlg = (HtmlInputHidden)tr.FindControl("hfOrigIngredSelFlg" + iRow); bool fIngredSel = DB.Bool(dr["IngredSelFlg"]); hfIngredSelFlg.Value = hfOrigIngredSelFlg.Value = fIngredSel.ToString(); HtmlInputHidden hfIngredSel = (HtmlInputHidden)tr.FindControl("hfIngredSel" + iRow); HtmlInputHidden hfOrigIngredSel = (HtmlInputHidden)tr.FindControl("hfOrigIngredSel" + iRow); hfIngredSel.Value = hfOrigIngredSel.Value = DB.Str(dr["IngredSel"]); HtmlInputHidden hfIngredSelAutoPop = (HtmlInputHidden)tr.FindControl("hfIngredSelAutoPop" + iRow); hfIngredSelAutoPop.Value = false.ToString(); TextBox txtCategory = (TextBox)tr.FindControl("txtCategory" + iRow); HtmlInputHidden hfOrigCategory = (HtmlInputHidden)tr.FindControl("hfOrigCategory" + iRow); txtCategory.Text = hfOrigCategory.Value = DB.Str(dr["Category"]); txtCategory.CssClass = (fDup ? "DupFoodCategory " : "") + "FoodCategory"; TextBox txtMenuItem = (TextBox)tr.FindControl("txtMenuItem" + iRow); HtmlInputHidden hfOrigMenuItem = (HtmlInputHidden)tr.FindControl("hfOrigMenuItem" + iRow); txtMenuItem.Text = hfOrigMenuItem.Value = DB.Str(dr["MenuItem"]); txtMenuItem.CssClass = (fDup ? "DupMenuItem " : "") + "MenuItem"; SelectList slMenuItem = SelectList.Find("MenuItem" + iRow); if (slMenuItem != null) { Sql = "Select Distinct MenuItem From mcJobMenuItems Where Category = " + DB.PutStr(txtCategory.Text) + " And HideFlg != 1 Order By MenuItem"; slMenuItem.ClearValues(); slMenuItem.AddDBValues(db, Sql); } Label lblIngredSel = (Label)tr.FindControl("lblIngredSel" + iRow); if (fIngredSel) { string ToolTip = "<div class='IngredSelQtip'>Selected Ingredients</div>"; Sql = string.Format( "Select Coalesce(i.Name, r.Name) as Name, " + "r.GlutenFreeFlg, r.VeganFlg, r.VegetarianFlg, r.DairyFreeFlg, r.NutsFlg " + "From RecipeIngredXref x " + "Left Join Ingredients i On i.IngredRno = x.IngredRno " + "Left Join Recipes r on r.RecipeRno = x.SubrecipeRno " + "Where x.RecipeRno = {0} " + "And RecipeIngredRno In ({1}) " + "Order By x.RecipeSeq", DB.Int32(dr["RecipeRno"]), (hfIngredSel.Value != string.Empty ? hfIngredSel.Value : "null")); DataTable dtXref = db.DataTable(Sql); foreach (DataRow drXref in dtXref.Rows) { ToolTip += DB.Str(drXref["Name"]) + (DB.Bool(drXref["GlutenFreeFlg"]) ? " [GF]" : string.Empty) + (DB.Bool(drXref["VeganFlg"]) ? " [V]" : string.Empty) + (DB.Bool(drXref["VegetarianFlg"]) ? " [Veg]" : string.Empty) + (DB.Bool(drXref["DairyFreeFlg"]) ? " [DF]" : string.Empty) + (DB.Bool(drXref["NutsFlg"]) ? " [N]" : string.Empty) + "<br/>"; } lblIngredSel.ToolTip = ToolTip; lblIngredSel.Attributes.Add("style", "display: inline;"); } else { lblIngredSel.ToolTip = "Select ingredients for the menu item."; lblIngredSel.Attributes["style"] = string.Empty; } //TextBox txtQtyNote = (TextBox)tr.FindControl("txtQtyNote" + iRow); //TextBox txtOrigQtyNote = (TextBox)tr.FindControl("txtOrigQtyNote" + iRow); //txtQtyNote.Text = //txtOrigQtyNote.Text = DB.Str(dr["QtyNote"]); TextBox txtQty = (TextBox)tr.FindControl("txtQty" + iRow); TextBox txtOrigQty = (TextBox)tr.FindControl("txtOrigQty" + iRow); txtQty.Text = txtOrigQty.Text = DB.Int32(dr["Qty"]).ToString("##,###"); TextBox txtServiceNote = (TextBox)tr.FindControl("txtServiceNote" + iRow); TextBox txtOrigServiceNote = (TextBox)tr.FindControl("txtOrigServiceNote" + iRow); txtServiceNote.Text = txtOrigServiceNote.Text = DB.Str(dr["ServiceNote"]); decimal ServingQuote = DB.Dec(dr["ServingQuote"]); Label lblQuote = (Label)tr.FindControl("lblQuote" + iRow); lblQuote.Text = Fmt.Dollar(ServingQuote); decimal ServingPrice = DB.Dec(dr["ServingPrice"]); Label lblPrice = (Label)tr.FindControl("lblPrice" + iRow); lblPrice.Text = Fmt.Dollar(ServingPrice); bool fInaccuratePrice = DB.Bool(dr["InaccuratePriceFlg"]); Label lblInaccuratePrice = (Label)tr.FindControl("lblInaccuratePrice" + iRow); if (fInaccuratePrice) { lblInaccuratePrice.CssClass = "icon-dollar"; lblInaccuratePrice.ToolTip = "Cost and Price are inaccurate because there are ingredients with no price from receipts."; } } } catch (Exception Ex) { Err Err = new Err(Ex, Sql); Response.Write(Err.Html()); } } else { cItems = 1; AddLines(); } //if (FocusField.Length == 0) { FocusField = "txtCategory" + cItems; } }