Esempio n. 1
0
    // build a comma delimited list of PropPricingRno values that are checked
    protected string ResponseOptions(string PricingCode)
    {
        string Options = string.Empty;
        string Sql     = string.Format(
            "Select PropPricingRno, OptionType From ProposalPricingOptions " +
            "Where PricingCode = '{0}' " +
            "And Seq Is Not Null And " +
            "DeletedDtTm Is Null " +
            "Order by Seq",
            PricingCode);

        try
        {
            DataTable dt = db.DataTable(Sql);
            {
                foreach (DataRow dr in dt.Rows)
                {
                    int    PropPricingRno = DB.Int32(dr["PropPricingRno"]);
                    string Type           = DB.Str(dr["OptionType"]);
                    string ID             = string.Format("opt_{0}", PropPricingRno);

                    switch (Type)
                    {
                    case OptionType.Hidden:
                        break;

                    case OptionType.Checkbox:
                        if (Parm.Bool(ID))
                        {
                            Options += string.Format(",{0}", PropPricingRno);
                        }
                        break;

                    case OptionType.Number:
                        int Num = Parm.Int(ID);
                        Options += string.Format(",{0} {1}", PropPricingRno, Num);
                        break;
                    }
                }
            }

            if (Options.Length > 0)
            {
                Options = Options.Substring(1);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        return(Options);
    }
Esempio n. 2
0
    private void SaveConversions(int IngredRno)
    {
        for (int iConversion = 1; iConversion <= cConversions; iConversion++)
        {
            int     IngredConvRno   = Parm.Int("hfIngredConvRno" + iConversion);
            decimal Qty             = Str.Fract(Parm.Str("txtQty" + iConversion));
            int     RecipeUnitRno   = Parm.Int("hfRecipeUnitRno" + iConversion);
            decimal PurchaseQty     = Parm.Dec("hfPurchaseQty" + iConversion);
            int     PurchaseUnitRno = Parm.Int("hfPurchaseUnitRno" + iConversion);
            string  Sql             = string.Empty;

            bool fRemove = Parm.Bool("chkRemove" + iConversion);
            if (!fRemove)
            {
                try
                {
                    if (Qty > 0)
                    {
                        if (IngredConvRno == 0)
                        {
                            Sql = string.Format(
                                "Insert Into IngredConv (IngredRno, PurchaseQty, PurchaseUnitRno, RecipeUnitRno, CreatedDtTm, CreatedUser) Values (" +
                                "{0}, {1}, {2}, {3}, GetDate(), {4}); " +
                                "Select Scope_Identity()",
                                IngredRno,
                                PurchaseQty,
                                PurchaseUnitRno,
                                RecipeUnitRno,
                                DB.PutStr(g.User));
                            IngredConvRno = db.SqlNum(Sql);
                        }

                        Sql = string.Format(
                            "Update IngredConv Set " +
                            "RecipeQty = {1}, " +
                            "UpdatedDtTm = GetDate(), " +
                            "UpdatedUser = {2} " +
                            "Where IngredConvRno = {0}",
                            IngredConvRno,
                            Qty,
                            DB.PutStr(g.User));
                        db.Exec(Sql);
                    }
                }
                catch (Exception Ex)
                {
                    Err Err = new Err(Ex, Sql);
                    Response.Write(Err.Html());
                }
            }
        }
    }
Esempio n. 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // insure the user is logged in
     g.User = (string)Session["User"];
     if (!(g.User == null || g.User == ""))
     {
         switch (Parm.Str("Action"))
         {
         case "SetNonPurchase":
             SetNonPurchase(Parm.Int("Rno"), Parm.Bool("NonPurchase"));
             break;
         }
     }
 }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // insure the user is logged in
        g.User = (string)Session["User"];
        if (!(g.User == null || g.User == ""))
        {
            switch (Parm.Str("Action"))
            {
            case "SetAsHidden":
                SetAsHidden(Parm.Int("Rno"), Parm.Bool("Hide"));
                break;

            case "MarkAsIs":
                MarkAsIs(Parm.Int("Rno"), Parm.Bool("AsIs"));
                break;

            case "Recipe":
                Recipe(Parm.Int("Rno"), Parm.Int("RecipeRno"));
                break;
            }
        }
    }
