Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        g.User = (string)Session["User"];
        if (g.User != null && g.User != "")
        {
            Int32    PaymentRno = Parm.Int("PaymentRno");
            DateTime Tm         = DateTime.Now;

            string Sql =
                "Update Payments Set " +
                "CCPrintDtTm = " + DB.PutDtTm(Tm) + ", " +
                "CCPrintUser = "******", " +
                "UpdatedDtTm = " + DB.PutDtTm(Tm) + ", " +
                "UpdatedUser = "******" " +
                "Where PaymentRno = " + PaymentRno;

            try
            {
                DB.DBExec(Sql);
            }
            catch (Exception)
            {
            }
        }
    }
Пример #2
0
    protected void btnSave_Click(object sender, System.EventArgs e)
    {
        int Count = Parm.Int("hfParmCount");

        for (int i = 1; i <= Count; i++)
        {
            int     IngredRno = Parm.Int("hfIngredRno" + i);
            decimal Qty       = Parm.Dec("txtQty" + i);

            if (IngredRno != 0)
            {
                string Sql = string.Format(
                    "Update Ingredients Set StockedPurchaseQty = {1} Where IngredRno = {0}",
                    IngredRno,
                    Qty);
                try
                {
                    db.Exec(Sql);
                }
                catch (Exception Ex)
                {
                    Err Err = new Err(Ex, Sql);
                    Response.Write(Err.Html());
                }
            }
        }

        fReport = true;

        dtBeg = Str.DtTm(hfBegDate.Value);
        dtEnd = Str.DtTm(hfEndDate.Value);
    }
Пример #3
0
    private 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.Shopping.Title;

            // if an ingred rno passed in then well setup for a new receipt for the ingredient on today with No Vendor
            NewIngredRno = Parm.Int("IngredRno");
            if (NewIngredRno != 0)
            {
                IngredReceipt(NewIngredRno);
                LoadList();
                hfTab.Value = "1";
            }
            else
            {
                Setup();
            }
        }
    }
Пример #4
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();
    }
Пример #5
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();
        }
    }
Пример #6
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);
    }
Пример #7
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());
                }
            }
        }
    }
Пример #8
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;
         }
     }
 }
Пример #9
0
    private 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.Recipes.Title;
        }

        RecipeRno = Parm.Int("Rno");

        Scale();
    }
Пример #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int MenuItemRno = Parm.Int("Rno");

        if (MenuItemRno > 0)
        {
            string Sql = string.Empty;
            try
            {
                Sql = string.Format("Update mcJobMenuItems Set HideFlg = 1 Where MenuItemRno = {0}", MenuItemRno);
                DB db = new DB();

                db.Exec(Sql);
                db.Close();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
    }
Пример #11
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());
            }
        }
    }
Пример #12
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;
            }
        }
    }
Пример #13
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());
             }
         }
     }
 }
Пример #14
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());
        }
    }
Пример #15
0
    private void Page_Load(object sender, System.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)
        {
            ClearData();
            Setup();

            // handle a particular menu item being edited
            int MenuItemRno = Parm.Int("Rno");
            if (MenuItemRno != 0)
            {
                GetData(MenuItemRno);
            }
        }
    }
Пример #16
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());
             }
         }
     }
 }
Пример #17
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());
        }
    }
Пример #18
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);
            }
        }
    }
Пример #19
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());
        }
    }
Пример #20
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());
        }
    }
Пример #21
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());
        }
    }
Пример #22
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());
                    }
                }
            }
        }
    }
Пример #23
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());
        }
    }
Пример #24
0
    protected int SaveData()
    {
        int ShoppingListRno = Str.Num(hfShoppingListRno.Value);
        int Rno             = Str.Num(hfRno.Value);

        cDetails = Str.Num(hfNumDetails.Value);
        string Sql = string.Empty;

        try
        {
            int VendorRno = Parm.Int("hfVendorRno");
            if (Rno == 0)
            {
                Sql = string.Format(
                    "Insert Into Purchases (VendorRno, CreatedDtTm, CreatedUser) Values ({0}, GetDate(), {1}); " +
                    "Select Scope_Identity()",
                    VendorRno,
                    DB.PutStr(g.User));
                Rno = db.SqlNum(Sql);
            }

            Sql = string.Format(
                "Update Purchases Set " +
                "VendorRno = {1}, " +
                "PurchaseDt = {2}, " +
                "PurchaseOrdNum = {3}, " +
                "VendorInvNum = {4}, " +
                "UpdatedDtTm = GetDate(), " +
                "UpdatedUser = {5} " +
                "Where PurchaseRno = {0}",
                Rno,
                VendorRno,
                DB.PutDtTm(Parm.DtTm("txtPurchaseDate")),
                DB.PutStr(txtOrderNum.Text, 20),
                DB.PutStr(txtVendorInvoice.Text, 20),
                DB.PutStr(g.User));
            db.Exec(Sql);

            StartHere = Rno;

            RemoveDetails();
            SaveDetails(Rno);

            // cleanup shopping list
            if (ShoppingListRno != 0)
            {
                Sql = string.Format(
                    "Delete From ShoppingListDetails Where ShoppingListRno = {0};\n" +
                    "Delete From ShoppingLists Where ShoppingListRno = {0};",
                    ShoppingListRno);
                db.Exec(Sql);
                LoadShoppingList();
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex);
            Response.Write(Err.Html());
        }

        return(Rno);
    }