Ejemplo n.º 1
0
        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            string password = Hash(Login1.Password);
              using (DataClasses1DataContext db = new DataClasses1DataContext())
              {
            var department = from a in db.Peoples
                         where (a.UserName == Login1.UserName) && (a.PasswordHash == password)
                         select a;

            foreach( var n in department)
            {
              if (n.DepartmentID == 2)
              {
            Session["User"] = -1;
            Response.Redirect("QABugs.aspx");
              }
              else if (n.DepartmentID == 1)
              {
            Session["User"] = n.PersonID;
            Response.Redirect("DevBugs.aspx");
              }
              else if (n.DepartmentID == 3)
              {
            Session["User"] = n.PersonID;
            Response.Redirect("BugsGalore.aspx");
              }
            }

              }
        }
        protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)
        {
            int key = (int)GridView1.SelectedDataKey.Value;

              lblRow.Text = "";

              using(DataClasses1DataContext db = new DataClasses1DataContext())
              {
            int count = 0;
            var selectedBug = from n in db.Bugs
                          where n.BugID == key
                          select n;

            var selectedHistories = from n in db.BugHistories
                                orderby n.DateStamp
                                where n.BugID == key
                                select n;

            foreach (var n in selectedBug)
            {
              int id = n.ReporterID;
              var reporter = from a in db.Peoples
                         where a.PersonID == id
                         select a.FullName;

              lblRow.Text += "Product: " + n.ProductName + "<br/>Description: " + n.Description +
                          "<br/>Reporter: " + reporter.ToList()[0] + "<br/>";
            }

            foreach (var n in selectedHistories)
            {
              string name = "";

              if(n.OwnerID == -1)
            name = "QA";
              else{
            var owner = from a in db.Peoples
                        where a.PersonID == n.OwnerID
                        select a.FullName;

            name = owner.ToList()[0];
              }

              if(count == 0){
              lblRow.Text += "Date: " + n.DateStamp + "<br/>Status: " + n.Status + "<br/><br/>";
              }
              else{
            lblRow.Text += "Date: " + n.DateStamp + "<br/>Status: " + n.Status + "<br/>Response: " + n.Response +
                           "<br/>Owner: " + name + "<br/><br/>";
              }
              count++;
            }
              }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string severity = ddlSeverity.SelectedValue;
              string owner = DropDownList1.SelectedValue;

              if (severity.Equals(""))
            severity = Severity;

              if (severity != null)
            severity = severity.Trim();

              if (txtResponse.Text.Equals(""))
              {
            lblError.Text = "The response field is required";
            return;
              }

              // Insert record into bugHistory
              BugHistory newRecord = new BugHistory();
              newRecord.BugID = (int)Session["Modify"];
              newRecord.Status = Status;
              newRecord.Severity = severity;
              newRecord.Response = txtResponse.Text;
              newRecord.DateStamp = DateTime.Now;

              if (owner == null || owner.Equals("") || owner.Equals("11"))
            newRecord.OwnerID = -1;
              else
            newRecord.OwnerID = int.Parse(owner);

              using (DataClasses1DataContext db = new DataClasses1DataContext())
              {
            db.BugHistories.InsertOnSubmit(newRecord);
            db.SubmitChanges();
              }
              Response.Redirect("DevBugs.aspx");
        }
