protected override void ShowData(int projectTimeLineId) { base.ShowData(projectTimeLineId); oDetailButtonPanel.SetId = SetId; Clear(); var data = new ProjectTimeLineDataModel(); data.ProjectTimeLineId = projectTimeLineId; var entityList = ProjectTimeLineDataManager.GetEntityDetails(data, SessionVariables.RequestProfile); if (entityList.Count == 1) { foreach (var entityItem in entityList) { lblProjectTimeLineId.Text = entityItem.ProjectTimeLineId.ToString(); lblProjectId.Text = entityItem.Project.ToString(); lblStartDate.Text = entityItem.StartDate.ToString(); lblEndDate.Text = entityItem.EndDate.ToString(); oUpdateInfo.LoadText(entityItem.UpdatedDate, entityItem.UpdatedBy, entityItem.LastAction); oHistoryList.Setup((int)Framework.Components.DataAccess.SystemEntity.ProjectTimeLine, projectTimeLineId, "ProjectTimeLine"); dynAuditHistory.Visible = PerferenceUtility.GetUserPreferenceByKeyAsBoolean(ApplicationCommon.HistoryGridVisibilityKey, "ProjectTimeLine"); } } }
private static string CreateOrUpdate(ProjectTimeLineDataModel data, RequestProfile requestProfile, string action) { var sql = "EXEC "; switch (action) { case "Create": sql += "dbo.ProjectTimeLineInsert " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId); break; case "Update": sql += "dbo.ProjectTimeLineUpdate " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId); break; default: break; } sql = sql + ", " + ToSQLParameter(data, ProjectTimeLineDataModel.DataColumns.ProjectTimeLineId) + ", " + ToSQLParameter(data, ProjectTimeLineDataModel.DataColumns.ProjectId) + ", " + ToSQLParameter(data, ProjectTimeLineDataModel.DataColumns.StartDate) + ", " + ToSQLParameter(data, ProjectTimeLineDataModel.DataColumns.EndDate); return(sql); }
protected override DataTable UpdateData() { var UpdatedData = new DataTable(); var data = new ProjectTimeLineDataModel(); UpdatedData = ProjectTimeLineDataManager.Search(data, SessionVariables.RequestProfile).Clone(); for (var i = 0; i < SelectedData.Rows.Count; i++) { data.ProjectTimeLineId = Convert.ToInt32(SelectedData.Rows[i][ProjectTimeLineDataModel.DataColumns.ProjectTimeLineId].ToString()); data.ProjectId = Convert.ToInt32(SelectedData.Rows[i][ProjectTimeLineDataModel.DataColumns.ProjectId].ToString()); data.StartDate = !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(ProjectTimeLineDataModel.DataColumns.StartDate)) ? DateTime.Parse(CheckAndGetRepeaterTextBoxValue(ProjectTimeLineDataModel.DataColumns.StartDate).ToString()) : DateTime.Parse(SelectedData.Rows[i][ProjectTimeLineDataModel.DataColumns.StartDate].ToString()); data.EndDate = !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(ProjectTimeLineDataModel.DataColumns.EndDate)) ? DateTime.Parse(CheckAndGetRepeaterTextBoxValue(ProjectTimeLineDataModel.DataColumns.EndDate).ToString()) : DateTime.Parse(SelectedData.Rows[i][ProjectTimeLineDataModel.DataColumns.EndDate].ToString()); ProjectTimeLineDataManager.Update(data, SessionVariables.RequestProfile); data = new ProjectTimeLineDataModel(); data.ProjectTimeLineId = Convert.ToInt32(SelectedData.Rows[i][ProjectTimeLineDataModel.DataColumns.ProjectTimeLineId].ToString()); var dt = ProjectTimeLineDataManager.Search(data, SessionVariables.RequestProfile); if (dt.Rows.Count == 1) { UpdatedData.ImportRow(dt.Rows[0]); } } return(UpdatedData); }
static public List <ProjectTimeLineDataModel> GetEntityDetails(ProjectTimeLineDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails) { const string sql = @"dbo.ProjectTimeLineSearch "; var parameters = new { AuditId = requestProfile.AuditId , ApplicationId = requestProfile.ApplicationId , ReturnAuditInfo = returnAuditInfo , ProjectTimeLineId = dataQuery.ProjectTimeLineId }; List <ProjectTimeLineDataModel> result; using (var dataAccess = new DataAccessBase(DataStoreKey)) { result = dataAccess.Connection.Query <ProjectTimeLineDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList(); } return(result); }
public override int?Save(string action) { var data = new ProjectTimeLineDataModel(); data.ProjectTimeLineId = ProjectTimeLineId; data.ProjectId = ProjectId; data.StartDate = StartDate; data.EndDate = EndDate; if (action == "Insert") { var dtProjectTimeLine = ProjectTimeLineDataManager.DoesExist(data, SessionVariables.RequestProfile); if (dtProjectTimeLine.Rows.Count == 0) { ProjectTimeLineDataManager.Create(data, SessionVariables.RequestProfile); } else { throw new Exception("Record with given ID already exists."); } } else { ProjectTimeLineDataManager.Update(data, SessionVariables.RequestProfile); } // not correct ... when doing insert, we didn't get/change the value of CountryID ? return(ProjectTimeLineId); }
//public static List<ProjectTimeLineDataModel> GetEntityDetails(ProjectTimeLineDataModel data, int auditId) //{ // var sql = "EXEC dbo.ProjectTimeLineSearch " + // " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, auditId) + // ", " + ToSQLParameter(data, ProjectTimeLineDataModel.DataColumns.ProjectTimeLineId); // var result = new List<ProjectTimeLineDataModel>(); // using (var reader = new DBDataReader("Get Details", sql, DataStoreKey)) // { // var dbReader = reader.DBReader; // while (dbReader.Read()) // { // var dataItem = new ProjectTimeLineDataModel(); // dataItem.ProjectTimeLineId = (int?)dbReader[ProjectTimeLineDataModel.DataColumns.ProjectTimeLineId]; // dataItem.ProjectId = (int?)dbReader[ProjectTimeLineDataModel.DataColumns.ProjectId]; // dataItem.StartDate = (DateTime)dbReader[ProjectTimeLineDataModel.DataColumns.StartDate]; // dataItem.EndDate = (DateTime)dbReader[ProjectTimeLineDataModel.DataColumns.EndDate]; // dataItem.Project = (string)dbReader[ProjectTimeLineDataModel.DataColumns.Project]; // SetBaseInfo(dataItem, dbReader); // result.Add(dataItem); // } // } // return result; //} #endregion #region Create public static int Create(ProjectTimeLineDataModel data, RequestProfile requestProfile) { var sql = CreateOrUpdate(data, requestProfile, "Create"); var projectTimeLineId = DBDML.RunScalarSQL("ProjectTimeLine.Insert", sql, DataStoreKey); return(Convert.ToInt32(projectTimeLineId)); }
public static DataTable GetDetails(ProjectTimeLineDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile); var table = list.ToDataTable(); return(table); }
protected override DataTable GetEntityData(int?entityKey) { var projectTimeLinedata = new ProjectTimeLineDataModel(); projectTimeLinedata.ProjectTimeLineId = entityKey; var results = ProjectTimeLineDataManager.Search(projectTimeLinedata, SessionVariables.RequestProfile); return(results); }
private System.Data.DataTable GetData() { // TODO: on all export pages var data = new ProjectTimeLineDataModel(); var dt = ProjectTimeLineDataManager.Search(data, SessionVariables.RequestProfile); return(dt); }
protected override void Update(Dictionary <string, string> values) { var data = new ProjectTimeLineDataModel(); // copies properties from values dictionary object to data object PropertyMapper.CopyProperties(data, values); ProjectTimeLineDataManager.Update(data, SessionVariables.RequestProfile); base.Update(values); }
protected override void Clear() { base.Clear(); var data = new ProjectTimeLineDataModel(); ProjectTimeLineId = data.ProjectTimeLineId; ProjectId = data.ProjectId; StartDate = data.StartDate; EndDate = data.EndDate; }
public static DataTable DoesExist(ProjectTimeLineDataModel data, RequestProfile requestProfile) { var sql = "EXEC dbo.ProjectTimeLineSearch " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId) + ", " + ToSQLParameter(data, ProjectTimeLineDataModel.DataColumns.ProjectId) + ", " + ToSQLParameter(data, ProjectTimeLineDataModel.DataColumns.ProjectTimeLineId); var oDT = new DBDataTable("ProjectTimeLine.DoesExist", sql, DataStoreKey); return(oDT.DBTable); }
public static DataTable Search(ProjectTimeLineDataModel data, RequestProfile requestProfile) { // formulate SQL var sql = "EXEC dbo.ProjectTimeLineSearch " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId) + //", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationMode, requestProfile.ApplicationModeId) + ", " + ToSQLParameter(data, ProjectTimeLineDataModel.DataColumns.ProjectTimeLineId) + ", " + ToSQLParameter(data, ProjectTimeLineDataModel.DataColumns.ProjectId) + ", " + ToSQLParameter(data, ProjectTimeLineDataModel.DataColumns.StartDate) + ", " + ToSQLParameter(data, ProjectTimeLineDataModel.DataColumns.EndDate); var oDT = new DBDataTable("ProjectTimeLine.Search", sql, DataStoreKey); return(oDT.DBTable); }
public static void Delete(ProjectTimeLineDataModel dataQuery, int auditId) { const string sql = @"dbo.ProjectTimeLineDelete "; var parameters = new { AuditId = auditId , ProjectTimeLineId = dataQuery.ProjectTimeLineId }; using (var dataAccess = new DataAccessBase(DataStoreKey)) { dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure); } }
protected void btnDelete_Click(object sender, EventArgs e) { try { string[] deleteIndexList = DeleteIds.Split(','); foreach (string index in deleteIndexList) { var data = new ProjectTimeLineDataModel(); data.ProjectTimeLineId = int.Parse(index); ProjectTimeLineDataManager.Delete(data, SessionVariables.RequestProfile.AuditId); } DeleteAndRedirect(); } catch (Exception ex) { Response.Write(ex.Message); } }
public void LoadData(int projectTimeLineId, bool showId) { // clear UI Clear(); var dataQuery = new ProjectTimeLineDataModel(); dataQuery.ProjectTimeLineId = projectTimeLineId; var items = ProjectTimeLineDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile); if (items.Count != 1) { return; } var item = items[0]; ProjectTimeLineId = item.ProjectTimeLineId; ProjectId = item.ProjectId; StartDate = item.StartDate; EndDate = item.EndDate; if (!showId) { txtProjectTimeLineId.Text = item.ProjectTimeLineId.ToString(); // only show Audit History in case of Update page, not for Clone. oHistoryList.Setup((int)Framework.Components.DataAccess.SystemEntity.ProjectTimeLine, projectTimeLineId, "ProjectTimeLine"); } else { txtProjectTimeLineId.Text = String.Empty; } oUpdateInfo.LoadText(item.UpdatedDate, item.UpdatedBy, item.LastAction); }
protected override DataTable GetData() { try { SuperKey = ApplicationCommon.GetSuperKey(); SetId = ApplicationCommon.GetSetId(); var selectedrows = new DataTable(); var projectTimeLinedata = new ProjectTimeLineDataModel(); selectedrows = ProjectTimeLineDataManager.GetDetails(projectTimeLinedata, SessionVariables.RequestProfile).Clone(); if (!string.IsNullOrEmpty(SuperKey)) { var systemEntityTypeId = (int)PrimaryEntity; var lstEntityKeys = ApplicationCommon.GetSuperKeyDetails(systemEntityTypeId, SuperKey); foreach (var entityKey in lstEntityKeys) { projectTimeLinedata.ProjectTimeLineId = entityKey; var result = ProjectTimeLineDataManager.GetDetails(projectTimeLinedata, SessionVariables.RequestProfile); selectedrows.ImportRow(result.Rows[0]); } } else { projectTimeLinedata.ProjectTimeLineId = SetId; var result = ProjectTimeLineDataManager.GetDetails(projectTimeLinedata, SessionVariables.RequestProfile); selectedrows.ImportRow(result.Rows[0]); } return(selectedrows); } catch (Exception ex) { Response.Write(ex.Message); } return(null); }
public static string ToSQLParameter(ProjectTimeLineDataModel data, string dataColumnName) { var returnValue = "NULL"; switch (dataColumnName) { case ProjectTimeLineDataModel.DataColumns.ProjectTimeLineId: if (data.ProjectTimeLineId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, ProjectTimeLineDataModel.DataColumns.ProjectTimeLineId, data.ProjectTimeLineId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, ProjectTimeLineDataModel.DataColumns.ProjectTimeLineId); } break; case ProjectTimeLineDataModel.DataColumns.ProjectId: if (data.ProjectId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, ProjectTimeLineDataModel.DataColumns.ProjectId, data.ProjectId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, ProjectTimeLineDataModel.DataColumns.ProjectId); } break; case ProjectTimeLineDataModel.DataColumns.Project: if (!string.IsNullOrEmpty(data.Project)) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, ProjectTimeLineDataModel.DataColumns.Project, data.Project); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, ProjectTimeLineDataModel.DataColumns.Project); } break; case ProjectTimeLineDataModel.DataColumns.StartDate: if (data.StartDate != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, ProjectTimeLineDataModel.DataColumns.StartDate, data.StartDate); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, ProjectTimeLineDataModel.DataColumns.StartDate); } break; case ProjectTimeLineDataModel.DataColumns.EndDate: if (data.EndDate != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, ProjectTimeLineDataModel.DataColumns.EndDate, data.EndDate); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, ProjectTimeLineDataModel.DataColumns.EndDate); } break; } return(returnValue); }
public static ProjectTimeLineDataModel GetDetails(ProjectTimeLineDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile); return(list.FirstOrDefault()); }
public static void Update(ProjectTimeLineDataModel data, RequestProfile requestProfile) { var sql = CreateOrUpdate(data, requestProfile, "Update"); DBDML.RunSQL("ProjectTimeLine.Update", sql, DataStoreKey); }