Esempio n. 1
0
        protected void btnSubmitIssue_Click(object sender, EventArgs e)
        {
            //Create a new Issue object and assign necessary values
            Issue issue = new Issue();
            issue.SubmittedBy = ddlNewName.SelectedItem.Text;
            issue.Title = txtBoxNewTitle.Text;
            issue.Type = ddlNewType.SelectedItem.Text;
            issue.Description = txtBoxNewDescription.Text;
            issue.DateCreated = DateTime.Now;
            issue.Status = "Pending Review";

            //save issue
            string message = Issue.saveIssue(issue);
            if (message == "Issue created successfully")
            {
                gvCurretIssues.DataBind();
                ddlNewName.Text = "Please Select";
                txtBoxNewTitle.Text = "";
                ddlNewType.Text = "Please Select";
                txtBoxNewDescription.Text = "";
                panelSubmitNew.Visible = false;
                btnCreateNewIssue.Visible = true;
            }
            else
            {
                lblSaveIssueMessage.Text = message;
                lblSaveIssueMessage.Visible = true;
            }
        }
Esempio n. 2
0
        public static Issue getIssue(int issueID)
        {
            SqlConnection dbConn;
            SqlCommand dbCmd;
            SqlDataReader dbReader;
            string sConnection;
            string sql;

            sConnection = GlobalVars.ConnectionString;
            dbConn = new SqlConnection(sConnection);
            dbConn.Open();

            sql = "SELECT datecreated, description, status, dateclosed, submittedby, type, reply,title FROM Issues "+
                "WHERE id = @id";

            dbCmd = new SqlCommand();
            dbCmd.CommandText = sql;
            dbCmd.Parameters.AddWithValue("@id", issueID);
            dbCmd.Connection = dbConn;

            dbReader = dbCmd.ExecuteReader();
            Issue issue = new Issue();
            while (dbReader.Read())
            {
                issue.DateCreated = Convert.ToDateTime(dbReader["datecreated"]);
                issue.Description = dbReader["description"].ToString();
                issue.Status = dbReader["status"].ToString();
                if (dbReader["dateclosed"] == DBNull.Value)
                {
                    issue.DateClosed = null;
                }
                else
                {
                    issue.DateClosed = Convert.ToDateTime(dbReader["dateclosed"]);
                }
                issue.SubmittedBy = dbReader["submittedby"].ToString();
                issue.Type = dbReader["dateclosed"].ToString();
                issue.Reply = dbReader["reply"].ToString();
                issue.Title  = dbReader["title"].ToString();
            }
            dbReader.Close();
            dbCmd.Parameters.Clear();

            return issue;
        }
Esempio n. 3
0
        public static string saveIssue(Issue issue)
        {
            SqlConnection dbConn;
            string sConnection;
            SqlCommand dbCmd;
            SqlTransaction transaction;
            StringBuilder message = new StringBuilder();

            sConnection = GlobalVars.ConnectionString;
            dbConn = new SqlConnection(sConnection);
            dbConn.Open();
            dbCmd = dbConn.CreateCommand();
            transaction = dbConn.BeginTransaction("Transaction");
            dbCmd.Transaction = transaction;
            try
            {
                //Insert into Issues table
                string sqlCommand = "INSERT INTO Issues (datecreated, description, status, submittedby, type, title) " +
                    "VALUES (@datecreated, @description, @status, @submittedby, @type, @title)";

                dbCmd.CommandText = sqlCommand;
                dbCmd.Parameters.AddWithValue("datecreated", issue.DateCreated);
                dbCmd.Parameters.AddWithValue("description", issue.Description);
                dbCmd.Parameters.AddWithValue("status", issue.Status);
                dbCmd.Parameters.AddWithValue("submittedby", issue.SubmittedBy);
                dbCmd.Parameters.AddWithValue("type", issue.Type);
                dbCmd.Parameters.AddWithValue("title", issue.Title);

                dbCmd.ExecuteNonQuery();
                dbCmd.Parameters.Clear();

                transaction.Commit();
                dbConn.Close();
                message.Append("Issue created successfully");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                message.Append(ex.ToString());
                transaction.Rollback();
            }
            return message.ToString();
        }
