本文整理汇总了C#中Util.getAvailability方法的典型用法代码示例。如果您正苦于以下问题:C# Util.getAvailability方法的具体用法?C# Util.getAvailability怎么用?C# Util.getAvailability使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Util
的用法示例。
在下文中一共展示了Util.getAvailability方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
//Prevent corruption. Double check availability. Delete cookies
if (Session["date"] != null && Session["AdvisorID"] != null)
{
int advisorId = Convert.ToInt32(Session["AdvisorID"].ToString());
string date = Session["date"].ToString();
int studentId = Convert.ToInt32(Session["StudentID"].ToString());
Session["date"] = null;
Session["AdvisorID"] = null;
Util get = new Util(advisorId);
DateTime datev2 = DateTime.ParseExact(date, "MM/dd/yyyy", null);
DateTime[] advisorAllSlots = get.getSlots(advisorId, date);
DateTime[] taken = get.getTaken(advisorId, date);
DateTime[] availibility = get.getAvailability(advisorAllSlots, taken);
bool proceed = false;
for (int i = 0; i < availibility.Length; i++)
{
if (dropdownlistTime.SelectedValue.ToString() == availibility[i].ToShortTimeString())
{
proceed = true;
}
}
if (proceed)
{
DateTime picked = new DateTime();
picked = DateTime.ParseExact(dropdownlistTime.SelectedValue.ToString(), "h:mm tt", CultureInfo.InvariantCulture);
int Student_Id = studentId;
int Advisor_Id = advisorId;
string Time_Start = picked.ToString("HH:mm:ss");
string Time_End = picked.AddMinutes(30).ToString("HH:mm:ss");
string Date = datev2.ToString("yyyy-MM-dd");
string Comments = TextArea1.Value.ToString();
int AdvisorScheduleID = get.getAvailableID(dropdownlistTime.SelectedValue.ToString());
string sqlQuery = "INSERT INTO Appointments (AdvisorScheduleID, Student_Id,Time_Start,Time_End,Date,Comment,Cancel)";
sqlQuery += " VALUES (@AdvisorScheduleID,@Student_Id,@Time_Start,@Time_End,@Date,@Comment,@Cancel)";
string connectionString = ConfigurationManager.ConnectionStrings["AdvisorBookingConnectionString"].ToString();
using (SqlConnection dataConnection = new SqlConnection(connectionString))
{
using (SqlCommand dataCommand = new SqlCommand(sqlQuery, dataConnection))
{
dataCommand.Parameters.AddWithValue("AdvisorScheduleID", AdvisorScheduleID);
dataCommand.Parameters.AddWithValue("Student_Id", studentId);
dataCommand.Parameters.AddWithValue("Time_Start", Time_Start);
dataCommand.Parameters.AddWithValue("Time_End", Time_End);
dataCommand.Parameters.AddWithValue("Date", Date);
dataCommand.Parameters.AddWithValue("Comment", Comments);
dataCommand.Parameters.AddWithValue("Cancel", 1);
dataConnection.Open();
dataCommand.ExecuteNonQuery();
dataConnection.Close();
}
}
Server.Transfer("FinishBooking.aspx");
}
else
{
Response.Write("<script type='text/javascript'>alert('Something went wrong. Try again later');</script>");
Server.Transfer("Advisor.aspx");
}
}
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
//Prevent some exceptions and corruptions.
Session["AdvisorID"] = Request.QueryString["AdvisorID"];
Session["date"] = Request.QueryString["bookingDate"];
if (Session["date"] == null || Session["AdvisorID"] == null)
Server.Transfer("Advisor.aspx");
try
{
Session["bookingTime"] = Request.QueryString["bookingTime"];
dropdownlistTime.SelectedValue = Session["bookingTime"].ToString();
}
catch { }
int studentId = Convert.ToInt32(Session["StudentID"].ToString());
int advisorId = Convert.ToInt32(Session["AdvisorID"].ToString());
string date = Session["date"].ToString();
Util get = new Util(advisorId);
btnSubmit.Visible = true;
DateTime datev2 = DateTime.ParseExact(Session["date"].ToString(), "MM/dd/yyyy", null);
DateTime[] advisorAllSlots = get.getSlots(advisorId, date);
DateTime[] taken = get.getTaken(advisorId, date);
DateTime[] availibility = get.getAvailability(advisorAllSlots, taken);
string[] shorttime = new string[availibility.Length];
for (int i = 0; i < availibility.Length; i++)
{ shorttime[i] = availibility[i].ToShortTimeString(); }
txtAdvisorName.Text = get.FullName;
txtDate.Text = datev2.ToShortDateString();
dropdownlistTime.DataSource = shorttime;
if (!IsPostBack)
{
dropdownlistTime.DataBind();
}
if (availibility.Length == 0)
{
Response.Write("<script type='text/javascript'>alert('It is fully booked.');</script>");
Server.Transfer("ViewScheduleCalendar.aspx");
}
}
示例3: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Page.Unload += PageUnload;
Util get = new Util();
string[] dates = get.getAdvisor2WeekSchedule();
DateTime[] datesv2 = new DateTime[dates.Length];
for (int i = 0; i < dates.Length; i++)
{
datesv2[i] = DateTime.Parse(dates[i]);
}
lblDay1.Text = datesv2[0].DayOfWeek.ToString();
lblDay2.Text = datesv2[1].DayOfWeek.ToString();
lblDay3.Text = datesv2[2].DayOfWeek.ToString();
lblDay4.Text = datesv2[3].DayOfWeek.ToString();
lblDay5.Text = datesv2[4].DayOfWeek.ToString();
lblDate1.Text = datesv2[0].ToString("dd MMM yyyy");
lblDate2.Text = datesv2[1].ToString("dd MMM yyyy");
lblDate3.Text = datesv2[2].ToString("dd MMM yyyy");
lblDate4.Text = datesv2[3].ToString("dd MMM yyyy");
lblDate5.Text = datesv2[4].ToString("dd MMM yyyy");
int[] ID = get.getAdvisorIDs();
for (int y = 0; y < ID.Length; y++)
{
TableCell[] td = new TableCell[8];
HyperLink link = new HyperLink();
link.NavigateUrl = "~/ViewScheduleCalendar.aspx?AdvisorID=" + ID[y];
for (int i = 0; i < 8; i++) { td[i] = new TableCell(); }
link.Text = get.getName(ID[y]) + "<br /> <img src='" + get.getAdvisorImage(ID[y]) + "' width='80' height='80' />";
link.ForeColor = System.Drawing.Color.Black;
link.Font.Underline = false;
td[0].Controls.Add(link);
td[0].Width = 120;
td[0].Height = 150;
td[1].Text = get.getDepartment(ID[y]).Replace("School of", "");
td[1].ForeColor = System.Drawing.Color.Black;
td[1].Width = 120;
for (int BookingColumn = 0; BookingColumn < 5; BookingColumn++)
{
for (int iii = 0; iii < 6; iii++)
{
DateTime[] advisorAllSlots = get.getSlots(ID[y], dates[BookingColumn]);
DateTime[] taken = get.getTaken(ID[y], dates[BookingColumn]);
DateTime[] availibility = get.getAvailability(advisorAllSlots, taken);
HyperLink[] link2 = new HyperLink[availibility.Length];
if (availibility.Length == 0 || iii == availibility.Length)
{ break; }
if (iii == 5)
{
link2[0] = new HyperLink();
link2[0].NavigateUrl = "~/MakeAppointment.aspx?AdvisorID=" + ID[y] + "&bookingDate=" + datesv2[BookingColumn].ToString("MM/dd/yyyy") + "&bookingTime=" + availibility[0].ToShortTimeString();
link2[0].Text = "more";
link2[0].ForeColor = System.Drawing.Color.Black;
td[BookingColumn + 2].Controls.Add(link2[0]);
}
else
{
for (int i = 0; i < link2.Length; i++) { link2[i] = new HyperLink(); }
link2[iii].NavigateUrl = "~/MakeAppointment.aspx?AdvisorID=" + ID[y] + "&bookingDate=" + datesv2[BookingColumn].ToString("MM/dd/yyyy") + "&bookingTime=" + availibility[iii].ToShortTimeString();
link2[iii].Text = availibility[iii].ToShortTimeString() + "<br />";
link2[iii].ForeColor = System.Drawing.Color.Black;
td[BookingColumn + 2].Controls.Add(link2[iii]);
}
}
//Width of cells from column 2-6
td[BookingColumn + 2].Width = 120;
td[BookingColumn + 2].HorizontalAlign = HorizontalAlign.Center;
}
//Column color
td[0].BackColor = System.Drawing.Color.White;
td[1].BackColor = System.Drawing.Color.WhiteSmoke;
td[2].BackColor = System.Drawing.Color.White;
td[3].BackColor = System.Drawing.Color.WhiteSmoke;
td[4].BackColor = System.Drawing.Color.White;
td[5].BackColor = System.Drawing.Color.WhiteSmoke;
td[6].BackColor = System.Drawing.Color.White;
TableRow tRow = new TableRow();
tRow.VerticalAlign = VerticalAlign.Top;
myTable.Rows.Add(tRow);
tRow.Cells.AddRange(td);
}
}