//reader for Edit private clsEntProjectDetails readForEdit(int Id, string projectNo) { clsEntProjectDetails objEnt = new clsEntProjectDetails(); objProjDtls = new ProjectDeatils(); objEnt = objProjDtls.readInfo(Id, projectNo); return(objEnt); }
protected void btnUpdate_Click(object sender, EventArgs e) { clsEntProjectDetails objEnt = new clsEntProjectDetails(); if (projectMaster_ID == null) { if (checkDate == true) { objEnt = this.readForEdit(0, txtProjectNo.Text); string projID = objEnt.ProjectID.ToString(); this.updateProject(projID); lblMessage.Text = "Information Successfully Updated"; ObjUtility.ResetFormControl(pageDiv); } } else { this.updateProject(projectMaster_ID); lblMessage.Text = "Information Successfully Updated"; ObjUtility.ResetFormControl(pageDiv); } }
//Fill All infor private void fillAllInfo(string projID, string projNo) { clsEntProjectDetails objEnt = new clsEntProjectDetails(); //Edit Function if (projID != null) { objEnt = this.readForEdit(Convert.ToInt32(projectMaster_ID), null); if (objEnt.ProjectID != null) { lblMessage.Text = "Information Available in Database"; //start Date if (objEnt.dtStartDate.ToString() == "") { txtStartDate.Text = ""; } else { DateTime dtStartDate = DateTime.Parse(objEnt.dtStartDate.ToString()); txtStartDate.Text = dtStartDate.ToString("dd MMM yyyy"); } //End Date if (objEnt.dtEndDate.ToString() == "") { txtEndDate.Text = ""; } else { DateTime dtEndDate = DateTime.Parse(objEnt.dtEndDate.ToString()); txtEndDate.Text = dtEndDate.ToString("dd MMM yyyy"); } txtProjectNo.Text = objEnt.projectNumber; txtProjectName.Text = objEnt.projectNameMaster; int agencyId = objEnt.agencyID; if (agencyId == 0) { drpAgency.SelectedIndex = 0; } else { drpAgency.SelectedValue = agencyId.ToString(); } string docId = objEnt.docCatID; if (docId == "") { drpDocCat.SelectedIndex = 0; } else { drpDocCat.SelectedValue = docId; } } else { lblMessage.Text = string.Empty; btnSubmit.Visible = true; btnUpdate.Visible = false; } } //Update Function if (projNo != null) { objEnt = this.readForEdit(0, txtProjectNo.Text); //start Date if (objEnt.projectNumber != null) { lblMessage.Text = "Information Available in Database"; if (objEnt.dtStartDate.ToString() == "") { txtStartDate.Text = ""; } else { DateTime dtStartDate = DateTime.Parse(objEnt.dtStartDate.ToString()); txtStartDate.Text = dtStartDate.ToString("dd MMM yyyy"); } //End Date if (objEnt.dtEndDate.ToString() == "") { txtEndDate.Text = ""; } else { DateTime dtEndDate = DateTime.Parse(objEnt.dtEndDate.ToString()); txtEndDate.Text = dtEndDate.ToString("dd MMM yyyy"); } txtProjectNo.Text = objEnt.projectNumber; txtProjectName.Text = objEnt.projectNameMaster; //Agency ID int agencyId = objEnt.agencyID; if (agencyId == 0) { drpAgency.SelectedIndex = 0; } else { drpAgency.SelectedValue = agencyId.ToString(); } //Category Details string docId = objEnt.docCatID.ToString(); if (docId == "") { drpDocCat.SelectedIndex = 0; } else { drpDocCat.SelectedValue = docId; } btnSubmit.Visible = false; btnUpdate.Visible = true; } else { lblMessage.Text = ""; btnSubmit.Visible = true; btnUpdate.Visible = false; } } }
public clsEntProjectDetails readInfo(int ID, string projectNo) { objEnt = new clsEntProjectDetails(); SqlDataReader objRead; objConnection = new SqlDataAccess(clsConstant.DBCONSTRING); try { if (objConnection.Connection.State == ConnectionState.Closed) { objConnection.Connection.Open(); } if (ID != 0) { SqlParameter[] pram = new SqlParameter[] { new SqlParameter("@projectID", ID) }; objRead = objConnection.ExecuteReaderQuery(clsConstant.SP_SELECT_PROJECT_MASTER_DETAIL, CommandType.StoredProcedure, pram); } else { SqlParameter[] pram = new SqlParameter[] { new SqlParameter("@projectNumber", projectNo) }; objRead = objConnection.ExecuteReaderQuery(clsConstant.SP_SELECT_PROJECT_MASTER_DETAIL, CommandType.StoredProcedure, pram); } while (objRead.Read()) { objEnt.ProjectID = objRead.GetValue(0).ToString(); objEnt.projectNumber = objRead.GetValue(1).ToString(); objEnt.projectNameMaster = objRead.GetValue(2).ToString(); object objObj = objRead.GetValue(3); if (DBNull.Value == objObj) { objEnt.agencyID = 0; } else { objEnt.agencyID = int.Parse(objObj.ToString()); } object objDocCat = objRead.GetValue(5); if (DBNull.Value == objDocCat) { objEnt.docCatID = ""; } else { objEnt.docCatID = objDocCat.ToString(); } string strDate = objRead.GetValue(7).ToString(); if (strDate == "" || strDate == "01-01-0001") { objEnt.dtStartDate = ""; } else { objEnt.dtStartDate = strDate; } string endDate = objRead.GetValue(8).ToString(); if (endDate == "" || endDate == "01-01-0001") { objEnt.dtEndDate = ""; } else { objEnt.dtEndDate = endDate; } } objRead.Close(); return(objEnt); } catch (Exception exMessage) { throw exMessage; } }