protected void SaveChanges(object sender, EventArgs e) { if (ddlProjectActNames.SelectedIndex == 0) { RegisterStartupScript("msg", "<script language='javascript'>alert('You must choose a Project to edit')</script>"); } else if(rblStaffTime.SelectedValue == "") { RegisterStartupScript("msg", "<script language='javascript'>alert('You must choose an option for Staff Time')</script>"); } else { Project sProjectValues = new Project(); sProjectValues = new Project(); sProjectValues.Id = Convert.ToInt32(ddlProjectActNames.SelectedValue.ToString()); sProjectValues.ProjectName = ddlProjectActNames.SelectedItem.Text.ToString(); sProjectValues.StaffTime = Convert.ToInt32(rblStaffTime.SelectedValue.ToString()); sProjectValues.NumPartsPrevious = txtNumPartsPrevious.Text.ToString(); sProjectValues.NumPartsCurrent = txtNumPartsCurrent.Text.ToString(); sProjectValues.NumPartsNext = txtNumPartsNext.Text.ToString(); sProjectValues.NetProfitPreviousQ1 = Convert.ToInt32(txtNetProfitPreviousQ1.Text.ToString() == "" ? "0" : txtNetProfitPreviousQ1.Text.ToString()); sProjectValues.NetProfitPreviousQ2 = Convert.ToInt32(txtNetProfitPreviousQ2.Text.ToString() == "" ? "0" : txtNetProfitPreviousQ2.Text.ToString()); sProjectValues.NetProfitPreviousQ3 = Convert.ToInt32(txtNetProfitPreviousQ3.Text.ToString() == "" ? "0" : txtNetProfitPreviousQ3.Text.ToString()); sProjectValues.NetProfitPreviousQ4 = Convert.ToInt32(txtNetProfitPreviousQ4.Text.ToString() == "" ? "0" : txtNetProfitPreviousQ4.Text.ToString()); sProjectValues.NetProfitCurrentQ1 = Convert.ToInt32(txtNetProfitCurrentQ1.Text.ToString() == "" ? "0" : txtNetProfitCurrentQ1.Text.ToString()); sProjectValues.NetProfitCurrentQ2 = Convert.ToInt32(txtNetProfitCurrentQ2.Text.ToString() == "" ? "0" : txtNetProfitCurrentQ2.Text.ToString()); sProjectValues.NetProfitCurrentQ3 = Convert.ToInt32(txtNetProfitCurrentQ3.Text.ToString() == "" ? "0" : txtNetProfitCurrentQ3.Text.ToString()); sProjectValues.NetProfitCurrentQ4 = Convert.ToInt32(txtNetProfitCurrentQ4.Text.ToString() == "" ? "0" : txtNetProfitCurrentQ4.Text.ToString()); sProjectValues.NetProfitNextQ1 = Convert.ToInt32(txtNetProfitNextQ1.Text.ToString() == "" ? "0" : txtNetProfitNextQ1.Text.ToString()); sProjectValues.NetProfitNextQ2 = Convert.ToInt32(txtNetProfitNextQ2.Text.ToString() == "" ? "0" : txtNetProfitNextQ2.Text.ToString()); sProjectValues.NetProfitNextQ3 = Convert.ToInt32(txtNetProfitNextQ3.Text.ToString() == "" ? "0" : txtNetProfitNextQ3.Text.ToString()); sProjectValues.NetProfitNextQ4 = Convert.ToInt32(txtNetProfitNextQ4.Text.ToString() == "" ? "0" : txtNetProfitNextQ4.Text.ToString()); sProjectValues.Impact = taImpact.Value.ToString(); sProjectValues.Comments = taComments.Value.ToString(); ISISLogic iLogic = new ISISLogic(); iLogic.SaveProject(sProjectValues); iLogic = null; Response.Redirect("Default.aspx"); } }
public List<Project> GetAllProjects() { conn = new SqlConnection(ConfigurationManager.AppSettings["ISISConnection"].ToString()); conn.Open(); cmd = new SqlCommand("GetAllProjects", conn); cmd.CommandType = System.Data.CommandType.StoredProcedure; rdr = cmd.ExecuteReader(); List<Project> lstProjectNames = new List<Project>(); Project sProjectValues; while (rdr.Read()) { sProjectValues = new Project(); sProjectValues.Id = Convert.ToInt32(rdr["Id"].ToString()); sProjectValues.ProjectName = rdr["ProjectName"].ToString(); string sStaffTime = ""; switch (rdr["StaffTime"].ToString()) { case "1": sStaffTime = "Low"; break; case "2": sStaffTime = "Mod"; break; case "3": sStaffTime = "High"; break; } sProjectValues.StaffTimeDisplay = sStaffTime; sProjectValues.PreviousYear = (DateTime.Now.Year - 1); sProjectValues.CurrentYear = (DateTime.Now.Year); sProjectValues.NextYear = (DateTime.Now.Year + 1); sProjectValues.NumPartsPrevious = rdr["NumPartsPrevious"].ToString(); sProjectValues.NumPartsCurrent = rdr["NumPartsCurrent"].ToString(); sProjectValues.NumPartsNext = rdr["NumPartsNext"].ToString(); sProjectValues.NetProfitPreviousQ1 = Convert.ToInt32(rdr["NetProfitPreviousQ1"].ToString() == "" ? "0" : rdr["NetProfitPreviousQ1"].ToString()); sProjectValues.NetProfitPreviousQ2 = Convert.ToInt32(rdr["NetProfitPreviousQ2"].ToString() == "" ? "0" : rdr["NetProfitPreviousQ2"].ToString()); sProjectValues.NetProfitPreviousQ3 = Convert.ToInt32(rdr["NetProfitPreviousQ3"].ToString() == "" ? "0" : rdr["NetProfitPreviousQ3"].ToString()); sProjectValues.NetProfitPreviousQ4 = Convert.ToInt32(rdr["NetProfitPreviousQ4"].ToString() == "" ? "0" : rdr["NetProfitPreviousQ4"].ToString()); sProjectValues.NetProfitCurrentQ1 = Convert.ToInt32(rdr["NetProfitCurrentQ1"].ToString() == "" ? "0" : rdr["NetProfitCurrentQ1"].ToString()); sProjectValues.NetProfitCurrentQ2 = Convert.ToInt32(rdr["NetProfitCurrentQ2"].ToString() == "" ? "0" : rdr["NetProfitCurrentQ2"].ToString()); sProjectValues.NetProfitCurrentQ3 = Convert.ToInt32(rdr["NetProfitCurrentQ3"].ToString() == "" ? "0" : rdr["NetProfitCurrentQ3"].ToString()); sProjectValues.NetProfitCurrentQ4 = Convert.ToInt32(rdr["NetProfitCurrentQ4"].ToString() == "" ? "0" : rdr["NetProfitCurrentQ4"].ToString()); sProjectValues.NetProfitNextQ1 = Convert.ToInt32(rdr["NetProfitNextQ1"].ToString() == "" ? "0" : rdr["NetProfitNextQ1"].ToString()); sProjectValues.NetProfitNextQ2 = Convert.ToInt32(rdr["NetProfitNextQ2"].ToString() == "" ? "0" : rdr["NetProfitNextQ2"].ToString()); sProjectValues.NetProfitNextQ3 = Convert.ToInt32(rdr["NetProfitNextQ3"].ToString() == "" ? "0" : rdr["NetProfitNextQ3"].ToString()); sProjectValues.NetProfitNextQ4 = Convert.ToInt32(rdr["NetProfitNextQ4"].ToString() == "" ? "0" : rdr["NetProfitNextQ4"].ToString()); sProjectValues.Impact = rdr["Impact"].ToString(); sProjectValues.Comments = rdr["Comments"].ToString(); lstProjectNames.Add(sProjectValues); } rdr.Close(); conn.Close(); conn.Dispose(); cmd.Dispose(); rdr.Dispose(); conn = null; cmd = null; rdr = null; return lstProjectNames; }
public string SaveProject(Project objProject) { try { string sAllocate = Allocate("STFMProjectInventorySaveProject"); if (sAllocate == "") { cmd.Parameters.Add(new SqlParameter("@Id", objProject.Id)); cmd.Parameters.Add(new SqlParameter("@ProjectName", objProject.ProjectName)); cmd.Parameters.Add(new SqlParameter("@StaffTime", objProject.StaffTime)); cmd.Parameters.Add(new SqlParameter("@NumPartsPrevious", objProject.NumPartsPrevious)); cmd.Parameters.Add(new SqlParameter("@NumPartsCurrent", objProject.NumPartsCurrent)); cmd.Parameters.Add(new SqlParameter("@NumPartsNext", objProject.NumPartsNext)); cmd.Parameters.Add(new SqlParameter("@NetProfitPreviousQ1", objProject.NetProfitPreviousQ1)); cmd.Parameters.Add(new SqlParameter("@NetProfitPreviousQ2", objProject.NetProfitPreviousQ2)); cmd.Parameters.Add(new SqlParameter("@NetProfitPreviousQ3", objProject.NetProfitPreviousQ3)); cmd.Parameters.Add(new SqlParameter("@NetProfitPreviousQ4", objProject.NetProfitPreviousQ4)); cmd.Parameters.Add(new SqlParameter("@NetProfitCurrentQ1", objProject.NetProfitCurrentQ1)); cmd.Parameters.Add(new SqlParameter("@NetProfitCurrentQ2", objProject.NetProfitCurrentQ2)); cmd.Parameters.Add(new SqlParameter("@NetProfitCurrentQ3", objProject.NetProfitCurrentQ3)); cmd.Parameters.Add(new SqlParameter("@NetProfitCurrentQ4", objProject.NetProfitCurrentQ4)); cmd.Parameters.Add(new SqlParameter("@NetProfitNextQ1", objProject.NetProfitNextQ1)); cmd.Parameters.Add(new SqlParameter("@NetProfitNextQ2", objProject.NetProfitNextQ2)); cmd.Parameters.Add(new SqlParameter("@NetProfitNextQ3", objProject.NetProfitNextQ3)); cmd.Parameters.Add(new SqlParameter("@NetProfitNextQ4", objProject.NetProfitNextQ4)); cmd.Parameters.Add(new SqlParameter("@Impact", objProject.Impact)); cmd.Parameters.Add(new SqlParameter("@Comments", objProject.Comments)); cmd.ExecuteNonQuery(); Deallocate(); return ""; } else { Deallocate(); return sAllocate; } } catch (Exception ex) { Deallocate(); return ex.Message.ToString(); } }
public List<Project> GetProjects() { conn = new SqlConnection(ConfigurationManager.AppSettings["ISISConnection"].ToString()); conn.Open(); cmd = new SqlCommand("GetProjects", conn); cmd.CommandType = System.Data.CommandType.StoredProcedure; rdr = cmd.ExecuteReader(); List<Project> lstProjectNames = new List<Project>(); Project sProjectValues = new Project(); sProjectValues.Id = 0; sProjectValues.ProjectName = ""; lstProjectNames.Add(sProjectValues); while (rdr.Read()) { sProjectValues = new Project(); sProjectValues.Id = Convert.ToInt32(rdr["Id"].ToString()); sProjectValues.ProjectName = rdr["ProjectName"].ToString(); lstProjectNames.Add(sProjectValues); } rdr.Close(); conn.Close(); conn.Dispose(); cmd.Dispose(); rdr.Dispose(); conn = null; cmd = null; rdr = null; return lstProjectNames; }
public Project GetProject(int iId) { conn = new SqlConnection(ConfigurationManager.AppSettings["ISISConnection"].ToString()); conn.Open(); cmd = new SqlCommand("GetProject", conn); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@Id", iId)); rdr = cmd.ExecuteReader(); List<Project> lstProjectNames = new List<Project>(); Project sProjectValues = new Project(); //sProjectValues.Id = 0; //sProjectValues.ProjectName = ""; //lstProjectNames.Add(sProjectValues); while (rdr.Read()) { sProjectValues = new Project(); sProjectValues.Id = Convert.ToInt32(rdr["Id"].ToString()); sProjectValues.ProjectName = rdr["ProjectName"].ToString(); sProjectValues.StaffTime = Convert.ToInt32(rdr["StaffTime"].ToString() == "" ? "0" : rdr["StaffTime"].ToString()); sProjectValues.NumPartsPrevious = rdr["NumPartsPrevious"].ToString(); sProjectValues.NumPartsCurrent = rdr["NumPartsCurrent"].ToString(); sProjectValues.NumPartsNext = rdr["NumPartsNext"].ToString(); sProjectValues.NetProfitPreviousQ1 = rdr["NetProfitPreviousQ1"].ToString() == "" ? 0 : Convert.ToInt32(rdr["NetProfitPreviousQ1"].ToString()); sProjectValues.NetProfitPreviousQ2 = rdr["NetProfitPreviousQ2"].ToString() == "" ? 0 : Convert.ToInt32(rdr["NetProfitPreviousQ2"].ToString()); sProjectValues.NetProfitPreviousQ3 = rdr["NetProfitPreviousQ3"].ToString() == "" ? 0 : Convert.ToInt32(rdr["NetProfitPreviousQ3"].ToString()); sProjectValues.NetProfitPreviousQ4 = rdr["NetProfitPreviousQ4"].ToString() == "" ? 0 : Convert.ToInt32(rdr["NetProfitPreviousQ4"].ToString()); sProjectValues.NetProfitCurrentQ1 = rdr["NetProfitCurrentQ1"].ToString() == "" ? 0 : Convert.ToInt32(rdr["NetProfitCurrentQ1"].ToString()); sProjectValues.NetProfitCurrentQ2 = rdr["NetProfitCurrentQ2"].ToString() == "" ? 0 : Convert.ToInt32(rdr["NetProfitCurrentQ2"].ToString()); sProjectValues.NetProfitCurrentQ3 = rdr["NetProfitCurrentQ3"].ToString() == "" ? 0 : Convert.ToInt32(rdr["NetProfitCurrentQ3"].ToString()); sProjectValues.NetProfitCurrentQ4 = rdr["NetProfitCurrentQ4"].ToString() == "" ? 0 : Convert.ToInt32(rdr["NetProfitCurrentQ4"].ToString()); sProjectValues.NetProfitNextQ1 = rdr["NetProfitNextQ1"].ToString() == "" ? 0 : Convert.ToInt32(rdr["NetProfitNextQ1"].ToString()); sProjectValues.NetProfitNextQ2 = rdr["NetProfitNextQ2"].ToString() == "" ? 0 : Convert.ToInt32(rdr["NetProfitNextQ2"].ToString()); sProjectValues.NetProfitNextQ3 = rdr["NetProfitNextQ3"].ToString() == "" ? 0 : Convert.ToInt32(rdr["NetProfitNextQ3"].ToString()); sProjectValues.NetProfitNextQ4 = rdr["NetProfitNextQ4"].ToString() == "" ? 0 : Convert.ToInt32(rdr["NetProfitNextQ4"].ToString()); sProjectValues.Impact = rdr["Impact"].ToString(); sProjectValues.Comments = rdr["Comments"].ToString(); //lstProjectNames.Add(sProjectValues); } rdr.Close(); conn.Close(); conn.Dispose(); cmd.Dispose(); rdr.Dispose(); conn = null; cmd = null; rdr = null; return sProjectValues; // lstProjectNames; }
public void SaveProject(Project objProject) { ISISData iData = new ISISData(); iData.SaveProject(objProject); iData = null; }