Esempio n. 4
0
        protected void btnUpdateIssue_Click(object sender, EventArgs e)
        {
            //get values from popup
            Issue issue = new Issue();
            issue.Title = txtBoxTitle.Text;
            issue.Type = ddlType.Text;
            issue.SubmittedBy = ddlSubmittedBy.Text;
            issue.Status = ddlStatus.Text;
            issue.DateCreated = Convert.ToDateTime(txtBoxDateCreated.Text);
            if (txtBoxDateClosed.Text == "")
            {
                issue.DateClosed = null;
            }
            else
            {
                issue.DateClosed = Convert.ToDateTime(txtBoxDateClosed.Text);
            }
            issue.Description = txtBoxDescription.Text;
            issue.Reply = txtBoxReply.Text;

            issue.ID = Convert.ToInt32(hfID.Value);

            //update issue
            Issue.updateIssue(issue);

            //refresh both gridviews
            gvCurretIssues.DataBind();
            gvPastIssues.DataBind();

            //clear out any old data in modal popup
            txtBoxTitle.Text = "";
            txtBoxDateCreated.Text = "";
            txtBoxDateClosed.Text = "";
            txtBoxDescription.Text = "";
            txtBoxReply.Text = "";
        }
Esempio n. 5
0
        protected void lnkBtnSelect_Click1(object sender, EventArgs e)
        {
            //clear out any old data in modal popup
            txtBoxTitle.Text = "";
            txtBoxDateCreated.Text = "";
            txtBoxDateClosed.Text = "";
            txtBoxDescription.Text = "";
            txtBoxReply.Text = "";

            //get primary key from datagrid to get issue from DB
            LinkButton lnkButton = (LinkButton)sender;
            gvPastIssues.SelectedIndex = Convert.ToInt32(lnkButton.CommandArgument);
            int issueID = Convert.ToInt32(gvPastIssues.SelectedDataKey.Value);
            Issue issue = new Issue();
            issue = Issue.getIssue(issueID);

            //populate modial popup
            txtBoxTitle.Text = issue.Title;
            ddlType.Text = issue.Type;
            ddlSubmittedBy.Text = issue.SubmittedBy;
            ddlStatus.Text = issue.Status;
            txtBoxDateCreated.Text = issue.DateCreated.ToShortDateString();
            if (issue.DateClosed != null)
            {
                txtBoxDateClosed.Text = Convert.ToDateTime(issue.DateClosed).ToShortDateString();
            }
            txtBoxDescription.Text = issue.Description;
            txtBoxReply.Text = issue.Reply;

            hfID.Value = issueID.ToString();

            btnPopUp_ModalPopUpExtender.Show();
        }
Esempio n. 6
0
        public static Issue updateIssue(Issue issue)
        {
            SqlConnection dbConn;
            SqlCommand dbCmd;
            string sConnection;
            string sql;

            try
            {
                sConnection = GlobalVars.ConnectionString;
                dbConn = new SqlConnection(sConnection);
                dbConn.Open();

                sql = "UPDATE Issues SET datecreated = @datecreated, description = @description, status = @status, dateclosed = @dateclosed, submittedby = @submittedby" +
                    ", type = @type, reply = @reply, title = @title WHERE id = @id";

                dbCmd = new SqlCommand();
                dbCmd.CommandText = sql;
                dbCmd.Parameters.AddWithValue("id", issue.ID);
                dbCmd.Parameters.AddWithValue("datecreated", issue.DateCreated);
                dbCmd.Parameters.AddWithValue("description", issue.Description);
                dbCmd.Parameters.AddWithValue("status", issue.Status);
                if (issue.DateClosed == null)
                {
                    dbCmd.Parameters.AddWithValue("dateclosed", DBNull.Value);
                }
                else
                {
                    dbCmd.Parameters.AddWithValue("dateclosed", issue.DateClosed);
                }
                dbCmd.Parameters.AddWithValue("submittedby", issue.SubmittedBy);
                dbCmd.Parameters.AddWithValue("type", issue.Type);
                dbCmd.Parameters.AddWithValue("reply", issue.Reply);
                dbCmd.Parameters.AddWithValue("title", issue.Title);

                dbCmd.Connection = dbConn;

                dbCmd.ExecuteNonQuery();

                dbCmd.Parameters.Clear();
                dbConn.Close();

                return issue;
            }
            catch (Exception ex)
            {
                ex.ToString();
                return null;
            }
        }
Esempio n. 7
0
 public static Issue updateIssue(Issue issue)
 {
     return IssueDA.updateIssue(issue);
 }
Esempio n. 8
0
 public static string saveIssue(Issue issue)
 {
     return IssueDA.saveIssue(issue);
 }