Int64 IOTScheduleDataAccess.Add(OTScheduleEntity oTScheduleEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(oTScheduleEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(oTScheduleEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
Int64 IOTScheduleDataAccess.Delete(OTScheduleEntity oTScheduleEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Delete(oTScheduleEntity, filterExpression, option); break; } case TransactionRequired.Yes: { retValues = DeleteTran(oTScheduleEntity, filterExpression, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private Int64 Update(OTScheduleEntity oTScheduleEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.OTSchedule_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@ScheduleID", DbType.Int64, oTScheduleEntity.ScheduleID); Database.AddInParameter(cmd, "@ScheduleIdentityCategoryID", DbType.Int64, oTScheduleEntity.ScheduleIdentityCategoryID); Database.AddInParameter(cmd, "@ScheduleCategoryID", DbType.Int64, oTScheduleEntity.ScheduleCategoryID); Database.AddInParameter(cmd, "@ReferenceID", DbType.Int64, oTScheduleEntity.ReferenceID); Database.AddInParameter(cmd, "@Title", DbType.String, oTScheduleEntity.Title); Database.AddInParameter(cmd, "@Description", DbType.String, oTScheduleEntity.Description); Database.AddInParameter(cmd, "@SchedulePriorityID", DbType.Int64, oTScheduleEntity.SchedulePriorityID); Database.AddInParameter(cmd, "@CreatedByMemberID", DbType.Int64, oTScheduleEntity.CreatedByMemberID); Database.AddInParameter(cmd, "@CreateDate", DbType.DateTime, oTScheduleEntity.CreateDate); Database.AddInParameter(cmd, "@Duration", DbType.Decimal, oTScheduleEntity.Duration); Database.AddInParameter(cmd, "@StartDateTime", DbType.DateTime, oTScheduleEntity.StartDateTime); Database.AddInParameter(cmd, "@EndDateTime", DbType.DateTime, oTScheduleEntity.EndDateTime); Database.AddInParameter(cmd, "@NotifyBeforeMin", DbType.Int32, oTScheduleEntity.NotifyBeforeMin); Database.AddInParameter(cmd, "@IsNotifyCompleted", DbType.Boolean, oTScheduleEntity.IsNotifyCompleted); Database.AddInParameter(cmd, "@Remarks", DbType.String, oTScheduleEntity.Remarks); Database.AddInParameter(cmd, "@ReferenceScheduleID", DbType.Int64, oTScheduleEntity.ReferenceScheduleID); Database.AddInParameter(cmd, "@IsRescheduled", DbType.Boolean, oTScheduleEntity.IsRescheduled); Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, oTScheduleEntity.IsRemoved); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("OTScheduleEntity already exists. Please specify another OTScheduleEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("OTScheduleEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("OTScheduleEntity already exists. Please specify another OTScheduleEntity."); } } } } return(returnCode); }
private void SaveOTScheduleEntity() { if (IsValid) { try { OTScheduleEntity oTScheduleEntity = BuildOTScheduleEntity(); Int64 result = -1; if (oTScheduleEntity.IsNew) { result = FCCOTSchedule.GetFacadeCreate().Add(oTScheduleEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(OTScheduleEntity.FLD_NAME_ScheduleID, oTScheduleEntity.ScheduleID.ToString(), SQLMatchType.Equal); result = FCCOTSchedule.GetFacadeCreate().Update(oTScheduleEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _ScheduleID = 0; _OTScheduleEntity = new OTScheduleEntity(); PrepareInitialView(); BindOTScheduleList(); if (oTScheduleEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "O TSchedule Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "O TSchedule Information has been updated successfully.", false); } } else { if (oTScheduleEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add O TSchedule Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update O TSchedule Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
protected void lvOTSchedule_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 ScheduleID; Int64.TryParse(e.CommandArgument.ToString(), out ScheduleID); if (ScheduleID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _ScheduleID = ScheduleID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(OTScheduleEntity.FLD_NAME_ScheduleID, ScheduleID.ToString(), SQLMatchType.Equal); OTScheduleEntity oTScheduleEntity = new OTScheduleEntity(); result = FCCOTSchedule.GetFacadeCreate().Delete(oTScheduleEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _ScheduleID = 0; _OTScheduleEntity = new OTScheduleEntity(); PrepareInitialView(); BindOTScheduleList(); MiscUtil.ShowMessage(lblMessage, "O TSchedule has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete O TSchedule.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 DeleteTran(OTScheduleEntity oTScheduleEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.OTSchedule_SET"; Database db = DatabaseFactory.CreateDatabase(); using (DbCommand cmd = db.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd, db); AddFilterExpressionParameter(cmd, filterExpression, db); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { using (IDataReader reader = db.ExecuteReader(cmd, transaction)) { returnCode = GetReturnCodeFromParameter(cmd); } if (returnCode >= 0) { transaction.Commit(); } else { throw new ArgumentException("Error Code." + returnCode.ToString()); } } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { transaction.Dispose(); connection.Close(); connection = null; } } return(returnCode); }
private void PrepareEditView() { OTScheduleEntity oTScheduleEntity = CurrentOTScheduleEntity; if (!oTScheduleEntity.IsNew) { if (ddlScheduleIdentityCategoryID.Items.Count > 0 && oTScheduleEntity.ScheduleIdentityCategoryID != null) { ddlScheduleIdentityCategoryID.SelectedValue = oTScheduleEntity.ScheduleIdentityCategoryID.ToString(); } if (ddlScheduleCategoryID.Items.Count > 0 && oTScheduleEntity.ScheduleCategoryID != null) { ddlScheduleCategoryID.SelectedValue = oTScheduleEntity.ScheduleCategoryID.ToString(); } txtReferenceID.Text = oTScheduleEntity.ReferenceID.ToString(); txtTitle.Text = oTScheduleEntity.Title.ToString(); txtDescription.Text = oTScheduleEntity.Description.ToString(); if (ddlSchedulePriorityID.Items.Count > 0 && oTScheduleEntity.SchedulePriorityID != null) { ddlSchedulePriorityID.SelectedValue = oTScheduleEntity.SchedulePriorityID.ToString(); } if (ddlCreatedByMemberID.Items.Count > 0 && oTScheduleEntity.CreatedByMemberID != null) { ddlCreatedByMemberID.SelectedValue = oTScheduleEntity.CreatedByMemberID.ToString(); } txtCreateDate.Text = oTScheduleEntity.CreateDate.ToStringDefault(); txtDuration.Text = oTScheduleEntity.Duration.ToString(); txtStartDateTime.Text = oTScheduleEntity.StartDateTime.ToStringDefault(); txtEndDateTime.Text = oTScheduleEntity.EndDateTime.ToStringDefault(); txtNotifyBeforeMin.Text = oTScheduleEntity.NotifyBeforeMin.ToString(); chkIsNotifyCompleted.Checked = oTScheduleEntity.IsNotifyCompleted; txtRemarks.Text = oTScheduleEntity.Remarks.ToString(); if (ddlReferenceScheduleID.Items.Count > 0 && oTScheduleEntity.ReferenceScheduleID != null) { ddlReferenceScheduleID.SelectedValue = oTScheduleEntity.ReferenceScheduleID.ToString(); } chkIsRescheduled.Checked = oTScheduleEntity.IsRescheduled; chkIsRemoved.Checked = oTScheduleEntity.IsRemoved; btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private Int64 Delete(OTScheduleEntity oTScheduleEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.OTSchedule_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("OTScheduleEntity already exists. Please specify another OTScheduleEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("OTScheduleEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("OTScheduleEntity already exists. Please specify another OTScheduleEntity."); } } } } return(returnCode); }
protected void btnAddNew_Click(object sender, EventArgs e) { _ScheduleID = 0; _OTScheduleEntity = new OTScheduleEntity(); PrepareInitialView(); }
private OTScheduleEntity BuildOTScheduleEntity() { OTScheduleEntity oTScheduleEntity = CurrentOTScheduleEntity; if (ddlScheduleIdentityCategoryID.Items.Count > 0) { if (ddlScheduleIdentityCategoryID.SelectedValue == "0") { } else { oTScheduleEntity.ScheduleIdentityCategoryID = Int64.Parse(ddlScheduleIdentityCategoryID.SelectedValue); } } if (ddlScheduleCategoryID.Items.Count > 0) { if (ddlScheduleCategoryID.SelectedValue == "0") { } else { oTScheduleEntity.ScheduleCategoryID = Int64.Parse(ddlScheduleCategoryID.SelectedValue); } } if (!txtReferenceID.Text.Trim().IsNullOrEmpty()) { oTScheduleEntity.ReferenceID = Int64.Parse(txtReferenceID.Text.Trim()); } else { oTScheduleEntity.ReferenceID = null; } oTScheduleEntity.Title = txtTitle.Text.Trim(); oTScheduleEntity.Description = txtDescription.Text.Trim(); if (ddlSchedulePriorityID.Items.Count > 0) { if (ddlSchedulePriorityID.SelectedValue == "0") { } else { oTScheduleEntity.SchedulePriorityID = Int64.Parse(ddlSchedulePriorityID.SelectedValue); } } if (ddlCreatedByMemberID.Items.Count > 0) { if (ddlCreatedByMemberID.SelectedValue == "0") { } else { oTScheduleEntity.CreatedByMemberID = Int64.Parse(ddlCreatedByMemberID.SelectedValue); } } if (txtCreateDate.Text.Trim().IsNotNullOrEmpty()) { oTScheduleEntity.CreateDate = MiscUtil.ParseToDateTime(txtCreateDate.Text); } else { oTScheduleEntity.CreateDate = null; } if (!txtDuration.Text.Trim().IsNullOrEmpty()) { oTScheduleEntity.Duration = Decimal.Parse(txtDuration.Text.Trim()); } else { oTScheduleEntity.Duration = null; } if (txtStartDateTime.Text.Trim().IsNotNullOrEmpty()) { oTScheduleEntity.StartDateTime = MiscUtil.ParseToDateTime(txtStartDateTime.Text); } else { oTScheduleEntity.StartDateTime = null; } if (txtEndDateTime.Text.Trim().IsNotNullOrEmpty()) { oTScheduleEntity.EndDateTime = MiscUtil.ParseToDateTime(txtEndDateTime.Text); } else { oTScheduleEntity.EndDateTime = null; } if (!txtNotifyBeforeMin.Text.Trim().IsNullOrEmpty()) { oTScheduleEntity.NotifyBeforeMin = Int32.Parse(txtNotifyBeforeMin.Text.Trim()); } else { oTScheduleEntity.NotifyBeforeMin = null; } oTScheduleEntity.IsNotifyCompleted = chkIsNotifyCompleted.Checked; oTScheduleEntity.Remarks = txtRemarks.Text.Trim(); if (ddlReferenceScheduleID.Items.Count > 0) { if (ddlReferenceScheduleID.SelectedValue == "0") { oTScheduleEntity.ReferenceScheduleID = null; } else { oTScheduleEntity.ReferenceScheduleID = Int64.Parse(ddlReferenceScheduleID.SelectedValue); } } oTScheduleEntity.IsRescheduled = chkIsRescheduled.Checked; oTScheduleEntity.IsRemoved = chkIsRemoved.Checked; return(oTScheduleEntity); }
private Int64 UpdateTran(OTScheduleEntity oTScheduleEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.OTSchedule_SET"; Database db = DatabaseFactory.CreateDatabase(); using (DbCommand cmd = db.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option, db); AddOutputParameter(cmd, db); AddFilterExpressionParameter(cmd, filterExpression, db); db.AddInParameter(cmd, "@ScheduleID", DbType.Int64, oTScheduleEntity.ScheduleID); db.AddInParameter(cmd, "@ScheduleIdentityCategoryID", DbType.Int64, oTScheduleEntity.ScheduleIdentityCategoryID); db.AddInParameter(cmd, "@ScheduleCategoryID", DbType.Int64, oTScheduleEntity.ScheduleCategoryID); db.AddInParameter(cmd, "@ReferenceID", DbType.Int64, oTScheduleEntity.ReferenceID); db.AddInParameter(cmd, "@Title", DbType.String, oTScheduleEntity.Title); db.AddInParameter(cmd, "@Description", DbType.String, oTScheduleEntity.Description); db.AddInParameter(cmd, "@SchedulePriorityID", DbType.Int64, oTScheduleEntity.SchedulePriorityID); db.AddInParameter(cmd, "@CreatedByMemberID", DbType.Int64, oTScheduleEntity.CreatedByMemberID); db.AddInParameter(cmd, "@CreateDate", DbType.DateTime, oTScheduleEntity.CreateDate); db.AddInParameter(cmd, "@Duration", DbType.Decimal, oTScheduleEntity.Duration); db.AddInParameter(cmd, "@StartDateTime", DbType.DateTime, oTScheduleEntity.StartDateTime); db.AddInParameter(cmd, "@EndDateTime", DbType.DateTime, oTScheduleEntity.EndDateTime); db.AddInParameter(cmd, "@NotifyBeforeMin", DbType.Int32, oTScheduleEntity.NotifyBeforeMin); db.AddInParameter(cmd, "@IsNotifyCompleted", DbType.Boolean, oTScheduleEntity.IsNotifyCompleted); db.AddInParameter(cmd, "@Remarks", DbType.String, oTScheduleEntity.Remarks); db.AddInParameter(cmd, "@ReferenceScheduleID", DbType.Int64, oTScheduleEntity.ReferenceScheduleID); db.AddInParameter(cmd, "@IsRescheduled", DbType.Boolean, oTScheduleEntity.IsRescheduled); db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, oTScheduleEntity.IsRemoved); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { using (IDataReader reader = db.ExecuteReader(cmd, transaction)) { returnCode = GetReturnCodeFromParameter(cmd); } if (returnCode > 0) { transaction.Commit(); } else { throw new ArgumentException("Error Code." + returnCode.ToString()); } } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { transaction.Dispose(); connection.Close(); connection = null; } } return(returnCode); }
protected void lvOTIssue_Detailed_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 IssueID; Int64.TryParse(e.CommandArgument.ToString(), out IssueID); if (IssueID > 0) { if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(OTIssueEntity.FLD_NAME_IssueID, IssueID.ToString(), SQLMatchType.Equal); OTIssueEntity oTIssueEntity = new OTIssueEntity(); result = FCCOTIssue.GetFacadeCreate().Delete(oTIssueEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _IssueID = 0; _OTIssueEntity = new OTIssueEntity(); PrepareInitialView(); BindOTIssueList(); MiscUtil.ShowMessage(lblMessage, "Issue has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Issue.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } else if (string.Equals(e.CommandName, "UpdateItem")) { try { _IssueID = IssueID; OTIssueEntity oTIssueEntity = CurrentOTIssueEntity; if (CurrentOTIssueEntity.IssueStatusID == MasterDataConstants.MDIssueStatus.COMPLETED) { MiscUtil.ShowMessage(lblMessage, "Issue Already Completed.", false); return; } Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(OTIssueEntity.FLD_NAME_IssueID, IssueID.ToString(), SQLMatchType.Equal); oTIssueEntity.IssueStatusID = MasterDataConstants.MDIssueStatus.COMPLETED; oTIssueEntity.CompletionPercentage = 100; result = FCCOTIssue.GetFacadeCreate().Update(oTIssueEntity, fe, DatabaseOperationType.Update, TransactionRequired.No); if (result > 0) { _IssueID = 0; _OTIssueEntity = new OTIssueEntity(); PrepareInitialView(); BindOTIssueList(); MiscUtil.ShowMessage(lblMessage, "Issue has been successfully Updated.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to Update Issue.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } else if (string.Equals(e.CommandName, "AddToSchedule")) { try { OTIssueEntity oTIssueEntity = FCCOTIssue.GetFacadeCreate().GetByID(IssueID); OTScheduleEntity oTScheduleEntity = new OTScheduleEntity(); } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
Int64 IOTScheduleFacade.Delete(OTScheduleEntity oTScheduleEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateOTScheduleDataAccess().Delete(oTScheduleEntity, filterExpression, option, reqTran)); }
Int64 IOTScheduleFacade.Add(OTScheduleEntity oTScheduleEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateOTScheduleDataAccess().Add(oTScheduleEntity, option, reqTran)); }
protected void lvOTIssue_Detailed_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 IssueID; Int64.TryParse(e.CommandArgument.ToString(), out IssueID); if (IssueID > 0) { if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(OTIssueEntity.FLD_NAME_IssueID, IssueID.ToString(), SQLMatchType.Equal); OTIssueEntity oTIssueEntity = new OTIssueEntity(); result = FCCOTIssue.GetFacadeCreate().Delete(oTIssueEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _IssueID = 0; _OTIssueEntity = new OTIssueEntity(); PrepareInitialView(); BindOTIssueList(); MiscUtil.ShowMessage(lblMessage, "O TIssue has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete O TIssue.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } else if (string.Equals(e.CommandName, "AddToSchedule")) { try { OTIssueEntity oTIssueEntity = FCCOTIssue.GetFacadeCreate().GetByID(IssueID); OTScheduleEntity oTScheduleEntity = new OTScheduleEntity(); //oTScheduleEntity //if (result == 0) //{ // MiscUtil.ShowMessage(lblMessage, "O TIssue has been successfully deleted.", true); //} //else //{ // MiscUtil.ShowMessage(lblMessage, "Failed to delete O TIssue.", true); //} } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
protected void lvOTIssue_Detailed_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 IssueID; Int64.TryParse(e.CommandArgument.ToString(), out IssueID); if (IssueID > 0) { if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(OTIssueEntity.FLD_NAME_IssueID, IssueID.ToString(), SQLMatchType.Equal); OTIssueEntity oTIssueEntity = new OTIssueEntity(); result = FCCOTIssue.GetFacadeCreate().Delete(oTIssueEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _IssueID = 0; _OTIssueEntity = new OTIssueEntity(); PrepareInitialView(); BindOTIssueList(); MiscUtil.ShowMessage(lblMessage, "Issue has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Issue.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } else if (string.Equals(e.CommandName, "UpdateItem")) { try { _IssueID = IssueID; OTIssueEntity oTIssueEntity = CurrentOTIssueEntity; if (CurrentOTIssueEntity.IssueStatusID == MasterDataConstants.MDIssueStatus.COMPLETED) { MiscUtil.ShowMessage(lblMessage, "Issue Already Completed.", false); return; } Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(OTIssueEntity.FLD_NAME_IssueID, IssueID.ToString(), SQLMatchType.Equal); oTIssueEntity.IssueStatusID = MasterDataConstants.MDIssueStatus.COMPLETED; oTIssueEntity.CompletionPercentage = 100; result = FCCOTIssue.GetFacadeCreate().Update(oTIssueEntity, fe, DatabaseOperationType.Update, TransactionRequired.No); if (result > 0) { _IssueID = 0; _OTIssueEntity = new OTIssueEntity(); PrepareInitialView(); BindOTIssueList(); MiscUtil.ShowMessage(lblMessage, "Issue has been successfully Updated.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to Update Issue.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } else if (string.Equals(e.CommandName, "EditGrid")) { try { _IssueID = IssueID; OTIssueEntity oTIssueEntity = CurrentOTIssueEntity; Label lblTitleLV = (Label)e.Item.FindControl("lblTitleLV"); Label lblDurationLV = (Label)e.Item.FindControl("lblDurationLV"); Label lblIssueCategoryLV = (Label)e.Item.FindControl("lblIssueCategoryLV"); Label lblIssueStatusLV = (Label)e.Item.FindControl("lblIssueStatusLV"); Label lblIssueCategoryIDLV = (Label)e.Item.FindControl("lblIssueCategoryIDLV"); Label lblIssueStatusIDLV = (Label)e.Item.FindControl("lblIssueStatusIDLV"); Label lblProjectLV = (Label)e.Item.FindControl("lblProjectLV"); Label lblProjectIDLV = (Label)e.Item.FindControl("lblProjectIDLV"); DropDownList ddlIssueCategoryLV = (DropDownList)e.Item.FindControl("ddlIssueCategoryLV"); DropDownList ddlIssueStatusLV = (DropDownList)e.Item.FindControl("ddlIssueStatusLV"); DropDownList ddlProjectIDLV = (DropDownList)e.Item.FindControl("ddlProjectIDLV"); TextBox txtTitleLV = (TextBox)e.Item.FindControl("txtTitleLV"); TextBox txtDurationLV = (TextBox)e.Item.FindControl("txtDurationLV"); LinkButton lnkBtnUpdateGrid = (LinkButton)e.Item.FindControl("lnkBtnUpdateGrid"); LinkButton lnBtnCancelGrid = (LinkButton)e.Item.FindControl("lnBtnCancelGrid"); LinkButton lnkBtnEditGrid = (LinkButton)e.Item.FindControl("lnkBtnEditGrid"); txtTitleLV.Visible = true; txtDurationLV.Visible = true; ddlIssueCategoryLV.Visible = true; ddlIssueStatusLV.Visible = true; ddlProjectIDLV.Visible = true; lblIssueCategoryLV.Visible = false; lblIssueStatusLV.Visible = false; lblTitleLV.Visible = false; lblProjectLV.Visible = false; lblDurationLV.Visible = false; lnBtnCancelGrid.Visible = true; lnkBtnUpdateGrid.Visible = true; lnkBtnEditGrid.Visible = false; MiscUtil.PopulateMDIssueCategoryForDTL(ddlIssueCategoryLV, false); MiscUtil.PopulateMDIssueStatusForDTL(ddlIssueStatusLV, false); MiscUtil.PopulateBDProjectForDTL(ddlProjectIDLV, true); if (ddlIssueCategoryLV != null && ddlIssueCategoryLV.Items.Count > 0) { ddlIssueCategoryLV.SelectedValue = lblIssueCategoryIDLV.Text; } if (ddlIssueStatusLV != null && ddlIssueStatusLV.Items.Count > 0) { ddlIssueStatusLV.SelectedValue = lblIssueStatusIDLV.Text; } if (ddlProjectIDLV != null && ddlProjectIDLV.Items.Count > 0) { ddlProjectIDLV.SelectedValue = lblProjectIDLV.Text; } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } else if (string.Equals(e.CommandName, "AddToSchedule")) { try { OTIssueEntity oTIssueEntity = FCCOTIssue.GetFacadeCreate().GetByID(IssueID); OTScheduleEntity oTScheduleEntity = new OTScheduleEntity(); } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } else if (string.Equals(e.CommandName, "UpdateGrid")) { try { Label lblTitleLV = (Label)e.Item.FindControl("lblTitleLV"); Label lblDurationLV = (Label)e.Item.FindControl("lblDurationLV"); Label lblIssueCategoryLV = (Label)e.Item.FindControl("lblIssueCategoryLV"); Label lblIssueStatusLV = (Label)e.Item.FindControl("lblIssueStatusLV"); Label lblIssueCategoryIDLV = (Label)e.Item.FindControl("lblIssueCategoryIDLV"); Label lblIssueStatusIDLV = (Label)e.Item.FindControl("lblIssueStatusIDLV"); Label lblProjectLV = (Label)e.Item.FindControl("lblProjectLV"); Label lblProjectIDLV = (Label)e.Item.FindControl("lblProjectIDLV"); DropDownList ddlIssueCategoryLV = (DropDownList)e.Item.FindControl("ddlIssueCategoryLV"); DropDownList ddlIssueStatusLV = (DropDownList)e.Item.FindControl("ddlIssueStatusLV"); DropDownList ddlProjectIDLV = (DropDownList)e.Item.FindControl("ddlProjectIDLV"); TextBox txtTitleLV = (TextBox)e.Item.FindControl("txtTitleLV"); TextBox txtDurationLV = (TextBox)e.Item.FindControl("txtDurationLV"); LinkButton lnkBtnUpdateGrid = (LinkButton)e.Item.FindControl("lnkBtnUpdateGrid"); LinkButton lnBtnCancelGrid = (LinkButton)e.Item.FindControl("lnBtnCancelGrid"); LinkButton lnkBtnEditGrid = (LinkButton)e.Item.FindControl("lnkBtnEditGrid"); TimeSpan durationLV; TimeSpan.TryParse(txtDurationLV.Text.Trim(), out durationLV); OTIssueEntity oTIssueEntity = FCCOTIssue.GetFacadeCreate().GetByID(IssueID); oTIssueEntity.IssueStatusID = Int64.Parse(ddlIssueStatusLV.SelectedValue); oTIssueEntity.IssueCategoryID = Int64.Parse(ddlIssueCategoryLV.SelectedValue); oTIssueEntity.ReferenceID = Int64.Parse(ddlProjectIDLV.SelectedValue); oTIssueEntity.Title = txtTitleLV.Text.Trim().ToString(); oTIssueEntity.Duration = 0; oTIssueEntity.DTLDuration = durationLV.ToString(); String fe = SqlExpressionBuilder.PrepareFilterExpression(OTIssueEntity.FLD_NAME_IssueID, IssueID.ToString(), SQLMatchType.Equal); Int64 result = -1; String fe_update = SqlExpressionBuilder.PrepareFilterExpression(OTIssueEntity.FLD_NAME_IssueID, IssueID.ToString(), SQLMatchType.Equal); result = FCCOTIssue.GetFacadeCreate().Update(oTIssueEntity, fe, DatabaseOperationType.Update, TransactionRequired.No); if (result > 0) { _IssueID = 0; _OTIssueEntity = new OTIssueEntity(); PrepareInitialView(); BindOTIssueList(); txtTitleLV.Visible = false; txtDurationLV.Visible = false; ddlIssueCategoryLV.Visible = false; ddlIssueStatusLV.Visible = false; ddlProjectIDLV.Visible = false; lblIssueCategoryLV.Visible = true; lblIssueStatusLV.Visible = true; lblTitleLV.Visible = true; lblDurationLV.Visible = true; lblProjectLV.Visible = true; lnBtnCancelGrid.Visible = false; lnkBtnUpdateGrid.Visible = false; lnkBtnEditGrid.Visible = true; MiscUtil.ShowMessage(lblMessage, "Issue has been successfully updated.", false); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } else if (string.Equals(e.CommandName, "CancelGridEdit")) { try { Label lblTitleLV = (Label)e.Item.FindControl("lblTitleLV"); Label lblDurationLV = (Label)e.Item.FindControl("lblDurationLV"); Label lblIssueCategoryLV = (Label)e.Item.FindControl("lblIssueCategoryLV"); Label lblIssueStatusLV = (Label)e.Item.FindControl("lblIssueStatusLV"); Label lblIssueCategoryIDLV = (Label)e.Item.FindControl("lblIssueCategoryIDLV"); Label lblIssueStatusIDLV = (Label)e.Item.FindControl("lblIssueStatusIDLV"); Label lblProjectLV = (Label)e.Item.FindControl("lblProjectLV"); DropDownList ddlIssueCategoryLV = (DropDownList)e.Item.FindControl("ddlIssueCategoryLV"); DropDownList ddlIssueStatusLV = (DropDownList)e.Item.FindControl("ddlIssueStatusLV"); DropDownList ddlProjectIDLV = (DropDownList)e.Item.FindControl("ddlProjectIDLV"); TextBox txtTitleLV = (TextBox)e.Item.FindControl("txtTitleLV"); TextBox txtDurationLV = (TextBox)e.Item.FindControl("txtDurationLV"); LinkButton lnkBtnUpdateGrid = (LinkButton)e.Item.FindControl("lnkBtnUpdateGrid"); LinkButton lnBtnCancelGrid = (LinkButton)e.Item.FindControl("lnBtnCancelGrid"); LinkButton lnkBtnEditGrid = (LinkButton)e.Item.FindControl("lnkBtnEditGrid"); txtTitleLV.Visible = false; txtDurationLV.Visible = false; ddlIssueCategoryLV.Visible = false; ddlIssueStatusLV.Visible = false; ddlProjectIDLV.Visible = false; lblIssueCategoryLV.Visible = true; lblIssueStatusLV.Visible = true; lblTitleLV.Visible = true; lblDurationLV.Visible = true; lblProjectLV.Visible = true; lnBtnCancelGrid.Visible = false; lnkBtnUpdateGrid.Visible = false; lnkBtnEditGrid.Visible = true; } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } if (string.Equals(e.CommandName, "InsertItem")) { try { ListViewItem list = lvOTIssue_Detailed.InsertItem; TextBox txtTitleLV = (TextBox)list.FindControl("txtTitleLV"); TextBox txtDurationLV = (TextBox)list.FindControl("txtDurationLV"); DropDownList ddlIssueCategoryIDLV = (DropDownList)list.FindControl("ddlIssueCategoryIDLV"); DropDownList ddlIssueStatusIDLV = (DropDownList)list.FindControl("ddlIssueStatusIDLV"); DropDownList ddlProjectIDLV = (DropDownList)list.FindControl("ddlProjectIDLV"); if (ddlIssueCategoryIDLV.SelectedValue == "0") { MiscUtil.ShowMessage(lblMessage, "You have selected Category Head. Please Select Issue Category", true); return; } TimeSpan durationLV; TimeSpan.TryParse(txtDurationLV.Text.Trim(), out durationLV); OTIssueEntity oTIssueEntity = new OTIssueEntity(); oTIssueEntity.IssueCategoryID = Int64.Parse(ddlIssueCategoryIDLV.SelectedValue); oTIssueEntity.Title = txtTitleLV.Text.Trim(); oTIssueEntity.Description = "Daily Log Time"; oTIssueEntity.IssuePriorityID = MasterDataConstants.MDIssuePriority.HIGH; oTIssueEntity.CompletionPercentage = 0; oTIssueEntity.IssueStatusID = Int64.Parse(ddlIssueStatusIDLV.SelectedValue); oTIssueEntity.Duration = 0; //String startDate=DateTime.ParseExact(txtStartDate.Text, "ddd MMM dd yyyy HH:mm:ss 'GMT'zzz", System.Globalization.CultureInfo.InvariantCulture).ToString(); //String startDate = txtStartDate.Text; DateTime startDate = System.DateTime.Now; DateTime endDate = System.DateTime.Now; if (txtDate.Text.Trim().IsNotNullOrEmpty()) { startDate = MiscUtil.ParseToDateTime(txtDate.Text.Trim().ToString()); endDate = startDate; } oTIssueEntity.ExpectedStartDate = startDate; oTIssueEntity.ExpectedEndDate = endDate; oTIssueEntity.SupervisorEmployeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember); oTIssueEntity.AssignedToEmployeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember); oTIssueEntity.ActualStartDate = null; oTIssueEntity.ActualEndDate = null; oTIssueEntity.NotifyBeforeMin = null; oTIssueEntity.SupervisorAgreed = true; oTIssueEntity.ModifiedBySupervisorDateTime = System.DateTime.Now; oTIssueEntity.IP = MiscUtil.GetLocalIP(); oTIssueEntity.Remarks = String.Empty; oTIssueEntity.IssueIdentityCategoryID = MasterDataConstants.IssueIdentityCategory.ADHOC_ISSUE; oTIssueEntity.CreatedByMemberID = this.CurrentMember.MemberID; oTIssueEntity.CompletionPercentage = 0; oTIssueEntity.CreateDate = DateTime.Now; oTIssueEntity.IsNotifyCompleted = false; oTIssueEntity.IsRemoved = false; oTIssueEntity.ParentIssueID = null; oTIssueEntity.ReferenceID = Int64.Parse(ddlProjectIDLV.SelectedValue); oTIssueEntity.ReferenceIssueID = null; oTIssueEntity.DTLDuration = durationLV.ToString(); Int64 result = -1; result = FCCOTIssue.GetFacadeCreate().Add(oTIssueEntity, DatabaseOperationType.Add, TransactionRequired.No); if (result > 0) { BindList(); MiscUtil.ShowMessage(lblMessage, "Event Created Successfully", false); } else { MiscUtil.ShowMessage(lblMessage, "Can't Create Event.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, "Failed to save Daily Log Information.", true); } } }