Exemple #1
0
        private void startTrack_Click(object sender, EventArgs e)
        {
            select sl1      = taskList.SelectedItem as select;
            var    _task_ID = Convert.ToInt16(sl1.Value);

            GlobalVar.TaskID   = _task_ID;
            GlobalVar.TaskName = Convert.ToString(sl1.Text);

            if (GlobalVar.ProjectID <= 0)
            {
                message.Text = "Please select a project.";
            }
            else if (GlobalVar.TaskID <= 0)
            {
                message.Text = "Please select a task.";
            }
            else
            {
                Tracker tracker = new Tracker();
                tracker.Show();
                this.Hide();
                tracker.FormClosed += tracker_Closed;
            }
        }
Exemple #2
0
        private void projectList_SelectedIndexChanged(object sender, EventArgs e)
        {
            select sl1         = projectList.SelectedItem as select;
            var    _project_ID = Convert.ToInt16(sl1.Value);

            GlobalVar.ProjectID   = _project_ID;
            GlobalVar.ProjectName = Convert.ToString(sl1.Text);
            List <select> sl = new List <select>();


            if (GlobalVar.ProjectID > 0)
            {
                try
                {
                    string _url = GlobalVar.GlobalUrl + "tasks.php";

                    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(_url);
                    req.Method = "POST";
                    string Data      = "projectid=" + GlobalVar.ProjectID + "&userid=" + GlobalVar.GlobalID;
                    byte[] postBytes = Encoding.ASCII.GetBytes(Data);
                    req.ContentType   = "application/x-www-form-urlencoded";
                    req.ContentLength = postBytes.Length;
                    Stream requestStream = req.GetRequestStream();
                    requestStream.Write(postBytes, 0, postBytes.Length);
                    requestStream.Close();

                    HttpWebResponse response  = (HttpWebResponse)req.GetResponse();
                    Stream          resStream = response.GetResponseStream();

                    var    sr           = new StreamReader(response.GetResponseStream());
                    string responseText = sr.ReadToEnd();

                    JObject joResponse = JObject.Parse(responseText);
                    //JObject ojObject = (JObject)joResponse["response"];

                    if ((int)joResponse["num_tasks"] <= 0)
                    {
                        sl.Add(new select()
                        {
                            Text = "", Value = 0
                        });
                        taskList.DataSource    = sl;
                        taskList.DisplayMember = "Text";
                        MessageBox.Show("You are not assigned any tasks. Please contact Project Manager.");
                    }
                    else
                    {
                        sl.Add(new select()
                        {
                            Text = "Select Task From below", Value = 0
                        });
                        JArray tasks = (JArray)joResponse["tasks"];
                        foreach (var task in tasks)
                        {
                            sl.Add(new select()
                            {
                                Text = (string)task["taskTitle"], Value = (int)task["taskID"]
                            });
                        }
                        taskList.DataSource    = sl;
                        taskList.DisplayMember = "Text";
                    }
                }
                catch (WebException)
                {
                    MessageBox.Show("Please Check Your Internet Connection");
                }
            }
            else
            {
                sl.Add(new select()
                {
                    Text = "", Value = 0
                });
                taskList.DataSource    = sl;
                taskList.DisplayMember = "Text";
            }
        }