Esempio n. 1
0
    private void Setup()
    {
        DateTime Today = DateTime.Today;

        txtDayDate.Text          = Fmt.Dt(Today);
        txtWeekDate.Text         = txtDayDate.Text;
        txtMonthDate.Text        = Fmt.Dt(Today.AddDays(1 - Today.Day).AddMonths(1));
        txtBegDateRange.Text     =
            txtEndDateRange.Text = txtDayDate.Text;

        CustomerJobs();

        txtDayDate.Attributes.Add("onChange", "iSetChk('rdoDay', true);");
        txtWeekDate.Attributes.Add("onChange", "iSetChk('rdoWeek', true);");
        txtMonthDate.Attributes.Add("onChange", "iSetChk('rdoMonth', true);");
        txtBegDateRange.Attributes.Add("onChange", "iSetChk('rdoRange', true);");
        txtEndDateRange.Attributes.Add("onChange", "iSetChk('rdoRange', true);");
        ddlCustomerDate.Attributes.Add("onChange", "iSetChk('rdoCustomerDate', true);");
        lbJobs.Attributes.Add("onChange", "iSetChk('rdoCustomerDate', true);");

        chkSummaryOnly.Attributes.Add("onClick", "OptionSet(this.checked, 'tdSummaryOnly');");

        chkIncludeAll.Attributes.Add("onClick", "SameWindow();");
        btnReport.Attributes.Add("onClick", "NewWindow();");
    }
