コード例 #1
0
    public void newAppointment(DataManagment.appontment app, List <string> task)
    {
        string     command = "INSERT INTO Appointment (CostumerID,Date,Time) VALUES('" + app.costumerID + "','" + app.date + "','" + app.time + "')";
        SqlCommand com     = new SqlCommand(command, conn);

        conn.Open();
        com.ExecuteNonQuery();
        int appID = 0;

        command = "SELECT ID FROM Appointment";
        com     = new SqlCommand(command, conn);
        SqlDataReader reader = com.ExecuteReader();

        while (reader.Read())
        {
            appID = reader.GetInt32(0);
        }
        reader.Close();
        foreach (string tempTask in task)
        {
            command = "INSERT INTO Task (appID,Name) VALUES('" + appID + "','" + tempTask + "')";
            com     = new SqlCommand(command, conn);
            com.ExecuteNonQuery();
        }
        conn.Close();
    }
コード例 #2
0
        protected void Button5_Click(object sender, EventArgs e)
        {
            Label10.Visible = false;
            if (Label3.Text.Length < 1)
            {
                Label10.Visible = true;
                Label10.Text    = "Please choose the costumer";
                return;
            }
            if (TextBox11.Text.Length < 2)
            {
                Label10.Visible = true;
                Label10.Text    = "Please choose the date";
                return;
            }
            DataManagment.appontment app = new DataManagment.appontment();
            app.costumerID = Int32.Parse(Label3.Text);
            app.date       = Calendar1.SelectedDate;
            TimeSpan time = new TimeSpan(Int32.Parse(DropDownList1.SelectedItem.ToString()), Int32.Parse(DropDownList2.SelectedItem.ToString()), 0);

            app.time = time;
            DataBase db = new DataBase();

            db.newAppointment(app, tasks);
            sendEmail();
            Session["msg"] = "New appointment has been created successfully";
            Response.Redirect("Success.aspx");
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["email"] == null)
            {
                Response.Redirect("Index.aspx");
            }
            string email = Session["email"].ToString();

            Label1.Text = "WELCOME " + Session["name"].ToString().TrimEnd().ToUpper();
            id          = Int32.Parse(Session["ID"].ToString().TrimEnd());
            DataManagment.appontment app = db.getupcoming(id);
            getTaskList();
            if (app == null)
            {
                Label2.Text    = "There is no upcoming appointment for you";
                Label3.Visible = false;
                Table1.Visible = false;
                return;
            }
            else
            {
                Label2.Text = app.date.Year + "/" + app.date.Month + "/" + app.date.Day;
                Label3.Text = app.time.ToString();
            }
            List <string> tasks = db.getTaskList(app.ID);

            for (int i = 0; i < tasks.Count; i++)
            {
                TableRow row = new TableRow();
                row.HorizontalAlign = HorizontalAlign.Center;
                if (i % 2 != 0)
                {
                    row.BackColor = System.Drawing.Color.FromName("#D73739");
                    row.ForeColor = System.Drawing.Color.White;
                }
                else
                {
                    row.BackColor = System.Drawing.Color.White;
                    row.ForeColor = System.Drawing.Color.FromName("#D73739");
                }

                TableCell task = new TableCell();
                task.Text = tasks[i];
                row.Cells.Add(task);
                Table1.Rows.Add(row);
            }
        }
コード例 #4
0
    public List <DataManagment.appontment> getAppsbyID(int ID)
    {
        List <DataManagment.appontment> retVal = new List <DataManagment.appontment>();
        string        command = "SELECT * FROM Appointment WHERE CostumerID='" + ID + "'";
        SqlCommand    comm    = new SqlCommand(command, conn);
        SqlDataReader reader;

        conn.Open();
        reader = comm.ExecuteReader();
        while (reader.Read())
        {
            DataManagment.appontment temp = new DataManagment.appontment();
            temp.ID         = reader.GetInt32(0);
            temp.costumerID = reader.GetInt32(1);
            temp.date       = reader.GetDateTime(2);
            temp.time       = reader.GetTimeSpan(3);
            retVal.Add(temp);
        }
        reader.Close();
        conn.Close();
        return(retVal);
    }
コード例 #5
0
    public DataManagment.appontment getupcoming(int costumerId)
    {
        DateTime date = DateTime.Today;

        DataManagment.appontment app = new DataManagment.appontment();
        string        command        = "SELECT * FROM Appointment WHERE CostumerID='" + costumerId + "' AND Date>='" + date + "'";
        SqlCommand    com            = new SqlCommand(command, conn);
        SqlDataReader reader;

        conn.Open();
        reader = com.ExecuteReader();
        if (reader.Read())
        {
            app.ID   = reader.GetInt32(0);
            app.date = reader.GetDateTime(2);
            app.time = reader.GetTimeSpan(3);
            reader.Close();
            conn.Close();
            return(app);
        }
        reader.Close();
        conn.Close();
        return(null);
    }