コード例 #1
0
        protected void RemoveSelectedButton_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(Global.getConnectionString());
            SqlCommand    cmd = new SqlCommand("DELETE FROM pms_resourceproject WHERE ", con);
            string        pc = "", seperator = " OR ";
            bool          deleteAtLeastOne = false;
            int           count            = 0;
            int           projectID        = Convert.ToInt32(Request.QueryString["ProjectID"]);
            string        logAction        = "Removed resources from project: <br/>";

            foreach (GridViewRow row in GridView1.Rows)
            {
                CheckBox c = (CheckBox)row.FindControl("RemoveSelector");
                if (c != null && c.Checked)
                {
                    count++;
                    string loc = "resid" + count;
                    deleteAtLeastOne = true;
                    int resourceID = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
                    logAction       += "(ID: " + resourceID + ") " + row.Cells[1].Text + " <br/>";
                    cmd.CommandText += pc;
                    cmd.CommandText += "(project_id=" + projectID + " AND resource_id=@" + loc + ")";
                    cmd.Parameters.Add("@" + loc, SqlDbType.Int).Value = resourceID;
                    pc = seperator;
                }
            }

            if (deleteAtLeastOne)
            {
                try
                {
                    con.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
                finally
                {
                    con.Close();
                    cmd.Dispose();
                    Global.logEventProject(Convert.ToInt32(Session["UserID"]), logAction, projectID);
                }
            }
            string redirstr = "~/Manager/EditProjectResources.aspx?ProjectID=" + projectID.ToString();

            Response.Redirect(redirstr);
        }
コード例 #2
0
        protected void AddResToProj_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(Global.getConnectionString());
            SqlCommand    cmd = new SqlCommand("INSERT INTO pms_resourceproject (project_id, resource_id) VALUES ", con);
            string        pc = "", seperator = ", ";
            bool          addAtLeastOne = false;
            int           count         = 0;
            int           projectID     = Convert.ToInt32(Request.QueryString["ProjectID"]);
            string        logAction     = "Added resources to project: <br/>";

            foreach (GridViewRow row in GridView1.Rows)
            {
                CheckBox c = (CheckBox)row.FindControl("AddSel");
                if (c != null && c.Checked)
                {
                    count++;
                    string loc = "resid" + count;
                    addAtLeastOne = true;
                    int resourceID = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
                    logAction       += "(ID: " + resourceID + ") " + row.Cells[1].Text + " <br/>";
                    cmd.CommandText += pc;
                    cmd.CommandText += "( " + projectID + ", " + resourceID + ")";
                    pc = seperator;
                }
            }

            if (addAtLeastOne)
            {
                try
                {
                    con.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
                finally
                {
                    con.Close();
                    cmd.Dispose();
                    Global.logEventProject(Convert.ToInt32(Session["UserID"]), logAction, projectID);
                }
            }
            LoadGrid("id", "ASC");
            //string redirstr = "~/Manager/SearchResource.aspx?ProjectID=" + projectID.ToString();
            //Response.Redirect(redirstr);
        }
コード例 #3
0
        protected void submitButton_Click(object sender, EventArgs e)
        {
            string name  = pname.Value.ToString();
            string cus   = cust.SelectedValue.ToString();
            string inds  = ind.SelectedValue.ToString();
            string sdate = start.Value.ToString();
            string edate = end.Value.ToString();
            string sflx  = sflex.Value.ToString();
            string eflx  = eflex.Value.ToString();

            SqlConnection con = new SqlConnection(Global.getConnectionString());
            SqlCommand    cmd = new SqlCommand("INSERT INTO pms_project (name, start_date, end_date, start_date_flex, end_date_flex, customer_id, industry_id, manager_id) VALUES (@name, @start, @end, @sflex, @eflex, @cust, @ind, @mang);", con);

            cmd.Parameters.Add("@name", SqlDbType.VarChar).Value = name;
            cmd.Parameters.Add("@start", SqlDbType.Date).Value   = sdate;
            cmd.Parameters.Add("@end", SqlDbType.Date).Value     = edate;
            cmd.Parameters.Add("@sflex", SqlDbType.Int).Value    = sflx;
            cmd.Parameters.Add("@eflex", SqlDbType.Int).Value    = eflx;
            cmd.Parameters.Add("@cust", SqlDbType.Int).Value     = cus;
            cmd.Parameters.Add("@ind", SqlDbType.Int).Value      = inds;
            cmd.Parameters.Add("@mang", SqlDbType.Int).Value     = Convert.ToInt32(Session["UserID"]);

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                Global.logEventProject(Convert.ToInt32(Session["UserID"]), "Created Project " + "\"" + name + "\"!", 0);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                cmd.Dispose();
                con.Dispose();
                con.Close();
            }

            outputLabel.Visible = true;
        }