Ejemplo n.º 4
0
        protected void btnAddBug_Click(object sender, EventArgs e)
        {
            int User = (int)Session["User"];

              if (txtDescription.Text == "" || ddlProducts.SelectedValue == "")
              {
            Response.Write(@"<script language='javascript'>alert('Both Fields are required');</script>");
              }
              else
              {
            // add bug to db
            using (DataClasses1DataContext db = new DataClasses1DataContext())
            {
              Bug newBug = new Bug();
              newBug.Description = txtDescription.Text;
              newBug.ProductName = ddlProducts.SelectedValue;
              newBug.ReporterID = User;

              db.Bugs.InsertOnSubmit(newBug);
              db.SubmitChanges();

              var id = (from a in db.Bugs
                    select a.BugID).Max();

              BugHistory newHistory = new BugHistory();
              newHistory.BugID = id;
              newHistory.OwnerID = -1;
              newHistory.Status = "Open";
              newHistory.DateStamp = DateTime.Now;

              db.BugHistories.InsertOnSubmit(newHistory);
              db.SubmitChanges();
            }
            Response.Redirect("BugsGalore.aspx");
              }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int usr = (int)Session["User"];
              int bugID = (int)Session["Modify"];

              lblRow.Text = "";

              using (DataClasses1DataContext db = new DataClasses1DataContext())
              {
            int count = 0;
            var selectedBug = from n in db.Bugs
                          where n.BugID == bugID
                          select n;

            var selectedHistories = from n in db.BugHistories
                                orderby n.DateStamp
                                where n.BugID == bugID
                                select n;

            foreach (var n in selectedBug)
            {
              int id = n.ReporterID;
              var reporter = from a in db.Peoples
                         where a.PersonID == id
                         select a.FullName;

              lblRow.Text += "Product: " + n.ProductName + "<br/>Description: " + n.Description +
                          "<br/>Reporter: " + reporter.ToList()[0] + "<br/>";
            }

            foreach (var n in selectedHistories)
            {
              string name = "";

              if (n.OwnerID == -1)
            name = "QA";
              else
              {
            var owner = from a in db.Peoples
                        where a.PersonID == n.OwnerID
                        select a.FullName;

            name = owner.ToList()[0];
              }

              if (count == 0)
              {
            lblRow.Text += "Date: " + n.DateStamp + "<br/>Status: " + n.Status + "<br/><br/>";
              }
              else
              {
            lblRow.Text += "Date: " + n.DateStamp + "<br/>Status: " + n.Status + "<br/>Response: " + n.Response +
                           "<br/>Owner: " + name + "<br/><br/>";
              }
              Status = n.Status;
              Severity = n.Severity;
              Owner = n.OwnerID;
              count++;
            }
            Records++;
              }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string owner = ddlOwner.SelectedValue;
              string status = ddlStatus.SelectedValue;
              string severity = ddlSeverity.SelectedValue;

              if(ddlStatus.SelectedValue.Equals("Closed"))
            owner = "QA";
              else if(owner.Equals("11"))
            owner = "";

              if(severity.Equals(""))
            severity = Severity;

              if (status.Equals(""))
            status = Status;

              owner = owner.Trim();
              status = status.Trim();
              if (severity != null)
            severity = severity.Trim();

              if (status.Equals("Open") && Records <= 1)
              {
            if (severity == null)
            {
              lblError.Text = "The severity field is required";
              return;
            }

            if(severity.Equals("")){
              lblError.Text = "The severity field is required";
              return;
            }

            if (owner.Equals(""))
            {
              lblError.Text = "An owner must be assigned";
            }
              }

              if (owner.Equals("") && status.Equals("") && severity == null)
              {
            lblError.Text = "No changes were made";
            return;
              }

              if (txtResponse.Text.Equals(""))
              {
            lblError.Text += "The response field is required";
            return;
              }

              // Insert record into bugHistory
              BugHistory newRecord = new BugHistory();
              newRecord.BugID = (int) Session["Modify"];
              newRecord.Status = status;
              newRecord.Severity = severity;
              newRecord.Response = txtResponse.Text;
              newRecord.DateStamp = DateTime.Now;

              if(owner == null || owner.Equals("") || owner.Equals("QA"))
            newRecord.OwnerID = -1;
              else
            newRecord.OwnerID = int.Parse(owner);

              using (DataClasses1DataContext db = new DataClasses1DataContext())
              {
            db.BugHistories.InsertOnSubmit(newRecord);
            db.SubmitChanges();
              }
              Response.Redirect("QABugs.aspx");
        }