Beispiel #1
0
    protected async void btnProcess_Click(object sender, EventArgs e)
    {
        await StartSling();

        int NumJobsIDs = Str.Num(hfNumJobsIDs.Value);

        for (int i = 1; i <= NumJobsIDs; i++)
        {
            Int32 JobRno = Parm.Int("JobId_" + i.ToString());
            if (JobRno > 0)
            {
                // add the shift
                await AddShift(JobRno);
            }
        }

        int NumSlingIDs = Str.Num(hfNumSlingIDs.Value);

        for (int i = 1; i <= NumSlingIDs; i++)
        {
            string SlingId = Parm.Str("SlingId_" + i.ToString());
            if (SlingId != string.Empty)
            {
                // delete the shift
                await Sling.DeleteShift(Str.Num(SlingId));
            }
        }

        await LoadData();
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Int32  CustomerRno = Parm.Int("Customer");
        string ExportId    = Parm.Str("ExportId");

        if (CustomerRno == 0) // || ExportId.Length == 0)
        {
            Response.Clear();
            Response.ContentType = "text/plain";
            if (CustomerRno == 0)
            {
                Response.Write("Missing customer number: ExportedCustomer.asx?Customer=nnn\n");
            }
            //if (ExportId.Length == 0)
            //{
            //    Response.Write("Missing export ID: ExportedCustomer.asx?ExportId=xxx\n");
            //}
            Response.End();
        }
        else
        {
            string Sql = string.Format("Select Count(*) From mcJobs Where JobRno = {0}", CustomerRno);
            try
            {
                using (DB db = new DB())
                {
                    int Count = db.SqlNum(Sql);
                    if (Count > 0)
                    {
                        //Sql = string.Format("Update mcJobs Set CustomerExportId = '{1}', CustomerExportDtTm = GetDate() Where JobRno = {0}", CustomerRno, ExportId);
                        Sql = string.Format("Update mcJobs Set CustomerExportId = '{1}' Where JobRno = {0}", CustomerRno, ExportId);
                        db.Exec(Sql);

                        Response.Clear();
                        Response.ContentType = "text/plain";
                        Response.Write("OK");
                        Response.Flush();
                    }
                    else
                    {
                        Response.Clear();
                        Response.ContentType = "text/plain";
                        Response.Write("Customer not found");
                        Response.Flush();
                    }
                }
            }
            catch (Exception Ex)
            {
                Err Err = new Err(Ex, Sql);
                Response.Clear();
                Response.ContentType = "text/plain";
                Response.Write(Ex.ToString());
                Response.End();
            }
            Response.End();
        }
    }
Beispiel #3
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());
                }
            }
        }
    }
Beispiel #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 "SetNonPurchase":
             SetNonPurchase(Parm.Int("Rno"), Parm.Bool("NonPurchase"));
             break;
         }
     }
 }
Beispiel #5
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 sColor       = Parm.Str("txtColor" + iRow);
            string sOrdered     = Parm.Str("txtOrdered" + iRow);
            string sOther       = Parm.Str("txtOther" + iRow);

            string Sql = string.Format(fNew ?
                                       "Insert Into JobLinens (JobRno, Seq, Description, Caterer, Color, Ordered, Other, CreatedDtTm, CreatedUser) Values ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8})" :
                                       "Update JobLinens Set Caterer = {3}, Color = {4}, Ordered = {5}, Other = {6}, UpdatedDtTm = {7}, UpdatedUser = {8} Where JobRno = {0} and Seq = {1}",
                                       JobRno,
                                       Seq,
                                       DB.Put(sDescription, 20),
                                       DB.Put(sCaterer, 60),
                                       DB.Put(sColor, 20),
                                       DB.Put(sOrdered, 20),
                                       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());
            }
        }
    }
Beispiel #6
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;
            }
        }
    }
Beispiel #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();
    }
Beispiel #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());
        }
    }
Beispiel #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());
        }
    }
Beispiel #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());
                    }
                }
            }
        }
    }
Beispiel #11
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);
            }
        }
    }