Esempio n. 5
0
 private void RemoveConversions()
 {
     for (int iConversion = 1; iConversion <= cConversions; iConversion++)
     {
         bool fRemove = Parm.Bool("chkRemove" + iConversion);
         if (fRemove)
         {
             String Sql = "";
             try
             {
                 int IngredConvRno = Parm.Int("hfIngredConvRno" + iConversion);
                 Sql = "Delete From IngredConv Where IngredConvRno = " + IngredConvRno;
                 db.Exec(Sql);
             }
             catch (Exception Ex)
             {
                 Err Err = new Err(Ex, Sql);
                 Response.Write(Err.Html());
             }
         }
     }
 }
Esempio n. 6
0
 private void RemoveDetails()
 {
     for (int iDetail = 1; iDetail <= cDetails; iDetail++)
     {
         bool fRemove = Parm.Bool("chkRemove" + iDetail);
         if (fRemove)
         {
             String Sql = "";
             try
             {
                 int PurchaseDetailRno = Parm.Int("hfPurchaseDetailRno" + iDetail);
                 Sql = "Delete From PurchaseDetails Where PurchaseDetailRno = " + PurchaseDetailRno;
                 db.Exec(Sql);
             }
             catch (Exception Ex)
             {
                 Err Err = new Err(Ex, Sql);
                 Response.Write(Err.Html());
             }
         }
     }
 }
