private void LoadEditServices() { if (JobRno > 0) { String Sql = ""; try { Sql = "Select f1.ServiceSeq " + "From mcJobServices f1 Inner Join mcJobServices f2 " + "On f1.JobRno = f2.JobRno And f1.ServiceSeq <> f2.ServiceSeq " + "And f1.ServiceItem = f2.ServiceItem " + "Where f1.JobRno = " + JobRno; DupSeq Dups = new DupSeq(db, Sql); Sql = "Select * From mcJobServices Where JobRno = " + JobRno + " Order By ServiceSeq"; DataTable dt = db.DataTable(Sql); cServices = dt.Rows.Count + 1; AddEditLines(); int iRow = 0; foreach (DataRow dr in dt.Rows) { iRow++; TableRow tr = tblServices.Rows[iRow]; HtmlInputHidden txtServiceSeq = (HtmlInputHidden)tr.FindControl("txtServiceSeq" + iRow); txtServiceSeq.Value = DB.Str(dr["ServiceSeq"]); TextBox txtServiceItem = (TextBox)tr.FindControl("txtServiceItem" + iRow); TextBox txtOrigServiceItem = (TextBox)tr.FindControl("txtOrigServiceItem" + iRow); txtServiceItem.Text = txtOrigServiceItem.Text = DB.Str(dr["ServiceItem"]); txtServiceItem.CssClass = (Dups.In(DB.Int32(dr["ServiceSeq"])) ? "Dup" : "") + "ServiceItem"; bool fMCC = DB.Bool(dr["MCCRespFlg"]); bool fCustomer = DB.Bool(dr["CustomerRespFlg"]); string Class = (!fMCC && !fCustomer ? "NotChecked" : ""); CheckBox chkMCCResp = (CheckBox)tr.FindControl("chkMCCResp" + iRow); CheckBox chkOrigMCCResp = (CheckBox)tr.FindControl("chkOrigMCCResp" + iRow); chkMCCResp.Checked = chkOrigMCCResp.Checked = fMCC; chkMCCResp.CssClass = Class; CheckBox chkCustomerResp = (CheckBox)tr.FindControl("chkCustomerResp" + iRow); CheckBox chkOrigCustomerResp = (CheckBox)tr.FindControl("chkOrigCustomerResp" + iRow); chkCustomerResp.Checked = chkOrigCustomerResp.Checked = fCustomer; chkCustomerResp.CssClass = Class; TextBox txtNote = (TextBox)tr.FindControl("txtNote" + iRow); TextBox txtOrigNote = (TextBox)tr.FindControl("txtOrigNote" + iRow); txtNote.Text = txtOrigNote.Text = DB.Str(dr["Note"]); } } catch (Exception Ex) { Err Err = new Err(Ex, Sql); Response.Write(Err.Html()); } } else { cServices = 1; AddLines(); } FocusField = "txtServiceItem" + cServices; }
// 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; } }
private void LoadEditDishes() { if (JobRno > 0) { String Sql = ""; try { Sql = "Select f1.DishSeq " + "From mcJobDishes f1 Inner Join mcJobDishes f2 " + "On f1.JobRno = f2.JobRno And f1.DishSeq <> f2.DishSeq " + "And f1.DishItem = f2.DishItem " + "Where f1.JobRno = " + JobRno; DupSeq Dups = new DupSeq(db, Sql); Sql = "Select * From mcJobDishes Where JobRno = " + JobRno + " Order By DishSeq"; DataTable dt = db.DataTable(Sql); cDishes = dt.Rows.Count + 1; AddEditLines(); int iRow = 0; foreach (DataRow dr in dt.Rows) { iRow++; TableRow tr = tblDishes.Rows[iRow]; string Item = DB.Str(dr["DishItem"]); int Qty = DB.Int32(dr["DishSeq"]); string Note = DB.Str(dr["Note"]); bool fPaperGlass = (Item == cnPaperGlass); HtmlInputHidden txtDishSeq = (HtmlInputHidden)tr.FindControl("txtDishSeq" + iRow); txtDishSeq.Value = DB.Str(dr["DishSeq"]); TextBox txtDishItem = (TextBox)tr.FindControl("txtDishItem" + iRow); TextBox txtOrigDishItem = (TextBox)tr.FindControl("txtOrigDishItem" + iRow); txtDishItem.Text = txtOrigDishItem.Text = DB.Str(dr["DishItem"]); txtDishItem.CssClass = (Dups.In(DB.Int32(dr["DishSeq"])) ? "Dup" : "") + "DishItem"; TextBox txtQty = (TextBox)tr.FindControl("txtQty" + iRow); TextBox txtOrigQty = (TextBox)tr.FindControl("txtOrigQty" + iRow); txtQty.Text = txtOrigQty.Text = Fmt.Num(DB.Int32(dr["Qty"]), false); TextBox txtNote = (TextBox)tr.FindControl("txtNote" + iRow); TextBox txtOrigNote = (TextBox)tr.FindControl("txtOrigNote" + iRow); txtNote.Text = txtOrigNote.Text = DB.Str(dr["Note"]); if (fPaperGlass) { CheckBox chkRemove = (CheckBox)tr.FindControl("chkRemove" + iRow); System.Web.UI.WebControls.Image imgDishItem = (System.Web.UI.WebControls.Image)tr.FindControl("ddDishItem" + iRow); bool fPaper = (Note == cnPaper || Note == ""); chkRemove.Visible = imgDishItem.Visible = txtDishItem.Visible = txtQty.Visible = txtNote.Visible = false; RadioButton rbPaper = new RadioButton(); rbPaper.ID = "rbEditPaper"; rbPaper.GroupName = "rbEditPaperGlass"; rbPaper.Text = "Paper "; rbPaper.Checked = fPaper; RadioButton rbGlass = new RadioButton(); rbGlass.ID = "rbEditGlass"; rbGlass.GroupName = "rbEditPaperGlass"; rbGlass.Text = cnGlass; rbGlass.Checked = !fPaper; TableCell tc = tr.Cells[4]; tc.Controls.Add(rbPaper); tc.Controls.Add(rbGlass); } } } catch (Exception Ex) { Err Err = new Err(Ex, Sql); Response.Write(Err.Html()); } } else { cDishes = 1; AddEditLines(); } FocusField = "txtDishItem" + cDishes; }
private void LoadDetails(int Rno) { //Response.Write(string.Format("LoadDetails Rno {0}<br/>", Rno)); if (Rno > 0) { String Sql = ""; try { Sql = string.Format( "Select d1.PurchaseDetailRno " + "From PurchaseDetails d1 Inner Join PurchaseDetails d2 " + "On d1.PurchaseRno = d2.PurchaseRno And d1.PurchaseDetailRno <> d2.PurchaseDetailRno " + "Where d1.PurchaseRno = {0} " + "And d1.PurchaseDetailRno = d2.PurchaseDetailRno", Rno); DupSeq Dups = new DupSeq(db, Sql); Sql = string.Format( "Select d.*, i.Name, i.MenuItemAsIsFlg, u.UnitSingle, u.UnitPlural " + "From PurchaseDetails d " + "Inner Join Ingredients i On d.IngredRno = i.IngredRno " + "Inner Join Units u On d.PurchaseUnitRno = u.UnitRno " + "Where PurchaseRno = {0} Order By PurchaseDetailRno", Rno); DataTable dt = db.DataTable(Sql); cDetails = dt.Rows.Count + 1; //Response.Write(string.Format("dt rows {0} cDetails {1}<br/>", dt.Rows.Count, cDetails)); //Response.Write(Sql + "<br/>"); AddLines(); int iRow = 0; foreach (DataRow dr in dt.Rows) { iRow++; TableRow tr = tblDetails.Rows[iRow]; int PurchaseDetailRno = DB.Int32(dr["PurchaseDetailRno"]); bool fDup = Dups.In(PurchaseDetailRno); HtmlInputHidden hfPurchaseDetailRno = (HtmlInputHidden)tr.FindControl("hfPurchaseDetailRno" + iRow); HtmlInputHidden hfOrigIngredRno = (HtmlInputHidden)tr.FindControl("hfOrigIngredRno" + iRow); HtmlInputHidden hfIngredRno = (HtmlInputHidden)tr.FindControl("hfIngredRno" + iRow); TextBox txtIngredient = (TextBox)tr.FindControl("txtIngredient" + iRow); TextBox txtPurchaseQty = (TextBox)tr.FindControl("txtPurchaseQty" + iRow); TextBox txtUnitQty = (TextBox)tr.FindControl("txtUnitQty" + iRow); HtmlInputHidden hfUnitRno = (HtmlInputHidden)tr.FindControl("hfUnitRno" + iRow); TextBox txtUnit = (TextBox)tr.FindControl("txtUnit" + iRow); TextBox txtPrice = (TextBox)tr.FindControl("txtPrice" + iRow); CheckBox chkRemove = (CheckBox)tr.FindControl("chkRemove" + iRow); hfPurchaseDetailRno.Value = PurchaseDetailRno.ToString(); hfOrigIngredRno.Value = hfIngredRno.Value = DB.Int32(dr["IngredRno"]).ToString(); txtIngredient.Text = DB.Str(dr["Name"]); decimal Qty = DB.Dec(dr["PurchaseQty"]); txtPurchaseQty.Text = Str.ShowFract(Qty); txtUnitQty.Text = Str.ShowFract(DB.Dec(dr["PurchaseUnitQty"])); hfUnitRno.Value = DB.Int32(dr["PurchaseUnitRno"]).ToString(); txtUnit.Text = DB.Str(dr[Qty <= 1 ? "UnitSingle" : "UnitPlural"]); if (DB.Bool(dr["MenuItemAsIsFlg"])) { txtUnit.Attributes.Add("disabled", "true"); } txtPrice.Text = Fmt.Dollar(DB.Dec(dr["Price"])); chkRemove.Checked = false; } hfNumDetails.Value = cDetails.ToString(); } catch (Exception Ex) { Err Err = new Err(Ex, Sql); Response.Write(Err.Html()); } } else { cDetails = 1; AddLines(); } }
//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; //} private void LoadCrew() { if (JobRno > 0) { String Sql = ""; try { Sql = "Select f1.CrewSeq " + "From mcJobCrew f1 Inner Join mcJobCrew f2 " + "On f1.JobRno = f2.JobRno And f1.CrewSeq <> f2.CrewSeq " + "And f1.CrewMember = f2.CrewMember " + "Where f1.JobRno = " + JobRno; DupSeq Dups = new DupSeq(db, Sql); Sql = "Select * From mcJobCrew Where JobRno = " + JobRno + " Order By CrewSeq"; DataTable dt = db.DataTable(Sql); cCrew = dt.Rows.Count + 1; AddLines(); int iRow = 0; foreach (DataRow dr in dt.Rows) { iRow++; TableRow tr = tblCrew.Rows[iRow]; HtmlInputHidden txtCrewSeq = (HtmlInputHidden)tr.FindControl("txtCrewSeq" + iRow); txtCrewSeq.Value = DB.Str(dr["CrewSeq"]); TextBox txtCrewMember = (TextBox)tr.FindControl("txtCrewMember" + iRow); TextBox txtOrigCrewMember = (TextBox)tr.FindControl("txtOrigCrewMember" + iRow); txtCrewMember.Text = txtOrigCrewMember.Text = DB.Str(dr["CrewMember"]); txtCrewMember.CssClass = (Dups.In(DB.Int32(dr["CrewSeq"])) ? "Dup" : "") + "CrewMember"; TextBox txtAssignment = (TextBox)tr.FindControl("txtAssignment" + iRow); TextBox txtOrigAssignment = (TextBox)tr.FindControl("txtOrigAssignment" + iRow); txtAssignment.Text = txtOrigAssignment.Text = DB.Str(dr["CrewAssignment"]); TextBox txtReportTime = (TextBox)tr.FindControl("txtReportTime" + iRow); TextBox txtOrigReportTime = (TextBox)tr.FindControl("txtOrigReportTime" + iRow); txtReportTime.Text = txtOrigReportTime.Text = Fmt.Tm12Hr(DB.DtTm(dr["ReportTime"])); TextBox txtNote = (TextBox)tr.FindControl("txtNote" + iRow); TextBox txtOrigNote = (TextBox)tr.FindControl("txtOrigNote" + iRow); txtNote.Text = txtOrigNote.Text = DB.Str(dr["Note"]); } } catch (Exception Ex) { Err Err = new Err(Ex, Sql); Response.Write(Err.Html()); } } else { cCrew = 1; AddLines(); } if (FocusField.Length == 0) { FocusField = "txtCrewMember" + cCrew; } else { FocusField += cCrew - 1; } }