Esempio n. 2
0
    protected void GetShoppingData(int Rno)
    {
        string Sql = string.Format(
            "Select * " +
            "From ShoppingLists s Inner Join Vendors v On s.VendorRno = v.VendorRno " +
            "Where ShoppingListRno = {0}",
            Rno);

        ClearData();

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                hfShoppingListRno.Value = Rno.ToString();
                txtPurchaseDate.Text    = Fmt.Dt(DateTime.Today);
                hfVendorRno.Value       = DB.Int32(dr["VendorRno"]).ToString();
                txtVendor.Text          = DB.Str(dr["Name"]);

                btnDelete.Enabled = false;

                FocusField = "txtPurchaseDate";

                LoadShoppingDetails(Rno);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Esempio n. 3
0
    protected void btnReport_Click(object sender, System.EventArgs e)
    {
        if (rdoWeek.Checked)
        {
            dtBeg     = Convert.ToDateTime(txtWeekDate.Text);
            dtEnd     = EndDate(dtBeg.AddDays(6));
            CalPeriod = CalSched.ViewPeriod.Week;
            sPeriod   = "Week Beginning " + Fmt.Dt(dtBeg);
        }
        if (rdoMonth.Checked)
        {
            dtBeg     = Convert.ToDateTime(txtMonthDate.Text);
            dtBeg     = dtBeg.AddDays(1 - dtBeg.Day);
            dtEnd     = EndDate(dtBeg.AddMonths(1).AddDays(-1));
            CalPeriod = CalSched.ViewPeriod.Month;
            sPeriod   = "Month of " + dtBeg.ToString("MMMM yyyy");
        }
        if (rdoRange.Checked)
        {
            dtBeg     = Convert.ToDateTime(txtBegDateRange.Text);
            dtEnd     = Convert.ToDateTime(txtEndDateRange.Text);
            CalPeriod = ((dtEnd.Ticks - dtBeg.Ticks) / TimeSpan.TicksPerDay < 7 ? CalSched.ViewPeriod.Week : CalSched.ViewPeriod.Month);
            dtEnd     = EndDate(dtEnd);
            sPeriod   = "Date Range " + Fmt.Dt(dtBeg) + " - " + Fmt.Dt(dtEnd);
        }

        fReport = true;
    }
Esempio n. 4
0
    private void PriceHistory(int IngredRno)
    {
        string Sql = string.Format(
            "Select Top 15 p.PurchaseRno, d.PurchaseDetailRno, p.PurchaseDt, v.Name, d.PurchaseQty, d.PurchaseUnitQty, u.UnitSingle, u.UnitPlural, Price\n " +
            "From PurchaseDetails d\n " +
            "Inner Join Purchases p On p.PurchaseRno = d.PurchaseRno\n " +
            "Inner Join Vendors v On v.VendorRno = p.VendorRno\n " +
            "Inner Join Units u On u.UnitRno = d.PurchaseUnitRno\n " +
            "Where IngredRno = {0}\n " +
            "Order By PurchaseDt Desc",
            IngredRno);

        try
        {
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                decimal  PurchaseQty     = DB.Dec(dr["PurchaseQty"]);
                decimal  PurchaseUnitQty = DB.Dec(dr["PurchaseUnitQty"]);
                decimal  Price           = DB.Dec(dr["Price"]);
                TableRow tr = new TableRow();
                tr.Cells.Add(new TableCell());
                tr.Cells.Add(new TableCell()
                {
                    Text = Fmt.Dt(DB.DtTm(dr["PurchaseDt"]))
                });
                tr.Cells.Add(new TableCell()
                {
                    Text = DB.Str(dr["Name"])
                });
                tr.Cells.Add(new TableCell()
                {
                    Text = Str.ShowFract(PurchaseQty), CssClass = "Qty"
                });
                tr.Cells.Add(new TableCell()
                {
                    Text = string.Format("{0} {1}", Str.ShowFract(PurchaseUnitQty), DB.Str(dr[PurchaseUnitQty <= 1 ? "UnitSingle" : "UnitPlural"]))
                });
                tr.Cells.Add(new TableCell()
                {
                    Text = Fmt.Dollar(Price), CssClass = "Price"
                });
                tr.Cells.Add(new TableCell()
                {
                    Text = Fmt.Dollar(Math.Round((PurchaseQty != 0 ? Price / PurchaseQty : 0), 2)), CssClass = "Price"
                });
                tblPrices.Rows.Add(tr);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Esempio n. 5
0
    private void JobInfo()
    {
        string Sql =
            "Select j.NumMenServing, j.NumWomenServing, j.NumChildServing, j.Status, j.EventType, j.ServiceType, j.Location, " +
            "j.PrintDirectionsFlg, j.LocationDirections, j.JobDate, j.MealTime, j.ArrivalTime, j.DepartureTime, j.PricePerPerson, " +
            "j.JobNotes, j." +
            "cu.Name as Customer, c.Name, c.Phone, c.Cell, c.Fax, c.Email, " +
            "From mcJobs j " +
            "Left Join Contacts c on j.ContactRno = c.ContactRno " +
            "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
            "Where JobRno = " + JobRno;

        try
        {
            DataTable dt = db.DataTable(Sql);
            DataRow   r  = dt.Rows[0];

            Int32 cMen   = DB.Int32(r["NumMenServing"]);
            Int32 cWomen = DB.Int32(r["NumWomenServing"]);
            Int32 cChild = DB.Int32(r["NumChildServing"]);

            lblPrinted.Text   = String.Format("{0}", DateTime.Now);
            lblJobRno.Text    = JobRno.ToString();
            lblStatus.Text    = DB.Str(r["Status"]);
            lblCustomer.Text  = DB.Str(r["Customer"]);
            lblName.Text      = DB.Str(r["Name"]);
            lblPhone.Text     = DB.Str(r["Phone"]);
            lblCell.Text      = DB.Str(r["Cell"]);
            lblFax.Text       = DB.Str(r["Fax"]);
            lblEmail.Text     = DB.Str(r["Email"]);
            lblEventType.Text = DB.Str(r["EventType"]);
            lblServType.Text  = DB.Str(r["ServiceType"]);
            lblLocation.Text  = DB.Str(r["Location"]);
            if (DB.Bool(r["PrintDirectionsFlg"]))
            {
                lblDirections.Text = DB.Str(r["LocationDirections"]).Replace("\n", "<br>");
            }
            lblJobDate.Text         = Fmt.Dt(DB.DtTm(r["JobDate"]));
            lblMealTime.Text        = Fmt.Tm12Hr(DB.DtTm(r["MealTime"]));
            lblArrivalTime.Text     = Fmt.Tm12Hr(DB.DtTm(r["ArrivalTime"]));
            lblDepartureTime.Text   = Fmt.Tm12Hr(DB.DtTm(r["DepartureTime"]));
            lblNumServing.Text      = Fmt.Num(cMen + cWomen + cChild);
            lblNumMenServing.Text   = Fmt.Num(cMen);
            lblNumWomenServing.Text = Fmt.Num(cWomen);
            lblNumChildServing.Text = Fmt.Num(cChild);
            lblPricePerPerson.Text  = Fmt.Dollar(DB.Dec(r["PricePerPerson"]), false);
            lblJobNotes.Text        = DB.Str(r["JobNotes"]);
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Esempio n. 6
0
    public void JobSubPage(string PageName)
    {
        Int32  JobRno      = Str.Num((String)Session["JobRno"]);
        string Sql         = "";
        string Customer    = "";
        string JobDate     = "";
        string EventType   = "";
        string ServiceType = "";
        string NumServings = "";

        try
        {
            Sql =
                "Select Coalesce(cu.Name, c.Name) as Customer, JobDate, EventType, ServiceType, " +
                "IsNull(NumMenServing, 0) + IsNull(NumWomenServing, 0) + IsNull(NumChildServing, 0) As NumServings " +
                "From mcJobs j " +
                "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
                "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
                "Where JobRno = " + JobRno;
            DB        db = new DB();
            DataTable dt = db.DataTable(Sql);
            if (dt.Rows.Count > 0)
            {
                DataRow r = dt.Rows[0];
                Customer         = DB.Str(r["Customer"]);
                JobDate          = Fmt.Dt(DB.DtTm(r["JobDate"]));
                EventType        = DB.Str(r["EventType"]);
                ServiceType      = DB.Str(r["ServiceType"]);
                this.NumServings = DB.Int32(r["NumServings"]);
                NumServings      = Fmt.Num(this.NumServings);
            }
            db.Close();
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        string Html =
            "<table cellspacing=\"0\" cellpadding=\"0\" align=\"center\" border=\"0\" width=\"100%\" class=\"JobInfo\">\n" +
            "	<tr>\n"+
            "		<td colspan=\"2\" align=\"center\"><span class=\"FeatureMain\">"+ PageName + "</span></td>\n" +
            "	</tr>\n"+
            "	<tr>\n"+
            "		<td>"+ JobDate + "&nbsp;&nbsp;" + Customer + "&nbsp;&nbsp;&nbsp;<span class=\"JobInfoTitle\">Job #</span>" + JobRno + "</td>\n" +
            "		<td align=\"right\">"+ "<span class=\"JobInfoTitle\">Event:</span> " + EventType + "&nbsp;&nbsp;&nbsp;<span class=\"JobInfoTitle\">Service:</span> " + ServiceType + "&nbsp;&nbsp;&nbsp;<span class=\"JobInfoTitle\">Servings:</span> " + NumServings + "</td>\n" +
            "	</tr>\n"+
            "	<tr><td><img height=\"10\" src=\""+ Images + "/Space.gif\" width=\"1\" alt=\"\" /></td></tr>\n" +
            "</table>\n";

        Response.Write(Html);
    }
Esempio n. 7
0
    private void Setup()
    {
        DateTime Tomorrow = DateTime.Today.AddDays(1);

        txtWeekDate.Text         = Fmt.Dt(Tomorrow);
        txtMonthDate.Text        = Fmt.Dt(Tomorrow.AddDays(1 - Tomorrow.Day).AddMonths(1));
        txtBegDateRange.Text     =
            txtEndDateRange.Text = txtWeekDate.Text;

        txtWeekDate.Attributes.Add("onChange", "iSetChk('rdoWeek', true);");
        txtMonthDate.Attributes.Add("onChange", "iSetChk('rdoMonth', true);");
        txtBegDateRange.Attributes.Add("onChange", "iSetChk('rdoRange', true);");
        txtEndDateRange.Attributes.Add("onChange", "iSetChk('rdoRange', true);");
    }
Esempio n. 8
0
    protected void ClearData()
    {
        hfShoppingListRno.Value                                 =
            hfRno.Value                                         =
                txtPurchaseDate.Text                            =
                    txtVendor.Text                              =
                        txtOrderNum.Text                        =
                            txtVendorInvoice.Text               =
                                txtCreatedDt.Text               =
                                    txtCreatedUser.Text         =
                                        txtUpdatedDt.Text       =
                                            txtUpdatedUser.Text = string.Empty;

        btnDelete.Enabled = false;
        btnDelete.ToolTip = "New purchase record";

        txtPurchaseDate.Text = Fmt.Dt(DateTime.Today);
    }
Esempio n. 9
0
    private void Setup()
    {
        DateTime Today = DateTime.Today;

        txtDayDate.Text          = Fmt.Dt(Today);
        txtWeekDate.Text         = Fmt.Dt(Today.AddDays(-7));
        txtMonthDate.Text        = Fmt.Dt(Today.AddDays(1 - Today.Day));
        txtBegDateRange.Text     =
            txtEndDateRange.Text = txtDayDate.Text;

        txtDayDate.Attributes.Add("onChange", "iSetChk('rdoDay', true);");
        txtWeekDate.Attributes.Add("onChange", "iSetChk('rdoWeek', true);");
        txtMonthDate.Attributes.Add("onChange", "iSetChk('rdoMonth', true);");
        txtBegDateRange.Attributes.Add("onChange", "iSetChk('rdoRange', true);");
        txtEndDateRange.Attributes.Add("onChange", "iSetChk('rdoRange', true);");

        btnReport.Attributes.Add("onClick", "NewWindow();");
    }
Esempio n. 10
0
    private void Setup()
    {
        if (Request.QueryString["JobRno"] != null)
        {
            JobRno = Str.Num(Request.QueryString["JobRno"]);
        }

        DateTime Today    = DateTime.Today;
        DateTime FirstDay = Today.AddDays((Today.DayOfWeek < DayOfWeek.Saturday ? 0 : 7) - (int)Today.DayOfWeek);

        rdoRange.Checked = true;

        txtDayDate.Text      = Fmt.Dt(Today);
        txtBegDateRange.Text = Fmt.Dt(FirstDay);
        txtEndDateRange.Text = Fmt.Dt(FirstDay.AddDays(6));

        txtDayDate.Attributes.Add("onChange", "iSetChk('rdoDay', true);");
        txtBegDateRange.Attributes.Add("onChange", "iSetChk('rdoRange', true);");
        txtEndDateRange.Attributes.Add("onChange", "iSetChk('rdoRange', true);");
    }
Esempio n. 11
0
    private void CustomerJobs()
    {
        string Sql =
            "Select j.JobRno, Coalesce(cu.Name, c.Name) as Customer, j.JobDate " +
            "From mcJobs j " +
            "Inner Join Contacts c On j.ContactRno = c.ContactRno " +
            "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
            "Where j.CancelledDtTm Is Null And j.ProposalFlg <> 1 ";

        if (!chkIncludeAll.Checked)
        {
            Sql += "And j.JobDate >= " + DB.PutDtTm(DateTime.Today);             // + " And j.PrintedDtTm Is Null ";
        }
        Sql += "Order By Customer, j.JobDate";

        try
        {
            DataTable dt = db.DataTable(Sql);
            ddlCustomerDate.Items.Clear();
            lbJobs.Items.Clear();
            foreach (DataRow dr in dt.Rows)
            {
                //ddlCustomerDate.Items.Add(new ListItem(DB.Str(dr["Customer"]) + " - " + Fmt.Dt(DB.DtTm(dr["JobDate"])), DB.Str(dr["JobRno"])));
                ddlCustomerDate.Items.Add(new ListItem(Fmt.Dt(DB.DtTm(dr["JobDate"])) + " - " + DB.Str(dr["Customer"]), DB.Str(dr["JobRno"])));
                ListItem li = new ListItem(Fmt.Dt(DB.DtTm(dr["JobDate"])) + " - " + DB.Str(dr["JobRno"]) + " " + DB.Str(dr["Customer"]), DB.Str(dr["JobRno"]));
                li.Attributes.Add("Date", Fmt.Dt(DB.DtTm(dr["JobDate"])));
                li.Attributes.Add("Job", DB.Str(dr["JobRno"]));
                li.Attributes.Add("Customer", DB.Str(dr["Customer"]));
                lbJobs.Items.Add(li);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        lbJobs.Rows = Math.Min(10, Math.Max(1, lbJobs.Items.Count));
    }
Esempio n. 12
0
    protected void GetData(int Rno)
    {
        string Sql = string.Format(
            "Select * " +
            "From Purchases p Inner Join Vendors v On p.VendorRno = v.VendorRno " +
            "Where PurchaseRno = {0}",
            Rno);

        ClearData();

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                hfRno.Value           = Rno.ToString();
                txtPurchaseDate.Text  = Fmt.Dt(DB.DtTm(dr["PurchaseDt"]));
                hfVendorRno.Value     = DB.Int32(dr["VendorRno"]).ToString();
                txtVendor.Text        = DB.Str(dr["Name"]);
                txtOrderNum.Text      = DB.Str(dr["PurchaseOrdNum"]);
                txtVendorInvoice.Text = DB.Str(dr["VendorInvNum"]);
                txtCreatedDt.Text     = Fmt.DtTm(DB.DtTm(dr["CreatedDtTm"]));
                txtCreatedUser.Text   = DB.Str(dr["CreatedUser"]);
                txtUpdatedDt.Text     = Fmt.DtTm(DB.DtTm(dr["UpdatedDtTm"]));
                txtUpdatedUser.Text   = DB.Str(dr["UpdatedUser"]);

                btnDelete.Enabled = true;

                FocusField = "txtPurchaseDate";

                LoadDetails(Rno);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Esempio n. 13
0
    private void Setup()
    {
        FocusField = "ddlCrewMember";

        String Sql =
            "Select Distinct CrewMember From mcJobCrew " +
            "Where CrewMember Is Not Null Order By CrewMember";

        try
        {
            DataTable dt = db.DataTable(Sql);
            ddlCrewMember.Items.Clear();
            foreach (DataRow dr in dt.Rows)
            {
                string CrewMember = DB.Str(dr["CrewMember"]);
                ddlCrewMember.Items.Add(new ListItem(CrewMember, CrewMember));
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        DateTime Tomorrow = DateTime.Today.AddDays(1);

        txtWeekDate.Text         = Fmt.Dt(Tomorrow);
        txtMonthDate.Text        = Fmt.Dt(Tomorrow.AddDays(1 - Tomorrow.Day).AddMonths(1));
        txtBegDateRange.Text     =
            txtEndDateRange.Text = txtWeekDate.Text;

        ddlCrewMember.Attributes.Add("onChange", "iSetChk('chkCrewMember', true);");
        txtWeekDate.Attributes.Add("onChange", "iSetChk('rdoWeek', true);");
        txtMonthDate.Attributes.Add("onChange", "iSetChk('rdoMonth', true);");
        txtBegDateRange.Attributes.Add("onChange", "iSetChk('rdoRange', true);");
        txtEndDateRange.Attributes.Add("onChange", "iSetChk('rdoRange', true);");
        btnReport.Attributes.Add("OnClick", "return Print();");
    }
Esempio n. 14
0
 private void LoadListSql(string Sql, string NextCurrItem)
 {
     //Response.Write("NextCurr [" + NextCurrItem + "]<br/>");
     try
     {
         DataTable dt = db.DataTable(Sql);
         //Response.Write(string.Format("Num Rows {0}<br/>", dt.Rows.Count));
         foreach (DataRow dr in dt.Rows)
         {
             Int32    Rno        = DB.Int32(dr["PurchaseRno"]);
             DateTime dtPurchase = DB.DtTm(dr["PurchaseDt"]);
             String   Vendor     = DB.Str(dr["Vendor"]);
             ListItem Item       = new ListItem(string.Format("{0} - {1}", Fmt.Dt(dtPurchase), Vendor), Rno.ToString());
             Item.Selected = (Item.Value == NextCurrItem);
             lstList.Items.Add(Item);
         }
     }
     catch (Exception Ex)
     {
         Err Err = new Err(Ex, Sql);
         Response.Write(Err.Html());
     }
 }
Esempio n. 15
0
    public string FindCheckNum()
    {
        string Html = string.Empty;
        string Sql  = string.Empty;

        try
        {
            if (txtCheckNum.Text.Length > 0)
            {
                decimal RptTotal = 0;

                Sql = string.Format(
                    "Select p.JobRno, p.Seq, p.Reference, Coalesce(cu.Name, c.Name) as Customer, " +
                    "j.JobDate, j.SubTotAmt, j.PreTaxSubTotAmt, j.SalesTaxTotAmt, j.InvTotAmt, j.InvBalAmt " +
                    "From Payments p " +
                    "Inner Join mcJobs j on p.JobRno = j.JobRno " +
                    "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
                    "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
                    "Where Method = 'Check' And Reference Like '%{0}%' " +
                    "Order By p.JobRno, p.Seq",
                    txtCheckNum.Text);
                DataTable dt = db.DataTable(Sql);
                foreach (DataRow dr in dt.Rows)
                {
                    string  Customer      = DB.Str(dr["Customer"]);
                    string  Ref           = string.Format("Payment #{0} - {1}", DB.Int32(dr["Seq"]), DB.Str(dr["Reference"]));
                    decimal Subtotal      = DB.Dec(dr["SubTotAmt"]);
                    decimal OtherTotal    = DB.Dec(dr["PreTaxSubTotAmt"]) - Subtotal;
                    decimal SalesTaxTotal = DB.Dec(dr["SalesTaxTotAmt"]);
                    decimal Total         = DB.Dec(dr["InvTotAmt"]);
                    decimal Balance       = DB.Dec(dr["InvBalAmt"]);

                    Html += string.Format(
                        "<tr>\n" +
                        "<td class=\"Right\"><a href=\"Invoice.aspx?JobRno={0}\" target=\"invoice\">{0}</a></td>\n" +
                        "<td>{1}</td>\n" +
                        "<td class=\"Center\">{2}</td>\n" +
                        "<td>{3}</td>\n" +
                        "<td class=\"Right\">{4}</td>\n" +
                        "<td class=\"Right\">{5}</td>\n" +
                        "<td class=\"Right\">{6}</td>\n" +
                        "<td class=\"Right\">{7}</td>\n" +
                        "</tr>\n",
                        DB.Int32(dr["JobRno"]),
                        DB.Str(dr["Customer"]),
                        Fmt.Dt(DB.DtTm(dr["JobDate"])),
                        Ref,
                        Fmt.Dollar(Subtotal),
                        Fmt.Dollar(OtherTotal),
                        Fmt.Dollar(SalesTaxTotal),
                        Fmt.Dollar(Total));
                    RptTotal += Math.Round(Total, 2);

                    //Html += CCPayment(dr, "1");
                    //Html += CCPayment(dr, "2");
                    //Html += CCPayment(dr, "3");
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        return(Html);
    }
Esempio n. 16
0
    protected string Jobs()
    {
        string Html = string.Empty;
        string Sql  = string.Empty;

        try
        {
            decimal RptTotal        = 0;
            decimal RptTotalBalance = 0;

            int iRow = 0;

            DateTime PrevDay   = DateTime.MinValue;
            bool     fFirstDay = true;

            string Where = "JobDate <= GetDate() and InvBalAmt > 0 and PaidInFullDtTm is null and IsNull(ProposalFlg, 0) = 0 and CancelledDtTm is null";
            Sql = "Select *, Coalesce(cu.Name, c.Name) as Customer " +
                  "From mcJobs j " +
                  "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
                  "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
                  "Where " + Where + " " +
                  "Order By JobDate, JobRno";
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                InvoiceAmounts(dr);

                DateTime JobDate       = DB.DtTm(dr["JobDate"]);
                string   Customer      = DB.Str(dr["Customer"]);
                DateTime?Final         = DB.DtTm(dr["FinalDtTm"]);
                DateTime?Processed     = DB.DtTm(dr["ProcessedDtTm"]);
                DateTime?EditProcessed = DB.DtTm(dr["EditProcessedDtTm"]);
                DateTime?Updated       = DB.DtTm(dr["InvUpdatedDtTm"]);

                if (Updated.HasValue && Updated.Value == DateTime.MinValue)
                {
                    Updated = null;
                }

                bool   fUpdated = false;
                string Title    = string.Empty;

                if (JobDate != PrevDay)
                {
                    if (!fFirstDay)
                    {
                        //Html += "\t\t</tbody>\n\t</table>\n";
                        Html += "\t\t</tbody>\n";
                    }
                    Html += string.Format(
                        //"<div class=\"FeatureSub\">{0:M/d/yyyy}</div>\n" +
                        //"\t<table class=\"Acct\">\n" +
                        "\t\t<thead>\n" +
                        "\t\t\t<tr><td colspan=\"10\"><div class=\"FeatureSub\">{0:M/d/yyyy}</div></td></tr>\n" +
                        "\t\t\t<tr>\n" +
                        "\t\t\t\t<th>Paid</th>\n" +
                        "\t\t\t\t<th style=\"white-space: nowrap;\">Inv #</th>\n" +
                        "\t\t\t\t<th>Name</th>\n" +
                        "\t\t\t\t<th>Date</th>\n" +
                        "\t\t\t\t<th>Location</th>\n" +
                        "\t\t\t\t<th>Subtotal</th>\n" +
                        "\t\t\t\t<th>Other</th>\n" +
                        "\t\t\t\t<th>Tax</th>\n" +
                        "\t\t\t\t<th>Total</th>\n" +
                        "\t\t\t\t<th>Balance</th>\n" +
                        "\t\t\t</tr>\n" +
                        "\t\t</thead>\n" +
                        "\t\t</tbody>\n",
                        JobDate
                        );
                    PrevDay   = JobDate;
                    fFirstDay = false;
                }

                Html += string.Format(
                    "<tr class=\"{12}\">\n" +
                    "<td class=\"Center\"><input type=\"checkbox\" name=\"chkProc{0}\" value=\"{2}\" /></td>\n" +
                    "<td class=\"Right\" title=\"{13}\">{11}<a href=\"Invoice.aspx?JobRno={2}\" target=\"invoice\">{2}</a></td>\n" +
                    "<td>{3}</td>\n" +
                    "<td class=\"Center\">{4}</td>\n" +
                    "<td>{5}</td>\n" +
                    "<td class=\"Right\">{6}</td>\n" +
                    "<td class=\"Right\">{7}</td>\n" +
                    "<td class=\"Right\">{8}</td>\n" +
                    "<td class=\"Right\">{9}</td>\n" +
                    "<td class=\"Right\">{10}</td>\n" +
                    "</tr>\n",
                    ++iRow,
                    "",
                    DB.Int32(dr["JobRno"]),
                    DB.Str(dr["Customer"]),
                    Fmt.Dt(DB.DtTm(dr["JobDate"])),
                    DB.Str(dr["Location"]),
                    Fmt.Dollar(Subtotal),
                    Fmt.Dollar(OtherTotal),
                    Fmt.Dollar(SalesTaxTotal),
                    Fmt.Dollar(Total),
                    Fmt.Dollar(Balance),
                    (fUpdated ? "*" : ""),
                    (fUpdated ? "Updated" : ""),
                    Title);
                RptTotal        += Math.Round(Total, 2);
                RptTotalBalance += Math.Round(Balance, 2);
            }

            Html += string.Format(
                "<tr>\n" +
                "<td><input type=\"hidden\" name=\"{0}Count\" value=\"{1}\"/></td>\n" +
                //"<td colspan=\"2\"><span style='color: Red;'>*</span><span style='font-size: 80%'>Updated</span></td>\n" +
                "<td colspan=\"2\"></td>\n" +
                "<td colspan=\"2\"></td>\n" +
                "<td align=\"right\"><b>Count</b></td>\n" +
                "<td align=\"right\"><b>{2}</b></td>\n" +
                "<td align=\"right\"><b>Total</b></td>\n" +
                "<td align=\"right\"><b>{3}</b></td>\n" +
                "<td align=\"right\"><b>{4}</b></td>\n" +
                "</tr>\n",
                "",
                iRow,
                dt.Rows.Count,
                Fmt.Dollar(RptTotal),
                Fmt.Dollar(RptTotalBalance));
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        return(Html);
    }
Esempio n. 17
0
    //protected void ReportData(FoodType eFoodType, ref DataTable dt)
    protected void ReportData(ref DataTable dt, int KitchenLocRno, string KitchenLocation)
    {
        //this.eFoodType = eFoodType;
        DateTime PrevDate       = DateTime.MinValue;
        DateTime PrevDepartTime = DateTime.MinValue;
        int      cDays          = 0;
        int      cJobs          = 0;
        int      cServ          = 0;

        foreach (DataRow dr in dt.Rows)
        {
            int      JobRno     = DB.Int32(dr["JobRno"]);
            DateTime JobDate    = DB.DtTm(dr["JobDate"]);
            DateTime DepartTime = DB.DtTm(dr["DepartTime"]);

            if (JobDate != PrevDate || DepartTime.Hour < 12 && !(PrevDepartTime.Hour < 12) || DepartTime.Hour >= 12 && !(PrevDepartTime.Hour >= 12))
            {
                if (JobDate != PrevDate)
                {
                    cDays++;
                    PrevDate = JobDate;
                }
                PrevDepartTime = DepartTime;

                if (!fSummaryOnly)
                {
                    DayHeader(JobDate, DepartTime.Hour < 12, DepartTime.Hour >= 12, KitchenLocation);
                }
            }

            if (fSummaryOnly)
            {
                //int JobRno = DB.Int32(dr["JobRno"]);
                int cMen      = DB.Int32(dr["NumMenServing"]);
                int cWomen    = DB.Int32(dr["NumWomenServing"]);
                int cChild    = DB.Int32(dr["NumChildServing"]);
                int cServings = cMen + cWomen + cChild;

                cJobs++;
                cServ += cServings;

                Response.Write(
                    WebPage.Tabs(1) + "<tr>\n" +
                    WebPage.Tabs(2) + "<td align='right'>" + Fmt.Dt(DB.DtTm(dr["JobDate"])) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right'>" + Fmt.Tm12Hr(DB.DtTm(dr["DepartureTime"])) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right'>" + Fmt.Tm12Hr(DB.DtTm(dr["MealTime"])) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td>" + DB.Str(dr["Customer"]) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td>" + DB.Str(dr["EventType"]) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td>" + DB.Str(dr["ServiceType"]) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right'>" + Fmt.Num(cServings, false) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right' class='SmallPrint'>" + Fmt.Num(cMen, false) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right' class='SmallPrint'>" + Fmt.Num(cWomen, false) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right' class='SmallPrint'>" + Fmt.Num(cChild, false) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right' class='SmallPrint'>" + JobRno + "</td>\n" +
                    WebPage.Tabs(1) + "</tr>\n"
                    );
            }
            else
            {
                //DayHeader(dtCurr);	//each job at the top of the page
                JobData(dr, KitchenLocRno);
            }
        }

        //if (dt.Rows.Count > 0)
        //{
        //    cDays++;
        //}


        if (fSummaryOnly)
        {
            Response.Write(WebPage.Tabs(0) + WebPage.TableEnd());

            string sTotals = "<b>" + cDays + "</b> Dates,&nbsp;&nbsp;<b>" + cJobs + "</b> Jobs,&nbsp;&nbsp;<b>" + Fmt.Num(cServ) + "</b> Servings";
            Response.Write("<script language='javascript'>oSetStr('Totals', '" + sTotals + "');</script>\n");
        }
    }
Esempio n. 18
0
    protected void PrintJobs()
    {
        DateTime PrevDate = DateTime.MinValue;
        int      cDays    = 0;
        int      cJobs    = 0;
        int      cServ    = 0;

        string SqlWhere = "";

        SqlWhere = DB.And(SqlWhere, "CreatedDtTm Between " + DB.PutDtTm(dtBeg) + " And " + DB.PutDtTm(dtEnd));

        string Sql =
            "Select * From mcJobs " +
            "Where " + SqlWhere +
            " Order By CreatedDtTm";

        try
        {
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                JobRno = DB.Int32(dr["JobRno"]);

                int      cMen      = DB.Int32(dr["NumMenServing"]);
                int      cWomen    = DB.Int32(dr["NumWomenServing"]);
                int      cChild    = DB.Int32(dr["NumChildServing"]);
                int      cServings = cMen + cWomen + cChild;
                DateTime JobDate   = DB.DtTm(dr["JobDate"]);

                if (JobDate != PrevDate)
                {
                    cDays++;
                    PrevDate = JobDate;
                }

                cJobs++;
                cServ += cServings;

                Response.Write(
                    WebPage.Tabs(1) + "<tr>\n" +
                    WebPage.Tabs(2) + "<td align='right'>" + Fmt.Dt(DB.DtTm(dr["CreatedDtTm"])) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right'>" + Fmt.Tm12Hr(DB.DtTm(dr["CreatedDtTm"])) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right'>" + Fmt.Dt(JobDate) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right'>" + Fmt.Tm12Hr(DB.DtTm(dr["DepartureTime"])) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right'>" + Fmt.Tm12Hr(DB.DtTm(dr["MealTime"])) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td>" + DB.Str(dr["Customer"]) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td>" + DB.Str(dr["EventType"]) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td>" + DB.Str(dr["ServiceType"]) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right'>" + Fmt.Num(cServings, false) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right' class='SmallPrint'>" + Fmt.Num(cMen, false) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right' class='SmallPrint'>" + Fmt.Num(cWomen, false) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right' class='SmallPrint'>" + Fmt.Num(cChild, false) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right' class='SmallPrint'>" + JobRno + "</td>\n" +
                    WebPage.Tabs(1) + "</tr>\n"
                    );
            }

            if (dt.Rows.Count == 0)
            {
                Response.Write("<br><br><div class='JobSubTitle' align='center'>No Jobs Found to Print</div>\n");
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        Response.Write(WebPage.Tabs(0) + WebPage.TableEnd());

        string sTotals = "<b>" + cDays + "</b> Dates,&nbsp;&nbsp;<b>" + cJobs + "</b> Jobs,&nbsp;&nbsp;<b>" + Fmt.Num(cServ) + "</b> Servings";

        Response.Write("<script language='javascript'>oSetStr('Totals', '" + sTotals + "');</script>\n");
    }
Esempio n. 19
0
    private void DayHeader(DateTime dtRpt, bool fAM, bool fPM, string KitchenLocation)
    {
        int cJobs     = 0;
        int cServings = 0;

        string Sql =
            "Select Count(*) As Cnt, " +
            "(IsNull(Sum(NumMenServing), 0) + IsNull(Sum(NumWomenServing), 0) + IsNull(Sum(NumChildServing), 0)) As NumServings " +
            "From mcJobs Where JobDate = " + DB.PutDtTm(dtRpt) + " " +
            (fAM ? "And Datepart(hour, Coalesce(DepartureTime, MealTime, '1/1/1 00:00:01')) < 12 " : string.Empty) +
            (fPM ? "And Datepart(hour, Coalesce(DepartureTime, MealTime, '1/1/1 00:00:01')) >= 12 " : string.Empty) +
            "And CancelledDtTm Is Null";

        try
        {
            DataTable dt = db.DataTable(Sql);
            DataRow   dr = dt.Rows[0];
            cJobs     = DB.Int32(dr["Cnt"]);
            cServings = DB.Int32(dr["NumServings"]);
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        if (cJobs > 0)
        {
            if (fNewPage)
            {
                Response.Write(
                    "<div style='page-break-before: always;'><img width='1' height='1' src='Images/Space.gif' alt='' /></div>");
            }

            string Desc = KitchenLocation;

            Response.Write(
                //WebPage.Table("width='760' align='center'" + (fNewPage ? " style='page-break-before: always;" : "") + "'") +
                WebPage.Table("width='500' align='center'") +
                WebPage.Tabs(1) + "<tr>\n" +
                WebPage.Tabs(2) + "<td width='30%' valign='bottom'>\n" +
                WebPage.Tabs(3) + WebPage.Span(Desc, "RptNotice") + "\n" +
                WebPage.Tabs(2) + "</td>\n" +
                WebPage.Tabs(2) + "<td align='center'>\n" +
                WebPage.Tabs(3) + WebPage.Div("Production Sheets", "center", "RptTitle") +
                WebPage.Tabs(4) + WebPage.Table("class='RptSubTitleBorder' style='padding-left: 2px; padding-right: 2px;'") +
                WebPage.Tabs(5) + "<tr><td class='RptSubTitle'>" + (fAM ? "AM " : string.Empty) + (fPM ? "PM " : string.Empty) + Fmt.DayOfWeek(dtRpt) + ", " + Fmt.Dt(dtRpt) + "</td></tr>\n" +
                WebPage.Tabs(3) + WebPage.TableEnd() +
                WebPage.Tabs(2) + "</td>\n" +
                WebPage.Tabs(2) + "<td width='30%' valign='bottom' align='right'>" +
                WebPage.Span(Fmt.Num(cJobs), "RptNotice") + " Jobs, " +
                WebPage.Span(Fmt.Num(cServings), "RptNotice") + " Servings</td>\n" +
                WebPage.Tabs(1) + "</tr>\n" +
                WebPage.TableEnd() +
                WebPage.SpaceTable(1, 40)
                );

            fNewPage = true;
        }
    }
Esempio n. 20
0
    protected void GetData(int Rno)
    {
        string Sql = string.Format(
            "Select * " +
            "From Contacts " +
            "Where ContactRno = {0}",
            Rno);

        ClearData();

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                hfRno.Value = Rno.ToString();
                int CustomerRno = DB.Int32(dr["CustomerRno"]);
                ddlCustomer.ClearSelection();
                ListItem Item = ddlCustomer.Items.FindByValue(CustomerRno == 0 ? "" : CustomerRno.ToString());
                if (Item != null)
                {
                    Item.Selected = true;
                }

                txtName.Text        = DB.Str(dr["Name"]);
                chkHide.Checked     = (DB.DtTm(dr["InactiveDtTm"]) != DateTime.MinValue);
                txtPhone.Text       = DB.Str(dr["Phone"]);
                txtCell.Text        = DB.Str(dr["Cell"]);
                txtFax.Text         = DB.Str(dr["Fax"]);
                txtEmail.Text       = DB.Str(dr["Email"]);
                txtTitle.Text       = DB.Str(dr["Title"]);
                txtCreatedDt.Text   = Fmt.DtTm(DB.DtTm(dr["CreatedDtTm"]));
                txtCreatedUser.Text = DB.Str(dr["CreatedUser"]);
                txtUpdatedDt.Text   = Fmt.DtTm(DB.DtTm(dr["UpdatedDtTm"]));
                txtUpdatedUser.Text = DB.Str(dr["UpdatedUser"]);

                Sql = string.Format("Select Count(*) From mcJobs Where ContactRno = {0}", Rno);
                int Count = db.SqlNum(Sql);

                if (Count > 0)
                {
                    btnDelete.Enabled = false;
                    btnDelete.ToolTip = string.Format("Contact for {0} jobs", Count);
                }
                else
                {
                    btnDelete.Enabled = true;
                    btnDelete.ToolTip = "Not a contact for any jobs";
                }

                FocusField = "txtName";

                // jobs
                Sql = string.Format("Select JobRno, JobDesc, JobDate From mcJobs Where ContactRno = {0} Order By JobDate Desc", Rno);
                DataTable dt = db.DataTable(Sql);
                foreach (DataRow drJobs in dt.Rows)
                {
                    int JobRno            = DB.Int32(drJobs["JobRno"]);
                    HtmlGenericControl li = new HtmlGenericControl("li");
                    HtmlAnchor         a  = new HtmlAnchor()
                    {
                        InnerText = string.Format("{0} {1}", JobRno, DB.Str(drJobs["JobDesc"])),
                        HRef      = Page.ResolveUrl(string.Format("{0}?JobRno={1}", @"~\Job.aspx", JobRno)), Target = "Job"
                    };
                    HtmlGenericControl div = new HtmlGenericControl("div")
                    {
                        InnerText = Fmt.Dt(DB.DtTm(drJobs["JobDate"]))
                    };
                    div.Attributes.Add("class", "Date");
                    li.Controls.Add(div);
                    li.Controls.Add(a);
                    phJobs.Controls.Add(li);
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Esempio n. 21
0
    protected void Summary()
    {
        string SubTitle = Fmt.Dt(dtBeg) + " - " + Fmt.Dt(dtEnd);

        Response.Write(
            WebPage.Table("align='center'") +
            WebPage.Tabs(1) + "<tr>\n" +
            WebPage.Tabs(2) + "<td width='30%' valign='bottom'>\n" +
            WebPage.Tabs(2) + "</td>\n" +
            WebPage.Tabs(2) + "<td align='center'>\n" +
            WebPage.Tabs(3) + WebPage.Div("Jobs Entered", "center", "RptTitle") +
            WebPage.Tabs(3) + WebPage.Div(SubTitle, "center", "RptSubTitle") +
            WebPage.Tabs(2) + "</td>\n" +
            WebPage.Tabs(2) + "<td width='30%' valign='bottom' align='right'>" +
            WebPage.Tabs(1) + "</tr>\n" +
            WebPage.TableEnd() +
            WebPage.Table("align='center'") +
            WebPage.Tabs(1) + "<tr>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + WebPage.Space(10, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + WebPage.Space(10, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + WebPage.Space(20, 30) +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + WebPage.Space(10, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + WebPage.Space(10, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + WebPage.Space(10, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + WebPage.Space(10, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + WebPage.Space(10, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + WebPage.Space(10, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + WebPage.Space(5, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + WebPage.Space(5, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + WebPage.Space(10, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(1) + "</tr>\n" +
            WebPage.Tabs(1) + "<tr><td colspan='25' align='right' id='Totals'></td></tr>\n" +
            WebPage.Tabs(1) + WebPage.SpaceTr(1, 10) +
            WebPage.Tabs(1) + "<tr>\n" +
            WebPage.Tabs(2) + "<td align='center'><b>Entered</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td align='center'><b>Time</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td align='center'><b>Date</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td align='center'><b>Depart Time</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td align='center'><b>Meal Time</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td><b>Customer</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td><b>Event Type</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td><b>Service Type</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td align='right'><b>Servings</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td align='right' class='SmallPrint'><b>M</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td align='right' class='SmallPrint'><b>W</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td align='right' class='SmallPrint'><b>C</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td align='right' class='SmallPrint'><b>Job #</b></td>\n" +
            WebPage.Tabs(1) + "</tr>\n"
            );
    }
Esempio n. 22
0
    public string FindPayment()
    {
        string Html = string.Empty;
        string Sql  = string.Empty;

        try
        {
            if (txtPaymentAmt.Text.Length > 0)
            {
                decimal RptTotal = 0;

                Sql = string.Format(
                    "Select Coalesce(cu.Name, c.Name) as Customer, *, 1 as Section " +
                    "From mcJobs j " +
                    "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
                    "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
                    "Where {0} = j.InvBalAmt And j.InvCreatedDtTm Is Not Null And j.JobDate >= DateAdd(day, -90, GetDate())\n" +
                    "union\n" +
                    "Select Coalesce(cu.Name, c.Name) as Customer, *, 2 as Section " +
                    "From mcJobs j " +
                    "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
                    "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
                    "Where {0} Between j.InvBalAmt And j.InvBalAmt + 0.25 * j.SubTotAmt And j.InvBalAmt > 0 And j.InvCreatedDtTm Is Not Null And j.JobDate >= DateAdd(day, -90, GetDate())\n" +
                    "Order by Section, JobDate",
                    Str.Dec(txtPaymentAmt.Text));
                DataTable dt = db.DataTable(Sql);
                foreach (DataRow dr in dt.Rows)
                {
                    InvoiceAmounts(dr);

                    string Customer = DB.Str(dr["Customer"]);

                    Html += string.Format(
                        "<tr>\n" +
                        "<td class=\"Right\"><a href=\"Invoice.aspx?JobRno={0}\" target=\"invoice\">{0}</a></td>\n" +
                        "<td>{1}</td>\n" +
                        "<td class=\"Center\">{2}</td>\n" +
                        "<td>{3}</td>\n" +
                        "<td class=\"Right\">{4}</td>\n" +
                        "<td class=\"Right\">{5}</td>\n" +
                        "<td class=\"Right\">{6}</td>\n" +
                        "<td class=\"Right\">{7}</td>\n" +
                        "<td class=\"Right\">{8}</td>\n" +
                        "</tr>\n",
                        DB.Int32(dr["JobRno"]),
                        DB.Str(dr["Customer"]),
                        Fmt.Dt(DB.DtTm(dr["JobDate"])),
                        DB.Str(dr["Location"]),
                        Fmt.Dollar(Subtotal),
                        Fmt.Dollar(OtherTotal),
                        Fmt.Dollar(SalesTaxTotal),
                        Fmt.Dollar(Total),
                        Fmt.Dollar(Balance));
                    RptTotal += Math.Round(Total, 2);

                    Html += CCPayments(DB.Int32(dr["JobRno"]));
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        return(Html);
    }
Esempio n. 23
0
    private string FinalizedJobs(StatusType Type)
    {
        string Html = string.Empty;
        string Sql  = string.Empty;

        try
        {
            decimal RptTotal = 0;

            int iRow = 0;

            string sType = (Type == StatusType.RecentlyEdited ? "Re" : string.Empty);
            string Where = string.Empty;

            switch (Type)
            {
            case StatusType.RecentlyEdited:
                Where = "FinalDtTm Is Not Null And ProcessedDtTm Is Not Null And EditProcessedDtTm Is Not Null";
                break;

            case StatusType.Finalized:
                Where = "FinalDtTm Is Not Null And ProcessedDtTm Is Null";
                break;

            case StatusType.NotFinalized:
                Where = "FinalDtTm Is Null And ProcessedDtTm Is Null And InvCreatedDtTm Is Not Null";
                break;
            }

            Sql =
                "Select Coalesce(cu.Name, c.Name) as Customer, * " +
                "From mcJobs j " +
                "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
                "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
                "Where " + Where + " Order By JobRno";

            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                InvoiceAmounts(dr);

                string   Customer      = DB.Str(dr["Customer"]);
                DateTime?Final         = DB.DtTm(dr["FinalDtTm"]);
                DateTime?Processed     = DB.DtTm(dr["ProcessedDtTm"]);
                DateTime?EditProcessed = DB.DtTm(dr["EditProcessedDtTm"]);
                DateTime?Updated       = DB.DtTm(dr["InvUpdatedDtTm"]);

                if (Updated.HasValue && Updated.Value == DateTime.MinValue)
                {
                    Updated = null;
                }

                bool   fUpdated = false;
                string Title    = string.Empty;
                if (Updated.HasValue)
                {
                    DateTime dtUpdated = Updated.Value.AddMinutes(-5);
                    switch (Type)
                    {
                    case StatusType.RecentlyEdited:
                        fUpdated = (dtUpdated > EditProcessed);
                        if (fUpdated)
                        {
                            Title = string.Format("Invoice was saved final on {0}\nand then updated again on {1}.", Fmt.DtTm(EditProcessed.Value), Fmt.DtTm(Updated.Value));
                        }
                        break;

                    case StatusType.Finalized:
                        fUpdated = (dtUpdated > Final);
                        if (fUpdated)
                        {
                            Title = string.Format("Invoice was saved final on {0}\nand then updated again on {1}.", Fmt.DtTm(Final.Value), Fmt.DtTm(Updated.Value));
                        }
                        break;
                    }
                }

                Int32 JobRno = DB.Int32(dr["JobRno"]);


                Html += string.Format(
                    "<tr class=\"{11}\">\n" +
                    "<td class=\"Center\"><input type=\"checkbox\" name=\"chk{1}Proc{0}\" value=\"{2}\" /></td>\n" +
                    "<td class=\"Right\" title=\"{12}\">{10}<a href=\"Invoice.aspx?JobRno={2}\" target=\"invoice\">{2}</a></td>\n" +
                    "<td>{3}</td>\n" +
                    "<td class=\"Center\">{4}</td>\n" +
                    "<td>{5}</td>\n" +
                    "<td class=\"Right\">{6}</td>\n" +
                    "<td class=\"Right\">{7}</td>\n" +
                    "<td class=\"Right\">{8}</td>\n" +
                    "<td class=\"Right\">{9}</td>\n" +
                    "</tr>\n",
                    ++iRow,
                    sType,
                    JobRno,
                    DB.Str(dr["Customer"]),
                    Fmt.Dt(DB.DtTm(dr["JobDate"])),
                    DB.Str(dr["Location"]),
                    Fmt.Dollar(Subtotal),
                    Fmt.Dollar(OtherTotal),
                    Fmt.Dollar(SalesTaxTotal),
                    Fmt.Dollar(Total),
                    (fUpdated ? "*" : ""),
                    (fUpdated ? "Updated" : ""),
                    Title);
                RptTotal += Math.Round(Total, 2);

                string PmtSql = string.Format("Select * from Payments where JobRno = {0} Order by Seq", JobRno);
                try
                {
                    DataTable dtPmt = db.DataTable(PmtSql);
                    foreach (DataRow drPmt in dtPmt.Rows)
                    {
                        Html += CCPayment(drPmt);
                    }
                }
                catch (Exception Ex)
                {
                    Err Err = new Err(Ex, Sql);
                    Response.Write(Err.Html());
                }

                //            Html += CCPayment(dr, "1");
                //Html += CCPayment(dr, "2");
                //Html += CCPayment(dr, "3");
            }

            Html += string.Format(
                "<tr>\n" +
                "<td><input type=\"hidden\" name=\"{0}Count\" value=\"{1}\"/></td>\n" +
                "<td colspan=\"2\"><span style='color: Red;'>*</span><span style='font-size: 80%'>Updated</span></td>\n" +
                "<td colspan=\"2\"></td>\n" +
                "<td align=\"right\"><b>Count</b></td>\n" +
                "<td align=\"right\"><b>{2}</b></td>\n" +
                "<td align=\"right\"><b>Total</b></td>\n" +
                "<td align=\"right\"><b>{3}</b></td>\n" +
                "</tr>\n",
                sType,
                iRow,
                dt.Rows.Count,
                Fmt.Dollar(RptTotal));
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        return(Html);
    }
Esempio n. 24
0
    private void Report()
    {
        lstIngred = new List <Ingred>();

        hfBegDate.Value = dtBeg.ToString();
        hfEndDate.Value = dtEnd.ToString();

        ltlBegDate.Text = Fmt.Dt(dtBeg);
        ltlEndDate.Text = Fmt.Dt(dtEnd);

        string Sql = string.Format(
            "Select\n" +
            "j.JobRno, Coalesce(cu.Name, c.Name) as Customer, j.NumMenServing, NumWomenServing, NumChildServing, " +
            "f.Qty, f.MenuItem, r.RecipeRno, r.Name As Recipe,\n" +
            "r.NumServings, r.MenServingRatio, r.WomenServingRatio, r.ChildServingRatio,\n" +
            "r.YieldQty, r.YieldUnitRno, (Select UnitSingle From Units Where UnitRno = r.YieldUnitRno) As YieldUnit,\n" +
            "r.PortionQty, r.PortionUnitRno, (Select UnitSingle From Units Where UnitRno = r.PortionUnitRno) As PortionUnit,\n" +
            "x.IngredRno, x.SubrecipeRno, x.UnitQty, x.UnitRno,\n" +
            "(Select UnitSingle From Units Where UnitRno = x.UnitRno) As UnitSingle,\n" +
            "(Select UnitPlural From Units Where UnitRno = x.UnitRno) As UnitPlural\n" +
            "From mcJobs j\n" +
            "Inner Join Contacts c On j.ContactRno = c.ContactRno\n" +
            "Left Join Customers cu on c.CustomerRno = cu.CustomerRno\n" +
            "Inner Join mcJobFood f On j.JobRno = f.JobRno\n" +
            "Inner Join mcJobMenuItems m On f.MenuItemRno = m.MenuItemRno\n" +
            "Inner Join Recipes r On m.RecipeRno = r.RecipeRno\n" +
            "Inner join RecipeIngredXref x On r.RecipeRno = x.RecipeRno\n" +
            "Where JobDate Between {0} And {1}\n" +
            "And j.ProposalFlg = 0\n" +
            "And j.CancelledDtTm Is Null\n" +
            "Order By j.JobRno, f.MenuItem\n",
            DB.PutDtTm(dtBeg),
            DB.PutDtTm(dtEnd));

        try
        {
            //Response.Write(Sql + "<br/>");
            DataTable dtRecipeIngredXref = db.DataTable(Sql);
            //Response.Write(dtRecipeIngredXref.Rows.Count + "<br/>");
            if (dtRecipeIngredXref.Rows.Count > 0)
            {
                Ingred.LoadVendors();
                Ingred.LoadIngredConversions();
                Ingred.LoadIngredPurchases();

                // find the ingredients for the recipes
                Sql = string.Format(
                    "With IngredData As (\n" +
                    "\tSelect IngredRno, Name, IsNull(StockedFlg, 0) As StockedFlg, PrefVendors\n" +
                    //"\t(Select Top 1 v.VendorRno From VendorIngredXref x Inner Join Vendors v On x.VendorRno = v.VendorRno Where x.IngredRno = i.IngredRno) As VendorRno, " +
                    //"\t(Select Top 1 v.Name From VendorIngredXref x Inner Join Vendors v On x.VendorRno = v.VendorRno Where x.IngredRno = i.IngredRno) As Vendor " +
                    "\tFrom Ingredients i\n" +
                    "\tWhere (IngredRno In ({0}) Or IsNull(StockedFlg, 0) = 1 And IsNull(StockedPurchaseQty, 0) <> 0 And IsNull(HideFlg, 0) = 0)\n" +
                    "\tAnd IsNull(NonPurchaseFlg, 0) = 0\n" +
                    ")\n" +
                    "Select * From IngredData {1}\n",
                    Str.Join(DB.StrArray(dtRecipeIngredXref, "IngredRno"), ","),
                    //(chkIncludeStocked.Checked ? string.Empty : "Where StockedFlg = 0\n"));
                    string.Empty);
                DataTable dt = db.DataTable(Sql);
                //Response.Write(Sql + "<br/>");

                // build a collection of ingredients
                foreach (DataRow dr in dt.Rows)
                {
                    AddIngredient(dr);
                }

                // add the number of servings and recipe quantities
                foreach (DataRow dr in dtRecipeIngredXref.Rows)
                {
                    int JobServings = DB.Int32(dr["Qty"]);
                    if (JobServings == 0)
                    {
                        JobServings = DB.Int32(dr["NumMenServing"]) + DB.Int32(dr["NumWomenServing"]) + DB.Int32(dr["NumChildServing"]);
                    }

                    int     IngredRno    = DB.Int32(dr["IngredRno"]);
                    int     SubrecipeRno = DB.Int32(dr["SubrecipeRno"]);
                    decimal NumServings  = DB.Dec(dr["NumServings"]);

                    // if an ingredient
                    if (IngredRno != 0)
                    {
                        AddServings(IngredRno, JobServings, DB.Int32(dr["JobRno"]), DB.Str(dr["Customer"]), JobServings, DB.Str(dr["MenuItem"]), DB.Int32(dr["RecipeRno"]), DB.Str(dr["Recipe"]), NumServings, DB.Dec(dr["UnitQty"]), DB.Int32(dr["UnitRno"]), DB.Str(dr["UnitSingle"]), DB.Str(dr["UnitPlural"]), string.Empty, null);
                    }

                    // if a subrecipe
                    if (SubrecipeRno != 0)
                    {
                        if (NumServings != 0)
                        {
                            int RecipeRno = DB.Int32(dr["RecipeRno"]);
                            AddSubrecipe(RecipeRno, SubrecipeRno, JobServings / NumServings, DB.Int32(dr["JobRno"]), DB.Str(dr["Customer"]), JobServings, DB.Str(dr["MenuItem"]), RecipeRno, DB.Str(dr["Recipe"]), DB.Dec(dr["UnitQty"]), DB.Int32(dr["UnitRno"]), DB.Str(dr["UnitSingle"]), DB.Str(dr["UnitPlural"]), string.Empty, new List <string>());
                        }
                    }
                }

                // add any menu items that do not have a recipe
                Sql = string.Format(
                    "Select j.JobRno, Coalesce(cu.Name, c.Name) as Customer, j.NumMenServing, NumWomenServing, NumChildServing, f.Qty, f.Category, f.MenuItem, f.MenuItemRno,\n" +
                    "u.UnitRno, u.UnitSingle, u.UnitPlural, m.AsIsFlg, m.RecipeRno\n" +
                    "From mcJobs j\n" +
                    "Inner Join Contacts c On j.ContactRno = c.ContactRno\n" +
                    "Left Join Customers cu on c.CustomerRno = cu.CustomerRno\n" +
                    "Inner Join mcJobFood f On j.JobRno = f.JobRno\n" +
                    "Inner Join mcJobMenuItems m On f.MenuItemRno = m.MenuItemRno\n" +
                    "Inner Join Units u on u.UnitSingle = 'ea'\n" +
                    "Where JobDate Between {0} And {1}\n" +
                    "And j.ProposalFlg = 0\n" +
                    "And j.CancelledDtTm Is Null\n" +
                    "And m.RecipeRno Is Null\n" +
                    "And m.MenuItem <> ''\n" +
                    "Order By j.JobRno, f.MenuItem",
                    DB.PutDtTm(dtBeg),
                    DB.PutDtTm(dtEnd));
                dt = db.DataTable(Sql);
                foreach (DataRow dr in dt.Rows)
                {
                    int JobServings = DB.Int32(dr["Qty"]);
                    if (JobServings == 0)
                    {
                        JobServings = DB.Int32(dr["NumMenServing"]) + DB.Int32(dr["NumWomenServing"]) + DB.Int32(dr["NumChildServing"]);
                    }

                    string MenuItem = string.Format("{0} - {1}", DB.Str(dr["Category"]), DB.Str(dr["MenuItem"]));

                    Ingred NotIngred = null;
                    foreach (Ingred CurrIngred in lstIngred)
                    {
                        if (CurrIngred.IngredRno == 0 && CurrIngred.Name == MenuItem)
                        {
                            NotIngred = CurrIngred;
                            break;
                        }
                    }

                    if (NotIngred == null)
                    {
                        NotIngred      = new Ingred(0);
                        NotIngred.Name = MenuItem;
                        if (!DB.Bool(dr["AsIsFlg"]) && DB.Int32(dr["RecipeRno"]) == 0)
                        {
                            NotIngred.AddNote(string.Format("Menu item needs a <a href=\"Recipes.aspx\" target=\"_blank\">recipe</a> or <a href=\"SetupMenuItems.aspx?Rno={0}\" target=\"_blank\">checked As Is.</a>", DB.Int32(dr["MenuItemRno"])));
                        }
                        lstIngred.Add(NotIngred);
                    }

                    NotIngred.AddQty(JobServings, DB.Int32(dr["JobRno"]), DB.Str(dr["Customer"]), JobServings, MenuItem, 0, MenuItem, 1, 1, DB.Int32(dr["UnitRno"]), DB.Str(dr["UnitSingle"]), DB.Str(dr["UnitPlural"]), string.Empty);
                }

                // sort by vendor, ingredient
                lstIngred.Sort();

                string PrevVendor = string.Empty;
                int    iCount     = 0;

                //Html += ReportHeader();

                foreach (Ingred CurrIngred in lstIngred)
                {
                    //if (CurrIngred.Vendor != PrevVendor)
                    //{
                    //	Html += NewVendor(CurrIngred.Vendor, fFirst);
                    //	fFirst = false;
                    //	fPrevStockedFlg = false;
                    //}

                    //if (CurrIngred.StockedFlg != fPrevStockedFlg)
                    //{
                    //	Html += "<tr><td colspan='8' class='Stocked'>Stock Items</td></tr>\n";
                    //}

                    CurrIngred.FindPurchaseInfo();

                    // replace stocked items quantity
                    if (CurrIngred.StockedFlg)
                    {
                        CurrIngred.AdjustStockedItemsQuantity(db);
                    }

                    decimal Qty = (CurrIngred.StockedFlg ? CurrIngred.StockedPurchaseQty : CurrIngred.PurchaseQty);     // && CurrIngred.StockedPurchaseQty != 0
                    if (Qty == 0)
                    {
                        continue;
                    }

                    /*
                     * if (CurrIngred.fFoundConversion)
                     *                  {
                     *                          Html += string.Format(
                     *                                  "\t\t<tr>\n" +
                     *                                  "\t\t\t<td><img src='Images/Box.gif'/></td>\n" +
                     *                                  "\t\t\t<td class='Qty'>{0}</td>\n" +
                     *                                  "\t\t\t<td>{1}</td>\n" +
                     *                                  "\t\t\t<td title='{7}' class='qtp Ingred'><a href='Ingredients.aspx?Rno={8}' target='_blank'>{2}</a></td>\n" +
                     *                                  "\t\t\t<td class='Qty'>{3}</td>\n" +
                     *                                  "\t\t\t<td>{4}{5}</td>\n" +
                     *                                  "\t\t\t<td>{6}</td>\n" +
                     *                                  "\t\t</tr>\n",
                     *                                  Str.ShowFract(CurrIngred.PurchaseQty * CurrIngred.PurchaseUnitQty, 2),
                     *                                  (CurrIngred.PurchaseQty <= 1 ? CurrIngred.PurchaseUnitSingle : CurrIngred.PurchaseUnitPlural),
                     *                                  CurrIngred.Name.Replace("'", "&apos;"),
                     *                                  Math.Ceiling(CurrIngred.PurchaseQty),
                     *                                  (CurrIngred.PurchaseUnitQty != 1 ? Math.Ceiling(CurrIngred.PurchaseUnitQty) + " " : string.Empty),
                     *                                  (CurrIngred.PurchaseQty <= 1 ? CurrIngred.PurchaseUnitSingle : CurrIngred.PurchaseUnitPlural),
                     *                                  CurrIngred.Vendor,
                     *                                  CurrIngred.AddlInfo,
                     *                                  CurrIngred.IngredRno);
                     *                  }
                     *                  else
                     *                  {
                     *                          Html += string.Format(
                     *                                  "\t\t<tr>\n" +
                     *                                  "\t\t\t<td><img src='Images/Box.gif'/></td>\n" +
                     *                                  "\t\t\t<td class='Qty'>{0}</td>\n" +
                     *                                  "\t\t\t<td>{1}</td>\n" +
                     *                                  "\t\t\t<td title='{7}' class='qtp'>{3}</td>\n" +
                     *                                  "\t\t\t<td class='Qty'>{3}</td>\n" +
                     *                                  "\t\t\t<td>{4}{5}</td>\n" +
                     *                                  "\t\t\t<td>{6}</td>\n" +
                     *                                  "\t\t</tr>\n",
                     *                                  Str.ShowFract(CurrIngred.Qty, 2),
                     *                                  (CurrIngred.Qty <= 1 ? CurrIngred.UnitSingle : CurrIngred.UnitPlural),
                     *                                  CurrIngred.Name.Replace("'", "&apos;"),
                     *                                  "?",
                     *                                  (CurrIngred.PurchaseUnitQty != 1 ? Math.Ceiling(CurrIngred.PurchaseUnitQty) + " " : string.Empty),
                     *                                  (CurrIngred.PurchaseQty <= 1 ? CurrIngred.PurchaseUnitSingle : CurrIngred.PurchaseUnitPlural),
                     *                                  CurrIngred.Vendor,
                     *                                  CurrIngred.AddlInfo);
                     *
                     *                          if (CurrIngred.PurchaseUnitRno != 0)
                     *                          {
                     *                                  CurrIngred.AddNote(string.Format("<a href='Ingredients.aspx?Rno={2}' target='_blank'><i class=\"icon-warning-sign\"></i> Need conversion from {0} to {1}.</a>", CurrIngred.UnitPlural, CurrIngred.PurchaseUnitPlural, CurrIngred.IngredRno));
                     *                          }
                     *                  }
                     *
                     *                  if (CurrIngred.Note.Length > 0)
                     *                  {
                     *                          Html += string.Format(
                     *                                  "<tr><td colspan='8' class='Notes'><ul>{0}</ul></td></tr>\n",
                     *                                  CurrIngred.Note);
                     *                  }
                     */

                    TableRow tr = new TableRow();
                    tblReport.Rows.Add(tr);

                    TableCell tc = new TableCell();
                    tr.Cells.Add(tc);

                    tc.Controls.Add(new Image()
                    {
                        ImageUrl = "Images/Box.gif"
                    });
                    tc.Controls.Add(new HiddenField()
                    {
                        ID = "hfIngredRno" + iCount, Value = CurrIngred.IngredRno.ToString()
                    });
                    tc.Controls.Add(new HiddenField()
                    {
                        ID = "hfStocked" + iCount, Value = CurrIngred.StockedFlg.ToString()
                    });
                    tc.Controls.Add(new HiddenField()
                    {
                        ID = "hfStockedQty" + iCount, Value = CurrIngred.StockedPurchaseQty.ToString()
                    });
                    tc.Controls.Add(new HiddenField()
                    {
                        ID = "hfQty" + iCount, Value = CurrIngred.PurchaseQty.ToString()
                    });
                    tc.Controls.Add(new HiddenField()
                    {
                        ID = "hfUnitQty" + iCount, Value = CurrIngred.PurchaseUnitQty.ToString()
                    });
                    tc.Controls.Add(new HiddenField()
                    {
                        ID = "hfUnitRno" + iCount, Value = CurrIngred.PurchaseUnitRno.ToString()
                    });
                    tc.Controls.Add(new HiddenField()
                    {
                        ID = "hfVendorRno" + iCount, Value = CurrIngred.VendorRno.ToString()
                    });

                    tr.Cells.Add(new TableCell()
                    {
                        CssClass = "Qty", Text = Str.ShowFract(CurrIngred.PurchaseQty * CurrIngred.PurchaseUnitQty, 2)
                    });
                    tr.Cells.Add(new TableCell()
                    {
                        Text = (CurrIngred.PurchaseQty <= 1 ? CurrIngred.PurchaseUnitSingle : CurrIngred.PurchaseUnitPlural)
                    });

                    string Name = CurrIngred.Name.Replace("'", "&apos;");
                    if (CurrIngred.fFoundConversion)
                    {
                        tc = new TableCell()
                        {
                            ToolTip = CurrIngred.AddlInfo, CssClass = "qtp Ingred"
                        };
                        tr.Cells.Add(tc);
                        tc.Controls.Add(new HyperLink()
                        {
                            NavigateUrl = "Ingredients.aspx?Rno=" + CurrIngred.IngredRno, Target = "_blank", Text = Name
                        });
                    }
                    else
                    {
                        tr.Cells.Add(new TableCell()
                        {
                            ToolTip = CurrIngred.AddlInfo, CssClass = "qtp Ingred", Text = Name
                        });
                    }

                    tr.Cells.Add(new TableCell()
                    {
                        CssClass = "Qty", Text = Math.Ceiling(Qty).ToString()
                    });
                    tr.Cells.Add(new TableCell()
                    {
                        Text = string.Format("{0}{1}", (CurrIngred.PurchaseUnitQty != 1 ? Math.Ceiling(CurrIngred.PurchaseUnitQty).ToString() : string.Empty), (CurrIngred.PurchaseQty <= 1 ? CurrIngred.PurchaseUnitSingle : CurrIngred.PurchaseUnitPlural))
                    });
                    tr.Cells.Add(new TableCell()
                    {
                        CssClass = "Vendor", Text = CurrIngred.Vendor
                    });

                    if (!CurrIngred.fFoundConversion && CurrIngred.PurchaseUnitRno != 0)
                    {
                        CurrIngred.AddNote(
                            string.Format(
                                "<a href='Ingredients.aspx?Rno={2}' target='_blank' tabindex='-1'><i class=\"icon-warning-sign\"></i> Need conversion from {0} to {1}.</a>",
                                CurrIngred.UnitPlural,
                                CurrIngred.PurchaseUnitPlural,
                                CurrIngred.IngredRno));
                    }

                    if (CurrIngred.Note.Length > 0)
                    {
                        tr = new TableRow();
                        tblReport.Rows.Add(tr);
                        tr.Cells.Add(new TableCell()
                        {
                            ColumnSpan = 7, CssClass = "Notes", Text = string.Format("<ul>{0}</ul>", CurrIngred.Note)
                        });
                    }

                    iCount++;
                    //PrevVendor = CurrIngred.Vendor;
                    //fPrevStockedFlg = CurrIngred.StockedFlg;
                }
                hfParmCount.Value = iCount.ToString();
            }
            //Html += FinishVendor() + "<br /><br />";
            //Html += "</table><br /><br />";

            //ltlReport.Text = Html;

            FindVendorInfo();
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Esempio n. 25
0
    protected async Task Jobs()
    {
        // connect to sling, retrieve all the shifts and orgainize shifts into jobs
        await SetupSlingShifts();

        string JobDate = (rdoDay.Checked
            ? string.Format("= {0}", DB.PutDtTm(dtBeg))
            : string.Format("Between {0} And {1}", DB.PutDtTm(dtBeg), DB.PutDtTm(dtEnd)));
        string Sql = string.Format(
            "Select JobRno, JobDate, MealTime, Coalesce(cu.Name, c.Name) as Customer " +
            "From mcJobs j " +
            "Inner Join Contacts c On j.ContactRno = c.ContactRno " +
            "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
            "Where JobDate {0} And IsNull(Crew, '') > '' Order By JobDate, MealTime",
            JobDate);

        Collection <Job> cJobs = new Collection <Job>();

        try
        {
            // gather information on the jobs;
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                int      JobRno   = DB.Int32(dr["JobRno"]);
                DateTime Date     = DB.DtTm(dr["JobDate"]);
                DateTime Time     = DB.DtTm(dr["MealTime"]);
                string   Customer = DB.Str(dr["Customer"]);

                Job Job;
                cJobs.Add(Job = new Job()
                {
                    JobRno = JobRno, Date = Date, Time = Time, Customer = Customer
                });

                // find the shifts connected with this job
                foreach (Sling.CalendarEvent Shift in Sling.Shifts)
                {
                    if (Job.JobRno == Shift.JobRno)
                    {
                        Job.cShifts.Add(Shift);
                    }
                }

                // sort shifts within this job, job lead in first shift
                Sling.SortShiftCrew(Job.cShifts);
                if (Job.cShifts.Count > 0 && Job.cShifts[0].User != null && Job.cShifts[0].User.ID != 0)
                {
                    Job.JobLeadUserID = Job.cShifts[0].User.ID;
                }
            }

            // track who the job leads are
            Collection <int> JobLeads = new Collection <int>();

            int[] JobsToSend = SendNoticeJobs();

            // show the jobs and leads
            int Count = 0;
            foreach (Job Job in cJobs)
            {
                if (Job.JobLeadUserID == 0)
                {
                    continue;
                }

                Sling.User JobLead     = Job.cShifts[0].User;
                string     JobLeadName = FormatCrew(Job.cShifts[0]);

                string Link = string.Empty;
                if (JobLeadName.Length > 0)
                {
                    Link = string.Format("<a href='JobLeadJobs.aspx?userid={0}' target='JobLead'>Jobs</a>", JobLead.ID);
                }

                TableCell td;
                TableRow  tr = new TableRow();
                tblJobs.Rows.Add(tr);

                tr.Cells.Add(new TableCell()
                {
                    CssClass = "JobRno", Text = Job.JobRno.ToString()
                });
                tr.Cells.Add(new TableCell()
                {
                    CssClass = "Date", Text = Fmt.Dt(Job.Date)
                });
                tr.Cells.Add(new TableCell()
                {
                    CssClass = "Time", Text = Fmt.Tm12Hr(Job.Time)
                });
                tr.Cells.Add(new TableCell()
                {
                    CssClass = "Customer", Text = Job.Customer
                });
                tr.Cells.Add(new TableCell()
                {
                    CssClass = "Crew", Text = JobLeadName
                });

                tr.Cells.Add(td = new TableCell()
                {
                    CssClass = "Send"
                });
                td.Controls.Add(Job.chkSend = new CheckBox()
                {
                    ID = "chkSend" + ++Count
                });
                Job.chkSend.Checked = (!fSendNotices || SendToJob(JobsToSend, Job.JobRno));

                tr.Cells.Add(new TableCell()
                {
                    CssClass = "Link", Text = Link
                });
                tr.Cells.Add(td = new TableCell()
                {
                    CssClass = "Notice"
                });
                td.Controls.Add(Job.lblNotice = new Label());

                if (fSendNotices && Job.chkSend.Checked)
                {
                    AddJobLead(JobLeads, Job.JobLeadUserID);
                }
            }

            // send the actual notices
            if (fSendNotices)
            {
                // for each job lead
                foreach (int JobLeadUserID in JobLeads)
                {
                    bool   fFirst    = true;
                    string Note      = string.Empty;
                    string FirstName = string.Empty;
                    string LastName  = string.Empty;

                    // look through the jobs for this job lead
                    // put all the jobs for this job lead
                    foreach (Job Job in cJobs)
                    {
                        if (Job.JobLeadUserID == JobLeadUserID && Job.chkSend.Checked)
                        {
                            if (!fFirst)
                            {
                                Note += "----------------------------------------\n";
                            }
                            fFirst = false;
                            Note  += string.Format("Job #: {0}\\nDate: {1}\\nTime: {2}\\nCustomer: {3}\\n{4}://{5}{6}{7}?userid={8}",
                                                   Job.JobRno,
                                                   Fmt.Dt(Job.Date),
                                                   Fmt.Tm12Hr(Job.Time),
                                                   Job.Customer,
                                                   Request.Url.Scheme,
                                                   Request.Url.Host,
                                                   (Request.Url.Port == 80 || Request.Url.Port == 403 ? "" : ":" + Request.Url.Port),
                                                   ResolveUrl("~/JobLeadJobs.aspx"),
                                                   JobLeadUserID);
                            Job.lblNotice.Text = "Sent";

                            FirstName = Job.cShifts[0].User.FirstName;
                            LastName  = Job.cShifts[0].User.LastName;
                        }
                    }

                    string Msg = string.Format(
                        "{{" +
                        "\"content\": \"{0}\"," +
                        "\"name\": \"{1} {2}\"," +
                        "\"personas\": [{{" +
                        "\"id\": {3}," +
                        "\"type\": \"user\"" +
                        "}}]," +
                        "\"private\": true" +
                        "}}",
                        Note,
                        FirstName,
                        LastName,
                        JobLeadUserID);

                    // send the message
                    await Sling.AddToPrivateConversation(Msg);
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Esempio n. 26
0
    private void Setup()
    {
        DateTime dtBeg = DateTime.Today;
        //DateTime dtEnd = dtBeg.AddDays(14 - (int)dtBeg.DayOfWeek);
        DateTime dtEnd = dtBeg.AddDays(21 - (int)dtBeg.DayOfWeek);      // SaReena wants to try having more time to confirm
        //DateTime dtEnd = dtBeg.AddDays(21 - (int)dtBeg.DayOfWeek);    // for easier testing

        string Sql = string.Format(
            "Select j.JobRno, Coalesce(cu.Name, c.Name) as Customer, j.JobDate, j.FinalConfirmEmailedDtTm, c.Name, c.Email, c.Phone, c.Cell, j.ServiceType " +
            "From mcJobs j " +
            "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
            "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
            "Where (JobType = 'Corporate' Or ServiceType Like '%Pick Up%') And " +
            "    JobDate Between {0} And {1} And " +
            "    ConfirmedDtTm Is Null And " +
            "    CancelledDtTm Is Null And " +
            "    IsNull(ProposalFlg , 0) = 0 And " +
            "    IsNull(c.Email, '') <> '' " +
            "Order By JobDate, Customer",
            DB.Put(dtBeg),
            DB.Put(dtEnd));
        string Html = string.Empty;

        try
        {
            int       iRow = 0;
            DataTable dt   = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                int      JobRno = DB.Int32(dr["JobRno"]);
                DateTime dtJob  = DB.DtTm(dr["JobDate"]);
                Html += string.Format(
                    "<tr>\n" +
                    "<td class=\"Send\"><input type=\"checkbox\" name=\"chkSend{0}\" value=\"true\"{9}><input type=\"hidden\" name=\"hfJobRno{0}\" value={1}></td>\n" +
                    "<td><a href=\"Job.aspx?JobRno={1}\" target=\"Job\">{1}</a></td>\n" +
                    "<td class=\"Name\"><a href=\"Job.aspx?JobRno={1}\" target=\"Job\">{2}</a></td>\n" +
                    "<td>{3}</td>\n" +
                    "<td class=\"Sent\">{4}</td>\n" +
                    "<td class=\"Contact\">{5}</td>\n" +
                    "<td>{6}</td>\n" +
                    "<td>{7}</td>\n" +
                    //"<td>{8}</td>\n" +
                    "<td class=\"Confirmed\"><input type=\"checkbox\" name=\"chkConfirmed{0}\" value=\"true\"></td>\n" +
                    "</tr>\n",
                    iRow,
                    JobRno,
                    DB.Str(dr["Customer"]),
                    Fmt.Dt(dtJob),
                    Fmt.DtTm12Hr(DB.DtTm(dr["FinalConfirmEmailedDtTm"])),
                    DB.Str(dr["Name"]),
                    DB.Str(dr["Phone"]),
                    DB.Str(dr["Cell"]),
                    DB.Str(dr["ServiceType"]),
                    (DateTime.Now < Misc.ConfirmationDeadline(dtJob) && DB.Str(dr["Email"]).Length > 0 ? string.Empty : " disabled"));
                iRow++;
            }
            hfRow.Value    = iRow.ToString();
            lblReport.Text = Html;
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Esempio n. 27
0
    protected void GetShoppingList()
    {
        string Sql = String.Format(
            "Select i.Category, i.Name As Ingredient, " +
            "Coalesce(f.Qty, NumMenServing + NumWomenServing + NumChildServing) As Qty, " +
            "r.OneServQty, i.OrderUnits, j.JobDate, j.Customer, " +
            "Coalesce(j.MealTime, j.ArrivalTime, j.DepartureTime) As JobTime " +
            "From mcJobs j " +
            "Inner Join mcJobFood f On j.JobRno = f.JobRno " +
            "Inner Join mcJobMenuItems m On f.MenuItem = m.MenuItem " +
            "Inner Join Recipes r On m.MenuItemRno = r.MenuItemRno " +
            "Inner Join Ingredients i On r.IngredRno = i.IngredRno " +
            "Where JobDate Between {0} And {1} " +
            "And CancelledDtTm Is Null " +
            "Order By i.Category, i.Name, j.JobDate, JobTime, j.Customer",
            DB.PutDtTm(dtBeg),
            DB.PutDtTm(dtEnd));

        try
        {
            string PrevCategory   = null;
            string PrevIngredient = null;
            string FirstCategory  = "First";

            DataTable dt = db.DataTable(Sql);
            for (int iRow = 0; iRow < dt.Rows.Count; iRow++)
            {
                DataRow dr         = dt.Rows[iRow];
                string  Category   = DB.Str(dr["Category"]);
                string  Ingredient = GetIngredient(ref dr);

                int Qty;

                if (Ingredient != PrevIngredient)
                {
                    decimal PerServing = DB.Dec(dr["OneServQty"]);
                    string  Units      = DB.Str(dr["OrderUnits"]);

                    int iBeg  = iRow;
                    int cQty  = 0;
                    int cJobs = 0;

                    PrevIngredient = Ingredient;

                    while (Ingredient == PrevIngredient && iRow < dt.Rows.Count)
                    {
                        Qty = DB.Int32(dr["Qty"]);

                        cQty += Qty;
                        cJobs++;

                        if (++iRow < dt.Rows.Count)
                        {
                            dr         = dt.Rows[iRow];
                            Ingredient = GetIngredient(ref dr);
                        }
                    }

                    decimal PurchaseQty = cQty * PerServing;

                    string sClass    = (Category == PrevCategory ? "" : " class=\"" + FirstCategory + "RptCategory\"");
                    string sCategory = (Category == PrevCategory ? "" : "<b>" + Category + "</b>");

                    Response.Write(
                        WebPage.Tabs(1) + "<tr" + sClass + ">\n" +
                        WebPage.Tabs(2) + "<td>" + sCategory + "</td>\n" +
                        WebPage.Tabs(2) + "<td valign='top' align='right'><img src='Images/Diamond.gif' class='RptBullet'></td>\n" +
                        WebPage.Tabs(2) + "<td colspan='6' class='JobItem'><a href='javascript:ShowDtl(" + iDtl + ", " + (iDtl + cJobs - 1) + ");'>" + PrevIngredient + "</a></td>\n" +
                        WebPage.Tabs(2) + "<td></td>\n" +
                        WebPage.Tabs(2) + "<td align='right'>" + Fmt.Num(cJobs, false) + "</td>\n" +
                        WebPage.Tabs(2) + "<td></td>\n" +
                        WebPage.Tabs(2) + "<td align='right' class='RptNotice'>" + Fmt.Num(cQty, false) + "</td>\n" +
                        WebPage.Tabs(2) + "<td></td>\n" +
                        WebPage.Tabs(2) + "<td align='right'>" + Str.ShowFract(PerServing) + " " + Units + "</td>\n" +
                        WebPage.Tabs(2) + "<td></td>\n" +
                        WebPage.Tabs(2) + "<td align='right' class='RptNotice'>" + Fmt.Num((int)Math.Ceiling(PurchaseQty), false) + " " + Units + "</td>\n" +
                        WebPage.Tabs(2) + "<td></td>\n" +
                        WebPage.Tabs(2) + "<td class='StoreNote'>&nbsp;</td>\n" +
                        WebPage.Tabs(1) + "</tr>\n"
                        );

                    if (sClass != "")
                    {
                        FirstCategory = "";
                    }

                    iRow = iBeg;
                }

                dr         = dt.Rows[iRow];
                Ingredient = GetIngredient(ref dr);
                Qty        = DB.Int32(dr["Qty"]);

                Response.Write(
                    WebPage.Tabs(1) + "<tr id='Dtl" + iDtl++ + "' style='display: none;'>\n" +
                    WebPage.Tabs(2) + "<td colspan='3'></td>\n" +
                    WebPage.Tabs(2) + "<td>" + Fmt.Dt(DB.DtTm(dr["JobDate"])) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right'>" + Fmt.Tm12Hr(DB.DtTm(dr["JobTime"])) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td>" + DB.Str(dr["Customer"]) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right'>" + Fmt.Num(Qty, false) + "</td>\n" +
                    WebPage.Tabs(2) + "<td></td>\n" +
                    WebPage.Tabs(2) + "<td align='right'></td>\n" +
                    WebPage.Tabs(1) + "</tr>\n"
                    );

                PrevIngredient = Ingredient;
                PrevCategory   = Category;
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Esempio n. 28
0
    protected void GetData(int Rno)
    {
        string Sql = string.Format(
            "Select * " +
            "From Customers " +
            "Where CustomerRno = {0}",
            Rno);

        ClearData();

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                hfRno.Value                      = Rno.ToString();
                txtName.Text                     = DB.Str(dr["Name"]);
                chkHide.Checked                  = (DB.DtTm(dr["InactiveDtTm"]) != DateTime.MinValue);
                chkCompany.Checked               = DB.Bool(dr["CompanyFlg"]);
                chkTaxExempt.Checked             = DB.Bool(dr["TaxExemptFlg"]);
                chkOnlineOrders.Checked          = DB.Bool(dr["OnlineOrderFlg"]);
                chkEmailConfirmations.Checked    = DB.Bool(dr["EmailConfirmationsFlg"]);
                txtAnnualContractSignedName.Text = DB.Str(dr["AnnualContractSignedName"]);
                txtAnnualContractSignedDate.Text = Fmt.Dt(DB.DtTm(dr["AnnualContractSignedDtTm"]));
                txtCreatedDt.Text                = Fmt.DtTm(DB.DtTm(dr["CreatedDtTm"]));
                txtCreatedUser.Text              = DB.Str(dr["CreatedUser"]);
                txtUpdatedDt.Text                = Fmt.DtTm(DB.DtTm(dr["UpdatedDtTm"]));
                txtUpdatedUser.Text              = DB.Str(dr["UpdatedUser"]);

                Sql = string.Format("Select Count(*) From Contacts Where CustomerRno = {0}", Rno);
                int Count = db.SqlNum(Sql);

                if (Count > 0)
                {
                    btnDelete.Enabled = false;
                    btnDelete.ToolTip = string.Format("Customer for {0} contacts", Count);
                }
                else
                {
                    btnDelete.Enabled = true;
                    btnDelete.ToolTip = "Not a customer for any contacts";
                }

                FocusField = "txtName";

                // contacts
                Sql = string.Format("Select ContactRno, Name From Contacts Where CustomerRno = {0} Order By Name", Rno);
                DataTable dt = db.DataTable(Sql);
                foreach (DataRow drContact in dt.Rows)
                {
                    int ContactRno        = DB.Int32(drContact["ContactRno"]);
                    HtmlGenericControl li = new HtmlGenericControl("li");
                    HtmlAnchor         a  = new HtmlAnchor()
                    {
                        InnerText = DB.Str(drContact["Name"]),
                        HRef      = Page.ResolveUrl(string.Format("{0}?ContactRno={1}", @"~\Contacts.aspx", DB.Int32(drContact["ContactRno"]))),
                        Target    = "Contact"
                    };
                    li.Controls.Add(a);
                    phContacts.Controls.Add(li);
                }

                // jobs
                Sql = string.Format("Select JobRno, JobDesc, JobDate From mcJobs Where ContactRno In (Select ContactRno From Contacts Where CustomerRno = {0}) Order By JobDate Desc", Rno);
                dt  = db.DataTable(Sql);
                foreach (DataRow drJobs in dt.Rows)
                {
                    int JobRno            = DB.Int32(drJobs["JobRno"]);
                    HtmlGenericControl li = new HtmlGenericControl("li");
                    HtmlAnchor         a  = new HtmlAnchor()
                    {
                        InnerText = string.Format("{0} {1}", JobRno, DB.Str(drJobs["JobDesc"])),
                        HRef      = Page.ResolveUrl(string.Format("{0}?JobRno={1}", @"~\Job.aspx", JobRno)), Target = "Job"
                    };
                    HtmlGenericControl div = new HtmlGenericControl("div")
                    {
                        InnerText = Fmt.Dt(DB.DtTm(drJobs["JobDate"]))
                    };
                    div.Attributes.Add("class", "Date");
                    li.Controls.Add(div);
                    li.Controls.Add(a);
                    phJobs.Controls.Add(li);
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Esempio n. 29
0
    private void Report()
    {
        Debug.WriteLine("> Report");
        lstIngred = new List <Ingred>();

        hfBegDate.Value = dtBeg.ToString();
        hfEndDate.Value = dtEnd.ToString();

        ltlBegDate.Text = Fmt.Dt(dtBeg);
        ltlEndDate.Text = Fmt.Dt(dtEnd);

        string Sql = string.Format(
            "Select\n" +
            "j.JobRno, Coalesce(cu.Name, c.Name) as Customer, j.NumMenServing, NumWomenServing, NumChildServing, f.Qty, f.MenuItem,\n" +
            "r.RecipeRno, r.Name As Recipe,\n" +
            "r.NumServings, r.MenServingRatio, r.WomenServingRatio, r.ChildServingRatio,\n" +
            "r.YieldQty, r.YieldUnitRno, (Select UnitSingle From Units Where UnitRno = r.YieldUnitRno) As YieldUnit,\n" +
            "r.PortionQty, r.PortionUnitRno, (Select UnitSingle From Units Where UnitRno = r.PortionUnitRno) As PortionUnit,\n" +
            "x.IngredRno, x.SubrecipeRno, x.UnitQty, x.UnitRno,\n" +
            "(Select UnitSingle From Units Where UnitRno = x.UnitRno) As UnitSingle,\n" +
            "(Select UnitPlural From Units Where UnitRno = x.UnitRno) As UnitPlural\n" +
            "From mcJobs j\n" +
            "Inner Join Contacts c On j.ContactRno = c.ContactRno\n" +
            "Left Join Customers cu on c.CustomerRno = cu.CustomerRno\n" +
            "Inner Join mcJobFood f On j.JobRno = f.JobRno\n" +
            "Inner Join mcJobMenuItems m On f.MenuItemRno = m.MenuItemRno\n" +
            "Inner Join Recipes r On m.RecipeRno = r.RecipeRno\n" +
            "Inner join RecipeIngredXref x On r.RecipeRno = x.RecipeRno\n" +
            "Where JobDate Between {0} And {1}\n" +
            "And j.ProposalFlg = 0\n" +
            "And j.CancelledDtTm Is Null\n" +
            "Order By j.JobRno, f.MenuItem\n",
            DB.PutDtTm(dtBeg),
            DB.PutDtTm(dtEnd));

        try
        {
            string Html = string.Empty;
            int    ID   = 0;
            //Response.Write(Sql + "<br/>");
            DataTable dtRecipeIngredXref = db.DataTable(Sql);
            if (dtRecipeIngredXref.Rows.Count > 0)
            {
                Ingred.LoadVendors();
                Ingred.LoadIngredConversions();
                Ingred.LoadIngredPurchases();

                // find the ingredients for the recipes
                Sql = string.Format(
                    "Select IngredRno, Name, StockedFlg, PrefVendors\n" +
                    "From Ingredients i\n" +
                    "Where IsNull(NonPurchaseFlg, 0) = 0\n" +
                    "and IsNull(HideFlg, 0) = 0");
                //IngredRno In ({ 0})\n" +
                //"And
                //Str.Join(DB.StrArray(dtRecipeIngredXref, "IngredRno"), ","));
                DataTable dt = db.DataTable(Sql);
                //Response.Write(Sql + "<br/>");

                // build a collection of ingredients
                foreach (DataRow dr in dt.Rows)
                {
                    AddIngredient(dr);
                }

                // add the number of servings and recipe quantities
                foreach (DataRow dr in dtRecipeIngredXref.Rows)
                {
                    int JobServings = DB.Int32(dr["Qty"]);
                    if (JobServings == 0)
                    {
                        JobServings = DB.Int32(dr["NumMenServing"]) + DB.Int32(dr["NumWomenServing"]) + DB.Int32(dr["NumChildServing"]);
                    }

                    int     IngredRno    = DB.Int32(dr["IngredRno"]);
                    int     SubrecipeRno = DB.Int32(dr["SubrecipeRno"]);
                    decimal NumServings  = DB.Dec(dr["NumServings"]);

                    // if an ingredient
                    if (IngredRno != 0)
                    {
                        AddServings(IngredRno, JobServings, DB.Int32(dr["JobRno"]), DB.Str(dr["Customer"]), JobServings, DB.Str(dr["MenuItem"]), DB.Int32(dr["RecipeRno"]), DB.Str(dr["Recipe"]), NumServings, DB.Dec(dr["UnitQty"]), DB.Int32(dr["UnitRno"]), DB.Str(dr["UnitSingle"]), DB.Str(dr["UnitPlural"]), string.Empty, null);
                    }

                    // if a subrecipe
                    if (SubrecipeRno != 0)
                    {
                        if (NumServings != 0)
                        {
                            int RecipeRno = DB.Int32(dr["RecipeRno"]);
                            AddSubrecipe(RecipeRno, SubrecipeRno, JobServings / NumServings, DB.Int32(dr["JobRno"]), DB.Str(dr["Customer"]), JobServings, DB.Str(dr["MenuItem"]), RecipeRno, DB.Str(dr["Recipe"]), DB.Dec(dr["UnitQty"]), DB.Int32(dr["UnitRno"]), DB.Str(dr["UnitSingle"]), DB.Str(dr["UnitPlural"]), string.Empty, new List <string>());
                        }
                    }
                }

                // sort by vendor, ingredient
                lstIngred.Sort(CompareIngredByName);

                string PrevVendor = string.Empty;

                //Html += ReportHeader();

                foreach (Ingred CurrIngred in lstIngred)
                {
                    ID++;
                    string sID = ID.ToString();

                    CurrIngred.FindPurchaseInfo();
                    CurrIngred.Note = string.Empty;     // remove any "No prior receipt found" note

                    // replace stocked items quantity
                    if (CurrIngred.StockedFlg)
                    {
                        CurrIngred.AdjustStockedItemsQuantity(db);
                    }

                    /*
                     * if (CurrIngred.fFoundConversion)
                     * {
                     *  Html += string.Format(
                     *      "\t\t<tr>\n" +
                     *      "\t\t\t<td><input id='hfIngredRno{0}' type='hidden' value='{1}'/><img src='Images/Box.gif'/></td>\n" +
                     *      "\t\t\t<td class='Qty'>{2}</td>\n" +
                     *      "\t\t\t<td>{3}{4}</td>\n" +
                     *      "\t\t\t<td title='{11}' class='qtp Ingred'><a href='Ingredients.aspx?Rno={1}' target='_blank' tabindex='-1'>{5}</a></td>\n" +
                     *      "\t\t\t<td><input id='txtQty{0}' type=text class='Qty' value='{6}'/></td>\n" +
                     *      "\t\t\t<td><input id='txtUnitQty{0}' type=text class='Qty UnitQty' value='{7}'/></td>\n" +
                     *      "\t\t\t<td><input id='hfUnitRno{0}' type=hidden value='{8}' class='UnitRno'/><input id='txtUnit{0}' type=text class='Unit' value='{9}'/></td>\n" +
                     *      "\t\t\t<td>{10}</td>\n" +
                     *      "\t\t</tr>\n",
                     *      ID,
                     *      CurrIngred.IngredRno,
                     *      Str.ShowFract(CurrIngred.PurchaseQty * CurrIngred.PurchaseUnitQty, 2),
                     *      string.Empty,
                     *      (CurrIngred.PurchaseQty <= 1 ? CurrIngred.PurchaseUnitSingle : CurrIngred.PurchaseUnitPlural),
                     *      5 CurrIngred.Name.Replace("'", "&apos;"),
                     *      Math.Ceiling(CurrIngred.PurchaseQty),
                     *      (CurrIngred.PurchaseUnitQty != 1 ? CurrIngred.PurchaseUnitQty.ToString() : string.Empty),
                     *      CurrIngred.PurchaseUnitRno,
                     *      (CurrIngred.PurchaseQty <= 1 ? CurrIngred.PurchaseUnitSingle : CurrIngred.PurchaseUnitPlural),
                     *      10 CurrIngred.Vendor,
                     *      string.Empty,
                     *      CurrIngred.AddlInfo);
                     * }
                     * else
                     * {
                     *  Html += string.Format(
                     *      "\t\t<tr>\n" +
                     *      "\t\t\t<td><input id='hfIngredRno{0}' type='hidden' value='{1}'/><img src='Images/Box.gif'/></td>\n" +
                     *      "\t\t\t<td class='Qty'>{2}</td>\n" +
                     *      "\t\t\t<td>{3}{4}</td>\n" +
                     *      "\t\t\t<td title='{11}' class='qtp'>{5}</td>\n" +
                     *      "\t\t\t<td><input id='txtQty{0}' type=text class='Qty' value='{6}'/></td>\n" +
                     *      "\t\t\t<td><input id='txtUnitQty{0}' type=text class='Qty UnitQty' value='{7}'/></td>\n" +
                     *      "\t\t\t<td><input id='hfUnitRno{0}' type=hidden value='{8}' class='UnitRno'/><input id='txtUnit{0}' type=text class='Unit' value='{9}'/></td>\n" +
                     *      "\t\t\t<td>{10}</td>\n" +
                     *      "\t\t</tr>\n",
                     *      ID,
                     *      CurrIngred.IngredRno,
                     *      Str.ShowFract(CurrIngred.Qty, 2),
                     *      string.Empty,
                     *      (CurrIngred.Qty <= 1 ? CurrIngred.UnitSingle : CurrIngred.UnitPlural),
                     *      CurrIngred.Name.Replace("'", "&apos;"),
                     *      "?",
                     *      (CurrIngred.PurchaseUnitQty != 1 ? CurrIngred.PurchaseUnitQty + " " : string.Empty),
                     *      CurrIngred.PurchaseUnitRno,
                     *      (CurrIngred.PurchaseQty <= 1 ? CurrIngred.PurchaseUnitSingle : CurrIngred.PurchaseUnitPlural),
                     *      CurrIngred.Vendor,
                     *      string.Empty,
                     *      CurrIngred.AddlInfo);
                     *
                     *  if (CurrIngred.PurchaseUnitRno != 0)
                     *  {
                     *      CurrIngred.AddNote(
                     *          string.Format(
                     *              "<a href='Ingredients.aspx?Rno={2}' target='_blank' tabindex='-1'><i class=\"icon-warning-sign\"></i> Need conversion from {0} to {1}.</a>",
                     *              CurrIngred.UnitPlural,
                     *              CurrIngred.PurchaseUnitPlural,
                     *              CurrIngred.IngredRno));
                     *  }
                     * }
                     *
                     * if (CurrIngred.Note.Length > 0)
                     *                  {
                     *                          Html += string.Format(
                     *                              "<tr><td colspan='9' class='Notes'><ul>{0}</ul></td></tr>\n",
                     *                              CurrIngred.Note);
                     * }
                     */

                    TableRow tr = new TableRow();
                    tblReport.Rows.Add(tr);

                    TableCell tc = new TableCell();
                    tr.Cells.Add(tc);

                    tc.Controls.Add(new HiddenField()
                    {
                        ID = "hfIngredRno" + sID, Value = CurrIngred.IngredRno.ToString()
                    });
                    tc.Controls.Add(new Image()
                    {
                        ImageUrl = "Images/Box.gif"
                    });

                    tr.Cells.Add(new TableCell()
                    {
                        CssClass = "Qty", Text = Str.ShowFract(CurrIngred.PurchaseQty * CurrIngred.PurchaseUnitQty, 2)
                    });
                    tr.Cells.Add(new TableCell()
                    {
                        Text = (CurrIngred.PurchaseQty <= 1 ? CurrIngred.PurchaseUnitSingle : CurrIngred.PurchaseUnitPlural)
                    });

                    string Name = CurrIngred.Name.Replace("'", "&apos;");
                    if (CurrIngred.fFoundConversion)
                    {
                        tc = new TableCell()
                        {
                            ToolTip = CurrIngred.AddlInfo, CssClass = "qtp Ingred"
                        };
                        tr.Cells.Add(tc);
                        tc.Controls.Add(new HyperLink()
                        {
                            NavigateUrl = "Ingredients.aspx?Rno=" + CurrIngred.IngredRno, Target = "_blank", TabIndex = -1, Text = Name
                        });
                    }
                    else
                    {
                        tr.Cells.Add(new TableCell()
                        {
                            ToolTip = CurrIngred.AddlInfo, CssClass = "qtp", Text = Name
                        });
                    }

                    tr.Cells.Add(new TableCell()
                    {
                        CssClass = "Qty", Text = Math.Ceiling(CurrIngred.PurchaseQty).ToString()
                    });
                    tr.Cells.Add(new TableCell()
                    {
                        CssClass = "UnitQty",
                        Text     = string.Format("{0} {1}",
                                                 (CurrIngred.PurchaseUnitQty != 1 ? Math.Ceiling(CurrIngred.PurchaseUnitQty).ToString() : string.Empty),
                                                 (CurrIngred.PurchaseQty <= 1 ? CurrIngred.PurchaseUnitSingle : CurrIngred.PurchaseUnitPlural))
                    });

                    tc = new TableCell();
                    tr.Cells.Add(tc);
                    tc.Controls.Add(new TextBox()
                    {
                        ID = "txtQty" + sID, CssClass = "Qty", Text = (CurrIngred.StockedPurchaseQty != 0 ? Math.Ceiling(CurrIngred.StockedPurchaseQty).ToString() : string.Empty)
                    });

                    if (!CurrIngred.fFoundConversion && CurrIngred.PurchaseUnitRno != 0 && CurrIngred.UnitPlural.Length > 0 && CurrIngred.PurchaseUnitPlural.Length > 0)
                    {
                        CurrIngred.AddNote(
                            string.Format(
                                "<a href='Ingredients.aspx?Rno={2}' target='_blank' tabindex='-1'><i class=\"icon-warning-sign\"></i> Need conversion from {0} to {1}.</a>",
                                CurrIngred.UnitPlural,
                                CurrIngred.PurchaseUnitPlural,
                                CurrIngred.IngredRno));
                    }

                    if (CurrIngred.Note.Length > 0)
                    {
                        //Html += string.Format(
                        //	"<tr><td colspan='9' class='Notes'><ul>{0}</ul></td></tr>\n",
                        //	CurrIngred.Note);
                        tr = new TableRow();
                        tblReport.Rows.Add(tr);
                        tr.Cells.Add(new TableCell()
                        {
                            ColumnSpan = 8, CssClass = "Notes", Text = string.Format("<ul>{0}</ul>", CurrIngred.Note)
                        });
                    }
                }
            }
            //Html += "</table>";
            hfParmCount.Value = ID.ToString();
            //ltlReport.Text = Html;
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
        Debug.WriteLine("< Report");
    }
Esempio n. 30
0
    protected void Report()
    {
        Response.Write("</head>\n<body class='RptBody'>\n");

        int cJobs     = 0;
        int cServings = 0;

        string Sql = String.Format(
            "Select Count(*) As Cnt, " +
            "(Sum(NumMenServing) + Sum(NumWomenServing) + Sum(NumChildServing)) As NumServings " +
            "From mcJobs Where JobDate Between {0} And {1} " +
            "And CancelledDtTm Is Null",
            DB.PutDtTm(dtBeg),
            DB.PutDtTm(dtEnd));

        try
        {
            DataTable dt = db.DataTable(Sql);
            DataRow   dr = dt.Rows[0];
            cJobs     = DB.Int32(dr["Cnt"]);
            cServings = DB.Int32(dr["NumServings"]);
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        string Html =
            WebPage.Table("align='center' width='100%'") +
            WebPage.Tabs(1) + "<tr>\n" +
            WebPage.Tabs(2) + "<td width='30%' valign='bottom'>\n" +
            WebPage.Tabs(2) + "</td>\n" +
            WebPage.Tabs(2) + "<td align='center'>\n" +
            WebPage.Tabs(3) + WebPage.Div("Ingedients List", "center", "RptTitle") +
            WebPage.Tabs(5) + WebPage.Div(Fmt.Dt(dtBeg) + " - " + Fmt.Dt(dtEnd), "center", "RptSubTitle") +
            WebPage.Tabs(2) + "</td>\n" +
            WebPage.Tabs(2) + "<td width='30%' valign='bottom' align='right'>" +
            WebPage.Span(Fmt.Num(cJobs), "RptNotice") + " Jobs, " +
            WebPage.Span(Fmt.Num(cServings), "RptNotice") + " Servings</td>\n" +
            WebPage.Tabs(1) + "</tr>\n" +
            WebPage.TableEnd();

        Html +=
            WebPage.Table("align='center'") +
            WebPage.Tabs(1) + "<tr>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +                           // category
            WebPage.Tabs(2) + WebPage.Space(15, 15) +                   // bullet
            WebPage.Tabs(2) + WebPage.Space(20, 1) +                    // space before JobDate
            WebPage.Tabs(2) + "<td></td>\n" +                           // JobDate
            WebPage.Tabs(2) + WebPage.Space(5, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +                           // JobTime
            WebPage.Tabs(2) + WebPage.Space(5, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +                           // customer
            WebPage.Tabs(2) + WebPage.Space(10, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +                           // # jobs
            WebPage.Tabs(2) + WebPage.Space(20, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +                           // # servings
            WebPage.Tabs(2) + WebPage.Space(10, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +                           // per serving qty
            WebPage.Tabs(2) + WebPage.Space(10, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +                           // purchase qty
            WebPage.Tabs(2) + WebPage.Space(10, 1) +
            WebPage.Tabs(2) + "<td></td>\n" +                           // Vendor / Store Notes
            WebPage.Tabs(1) + "</tr>\n";

        Html +=
            WebPage.Tabs(1) + "<tr><td colspan='18' align='center'><span class='RptInfo'>Click an ingredient name to show or hide job details for that item.</span></td></tr>\n" +
            WebPage.Tabs(1) + "<tr>\n" +
            WebPage.Tabs(2) + "<td colspan='8'>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td align='right' class='RptHdrBold'><b># Jobs</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td align='right' class='RptHdrBold'><b># Servings</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td align='right' class='RptHdrBold'><b>Per Serving Qty</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td align='right' class='RptHdrBold'><b>Purchase Qty</b></td>\n" +
            WebPage.Tabs(2) + "<td></td>\n" +
            WebPage.Tabs(2) + "<td align='center' class='RptHdrBold'><b>Vendor / Store Notes</b></td>\n" +
            WebPage.Tabs(1) + "</tr>\n";

        Response.Write(Html);

        GetShoppingList();

        Response.Write(
            WebPage.Tabs(1) + "<tr>\n" +
            WebPage.Tabs(2) + WebPage.Space(1, 30) +
            WebPage.Tabs(1) + "</tr>\n" +
            WebPage.Tabs(1) + "<tr>\n" +
            WebPage.Tabs(2) + "<td colspan='2'></td>\n" +
            WebPage.Tabs(2) + "<td colspan='14'>\n" +
            WebPage.Tabs(3) + "<input type=button value='Show Details' title='Click to show job details for all items.' onClick='ShowAll();' class='RptSmallBtn'>\n" +
            WebPage.Tabs(3) + "<input type=button value='Hide Details' title='Click to hide job details for all items.' onClick='HideAll();' class='RptSmallBtn'>\n" +
            WebPage.Tabs(2) + "</td>\n" +
            WebPage.Tabs(1) + "</tr>\n" +
            WebPage.TableEnd() +
            "<script lang='javascript'>var iEndDtl = " + --iDtl + ";</script>\n"
            );
    }