コード例 #1
0
    protected void MarkConfirm()
    {
        int cRows = Str.Num(hfRow.Value);

        for (int iRow = 0; iRow < cRows; iRow++)
        {
            bool fConfirmed = Str.Bool(Request.Params["chkConfirmed" + iRow.ToString()]);
            int  JobRno     = Str.Num(Request.Params["hfJobRno" + iRow]);

            if (fConfirmed && JobRno != 0)
            {
                DateTime Tm  = DateTime.Now;
                string   Sql = "Update mcJobs Set " +
                               "ConfirmedDtTm = " + DB.Put(Tm) + ", " +
                               "ConfirmedBy = " + DB.Put(g.User) + ", " +
                               "UpdatedDtTm = " + DB.PutDtTm(Tm) + ", " +
                               "UpdatedUser = "******" " +
                               "Where JobRno = " + JobRno;
                try
                {
                    db.Exec(Sql);
                }
                catch (Exception Ex)
                {
                    Err Err = new Err(Ex, Sql);
                    Response.Write(Err.Html());
                }
            }
        }
    }
コード例 #2
0
    protected void SendConfirmEmail()
    {
        int cRows = Str.Num(hfRow.Value);

        for (int iRow = 0; iRow < cRows; iRow++)
        {
            bool fSend  = Str.Bool(Request.Params["chkSend" + iRow.ToString()]);
            int  JobRno = Str.Num(Request.Params["hfJobRno" + iRow]);

            if (fSend && JobRno != 0)
            {
                string Sql = string.Format(
                    "Select c.Email, JobDate, Guid, Coalesce(cu.Name, c.Name) as Customer, Location, GuestArrivalTime, MealTime, EndTime, NumMenServing, NumWomenServing, NumChildServing " +
                    "From mcJobs j " +
                    "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
                    "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
                    "Where JobRno = {0}", JobRno);
                try
                {
                    DataRow dr = db.DataRow(Sql);
                    if (dr != null)
                    {
                        string Email = DB.Str(dr["Email"]);
                        if (Email != null && Email.Length > 0)
                        {
                            string Subject = string.Format("Catering Confirmation for Event #{0}", JobRno);
                            string Guid    = DB.Str(dr["Guid"]);
                            if (Guid == string.Empty)
                            {
                                Sql  = string.Format("Update mcJobs Set Guid = NewID() Where JobRno = {0}; Select Guid From mcJobs Where JobRno = {0}", JobRno);
                                Guid = db.SqlStr(Sql);
                            }
                            DateTime dtJob      = DB.DtTm(dr["JobDate"]);
                            DateTime dtDeadline = Misc.ConfirmationDeadline(dtJob);
                            string   Customer   = DB.Str(dr["Customer"]);
                            string   Location   = DB.Str(dr["Location"]);
                            DateTime GuestTime  = DB.DtTm(dr["GuestArrivalTime"]);
                            DateTime BegTime    = DB.DtTm(dr["MealTime"]);
                            DateTime EndTime    = DB.DtTm(dr["EndTime"]);

                            if (GuestTime != DateTime.MinValue && GuestTime < BegTime)
                            {
                                BegTime = GuestTime;
                            }

                            string EventTime;
                            if (EndTime == DateTime.MinValue)
                            {
                                EventTime = BegTime.ToString("h:mm tt").ToLower();
                            }
                            else
                            {
                                EventTime = string.Format("{0} - {1}", BegTime.ToString("h:mm tt"), EndTime.ToString("h:mm tt")).ToLower();
                            }

                            int NumServings = DB.Int32(dr["NumMenServing"]) + DB.Int32(dr["NumWomenServing"]) + DB.Int32(dr["NumChildServing"]);

                            string eMailBody = string.Format(
                                "Thank you for booking with us! We need to do a final confirmation for your upcoming event on {2}.\n\n" +
                                "Please review the details on this <a href=\"{0}/CustomerConfirmation.aspx?id={1}\">confirmation page</a> " +
                                "and confirm your event by {3}.\n\n" +
                                "<table border=\"0\">" +
                                "<tr><td>" +
                                "<u>Job Information</u>" +
                                "</td></tr>" +
                                "<tr><td style=\"margin-right: 20px;\">" +
                                "Event: #{4}\n" +
                                "Customer: {5}\n" +
                                "Date: {2}\n" +
                                //"</td><td>" +
                                "Location: {6}\n" +
                                "Event Time: {7}\n" +
                                "Guest Count: {8}</div>" +
                                "</td></tr>" +
                                "</table>",
                                Request.Url.GetLeftPart(UriPartial.Authority),
                                Guid,
                                Fmt.DtNth(dtJob),
                                Fmt.DtTm12Hr(dtDeadline),
                                JobRno,
                                Customer,
                                Location,
                                EventTime,
                                NumServings);

                            Misc.SendCustomerConfirmationEmail(Page, db, JobRno, Email, Subject, eMailBody);
                        }
                    }
                }
                catch (Exception Ex)
                {
                    Err Err = new Err(Ex, Sql);
                    Response.Write(Err.Html());
                }
            }
        }
    }