Beispiel #1
0
        protected void convert_mode_btn_Click(object sender, EventArgs e)
        {
            int flag = 0;

            calStatus_lbl.Text = "";
            lbl_status.Text    = "";
            if (convert_mode_btn.Text == "Convert To Delete Mode")
            {
                flag                    = 1;
                add_btn.Enabled         = false;
                ToDoList_txtbox.Enabled = false;
                CheckBoxList1.Visible   = false;
                Del_List_Box.Visible    = true;
                del_btn.Visible         = true;
                convert_mode_btn.Text   = "Convert To Add Mode";
                //display todolist
                try
                {
                    DataTable dt     = new DataTable();
                    int       UserID = Convert.ToInt32(Session["UserID"]);
                    DateTime  Date   = Calendar1.SelectedDate == new DateTime(1, 1, 1) ? DateTime.Now : Calendar1.SelectedDate;
                    int       CatID  = Convert.ToInt32(ddl_category.SelectedItem.Value);
                    //string ToDoList = ToDoList_txtbox.Text;
                    dt = AccessLayer.ToDoList.selectbydatecat(UserID, CatID, new DateTime(Date.Year, Date.Month, Date.Day));

                    Del_List_Box.DataSource     = dt;
                    Del_List_Box.DataTextField  = "Todolist";
                    Del_List_Box.DataValueField = "ID";
                    Del_List_Box.DataBind();
                }
                catch
                {
                    calStatus_lbl.Text = "u should select date";
                }
            }
            if (flag == 0 && convert_mode_btn.Text == "Convert To Add Mode")
            {
                add_btn.Enabled         = true;
                ToDoList_txtbox.Enabled = true;
                CheckBoxList1.Visible   = true;
                Del_List_Box.Visible    = false;
                del_btn.Visible         = false;
                convert_mode_btn.Text   = "Convert To Delete Mode";

                DataTable dt     = new DataTable();
                int       UserID = Convert.ToInt32(Session["UserID"]);
                DateTime  Date   = Calendar1.SelectedDate == new DateTime(1, 1, 1) ? DateTime.Now : Calendar1.SelectedDate;
                int       CatID  = Convert.ToInt32(ddl_category.SelectedItem.Value);
                //string ToDoList = ToDoList_txtbox.Text;
                dt = AccessLayer.ToDoList.selectbydatecat(UserID, CatID, new DateTime(Date.Year, Date.Month, Date.Day));

                CheckBoxList1.DataSource     = AccessLayer.ToDoList.selectbydatecat(UserID, CatID, Date);
                CheckBoxList1.DataTextField  = "Todolist";
                CheckBoxList1.DataValueField = "ID";
                CheckBoxList1.DataBind();
            }
        }
Beispiel #2
0
        protected void del_btn_Click(object sender, EventArgs e)
        {
            calStatus_lbl.Text = "";
            lbl_status.Text    = "";
            //listBox1.Items.Remove(listBox1.SelectedIndex);
            //Del_List_Box.Items.RemoveAt(selected)
            //store
            DataTable dt     = new DataTable();
            int       UserID = Convert.ToInt32(Session["UserID"]);
            DateTime  Date   = Calendar1.SelectedDate == new DateTime(1, 1, 1) ? DateTime.Now.Date : Calendar1.SelectedDate.Date;
            int       CatID  = Convert.ToInt32(ddl_category.SelectedItem.Value);
            //string ToDoList = Del_List_Box.SelectedItem.ToString();
            int    i;
            string selectedItem = string.Empty;

            if (Del_List_Box.Items.Count > 0)
            {
                for (i = 0; i < Del_List_Box.Items.Count; i++)
                {
                    if (Del_List_Box.Items[i].Selected)
                    {
                        selectedItem = Del_List_Box.Items[i].Text.ToString();
                        Del_List_Box.Items.RemoveAt(Del_List_Box.SelectedIndex);
                        AccessLayer.ToDoList.delete(selectedItem);
                        //selectedItem += Del_List_Box.Items[i].Text.ToString() + ", ";
                        //insert command
                    }
                }
            }


            //int i = 0;
            //bool select = Del_List_Box.Items[i].Selected;
            //if (select) {
            //    string ToDoList = Del_List_Box.SelectedItem.ToString();
            //}
            //int ToDoList = Del_List_Box.SelectedIndex;
            //delete from listbox
            //Del_List_Box.Items.RemoveAt(Del_List_Box.SelectedIndex);



            //delete from DB
            //AccessLayer.ToDoList.delete(ToDoList);
            //update textbox from DB
            Del_List_Box.DataSource     = AccessLayer.ToDoList.selectbydatecat(UserID, CatID, Date);
            Del_List_Box.DataTextField  = "Todolist";
            Del_List_Box.DataValueField = "ID";
            Del_List_Box.DataBind();
        }