protected void btnLogin_Click(object sender, System.EventArgs e) { string strSQL = ""; clsGeneral General = new clsGeneral(); if (!ValidateForm()) return; //Validate Account Exists strSQL = "SELECT tblUsers.UserLevel, tblUsers.EmployeeID, tblEmployees.EmployeeFirst, tblEmployees.EmployeeLast "; strSQL += "FROM tblEmployees INNER JOIN "; strSQL += "tblUsers ON tblEmployees.EmployeeID = tblUsers.EmployeeID "; strSQL += "WHERE (tblUsers.UserName = '******') "; strSQL += "AND (tblUsers.Password = '******') "; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { Session["UserLevel"] = dt.Rows[0]["UserLevel"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["UserLevel"], ""); Session["EmployeeID"] = dt.Rows[0]["EmployeeID"].GetValueOrDefault<int>(); Session["UserName"] = dt.Rows[0]["EmployeeFirst"].GetValueOrDefault<string>() + " " + dt.Rows[0]["EmployeeLast"].GetValueOrDefault<string>(); } else { lblError.Text = "Invalid login."; lblError.Visible = true; } ds.Dispose(); ds = null; dt.Dispose(); dt = null; if (cbRememberMe.Checked) { Response.Cookies["KPFFAuthorization"]["Login"] = txtUserName.Text; Response.Cookies["KPFFAuthorization"]["Password"] = txtPassword.Text; Response.Cookies["KPFFAuthorization"].Expires = DateTime.Now.AddDays(10); } else { Response.Cookies["KPFFAuthorization"].Expires = DateTime.Now.AddDays(-1); } if (Session["UserLevel"].GetValueOrDefault<string>() == "Admin") { Response.Redirect("MyAdmin/Clients.aspx"); } else if (Session["UserLevel"].GetValueOrDefault<string>() == "User") { Response.Redirect("MyAccount/MyProjects.aspx"); } }
private void AddUpdateUser(int intEmployeeID) { clsGeneral General = new clsGeneral(); bool blnUserExists = false; //Check to see if User Account Exists strSQL = "SELECT ID "; strSQL += "FROM tblUsers "; strSQL += "WHERE EmployeeID = " + intEmployeeID; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { blnUserExists = true; } else { blnUserExists = false; } ds.Dispose(); ds = null; dt.Dispose(); dt = null; if (blnUserExists == true) { strSQL = "UPDATE tblUsers "; strSQL += "SET "; strSQL += "UserName = '******', "; strSQL += "Password = '******' "; strSQL += "WHERE EmployeeID = " + intEmployeeID; General.UpdateRecord(strSQL); } else { strSQL = "INSERT INTO tblUsers "; strSQL += "(UserName, Password, UserLevel, EmployeeID) "; strSQL += "VALUES ( "; strSQL += "'" + txtUserName.Text + "', "; strSQL += "'" + txtPassword.Text + "', "; strSQL += "'User', "; strSQL += intEmployeeID + ")"; General.AddRecord(strSQL); } }
private void PopulateEmployeeType() { int intUserID = Convert.ToInt32(Request.Params["UserID"]); string strSQL = ""; clsGeneral General = new clsGeneral(); strSQL = "SELECT * "; strSQL += "FROM tblEmployeeTypes "; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; DataView dv = new DataView(dt); cboEmployeeType.DataTextField = "EmployeeType"; cboEmployeeType.DataValueField = "id"; cboEmployeeType.DataSource = dv; cboEmployeeType.DataBind(); }
private void PopulateForm() { int intEmployeeId = Convert.ToInt32(Request.Params["EmployeeId"]); string strSQL = ""; clsGeneral General = new clsGeneral(); intEmployeeId = 1; strSQL = "SELECT * "; strSQL += "FROM tblEmployees "; strSQL += "WHERE EmployeeID = " + intEmployeeId; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { txtEmployeeName.Text = dt.Rows[0]["EmployeeName"].GetValueOrDefault<string>(); cboEmployeeType.Items.FindByText(dt.Rows[0]["EmployeeType"].GetValueOrDefault<string>()).Selected = true; txtAddress.Text = dt.Rows[0]["Address"].GetValueOrDefault<string>(); txtCity.Text = dt.Rows[0]["City"].GetValueOrDefault<string>(); if (!string.IsNullOrEmpty(dt.Rows[0]["State"].GetValueOrDefault<string>())) { cboState.Items.FindByText(dt.Rows[0]["State"].GetValueOrDefault<string>()).Selected = true; } txtZip.Text = dt.Rows[0]["Zip"].GetValueOrDefault<string>(); txtHomePhone.Text = dt.Rows[0]["HomePhone"].GetValueOrDefault<string>(); txtCellPhone.Text = dt.Rows[0]["CellPhone"].GetValueOrDefault<string>(); txtComments.Text = dt.Rows[0]["Comments"].GetValueOrDefault<string>(); //rbtnList.Text = Zz(dt.Rows[0]["EmployeeName"), "") } else { lblError.Text = "Employee does not exist."; lblError.Visible = true; } dt.Dispose(); ds.Dispose(); dt = null; ds = null; }
private void PopulateCombos() { string strSQL = ""; clsGeneral General = new clsGeneral(); strSQL = "SELECT * FROM tblClientTypes "; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; DataView dv = dt.DefaultView; dv.Sort = "ID"; cboClientType.DataSource = dv; cboClientType.DataTextField = "ClientType"; cboClientType.DataValueField = "ID"; cboClientType.DataBind(); dt.Dispose(); dt = null; ds.Dispose(); ds = null; }
public object GetTotalRecords() { int intTotalRecords = 0; clsGeneral General = new clsGeneral(); string strSQL = ""; strSQL = "SELECT tblEmployees.EmployeeID "; strSQL += "FROM tblEmployees LEFT OUTER JOIN tblEmployeeTypes ON tblEmployees.EmployeeTypeID = tblEmployeeTypes.ID "; strSQL += "ORDER BY tblEmployees.EmployeeCode"; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; intTotalRecords = dt.Rows.Count; ds.Dispose(); ds = null; dt.Dispose(); dt = null; return intTotalRecords; }
private void PopulateForm(int intClientID) { string strSQL = ""; clsGeneral General = new clsGeneral(); strSQL = "SELECT * FROM tblClients "; strSQL += "WHERE ID = " + intClientID; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { txtClientName.Text = dt.Rows[0]["ClientName"].GetValueOrDefault<string>(); cboClientType.SelectedValue = dt.Rows[0]["ClientTypeID"].GetValueOrDefault<int>().ToString(); txtAddress.Text = dt.Rows[0]["Address"].GetValueOrDefault<string>(); txtCity.Text = dt.Rows[0]["City"].GetValueOrDefault<string>(); txtState.Text = dt.Rows[0]["State"].GetValueOrDefault<string>(); txtZip.Text = dt.Rows[0]["Zip"].GetValueOrDefault<string>(); txtOfficePhone.Text = dt.Rows[0]["OfficePhone"].GetValueOrDefault<string>(); txtFax.Text = dt.Rows[0]["Fax"].GetValueOrDefault<string>(); txtComments.Text = dt.Rows[0]["Comments"].GetValueOrDefault<string>(); } }
private void PopulateUser(int intEmployeeID) { clsGeneral General = new clsGeneral(); strSQL = "SELECT UserName, Password "; strSQL += "FROM tblUsers "; strSQL += "WHERE EmployeeID = " + intEmployeeID; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { rbtnUserNo.Checked = false; rbtnUserYes.Checked = true; pnlUserAccount.Visible = true; txtUserName.Text = dt.Rows[0]["Username"].GetValueOrDefault<string>(); txtPassword.Text = dt.Rows[0]["Password"].GetValueOrDefault<string>(); } else { rbtnUserNo.Checked = true; rbtnUserYes.Checked = false; pnlUserAccount.Visible = false; } }
// private void PopulateForm(int intEmployeeID) { string strSQL = ""; clsGeneral General = new clsGeneral(); strSQL = "SELECT * "; strSQL += "FROM tblEmployees "; strSQL += "WHERE EmployeeID = " + intEmployeeID; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { lblName.Text = dt.Rows[0]["EmployeeFirst"].GetValueOrDefault<string>() + " " + dt.Rows[0]["EmployeeLast"].GetValueOrDefault<string>(); } ds.Dispose(); ds = null; dt.Dispose(); dt = null; }
private void PopulateForm(int intProjectID) { string strSQL = ""; clsGeneral General = new clsGeneral(); strSQL = "SELECT tblProjects.*, tblPhase.Phase, tblClients.ClientName "; strSQL += "FROM tblPhase RIGHT OUTER JOIN "; strSQL += "tblProjects ON tblPhase.ID = tblProjects.PhaseID LEFT OUTER JOIN "; strSQL += "tblClients ON tblProjects.ClientID = tblClients.ID "; strSQL += "WHERE (tblProjects.ID = " + intProjectID + ")"; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { txtProjectName.Text = dt.Rows[0]["ProjectName"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["ProjectName"], ""); txtProjectNo.Text = dt.Rows[0]["ProjectNo"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["ProjectNo"], ""); lblProjectNo.Text = dt.Rows[0]["ProjectNo"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["ProjectNo"], ""); if (dt.Rows[0]["PM1"] != DBNull.Value) //object.ReferenceEquals(dt.Rows[0]["PM1"], DBNull.Value))) { cboPM.SelectedValue = dt.Rows[0]["PM1"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["PM1"], 0); } if (dt.Rows[0]["PIC"] != DBNull.Value) //(!object.ReferenceEquals(dt.Rows[0]["PIC"], DBNull.Value))) { cboPIC.SelectedValue = dt.Rows[0]["PIC"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["PIC"], 0); } cboClientName.SelectedValue = dt.Rows[0]["ClientID"].GetValueOrDefault<int>().ToString(); // basToolbox.Nz(dt.Rows[0]["ClientID"], 1); txtProjectLocation.Text = dt.Rows[0]["ProjectLocation"].GetValueOrDefault<string>();// basToolbox.Nz(dt.Rows[0]["ProjectLocation"], ""); txtConstructionType.Text = dt.Rows[0]["ConstructionType"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["ConstructionType"], ""); txtProjectType.Text = dt.Rows[0]["ProjectType"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["ProjectType"], ""); cboPhase.SelectedValue = dt.Rows[0]["PhaseID"].GetValueOrDefault<int>().ToString(); // basToolbox.Nz(dt.Rows[0]["PhaseID"], 1); var estStartOfConstruction = dt.Rows[0]["EstimatedStartDate"].GetValueOrDefault<DateTime>(); var estCompletionOfConstruction = dt.Rows[0]["EstimatedCompletionDate"].GetValueOrDefault<DateTime>(); if (estStartOfConstruction != null && estStartOfConstruction != DateTime.MinValue) { txtEstStartOfConstruction.Text = estStartOfConstruction.ToShortDateString(); // basToolbox.Nz(dt.Rows[0]["EstimatedStartDate"], ""); } if (estCompletionOfConstruction != null && estCompletionOfConstruction != DateTime.MinValue) { txtEstCompletionOfConstruction.Text = estCompletionOfConstruction.ToShortDateString(); // basToolbox.Nz(dt.Rows[0]["EstimatedCompletionDate"], ""); } txtFeeAmount.Text = dt.Rows[0]["FeeAmount"].GetValueOrDefault<decimal>().ToString("C"); // Strings.FormatNumber(basToolbox.Nz(dt.Rows[0]["FeeAmount"], 0), 2); if (dt.Rows[0]["FeeStructure"] != DBNull.Value) // object.ReferenceEquals(dt.Rows[0]["FeeStructure"], DBNull.Value)) { cboFeeStructure.SelectedValue = dt.Rows[0]["FeeStructure"].GetValueOrDefault<int>().ToString(); // basToolbox.Nz(dt.Rows[0]["FeeStructure"], 1); } txtRemarks.Text = dt.Rows[0]["Comments"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["Comments"], ""); } }
private void PopulateCombos() { string strSQL = ""; clsGeneral General = new clsGeneral(); DataRow dtRow = default(DataRow); //Populate Client Combo strSQL = "SELECT ID, ClientName "; strSQL += "FROM tblClients"; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; DataView dv = dt.DefaultView; dv.Sort = "ClientName"; cboClientName.DataSource = dv; cboClientName.DataTextField = "ClientName"; cboClientName.DataValueField = "ID"; cboClientName.DataBind(); //Populate Phase Combo strSQL = "SELECT ID, Phase "; strSQL += "FROM tblPhase "; strSQL += "ORDER BY Sequence"; ds = new DataSet(); ds = General.FillDataset(strSQL); dt = new DataTable(); dt = ds.Tables[0]; dv = new DataView(); dv = dt.DefaultView; cboPhase.DataSource = dv; cboPhase.DataTextField = "Phase"; cboPhase.DataValueField = "ID"; cboPhase.DataBind(); //Populate Fee Structure Combo strSQL = "SELECT FeeStructureType "; strSQL += "FROM tblFeeStructures "; strSQL += "ORDER BY Sequence"; ds = new DataSet(); ds = General.FillDataset(strSQL); dt = new DataTable(); dt = ds.Tables[0]; dv = new DataView(); dv = dt.DefaultView; cboFeeStructure.DataSource = dv; cboFeeStructure.DataTextField = "FeeStructureType"; cboFeeStructure.DataValueField = "FeeStructureType"; cboFeeStructure.DataBind(); //Populate PIC Combo strSQL = "SELECT EmployeeID, EmployeeName "; strSQL += "FROM tblEmployees "; strSQL += "ORDER BY EmployeeName"; ds = new DataSet(); ds = General.FillDataset(strSQL); dt = new DataTable(); dt = ds.Tables[0]; dtRow = dt.NewRow(); dtRow[0] = 0; dtRow[1] = ""; dt.Rows.Add(dtRow); dv = new DataView(); dv = dt.DefaultView; dv.Sort = "EmployeeName"; cboPIC.DataSource = dv; cboPIC.DataTextField = "EmployeeName"; cboPIC.DataValueField = "EmployeeID"; cboPIC.DataBind(); //Populate PM Combo strSQL = "SELECT EmployeeID, EmployeeName "; strSQL += "FROM tblEmployees "; strSQL += "ORDER BY EmployeeName"; ds = new DataSet(); ds = General.FillDataset(strSQL); dt = new DataTable(); dt = ds.Tables[0]; dtRow = dt.NewRow(); dtRow[0] = 0; dtRow[1] = ""; dt.Rows.Add(dtRow); dv = new DataView(); dv = dt.DefaultView; dv.Sort = "EmployeeName"; cboPM.DataSource = dv; cboPM.DataTextField = "EmployeeName"; cboPM.DataValueField = "EmployeeID"; cboPM.DataBind(); dt.Dispose(); dt = null; ds.Dispose(); ds = null; }
private bool ValidateForm() { System.DateTime dtmDateTimeUS = default(System.DateTime); System.Globalization.CultureInfo format = new System.Globalization.CultureInfo("en-US", true); if (string.IsNullOrEmpty(txtProjectName.Text)) { lblError.Text = "Please enter project name."; lblError.Visible = true; return false; } if (string.IsNullOrEmpty(txtProjectNo.Text)) { lblError.Text = "Please enter project number."; lblError.Visible = true; return false; } if (txtProjectNo.Text != lblProjectNo.Text) { //Check Dupe Job # string strSQL = ""; clsGeneral General = new clsGeneral(); strSQL = "SELECT ID FROM tblProjects "; strSQL += "WHERE ProjectNo = '" + txtProjectNo.Text + "'"; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { lblError.Text = "Project number already exists."; lblError.Visible = true; return false; } } if (string.IsNullOrEmpty(cboClientName.SelectedItem.Text)) { lblError.Text = "Please select a client."; lblError.Visible = true; return false; } if (!string.IsNullOrEmpty(txtEstStartOfConstruction.Text)) { try { dtmDateTimeUS = System.DateTime.Parse(txtEstStartOfConstruction.Text, format); } catch (Exception ex) { lblError.Text = "Please enter a valid start of construction date - ex: mm/dd/yyyy."; lblError.Visible = true; return false; } } if (!string.IsNullOrEmpty(txtEstCompletionOfConstruction.Text)) { try { dtmDateTimeUS = System.DateTime.Parse(txtEstCompletionOfConstruction.Text, format); } catch (Exception ex) { lblError.Text = "Please enter a valid completion of construction date - ex: mm/dd/yyyy."; lblError.Visible = true; return false; } } lblError.Text = ""; lblError.Visible = false; return true; }
private void PopulateForm(int intProjectID) { string strSQL = ""; clsGeneral General = new clsGeneral(); strSQL = "SELECT tblProjects.*, tblPhase.Phase, tblClients.ClientName "; strSQL += "FROM tblPhase RIGHT OUTER JOIN "; strSQL += "tblProjects ON tblPhase.ID = tblProjects.PhaseID LEFT OUTER JOIN "; strSQL += "tblClients ON tblProjects.ClientID = tblClients.ID "; strSQL += "WHERE (tblProjects.ID = " + intProjectID + ")"; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { txtProjectName.Text = dt.Rows[0]["ProjectName"].GetValueOrDefault<string>(); txtProjectNo.Text = dt.Rows[0]["ProjectNo"].GetValueOrDefault<string>(); lblProjectNo.Text = dt.Rows[0]["ProjectNo"].GetValueOrDefault<string>(); if (!string.IsNullOrEmpty(dt.Rows[0]["PM1"].GetValueOrDefault<string>())) { cboPM.SelectedValue = dt.Rows[0]["PM1"].GetValueOrDefault<string>(); } if (!string.IsNullOrEmpty(dt.Rows[0]["PIC"].GetValueOrDefault<string>())) { cboPIC.SelectedValue = dt.Rows[0]["PIC"].GetValueOrDefault<string>(); } cboClientName.SelectedValue = dt.Rows[0]["ClientID"].GetValueOrDefault<string>(); txtProjectLocation.Text = dt.Rows[0]["ProjectLocation"].GetValueOrDefault<string>(); txtConstructionType.Text = dt.Rows[0]["ConstructionType"].GetValueOrDefault<string>(); txtProjectType.Text = dt.Rows[0]["ProjectType"].GetValueOrDefault<string>(); cboPhase.SelectedValue = dt.Rows[0]["PhaseID"].GetValueOrDefault<string>(); txtEstStartOfConstruction.Text = dt.Rows[0]["EstimatedStartDate"].GetValueOrDefault<string>(); txtEstCompletionOfConstruction.Text = dt.Rows[0]["EstimatedCompletionDate"].GetValueOrDefault<string>(); txtFeeAmount.Text = dt.Rows[0]["FeeAmount"].GetValueOrDefault<decimal>().ToString("c"); if (string.IsNullOrEmpty(dt.Rows[0]["FeeStructure"].GetValueOrDefault<string>())) { } else { cboFeeStructure.SelectedValue = dt.Rows[0]["FeeStructure"].GetValueOrDefault<string>(); } txtRemarks.Text = dt.Rows[0]["Comments"].GetValueOrDefault<string>(); } }
// private void PopulateForm(int intProjectID) { string strSQL = ""; clsGeneral General = new clsGeneral(); strSQL = "SELECT tblProjects.ProjectNo, tblProjects.ProjectName "; strSQL += "FROM tblProjects "; strSQL += "WHERE (tblProjects.ID = " + intProjectID + ")"; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { this.lblProjectNo.Text = dt.Rows[0]["ProjectNo"].GetValueOrDefault<string>(); this.lblProjectName.Text = dt.Rows[0]["ProjectName"].GetValueOrDefault<string>(); } }
private void UpdateProject(int intProjectID) { string strSQL = ""; clsGeneral General = new clsGeneral(); clsSchedule Schedule = new clsSchedule(); if (intProjectID == 0) return; strSQL = "UPDATE tblProjects "; strSQL += "SET ProjectName = '" + txtProjectName.Text + "', "; strSQL += "ProjectNo = '" + txtProjectNo.Text + "', "; strSQL += "ClientID = " + Convert.ToInt32(cboClientName.SelectedValue) + ", "; strSQL += "ProjectLocation = '" + txtProjectLocation.Text + "', "; strSQL += "ConstructionType = '" + txtConstructionType.Text + "', "; strSQL += "ProjectType = '" + txtProjectType.Text + "', "; strSQL += "PhaseID = " + Convert.ToInt32(cboPhase.SelectedValue) + ", "; if (!string.IsNullOrEmpty(txtEstStartOfConstruction.Text)) { strSQL += "EstimatedStartDate = '" + txtEstStartOfConstruction.Text + "', "; } else { strSQL += "EstimatedStartDate = NULL, "; } if (!string.IsNullOrEmpty(txtEstCompletionOfConstruction.Text)) { strSQL += "EstimatedCompletionDate = '" + txtEstCompletionOfConstruction.Text + "', "; } else { strSQL += "EstimatedCompletionDate = NULL, "; } if (!string.IsNullOrEmpty(txtFeeAmount.Text)) { decimal feeAmount = 0; decimal.TryParse(txtFeeAmount.Text.Replace("$", "").Replace(",", ""), out feeAmount); strSQL += "FeeAmount = " + feeAmount.ToString() + ", "; } else { strSQL += "FeeAmount = NULL, "; } strSQL += "FeeStructure = '" + cboFeeStructure.SelectedValue + "', "; if (Convert.ToInt32(cboPIC.SelectedValue) != 0) { strSQL += "PIC = " + cboPIC.SelectedValue + ", "; strSQL += "PICCode = '" + Schedule.GetEmployeeCode(Convert.ToInt32(cboPIC.SelectedValue)) + "', "; } else { strSQL += "PIC = NULL, "; strSQL += "PICCode = NULL, "; } if (Convert.ToInt32(cboPM.SelectedValue) != 0) { strSQL += "PM1 = " + cboPM.SelectedValue + ", "; strSQL += "PM1Code = '" + Schedule.GetEmployeeCode(Convert.ToInt32(cboPM.SelectedValue)) + "', "; } else { strSQL += "PM1 = NULL, "; strSQL += "PM1Code = NULL, "; } strSQL += "Comments = '" + txtRemarks.Text + "' "; strSQL += "WHERE ID = " + intProjectID; General.FillDataset(strSQL); }
private void PopulateEmployee(System.Object intEmployeeID) { clsGeneral General = new clsGeneral(); strSQL = "SELECT * FROM tblEmployees "; strSQL += "WHERE EmployeeID = " + intEmployeeID; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { txtEmployeeCode.Text = dt.Rows[0]["EmployeeCode"].GetValueOrDefault<string>(); txtFirstName.Text = dt.Rows[0]["EmployeeFirst"].GetValueOrDefault<string>(); txtLastName.Text = dt.Rows[0]["EmployeeLast"].GetValueOrDefault<string>(); cboEmployeeType.SelectedValue = dt.Rows[0]["EmployeeTypeID"].GetValueOrDefault<int>().ToString(); txtAddress.Text = dt.Rows[0]["Address"].GetValueOrDefault<string>(); txtCity.Text = dt.Rows[0]["City"].GetValueOrDefault<string>(); txtState.Text = dt.Rows[0]["State"].GetValueOrDefault<string>(); txtZip.Text = dt.Rows[0]["Zip"].GetValueOrDefault<string>(); txtHomePhone.Text = dt.Rows[0]["HomePhone"].GetValueOrDefault<string>(); txtCellPhone.Text = dt.Rows[0]["CellPhone"].GetValueOrDefault<string>(); txtPhoneExtension.Text = dt.Rows[0]["PhoneExtension"].GetValueOrDefault<string>(); txtEmail.Text = dt.Rows[0]["EmailAddress"].GetValueOrDefault<string>(); txtTitle.Text = dt.Rows[0]["Title"].GetValueOrDefault<string>(); txtEmployeeStartDate.Text = dt.Rows[0]["EmploymentStartDate"].GetValueOrDefault<string>(); txtEmployeeEndDate.Text = dt.Rows[0]["EmploymentEndDate"].GetValueOrDefault<string>(); txtYearsOfExperience.Text = dt.Rows[0]["YearsOfExperience"].GetValueOrDefault<string>(); txtEducation.Text = dt.Rows[0]["Education"].GetValueOrDefault<string>(); txtLicenses.Text = dt.Rows[0]["Licenses"].GetValueOrDefault<string>(); txtProfMemberships.Text = dt.Rows[0]["ProfessionalMemberships"].GetValueOrDefault<string>(); txtProfCommittees.Text = dt.Rows[0]["ProfessionalCommittees"].GetValueOrDefault<string>(); txtHoursPerWeek.Text = dt.Rows[0]["HoursPerWeek"].GetValueOrDefault<decimal>().ToString(); txtComments.Text = dt.Rows[0]["Comments"].GetValueOrDefault<string>(); if (dt.Rows[0]["Active"].GetValueOrDefault<int>() == 0) { rbtnActiveEmployeeNo.Checked = true; rbtnActiveEmployeeYes.Checked = false; } else { rbtnActiveEmployeeYes.Checked = true; rbtnActiveEmployeeNo.Checked = false; } if (dt.Rows[0]["PMFiscalSummary"].GetValueOrDefault<bool>() == true) { pmFiscalSummary.Checked = true; } if (dt.Rows[0]["PICFiscalSummary"].GetValueOrDefault<bool>() == true) { picFiscalSummary.Checked = true; } } dt.Dispose(); dt = null; ds.Dispose(); ds = null; }
private void PopulateForm() { string strSQL = ""; clsGeneral General = new clsGeneral(); strSQL = "SELECT tblProjects.*, tblPhase.Phase, tblClients.ClientName, "; strSQL += "(select MAX(LastModifiedDate) from tblSchedule s where s.ProjectID = tblProjects.ID) as LastModified,"; strSQL += "(select distinct EmployeeName from tblEmployees e inner join tblSchedule s on s.LastModifiedByUserID = e.EmployeeID where s.ProjectID = tblProjects.ID and s.LastModifiedDate = (select MAX(LastModifiedDate) from tblSchedule ss where ss.ProjectID = tblProjects.ID)) as LastModifiedBy "; strSQL += "FROM tblPhase RIGHT OUTER JOIN "; strSQL += "tblProjects ON tblPhase.ID = tblProjects.PhaseID LEFT OUTER JOIN "; strSQL += "tblClients ON tblProjects.ClientID = tblClients.ID "; strSQL += "WHERE (tblProjects.ID = " + SelectedProjectID + ")"; DataSet ds = General.FillDataset(strSQL); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { lblProjectName.Text = dt.Rows[0]["ProjectName"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["ProjectName"], ""); lblProjectNo.Text = dt.Rows[0]["ProjectNo"].GetValueOrDefault<string>(); //basToolbox.Nz(dt.Rows[0]["ProjectNo"], ""); lblPIC.Text = dt.Rows[0]["PICCode"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["PICCode"], ""); lblPM.Text = dt.Rows[0]["PM1Code"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["PM1Code"], ""); lblClientName.Text = dt.Rows[0]["ClientName"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["ClientName"], ""); lblProjectLocation.Text = dt.Rows[0]["ProjectLocation"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["ProjectLocation"], ""); lblConstructionType.Text = dt.Rows[0]["ConstructionType"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["ConstructionType"], ""); lblProjectType.Text = dt.Rows[0]["ProjectType"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["ProjectType"], ""); lblPhase.Text = dt.Rows[0]["Phase"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["Phase"], ""); var estStartOfConstruction = dt.Rows[0]["EstimatedStartDate"].GetValueOrDefault<DateTime>(); if (estStartOfConstruction != null && estStartOfConstruction != DateTime.MinValue) { lblEstStartOfConstruction.Text = estStartOfConstruction.ToShortDateString(); // basToolbox.Nz(dt.Rows[0]["EstimatedStartDate"], ""); } var estCompletionOfConstruction = dt.Rows[0]["EstimatedCompletionDate"].GetValueOrDefault<DateTime>(); if (estCompletionOfConstruction != null && estCompletionOfConstruction != DateTime.MinValue) { lblEstCompletionOfConstruction.Text = estCompletionOfConstruction.ToShortDateString(); // basToolbox.Nz(dt.Rows[0]["EstimatedCompletionDate"], ""); } lblFeeAmount.Text = dt.Rows[0]["FeeAmount"].GetValueOrDefault<decimal>().ToString("C"); // Strings.FormatNumber(basToolbox.Nz(dt.Rows[0]["FeeAmount"], 0), 2); lblFeeStructure.Text = dt.Rows[0]["FeeStructure"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["FeeStructure"], ""); lblRemarks.Text = dt.Rows[0]["Comments"].GetValueOrDefault<string>(); // basToolbox.Nz(dt.Rows[0]["Comments"], ""); var lastModifiedDate = dt.Rows[0]["LastModified"].GetValueOrDefault<DateTime>(); if (lastModifiedDate != null && lastModifiedDate != DateTime.MinValue) { lblLastUpdated.Text = string.Format("{0} by {1}", lastModifiedDate.ToShortDateString(), dt.Rows[0]["LastModifiedBy"].GetValueOrDefault<string>()); // basToolbox.Nz(dt.Rows[0]["LastModified"], ""), basToolbox.Nz(dt.Rows[0]["LastModifiedBy"], "")); } } }