Esempio n. 7
0
    protected void SaveData()
    {
        string Sql = string.Empty;

        try
        {
            if (Parm.Bool("hfMenuItemsSaved"))
            {
                int NumMenuItems = Parm.Int("hfNumMenuItems");
                for (int i = 0; i < NumMenuItems; i++)
                {
                    Sql = string.Format("Update mcJobMenuItems Set CategorySortOrder = {1} Where MenuItemRno = {0}", Parm.Int(string.Format("hfMenuItem{0}", i)), Parm.Int(string.Format("hfSortOrder{0}", i)));
                    db.Exec(Sql);
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Esempio n. 8
0
    protected void SaveUpdates()
    {
        string Sql = string.Empty;

        try
        {
            DB db = new DB();

            int cLines = Str.Num(hfNumLines.Value);
            for (int i = 0; i < cLines; i++)
            {
                int    JobFoodRno     = Parm.Int(string.Format("hfJobFoodRno{0}", i));
                int    SortOrder      = Parm.Int(string.Format("hfSortOrder{0}", i));
                bool   fProposalTitle = Parm.Bool(string.Format("hfTitle{0}", i));
                string Proposal       = Parm.Str(string.Format("txtProposal{0}", i));
                //bool fDelete = Parm.Bool(string.Format("chkDelete{0}", i));
                bool     fHide = Parm.Bool(string.Format("hfHide{0}", i));
                DateTime Tm    = DateTime.Now;

                // if deleting a title
                if (fHide && Proposal.Length == 0)
                {
                    Sql = string.Format("Delete From mcJobFood Where JobFoodRno = {0}", JobFoodRno);
                    db.Exec(Sql);
                }
                else
                {
                    // if a new title or item
                    if (JobFoodRno == 0)
                    {
                        // add to the menu
                        Sql = string.Format(
                            "Insert Into mcJobFood (JobRno, CreatedDtTm, CreatedUser) Values ({0}, {1}, {2}); Select @@Identity",
                            JobRno,
                            DB.PutDtTm(Tm),
                            DB.PutStr(g.User));
                        JobFoodRno = db.SqlNum(Sql);
                    }

                    Sql = string.Format("Select MenuItemRno From mcJobFood Where JobFoodRno = {0}", JobFoodRno);
                    int MenuItemRno = db.SqlNum(Sql);

                    // update group title or menu item
                    Sql = string.Format(
                        "Update mcJobFood Set ProposalSeq = {1}, ProposalMenuItem = {2}, ProposalTitleFlg = {3}, ProposalHideFlg = {4} Where JobFoodRno = {0}",
                        JobFoodRno,
                        SortOrder,
                        DB.PutStr(Proposal, 1000),
                        DB.PutBool(fProposalTitle),
                        DB.PutBool(fHide));
                    db.Exec(Sql);
                }
            }
            db.Close();
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Esempio n. 9
0
    private void SaveUpdates()
    {
        string Sql = string.Empty;

        try
        {
            DB db = new DB();

            int cItems = Str.Num(hfNumItems.Value);
            for (int i = 0; i < cItems; i++)
            {
                int    Rno      = Parm.Int(string.Format("hfRno{0}", i));
                string Value    = Parm.Str(string.Format("hfValue{0}", i));
                string NewValue = Parm.Str(string.Format("txtValue{0}", i));
                int    Seq      = Parm.Int(string.Format("hfSeq{0}", i));
                bool   fDelete  = Parm.Bool(string.Format("hfDelete{0}", i));

                if (Rno == 0)
                {
                    if (!fDelete)
                    {
                        Sql = string.Format("Insert Into mcJobSupplies (JobRno, SupplyItem, SupplySeq, CreatedDtTm, CreatedUser) Values (0, {0}, {1}, GetDate(), {2})",
                                            DB.PutStr(NewValue),
                                            Seq,
                                            DB.PutStr(g.User));
                        db.Exec(Sql);
                    }
                }
                else
                {
                    if (!fDelete)
                    {
                        Sql = string.Format("Update mcJobSupplies Set SupplySeq = {1}, UpdatedDtTm = GetDate(), UpdatedUser = {2} Where SupplyRno = {0}",
                                            Rno,
                                            Seq,
                                            DB.PutStr(g.User));
                        db.Exec(Sql);

                        // has the Value text itself changed?
                        if (NewValue != Value)
                        {
                            // has changed, update Value values
                            Sql = string.Format("Update mcJobSupplies Set SupplyItem = {1} Where SupplyRno = {0}",
                                                Rno,
                                                DB.PutStr(NewValue));
                            db.Exec(Sql);
                        }
                    }
                    else
                    {
                        Sql = string.Format("Delete From mcJobSupplies Where SupplyRno = {0}", Rno);
                        db.Exec(Sql);
                    }
                }
            }
            db.Close();
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Esempio n. 10
0
    // save (insert or update) the menu food items for the job
    private void SaveFood()
    {
        cItems = Str.Num(hfNumItems.Value);

        for (int iItem = 1; iItem <= cItems; iItem++)
        {
            //TableRow tr = tblFood.Rows[iItem];

            //CheckBox chkRemove = (CheckBox)tr.FindControl("chkRemove" + iItem);
            bool fRemoved = Utils.Parm.Bool("chkRemove" + iItem);

            //if (chkRemove != null && !chkRemove.Checked)
            if (!fRemoved)
            {
                //Int32 FoodSeq = Str.Num(WebPage.FindTextBox(ref tr, "txtFoodSeq" + iItem));
                Int32 FoodSeq    = Utils.Parm.Int("txtFoodSeq" + iItem);
                Int32 JobFoodRno = Utils.Parm.Int("hfJobFoodRno" + iItem);

                //String Category = WebPage.FindTextBox(ref tr, "txtCategory" + iItem);
                string Category = Utils.Parm.Str("txtCategory" + iItem);
                //String OrigCategory = WebPage.FindTextBox(ref tr, "txtOrigCategory" + iItem);
                string OrigCategory = Utils.Parm.Str("txtOrigCategory" + iItem);

                //String MenuItem = WebPage.FindTextBox(ref tr, "txtMenuItem" + iItem);
                string MenuItem = Utils.Parm.Str("txtMenuItem" + iItem);
                //String OrigMenuItem = FindTextBox(ref tr, "txtOrigMenuItem" + iItem);
                string OrigMenuItem = Utils.Parm.Str("hfOrigMenuItem" + iItem);

                string Proposal         = Parm.Str("hfProposal" + iItem);
                int    KitchenLocRno    = Parm.Int("hfLocRno" + iItem);
                bool   OneTime          = Parm.Bool("hfOneTime" + iItem);
                bool   IngredSelFlg     = Parm.Bool("hfIngredSelFlg" + iItem);
                bool   OrigIngredSelFlg = Parm.Bool("hfOrigIngredSelFlg" + iItem);
                string IngredSel        = Parm.Str("hfIngredSel" + iItem);
                string OrigIngredSel    = Parm.Str("hfOrigIngredSel" + iItem);



                ////String QtyNote = WebPage.FindTextBox(ref tr, "txtQtyNote" + iItem);
                ////String OrigQtyNote = WebPage.FindTextBox(ref tr, "txtOrigQtyNote" + iItem);

                //int Qty = Str.Num(WebPage.FindTextBox(ref tr, "txtQty" + iItem));
                int Qty = Utils.Parm.Int("txtQty" + iItem);
                //int OrigQty = Str.Num(WebPage.FindTextBox(ref tr, "txtOrigQty" + iItem));
                int OrigQty = Utils.Parm.Int("txtOrigQty" + iItem);

                //String ServiceNote = WebPage.FindTextBox(ref tr, "txtServiceNote" + iItem);
                string ServiceNote = Utils.Parm.Str("txtServiceNote" + iItem);
                //String OrigServiceNote = WebPage.FindTextBox(ref tr, "txtOrigServiceNote" + iItem);
                string OrigServiceNote = Utils.Parm.Str("txtOrigServiceNote" + iItem);

                if (Category != OrigCategory ||
                    MenuItem != OrigMenuItem ||
                    //QtyNote != OrigQtyNote ||
                    IngredSelFlg != OrigIngredSelFlg ||
                    IngredSel != OrigIngredSel ||
                    (Qty != OrigQty && (Category != "" || MenuItem != "" || ServiceNote != "")) ||
                    ServiceNote != OrigServiceNote)
                {
                    DateTime Tm  = DateTime.Now;
                    String   Sql = "";

                    try
                    {
                        //if (FoodSeq == 0)
                        if (JobFoodRno == 0)
                        {
                            FoodSeq = db.NextSeq("mcJobFood", "JobRno", JobRno, "FoodSeq");

                            Sql =
                                "Insert Into mcJobFood (JobRno, FoodSeq, ProposalSeq, CreatedDtTm, CreatedUser) Values (" +
                                JobRno + ", " +
                                FoodSeq + ", " +
                                FoodSeq + ", " +
                                DB.PutDtTm(Tm) + ", " +
                                DB.PutStr(g.User) + ") " +
                                "Select @@Identity";
                            JobFoodRno = db.SqlNum(Sql);
                        }

                        int MenuItemRno = FindOrAddMenuItem(Category, MenuItem, Proposal, KitchenLocRno, OneTime);

                        //Response.Write(string.Format("Category [{0}] OrigMenuItem [{1}] MenuItem [{2}] Proposal [{3}] ", Category, OrigMenuItem, MenuItem, Proposal));

                        string MenuItemProposal = GetMenuItemProposal(MenuItemRno);
                        if (Proposal.Length == 0)
                        {
                            Proposal = MenuItemProposal;
                            if (Proposal.Length == 0)
                            {
                                Proposal = MenuItem;
                            }
                        }

                        if (IngredSelFlg && IngredSel.Length > 0 && Proposal.CompareTo(MenuItemProposal) == 0)
                        {
                            Sql = string.Format(
                                "Select Coalesce(i.Name, r.Name) As Name " +
                                "From RecipeIngredXref x " +
                                "Left Join Ingredients i On i.IngredRno = x.IngredRno " +
                                "Left Join Recipes r On r.RecipeRno = x.SubrecipeRno " +
                                "Where x.RecipeIngredRno In ({0}) " +
                                "Order By Name",
                                IngredSel);
                            DataTable dtIngred = db.DataTable(Sql);
                            if (dtIngred.Rows.Count > 0)
                            {
                                Proposal += " - ";
                                foreach (DataRow drIngred in dtIngred.Rows)
                                {
                                    Proposal += DB.Str(drIngred["Name"]) + ", ";
                                }
                                Proposal = Proposal.Substring(0, Proposal.Length - 2);
                            }
                        }

                        //Response.Write(string.Format("Proposal [{0}]<br />", Proposal));

                        Sql =
                            "Update mcJobFood Set " +
                            "Category = " + DB.PutStr(Category, 50) + ", " +
                            "MenuItem = " + DB.PutStr(MenuItem, 50) + ", " +
                            "MenuItemRno = " + MenuItemRno + ", " +
                            //"QtyNote = " + DB.PutStr(QtyNote, 128) + ", " +
                            "Qty = " + Qty + ", " +
                            "ServiceNote = " + DB.PutStr(ServiceNote, 128) + ", " +
                            "ProposalMenuItem = " + DB.PutStr(Proposal, 100) + ", " +
                            "IngredSelFlg = " + DB.PutBool(IngredSelFlg) + ", " +
                            "IngredSel = " + DB.PutStr(IngredSel) + ", " +
                            "UpdatedDtTm = " + DB.PutDtTm(Tm) + ", " +
                            "UpdatedUser = "******" " +
                            //"Where JobRno = " + JobRno + " " +
                            //"And FoodSeq = " + FoodSeq;
                            "Where JobFoodRno = " + JobFoodRno;
                        db.Exec(Sql);
                    }
                    catch (Exception Ex)
                    {
                        Err Err = new Err(Ex, Sql);
                        Response.Write(Err.Html());
                    }
                }
            }
        }
    }
Esempio n. 11
0
    protected void btnSave_Click(object sender, System.EventArgs e)
    {
        DateTime Tm = DateTime.Now;

        fReport = true;
        dtBeg   = Str.DtTm(hfBegDate.Value);
        dtEnd   = Str.DtTm(hfEndDate.Value);

        string Sql = string.Format(
            "Delete From ShoppingListDetails Where ShoppingListRno in (Select ShoppingListRno From ShoppingLists Where BegDt = {0} And EndDt = {1});\n" +
            "Delete From ShoppingLists Where BegDt = {0} And EndDt = {1}",
            DB.PutDtTm(dtBeg),
            DB.PutDtTm(dtEnd));

        try
        {
            db.Exec(Sql);

            int Count = Parm.Int("hfParmCount");
            for (int i = 0; i < Count; i++)
            {
                Int32   IngredRno          = Parm.Int("hfIngredRno" + i);
                bool    fStocked           = Parm.Bool("hfStocked" + i);
                decimal StockedPurchaseQty = Parm.Dec("hfStockedQty" + i);
                decimal PurchaseQty        = Parm.Dec("hfQty" + i);
                decimal PurchaseUnitQty    = Parm.Dec("hfUnitQty" + i);
                Int32   PurchaseUnitRno    = Parm.Int("hfUnitRno" + i);
                Int32   VendorRno          = Parm.Int("hfVendorRno" + i);
                Int32   ShoppingListRno;

                Sql = string.Format(
                    "Select ShoppingListRno From ShoppingLists Where VendorRno = {0} And BegDt = {1} And EndDt = {2}",
                    VendorRno,
                    DB.PutDtTm(dtBeg),
                    DB.PutDtTm(dtEnd));
                ShoppingListRno = db.SqlNum(Sql);
                if (ShoppingListRno == 0)
                {
                    Sql = string.Format(
                        "Insert Into ShoppingLists (VendorRno, BegDt, EndDt, CreatedDtTm, CreatedUser, UpdatedDtTm, UpdatedUser) " +
                        "Values ({0}, {1}, {2}, {3}, {4}, {5}, {6});" +
                        "Select @@Identity",
                        VendorRno,
                        DB.PutDtTm(dtBeg),
                        DB.PutDtTm(dtEnd),
                        DB.PutDtTm(Tm),
                        DB.PutStr(g.User),
                        DB.PutDtTm(Tm),
                        DB.PutStr(g.User));
                    ShoppingListRno = db.SqlNum(Sql);
                }

                Sql = string.Format(
                    "Insert Into ShoppingListDetails (ShoppingListRno, IngredRno, PurchaseQty, PurchaseUnitQty, PurchaseUnitRno, CreatedDtTm, CreatedUser, UpdatedDtTm, UpdatedUser) " +
                    "Values ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8})",
                    ShoppingListRno,
                    IngredRno,
                    (fStocked ? StockedPurchaseQty : PurchaseQty),
                    PurchaseUnitQty,
                    PurchaseUnitRno,
                    DB.PutDtTm(Tm),
                    DB.PutStr(g.User),
                    DB.PutDtTm(Tm),
                    DB.PutStr(g.User));
                db.Exec(Sql);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Esempio n. 12
0
    private void SaveDetails(int Rno)
    {
        // force a refresh of last purchase prices
        Ingred.LoadIngredPurchases();

        for (int iDetail = 1; iDetail <= cDetails; iDetail++)
        {
            bool fRemove       = Parm.Bool("chkRemove" + iDetail);
            int  OrigIngredRno = Parm.Int("hfOrigIngredRno" + iDetail);
            int  IngredRno     = Parm.Int("hfIngredRno" + iDetail);

            if (!fRemove)
            {
                int     PurchaseDetailRno = Parm.Int("hfPurchaseDetailRno" + iDetail);
                bool    fNewRec           = (PurchaseDetailRno == 0);
                bool    fStockedFlg       = Parm.Bool("hfStocked" + iDetail);
                string  Ingredient        = Parm.Str("txtIngredient" + iDetail);
                decimal PurchaseQty       = Str.Fract(Parm.Str("txtPurchaseQty" + iDetail));
                decimal UnitQty           = Str.Fract(Parm.Str("txtUnitQty" + iDetail));
                int     UnitRno           = Parm.Int("hfUnitRno" + iDetail);
                decimal Price             = (Parm.Dec("txtPrice" + iDetail));

                DateTime Tm  = DateTime.Now;
                String   Sql = "";

                try
                {
                    // if a new ingredient, create it
                    if (Ingredient.Length > 0)
                    {
                        if (IngredRno == 0)
                        {
                            // first off, lets see if there is an ingredient with this name, just in case there already is one, probably hidden
                            Sql = string.Format("Select IngredRno, HideFlg From Ingredients Where Name = {0}", DB.PutStr(Ingredient));
                            DataRow dr = db.DataRow(Sql);
                            if (dr != null)
                            {
                                // the ingredient does indeed exist
                                IngredRno = DB.Int32(dr["IngredRno"]);
                                bool fHide = DB.Bool(dr["HideFlg"]);
                                if (fHide)
                                {
                                    // it is hidden, so now unhide it
                                    Sql = string.Format("Update Ingredients Set HideFlg = 0 Where IngredRno = {0}", IngredRno);
                                    db.Exec(Sql);
                                }
                            }
                            else
                            {
                                // the indgredient does indeed not exist, so create it
                                Sql = string.Format(
                                    "Insert Into Ingredients (Name, StockedFlg, CreatedDtTm, CreatedUser) " +
                                    "Values ({0}, {1}, GetDate(), {2});" +
                                    "Select Scope_Identity()",
                                    DB.PutStr(Ingredient),
                                    DB.PutBool(fStockedFlg),
                                    DB.PutStr(g.User));
                                IngredRno = db.SqlNum(Sql);
                            }
                        }

                        if (PurchaseDetailRno == 0)
                        {
                            Sql = string.Format(
                                "Insert Into PurchaseDetails (PurchaseRno, IngredRno, CreatedDtTm, CreatedUser) " +
                                "Values ({0}, {1}, GetDate(), {2});" +
                                "Select Scope_Identity()",
                                Rno,
                                IngredRno,
                                DB.PutStr(g.User));
                            PurchaseDetailRno = db.SqlNum(Sql);
                        }

                        Sql = string.Format(
                            "Update PurchaseDetails Set " +
                            "IngredRno = {1}, " +
                            "PurchaseQty = {2}, " +
                            "PurchaseUnitQty = {3}, " +
                            "PurchaseUnitRno = {4}, " +
                            "Price = {5}, " +
                            "UpdatedDtTm = GetDate(), " +
                            "UpdatedUser = {6} " +
                            "Where PurchaseDetailRno = {0}",
                            PurchaseDetailRno,
                            IngredRno,
                            PurchaseQty,
                            UnitQty,
                            UnitRno,
                            Price,
                            DB.PutStr(g.User));
                        db.Exec(Sql);

                        // update the ingredient prices
                        Ingred.UpdateWithLastPrice(IngredRno);
                    }
                }
                catch (Exception Ex)
                {
                    Err Err = new Err(Ex, Sql);
                    Response.Write(Err.Html());
                }
            }

            // if the deleted or changed, update the original ingredient prices
            if (fRemove || IngredRno != OrigIngredRno)
            {
                Ingred.UpdateWithLastPrice(OrigIngredRno);
            }
        }
    }
Esempio n. 13
0
    private void SaveUpdates()
    {
        string Sql = string.Empty;

        try
        {
            DB db = new DB();

            int cCats = Str.Num(hfNumCats.Value);
            for (int i = 0; i < cCats; i++)
            {
                string Category    = Parm.Str(string.Format("hfCategory{0}", i));
                string NewCategory = Parm.Str(string.Format("txtCategory{0}", i));

                if (Category.Length > 0 || Category.Length == 0 && NewCategory.Length == 0)
                {
                    //Sql = string.Format("Update mcJobMenuCategories Set SortOrder = {1}, MultSelFlg = {2}, HideFlg = {3}, UpdatedDtTm = GetDate(), UpdatedUser = {4} Where Category = {0}",
                    //	DB.PutStr(Category),
                    //	Parm.Int(string.Format("hfSortOrder{0}", i)),
                    //	(Parm.Bool(string.Format("chkMultSel{0}", i)) ? 1 : 0),
                    //	(Parm.Bool(string.Format("chkHide{0}", i)) ? 1 : 0),
                    //	DB.PutStr(g.User));
                    Sql = string.Format("Update mcJobMenuCategories Set SortOrder = {1}, UpdatedDtTm = GetDate(), UpdatedUser = {2} Where Category = {0}",
                                        DB.PutStr(Category),
                                        Parm.Int(string.Format("hfSortOrder{0}", i)),
                                        DB.PutStr(g.User));
                    db.Exec(Sql);

                    // has the category text itself changed?
                    if (NewCategory != Category && NewCategory.Length > 0)
                    {
                        // has changed, update category values
                        Sql = string.Format(
                            "Update mcJobMenuCategories Set Category = {1} Where Category = {0}; " +
                            "Update mcJobMenuItems Set Category = {1}, UpdatedDtTm = GetDate(), UpdatedUser = {2} Where Category = {0}; ",
                            DB.PutStr(Category),
                            DB.PutStr(NewCategory),
                            DB.PutStr(g.User));
                        db.Exec(Sql);
                    }
                }
                else
                {
                    //if (NewCategory.Length > 0)
                    {
                        Sql = string.Format("Insert Into mcJobMenuCategories (Category, SortOrder, MultSelFlg, HideFlg, CreatedDtTm, CreatedUser) Values ({0}, {1}, {2}, {3}, GetDate(), {4})",
                                            DB.PutStr(NewCategory),
                                            Parm.Int(string.Format("hfSortOrder{0}", i)),
                                            (Parm.Bool(string.Format("chkMultSel{0}", i)) ? 1 : 0),
                                            (Parm.Bool(string.Format("chkHide{0}", i)) ? 1 : 0),
                                            DB.PutStr(g.User));
                        db.Exec(Sql);
                    }
                }
            }
            db.Close();
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }