예제 #1
0
        protected void DeleteButton_Click(object sender, EventArgs e)
        {
            List <PERFORMANCEPARAMETER> errorplist = new List <PERFORMANCEPARAMETER>();

            getReviews();
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                CheckBox c = GridView1.Rows[i].Cells[0].FindControl("Selector") as CheckBox;
                if (c.Checked)
                {
                    int parameterid        = (int)GridView1.DataKeys[i].Value;
                    PERFORMANCEPARAMETER p = pplist.FirstOrDefault(pp => pp.ParameterId == parameterid);
                    if (isparameterused(p))
                    {
                        deleteparameter(p.ParameterId);
                    }
                    else
                    {
                        errorplist.Add(p);
                    }
                }
            }
            if (errorplist.Count > 0)
            {
                deleteerrorlabel.Text = "Following parameters could not be deleted as they are being used in some other reviews: <br/>";
                int i = 1;
                foreach (PERFORMANCEPARAMETER pp in errorplist)
                {
                    deleteerrorlabel.Text += i + ". " + pp.ParameterName + "<br/>";
                }
                deleteerrorlabel.Visible = true;
            }
        }
예제 #2
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row       = (GridViewRow)GridView1.Rows[e.RowIndex];
            TextBox     parameter = row.Cells[2].Controls[0] as TextBox;
            TextBox     minRating = row.Cells[3].Controls[0] as TextBox;
            TextBox     maxRating = row.Cells[4].Controls[0] as TextBox;
            //int parameterid = Convert.ToInt32( row.Cells[1].Text);

            PERFORMANCEPARAMETER p = new PERFORMANCEPARAMETER();

            p.JobTitleId    = jt.JobTitleId;
            p.MaxRating     = Convert.ToInt32(maxRating.Text);
            p.MinRating     = Convert.ToInt32(minRating.Text);
            p.ParameterName = parameter.Text;
            p.ParameterId   = (int)GridView1.DataKeys[e.RowIndex].Value;
            Response.Write(p.ParameterId);
            GridView1.EditIndex = -1;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Global.URIstring);
                //HTTP PUT
                var updateTask = client.PutAsJsonAsync("parameters/" + p.ParameterId, p);
                updateTask.Wait();

                var result = updateTask.Result;
            }

            getParameters(jt.JobTitleId);
            filterdata();
            // gvbind(); */
        }
예제 #3
0
        private bool isparameterused(PERFORMANCEPARAMETER p)
        {
            if (rlist == null)
            {
                return(true);
            }
            REVIEW rev = rlist.Find(r => r.PerameterId == p.ParameterId);

            if (rev == null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        //update new row in table
        protected void addbutton_Click(object sender, EventArgs e)
        {
            PERFORMANCEPARAMETER p = new PERFORMANCEPARAMETER();

            p.JobTitleId    = jt.JobTitleId;
            p.MaxRating     = Convert.ToInt32(newmaxratingtextbox.Text);
            p.MinRating     = Convert.ToInt32(newminratingtextbox.Text);
            p.ParameterName = newparametertextbox.Text;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Global.URIstring);
                //HTTP PUT
                var updateTask = client.PostAsJsonAsync("parameters/", p);
                updateTask.Wait();

                var result = updateTask.Result;
            }
            getParameters(jt.JobTitleId);
            filterdata();
        }
예제 #5
0
        protected void Save_Click(object sender, EventArgs e)
        {
            //code to delete the previously set reviews
            deletereviews(g.GenerateReviewId);

            bool error = false;

            foreach (TableRow tr in ParametersTable.Rows)
            {
                if (tr.Cells.Count == 3 && tr != ParametersTable.Rows[0])
                {
                    Label paramname        = (Label)tr.Cells[0].FindControl(ParametersTable.Rows.GetRowIndex(tr).ToString());
                    PERFORMANCEPARAMETER p = parameterList.FirstOrDefault(pr => pr.ParameterName == paramname.Text);
                    REVIEW r = new REVIEW();
                    r.GenerateReviewId = g.GenerateReviewId;
                    r.EmployeeId       = g.EmployeeId;
                    r.PerameterId      = p.ParameterId;
                    TextBox comment = (TextBox)tr.Cells[2].FindControl(p.ParameterId + p.ParameterName);
                    r.Comment = comment.Text;

                    for (int i = p.MinRating; i <= p.MaxRating; i++)
                    {
                        RadioButton rb = (RadioButton)tr.Cells[1].FindControl(p.ParameterName + i);
                        if (rb.Checked)
                        {
                            r.Rating = Convert.ToInt32(rb.Text);
                            break;
                        }
                    }
                    //update reviews in db
                    // Response.Write(r.GenerateReviewId + " " +r.PerameterId+" "+ r.Rating + " " + r.Comment + "\n" );
                    var client = new HttpClient();
                    client.BaseAddress = new Uri(Global.URIstring);

                    var postTask = client.PostAsJsonAsync <REVIEW>("reviews", r);
                    postTask.Wait();

                    var result = postTask.Result;
                    if (!result.IsSuccessStatusCode)
                    {
                        // occurs if some error in writing to db
                        Response.Write("Some error occured");
                        //TODO take appt. action for the error
                        error = true;
                        break;
                    }
                }
            }
            if (!error)
            {
                //update generatedreview status
                g.Status = "Assessed";

                var client = new HttpClient();
                client.BaseAddress = new Uri(Global.URIstring);
                var putTask = client.PutAsJsonAsync <GENERATEREVIEW>("generatedreviews/" + g.GenerateReviewId, g);
                putTask.Wait();

                var result = putTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    Response.Write("Review assessed successfully.");
                    Response.Redirect("CompletedReviews.aspx");
                }
            }
        }
예제 #6
0
        private void loadtable(List <GENERATEREVIEW> filterlist)
        {
            if (filterlist.Count == 0)
            {
                Table1.Visible         = false;
                noreviewslabel.Visible = true;
            }
            else
            {
                noreviewslabel.Visible = false;
                Table1.Visible         = true;
            }

            for (int i = 1; i < Table1.Rows.Count; i++)
            {
                Table1.Rows.RemoveAt(i);
            }

            foreach (GENERATEREVIEW g in filterlist)
            {
                EMPLOYEE        e   = elist.Find(emp => emp.EmployeeId == g.EmployeeId);
                PERSONALDETAILS pd  = pdlist.Find(p => p.PersonalDetailId == e.PersonalDetailId);
                TableRow        row = new TableRow();
                row.ID = g.GenerateReviewId.ToString();
                TableCell employee = new TableCell();
                employee.HorizontalAlign = HorizontalAlign.Center;
                Label employeelabel = new Label();
                employeelabel.Text = pd.FirstName + " " + pd.LastName;
                employee.Controls.Add(employeelabel);
                row.Cells.Add(employee);


                TableCell duration = new TableCell();
                duration.HorizontalAlign = HorizontalAlign.Center;
                Label dlabel = new Label();
                dlabel.Text = g.StartDate.ToShortDateString() + " to " + g.EndDate.ToShortDateString();
                duration.Controls.Add(dlabel);
                row.Cells.Add(duration);

                TableCell dd      = new TableCell();
                Label     ddlabel = new Label();
                dd.HorizontalAlign = HorizontalAlign.Center;
                ddlabel.Text       = g.DueDate.ToShortDateString();
                dd.Controls.Add(ddlabel);
                row.Cells.Add(dd);

                TableCell status = new TableCell();
                status.HorizontalAlign = HorizontalAlign.Center;
                Label statuslabel = new Label();
                statuslabel.Text = g.Status;
                status.Controls.Add(statuslabel);
                row.Cells.Add(status);



                TableCell review = new TableCell();
                review.HorizontalAlign = HorizontalAlign.Center;
                Table reviewtable = new Table();
                reviewtable.GridLines = GridLines.Both;
                TableHeaderRow hr = new TableHeaderRow();

                TableHeaderCell h1      = new TableHeaderCell();
                Label           h1label = new Label();
                h1label.Text = "Parameter";
                h1.Controls.Add(h1label);
                hr.Cells.Add(h1);

                TableHeaderCell h2      = new TableHeaderCell();
                Label           h2label = new Label();
                h2label.Text = "Rating";
                h2.Controls.Add(h2label);
                hr.Cells.Add(h2);

                TableHeaderCell h3      = new TableHeaderCell();
                Label           h3label = new Label();
                h3label.Text = "Comment";
                h3.Controls.Add(h3label);
                hr.Cells.Add(h3);
                reviewtable.Rows.Add(hr);
                List <REVIEW> rlist = getreviews(g.GenerateReviewId);
                foreach (REVIEW r in rlist)
                {
                    TableRow tr = new TableRow();


                    TableCell parameter = new TableCell();
                    parameter.HorizontalAlign = HorizontalAlign.Center;
                    parameter.Width           = 200;
                    PERFORMANCEPARAMETER p = getparameter(r.PerameterId);
                    String pname           = p.ParameterName;
                    Label  parametername   = new Label();
                    parametername.Text = pname;
                    parameter.Controls.Add(parametername);
                    tr.Cells.Add(parameter);

                    TableCell rating = new TableCell();
                    rating.HorizontalAlign = HorizontalAlign.Center;
                    rating.Width           = 200;
                    double rate        = ((double)r.Rating / ((double)p.MaxRating - (double)p.MinRating + 1)) * 100.0;
                    Label  ratinglabel = new Label();
                    ratinglabel.Text = rate + "% ";
                    rating.Controls.Add(ratinglabel);
                    tr.Cells.Add(rating);

                    TableCell comment = new TableCell();
                    comment.HorizontalAlign = HorizontalAlign.Center;
                    comment.Width           = 200;
                    Label commentlabel = new Label();
                    commentlabel.Text = r.Comment;
                    comment.Controls.Add(commentlabel);
                    tr.Cells.Add(comment);

                    reviewtable.Rows.Add(tr);
                }
                review.Controls.Add(reviewtable);
                row.Cells.Add(review);

                TableCell c1 = new TableCell();
                c1.HorizontalAlign = HorizontalAlign.Center;
                if (g.DueDate >= DateTime.Today)
                {
                    Button edit = new Button();
                    edit.Text            = "Edit";
                    edit.Command        += new CommandEventHandler(editbutton_Click);
                    edit.CommandArgument = g.GenerateReviewId.ToString();
                    c1.Controls.Add(edit);
                }
                row.Cells.Add(c1);
                Table1.Rows.Add(row);
            }
        }