Beispiel #12
0
    protected void SaveValues()
    {
        string Sql = string.Format("Select PropCreatedDtTm From mcJobs Where JobRno = {0}", JobRno);

        try
        {
            DateTime dtCreated = db.SqlDtTm(Sql);

            Sql = string.Format(
                "Update mcJobs Set " +
                "ServicePropDesc = {1}, " +
                "DeliveryPropDesc = {2}, " +
                "ChinaPropDesc = {3}, " +
                "AddServicePropDesc = {4}, " +
                "FuelTravelPropDesc = {5}, " +
                "FacilityPropDesc = {6}, " +
                "RentalsPropDesc = {7}, " +
                "Adj1PropDesc = {8}, " +
                "Adj2PropDesc = {9}, " +
                "ServicePropDescCustFlg = {10}, " +
                "DeliveryPropDescCustFlg = {11}, " +
                "ChinaPropDescCustFlg = {12}, " +
                "AddServicePropDescCustFlg = {13}, " +
                "FuelTravelPropDescCustFlg = {14}, " +
                "FacilityPropDescCustFlg = {15}, " +
                "RentalsPropDescCustFlg = {16}, " +
                "ServicePropOptions = '{17}', " +
                "DeliveryPropOptions = '{18}', " +
                "ChinaPropOptions = '{19}', " +
                "AddServicePropOptions = '{20}', " +
                "FuelTravelPropOptions = '{21}', " +
                "FacilityPropOptions = '{22}', " +
                "RentalsPropOptions = '{23}', " +
                "EstTotPropDesc = {24}, " +
                "EstTotPropDescCustFlg = {25}, " +
                "DepositPropDesc = {26}, " +
                "DepositPropDescCustFlg = {27}, " +
                "Prop{28}DtTm = '{29}', " +
                "Prop{28}User = '******' " +
                "Where JobRno = {0}",
                JobRno,
                DB.PutStr(txtServiceDesc.Text, 1000),
                DB.PutStr(txtDeliveryDesc.Text, 1000),
                DB.PutStr(txtChinaDesc.Text, 1000),
                DB.PutStr(txtAddServiceDesc.Text, 1000),
                DB.PutStr(txtFuelTravelDesc.Text, 1000),
                DB.PutStr(txtFacilityDesc.Text, 1000),
                DB.PutStr(txtRentalsDesc.Text, 1000),
                DB.PutStr(txtAdj1Desc.Text, 1000),
                DB.PutStr(txtAdj2Desc.Text, 1000),
                hfServiceCustomized.Value,
                hfDeliveryCustomized.Value,
                hfChinaCustomized.Value,
                hfAddServiceCustomized.Value,
                hfFuelTravelCustomized.Value,
                hfFacilityCustomized.Value,
                hfRentalsCustomized.Value,
                ResponseOptions(Service),
                ResponseOptions(Delivery),
                ResponseOptions(China),
                ResponseOptions(AddService),
                ResponseOptions(FuelTravel),
                ResponseOptions(Facility),
                ResponseOptions(Rentals),
                DB.PutStr(txtTotalDesc.Text, 1000),
                hfTotalCustomized.Value,
                DB.PutStr(txtDepositDesc.Text, 1000),
                hfDepositCustomized.Value,
                (dtCreated == DateTime.MinValue ? "Created" : "Updated"),
                DateTime.Now,
                g.User);

            // job info
            db.Exec(Sql);

            // prices
            Sql = string.Format("Select * From JobInvoicePrices Where JobRno = {0} Order By Seq", JobRno);
            DataTable dtPrices = db.DataTable(Sql);
            foreach (DataRow drPrice in dtPrices.Rows)
            {
                int    Rno       = DB.Int32(drPrice["Rno"]);
                string PriceType = DB.Str(drPrice["PriceType"]);

                switch (PriceType)
                {
                case Misc.cnPerPerson:
                    Sql = string.Format(
                        "Update JobInvoicePrices Set PropPerPersonDesc = {1}, PropPerPersonDescCustFlg = {2}, PropPerPersonOptions = {3} Where Rno = {0}",
                        Rno,
                        DB.Put(Parm.Str(string.Format("txtPrice_{0}", Rno))),
                        DB.Put(Parm.Str(string.Format("hfPriceCustomized_{0}", Rno))),
                        DB.Put(ResponseOptions(PerPerson)));
                    db.Exec(Sql);
                    break;

                case Misc.cnPerItem:
                    Sql = string.Format(
                        "Update JobInvoicePrices Set PropPerItemDesc = {1}, PropPerItemDescCustFlg = {2} Where Rno = {0}",
                        Rno,
                        DB.Put(Parm.Str(string.Format("txtPrice_{0}", Rno))),
                        Parm.Str(string.Format("hfPriceCustomized_{0}", Rno)));
                    db.Exec(Sql);
                    break;

                case Misc.cnAllIncl:
                    Sql = string.Format(
                        "Update JobInvoicePrices Set PropAllInclDesc = {1}, PropAllInclDescCustFlg = {2} Where Rno = {0}",
                        Rno,
                        DB.Put(Parm.Str(string.Format("txtPrice_{0}", Rno))),
                        Parm.Str(string.Format("hfPriceCustomized_{0}", Rno)));
                    db.Exec(Sql);
                    break;
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
    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());
        }
    }