コード例 #4
0
        private void logChanges(bool managerChanged, bool nameChanged, bool customerChanged, bool industryChanged, bool startdateChanged, bool enddateChanged, bool startdateflexChanged, bool enddateflexChanged, bool overrideChanged, bool stageChanged, bool stageAuto)
        {
            SqlConnection con = new SqlConnection(Global.getConnectionString());
            string        currentProjectName   = Projectname.Value,
                          currentCustomerID    = DropDownList4.SelectedValue,
                          currentIndustryID    = DropDownList5.SelectedValue,
                          currentStartDate     = Text1.Value,
                          currentManagerID     = DropDownList8.SelectedValue,
                          currentEndDate       = Text5.Value,
                          currentStartDateFlex = Text3.Value,
                          currentEndDateFlex   = Text4.Value,
                          currentProjectStage  = DropDownList9.SelectedValue;
            bool currentStageOverride          = check_StageOverride.Checked;

            string actionLog = "Changed";
            string pre       = " ";
            string separator = " <br/>";

            if (managerChanged)
            {
                try
                {
                    con.Open();

                    SqlCommand cmd = new SqlCommand("SELECT first_name + ' ' + last_name AS [name] FROM pms_user WHERE pms_user.id = @id;", con);
                    cmd.Parameters.Add("@id", SqlDbType.Int).Value = origManagerID;
                    string origmanagerName = (string)cmd.ExecuteScalar();
                    cmd.Dispose();
                    cmd = new SqlCommand("SELECT first_name + ' ' + last_name AS [name] FROM pms_user WHERE pms_user.id = @id;", con);
                    cmd.Parameters.Add("@id", SqlDbType.Int).Value = currentManagerID;
                    string currentmanagerName = (string)cmd.ExecuteScalar();
                    actionLog += pre;
                    actionLog += "Manager from \"" + origmanagerName + "\" to \"" + currentmanagerName + "\"";
                    pre        = separator;
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
                finally
                {
                    con.Close();
                }
            }

            if (nameChanged)
            {
                actionLog += pre;
                actionLog += "Project Name from \"" + origProjectName + "\" to \"" + currentProjectName + "\"";
                pre        = separator;
            }

            if (customerChanged)
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("SELECT name FROM pms_customer WHERE pms_customer.id = @custid;", con);
                    cmd.Parameters.Add("@custid", SqlDbType.Int).Value = origCustomerID;
                    string origcustomerName = (string)cmd.ExecuteScalar();
                    cmd.Dispose();
                    cmd = new SqlCommand("SELECT name FROM pms_customer WHERE pms_customer.id = @custid;", con);
                    cmd.Parameters.Add("@custid", SqlDbType.Int).Value = currentCustomerID;
                    string currentcustomerName = (string)cmd.ExecuteScalar();
                    actionLog += pre;
                    actionLog += "Customer from \"" + origcustomerName + "\" to \"" + currentcustomerName + "\"";
                    pre        = separator;
                }
                catch { }
                finally
                {
                    con.Close();
                }
            }

            if (industryChanged)
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("SELECT name FROM pms_industry WHERE pms_industry.id = @industid;", con);
                    cmd.Parameters.Add("@industid", SqlDbType.Int).Value = origIndustryID;
                    string origindustryName = (string)cmd.ExecuteScalar();
                    cmd.Dispose();
                    cmd = new SqlCommand("SELECT name FROM pms_industry WHERE pms_industry.id = @industid;", con);
                    cmd.Parameters.Add("@industid", SqlDbType.Int).Value = currentIndustryID;
                    string currentindustryName = (string)cmd.ExecuteScalar();
                    actionLog += pre;
                    actionLog += "Industry from \"" + origindustryName + "\" to \"" + currentindustryName + "\"";
                    pre        = separator;
                }
                catch { }
                finally
                {
                    con.Close();
                }
            }

            if (startdateChanged)
            {
                actionLog += pre;
                actionLog += "Start date from \"" + origStartDate + "\" to " + currentStartDate + "\"";
                pre        = separator;
            }

            if (enddateChanged)
            {
                actionLog += pre;
                actionLog += "End date from \"" + origEndDate + "\" to \"" + currentEndDate + "\"";
                pre        = separator;
            }

            if (startdateflexChanged)
            {
                actionLog += pre;
                actionLog += "Start date flexibility from \"" + origStartDateFlex + "\" weeks to \"" + currentStartDateFlex + "\" weeks";
                pre        = separator;
            }

            if (enddateflexChanged)
            {
                actionLog += pre;
                actionLog += "End date flexibility from \"" + origEndDateFlex + "\" weeks to \"" + currentEndDateFlex + "\" weeks";
                pre        = separator;
            }

            if (overrideChanged)
            {
                actionLog += pre;
                actionLog += "Stage override from \"" + origStageOverride + "\" to \"" + currentStageOverride + "\"";
                pre        = separator;
            }

            if (origStageOverride && stageAuto)
            {
                actionLog += pre;
                actionLog += "Stage level checking changed to automatic";
                pre        = separator;
            }
            else if (stageChanged)
            {
                actionLog += pre;
                actionLog += "Stage level changed from \"" + origProjectStage + "\" to \"" + currentProjectStage + "\"";
                pre        = separator;
            }

            Global.logEventProject(Convert.ToInt32(Session["UserID"]), actionLog, Convert.ToInt32(origProjectID));
            //dont forget to check if userid isn't null when clicking button
        }