Int64 IOTIssueDataAccess.Delete(OTIssueEntity oTIssueEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Delete(oTIssueEntity, filterExpression, option); break; } case TransactionRequired.Yes: { retValues = DeleteTran(oTIssueEntity, filterExpression, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void PrepareEditView() { OTIssueEntity oTIssueEntity = CurrentOTIssueEntity; if (!oTIssueEntity.IsNew) { if (ddlIssueCategoryID.Items.Count > 0 && oTIssueEntity.IssueCategoryID != null) { ddlIssueCategoryID.SelectedValue = oTIssueEntity.IssueCategoryID.ToString(); } txtTitle.Text = oTIssueEntity.Title.ToString(); txtDescription.Text = oTIssueEntity.Description.ToString(); if (ddlIssuePriorityID.Items.Count > 0 && oTIssueEntity.IssuePriorityID != null) { ddlIssuePriorityID.SelectedValue = oTIssueEntity.IssuePriorityID.ToString(); } txtCompletionPercentage.Text = oTIssueEntity.CompletionPercentage.ToString(); if (ddlIssueStatusID.Items.Count > 0 && oTIssueEntity.IssueStatusID != null) { ddlIssueStatusID.SelectedValue = oTIssueEntity.IssueStatusID.ToString(); } txtDuration.Text = oTIssueEntity.Duration.ToString(); txtExpectedStartDate.Text = oTIssueEntity.ExpectedStartDate.ToStringDefault(); txtExpectedEndDate.Text = oTIssueEntity.ExpectedEndDate.ToStringDefault(); txtActualStartDate.Text = oTIssueEntity.ActualStartDate.ToStringDefault(); txtActualEndDate.Text = oTIssueEntity.ActualEndDate.ToStringDefault(); txtNotifyBeforeMin.Text = oTIssueEntity.NotifyBeforeMin.ToString(); txtRemarks.Text = oTIssueEntity.Remarks.ToString(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
protected void Disagree_Click(object sender, EventArgs e) { try { OTIssueEntity oTIssueEntity = CurrentOTIssueEntity; oTIssueEntity.SupervisorAgreed = false; Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(OTIssueEntity.FLD_NAME_IssueID, _IssueID.ToString(), SQLMatchType.Equal); result = FCCOTIssue.GetFacadeCreate().Update(oTIssueEntity, fe, DatabaseOperationType.Update, TransactionRequired.No); if (result > 0) { MiscUtil.ShowMessage(lblMessage, "Issue has been successfully Updated.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to Update Issue.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } }
Int64 IOTIssueDataAccess.Add(OTIssueEntity oTIssueEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(oTIssueEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(oTIssueEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void PrepareEditView() { OTIssueEntity oTIssueEntity = CurrentOTIssueEntity; if (!oTIssueEntity.IsNew) { } }
private void SaveOTIssueEntity() { if (IsValid) { try { OTIssueEntity oTIssueEntity = BuildOTIssueEntity(); Int64 result = -1; if (oTIssueEntity.IsNew) { result = FCCOTIssue.GetFacadeCreate().Add(oTIssueEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(OTIssueEntity.FLD_NAME_IssueID, oTIssueEntity.IssueID.ToString(), SQLMatchType.Equal); result = FCCOTIssue.GetFacadeCreate().Update(oTIssueEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { if (oTIssueEntity.IsNew) { _IssueID = 0; _OTIssueEntity = new OTIssueEntity(); PrepareInitialView(); MiscUtil.ShowMessage(lblMessage, "Issue Information has been added successfully.", false); } else { PrepareInitialView(); PrepareEditView(); MiscUtil.ShowMessage(lblMessage, "Issue Information has been updated successfully.", false); } } else { if (oTIssueEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Issue Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Issue Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
protected void lvOTIssue_ItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { ListViewDataItem dataItem = (ListViewDataItem)e.Item; OTIssueEntity ent = (OTIssueEntity)dataItem.DataItem; HyperLink hypIssueReport = (HyperLink)e.Item.FindControl("hypIssueReport"); hypIssueReport.NavigateUrl = UrlHelper.BuildSecureUrl("~/Reports/ReportViewer.aspx", string.Empty, "do", ReportConstants.ISSUE_REPORT, UrlConstants.OVERVIEW_ISSUE_ID, ent.IssueID.ToString()).ToString(); hypIssueReport.Target = "_blank"; } }
private Int64 DeleteTran(OTIssueEntity oTIssueEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.OTIssue_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); }
protected void lvOTIssue_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 IssueID; Int64.TryParse(e.CommandArgument.ToString(), out IssueID); if (IssueID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _IssueID = IssueID; PrepareEditView(); } else 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); } } } }
private void SaveNodesToDB(TreeNode parentNode, Int64 parentProjectTaskID) { if (parentNode.ChildNodes.Count > 0) { foreach (TreeNode node in parentNode.ChildNodes) { if (node.Checked == true) { OTIssueEntity projectTask = new OTIssueEntity(); projectTask.Title = node.Text; // projectTask.IssueIdentityCategoryID = MasterDataConstants.IssueIdentityCategory.PROJECT_TASK; //Hard Codeed Member projectTask.CreatedByMemberID = 1;// this.CurrentMember.MemberID; projectTask.CreateDate = DateTime.Now; projectTask.IsNotifyCompleted = false; projectTask.IsRemoved = false; projectTask.ParentIssueID = parentProjectTaskID; projectTask.ReferenceID = this.OverviewProjectID; projectTask.ReferenceIssueID = null; #region Sensitive Hard Coded Here //Hard Coded Issue Status ID projectTask.IssueStatusID = 1; projectTask.IssueCategoryID = 2; projectTask.IssuePriorityID = 1; #endregion Int64 result = FCCOTIssue.GetFacadeCreate().Add(projectTask, DatabaseOperationType.Add, TransactionRequired.No); SaveNodesToDB(node, result); } } } }
private Int64 Delete(OTIssueEntity oTIssueEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.OTIssue_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("OTIssueEntity already exists. Please specify another OTIssueEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("OTIssueEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("OTIssueEntity already exists. Please specify another OTIssueEntity."); } } } } 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); } } } }
private void PrepareEditView() { OTIssueEntity oTIssueEntity = CurrentOTIssueEntity; if (!oTIssueEntity.IsNew) { if (ddlIssueCategoryID.Items.Count > 0 && oTIssueEntity.IssueCategoryID != null) { ddlIssueCategoryID.SelectedValue = oTIssueEntity.IssueCategoryID.ToString(); } txtTitle.Text = oTIssueEntity.Title.ToString(); txtDescription.Text = oTIssueEntity.Description.ToString(); if (ddlIssuePriorityID.Items.Count > 0 && oTIssueEntity.IssuePriorityID != null) { ddlIssuePriorityID.SelectedValue = oTIssueEntity.IssuePriorityID.ToString(); } txtCompletionPercentage.Text = oTIssueEntity.CompletionPercentage.ToString(); if (ddlIssueStatusID.Items.Count > 0 && oTIssueEntity.IssueStatusID != null) { ddlIssueStatusID.SelectedValue = oTIssueEntity.IssueStatusID.ToString(); } txtDuration.Text = oTIssueEntity.Duration.ToString(); txtExpectedStartDate.Text = MiscUtil.ConvertDateTSQLStringJQueryUI(DateTime.Parse(oTIssueEntity.ExpectedStartDate.ToString())); txtExpectedEndDate.Text = MiscUtil.ConvertDateTSQLStringJQueryUI(DateTime.Parse(oTIssueEntity.ExpectedEndDate.ToString())); if (oTIssueEntity.ActualStartDate.HasValue) { txtActualStartDate.Text = MiscUtil.ConvertDateTSQLStringJQueryUI(DateTime.Parse(oTIssueEntity.ActualStartDate.ToString())); } else { txtActualStartDate.Text = oTIssueEntity.ActualStartDate.ToStringDefault(); } if (oTIssueEntity.ActualEndDate.HasValue) { txtActualEndDate.Text = MiscUtil.ConvertDateTSQLStringJQueryUI(DateTime.Parse(oTIssueEntity.ActualEndDate.ToString())); } else { txtActualEndDate.Text = oTIssueEntity.ActualEndDate.ToStringDefault(); } if (ddlSupervisorEmployeeID.Items.Count > 0 && oTIssueEntity.SupervisorEmployeeID != null) { ddlSupervisorEmployeeID.SelectedValue = oTIssueEntity.SupervisorEmployeeID.ToString(); } if (ddlAssignedToEmployeeID.Items.Count > 0 && oTIssueEntity.AssignedToEmployeeID != null) { ddlAssignedToEmployeeID.SelectedValue = oTIssueEntity.AssignedToEmployeeID.ToString(); } txtNotifyBeforeMin.Text = oTIssueEntity.NotifyBeforeMin.ToString(); txtRemarks.Text = oTIssueEntity.Remarks.ToString(); switch (Action) { case "Edit": pnlCreateIssue.Visible = false; pnlEditMode.Visible = true; #region Supervior Panel Visible / Invisible Int64 employeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember); if (employeeID > 0) { if (employeeID == CurrentOTIssueEntity.SupervisorEmployeeID) { pnlSupervisor.Visible = true; } } else { pnlSupervisor.Visible = false; } #endregion break; case "EditDetails": pnlCreateIssue.Visible = true; pnlEditMode.Visible = false; break; case "ViewIssue": pnlCreateIssue.Visible = true; pnlEditMode.Visible = true; pnlCreateIssue.Enabled = false; pnlEditMode.Enabled = false; pnlCommon.Enabled = false; btnSubmit.Enabled = false; btnClear.Enabled = false; btnAddNew.Enabled = false; txtRemarks.Enabled = false; break; } pnlCommon.Visible = true; btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private void UpdateCMProjectScheduleTemplateItemMapEntity() { try { Int64 rootTaskID = 0; // search in the database.... String fe1 = SqlExpressionBuilder.PrepareFilterExpression(OTIssueEntity.FLD_NAME_ParentIssueID, String.Empty, SQLMatchType.IsNull); String fe2 = SqlExpressionBuilder.PrepareFilterExpression(OTIssueEntity.FLD_NAME_ReferenceID, this.OverviewProjectID.ToString(), SQLMatchType.Equal); String fe3 = SqlExpressionBuilder.PrepareFilterExpression(OTIssueEntity.FLD_NAME_IssueIdentityCategoryID, MasterDataConstants.IssueIdentityCategory.PROJECT_TASK.ToString(), SQLMatchType.Equal); String fe4 = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2); String fe = SqlExpressionBuilder.PrepareFilterExpression(fe3, SQLJoinType.AND, fe4); IList <OTIssueEntity> temporaryIssueList = FCCOTIssue.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression); if (temporaryIssueList != null && temporaryIssueList.Count > 0) { rootTaskID = Int64.Parse(temporaryIssueList[0].IssueID.ToString()); } else { OTIssueEntity rootTask = new OTIssueEntity(); rootTask.Title = OverviewProject.ProjectName + "Project Schedules"; rootTask.IssueIdentityCategoryID = MasterDataConstants.IssueIdentityCategory.PROJECT_TASK; //Hard Codeed Member rootTask.CreatedByMemberID = this.CurrentMember.MemberID; rootTask.CreateDate = DateTime.Now; rootTask.IsNotifyCompleted = false; rootTask.IsRemoved = false; rootTask.ParentIssueID = null; rootTask.ReferenceID = this.OverviewProjectID; rootTask.ReferenceIssueID = null; #region Badly Hard-Coded Here //Hard Coded Issue Status ID rootTask.IssuePriorityID = 1; rootTask.IssueStatusID = 1; rootTask.IssueCategoryID = 2; #endregion rootTaskID = FCCOTIssue.GetFacadeCreate().Add(rootTask, DatabaseOperationType.Add, TransactionRequired.No); } foreach (TreeNode rootNode in treeProjectSchedule.Nodes) { SaveNodesToDB(rootNode, rootTaskID); } MiscUtil.ShowMessage(lblMessage, "Project Schedule Template Issue Information has been added successfully.", false); } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, "An Error Occoured.", true); } }
private void PrepareEditView() { OTIssueEntity oTIssueEntity = CurrentOTIssueEntity; }
Int64 IOTIssueFacade.Delete(OTIssueEntity oTIssueEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateOTIssueDataAccess().Delete(oTIssueEntity, filterExpression, option, reqTran)); }
private void SaveOTIssueEntity() { if (IsValid) { try { OTIssueEntity oTIssueEntity = BuildOTIssueEntity(); Int64 result = -1; if (oTIssueEntity.IsNew) { result = FCCOTIssue.GetFacadeCreate().Add(oTIssueEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(OTIssueEntity.FLD_NAME_IssueID, oTIssueEntity.IssueID.ToString(), SQLMatchType.Equal); result = FCCOTIssue.GetFacadeCreate().Update(oTIssueEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { if (oTIssueEntity.IsNew) { #region Send Notification String mailSubject = String.Empty; String mailBody = String.Empty; String[] mailTo = new String[1]; String fe = SqlExpressionBuilder.PrepareFilterExpression("OTIssue." + OTIssueEntity.FLD_NAME_IssueID, result.ToString(), SQLMatchType.Equal); IList <OTIssue_DetailedEntity> lstOTIssueEntity = FCCOTIssue_Detailed.GetFacadeCreate().GetIL(10000, 1, String.Empty, fe); if (lstOTIssueEntity != null && lstOTIssueEntity.Count > 0) { mailSubject = lstOTIssueEntity[0].Title.ToString() + "-" + lstOTIssueEntity[0].SupervisorFullName; mailBody = lstOTIssueEntity[0].Description.ToString(); mailBody += "<br/>"; mailBody += "<br/>"; mailBody += "Expected Start Date: " + lstOTIssueEntity[0].ExpectedStartDate.ToString(UIConstants.SHORT_DATE_FORMAT); mailBody += "<br/>"; mailBody += "Expected End Date: " + lstOTIssueEntity[0].ExpectedEndDate.ToString(UIConstants.SHORT_DATE_FORMAT); HREmployeeEntity hREmployeeEntitiy = FCCHREmployee.GetFacadeCreate().GetByID(lstOTIssueEntity[0].AssignedToEmployeeID); if (hREmployeeEntitiy != null && hREmployeeEntitiy.EmployeeID > 0) { mailTo[0] = hREmployeeEntitiy.PrimaryEmail; MiscUtil.SendMail(mailTo, mailSubject, mailBody); } } #endregion _IssueID = 0; _OTIssueEntity = new OTIssueEntity(); PrepareInitialView(); MiscUtil.ShowMessage(lblMessage, "Issue Information has been added successfully.", false); String NavigationUrl = UrlHelper.BuildSecureUrl("~/OT/OTIssueAssignedResource.aspx", string.Empty, UrlConstants.OVERVIEW_ISSUE_ID, result.ToString()).ToString(); Response.Redirect(NavigationUrl); } else { PrepareInitialView(); PrepareEditView(); MiscUtil.ShowMessage(lblMessage, "Issue Information has been updated successfully.", false); } } else { if (oTIssueEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Issue Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Issue Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private Int64 Add(OTIssueEntity oTIssueEntity, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.OTIssue_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddNullPrimaryKeyParameter(cmd, "IssueID"); Database.AddInParameter(cmd, "@IssueIdentityCategoryID", DbType.Int64, oTIssueEntity.IssueIdentityCategoryID); Database.AddInParameter(cmd, "@IssueCategoryID", DbType.Int64, oTIssueEntity.IssueCategoryID); Database.AddInParameter(cmd, "@ParentIssueID", DbType.Int64, oTIssueEntity.ParentIssueID); Database.AddInParameter(cmd, "@ReferenceID", DbType.Int64, oTIssueEntity.ReferenceID); Database.AddInParameter(cmd, "@Title", DbType.String, oTIssueEntity.Title); Database.AddInParameter(cmd, "@Description", DbType.String, oTIssueEntity.Description); Database.AddInParameter(cmd, "@IssuePriorityID", DbType.Int64, oTIssueEntity.IssuePriorityID); Database.AddInParameter(cmd, "@CompletionPercentage", DbType.Decimal, oTIssueEntity.CompletionPercentage); Database.AddInParameter(cmd, "@IssueStatusID", DbType.Int64, oTIssueEntity.IssueStatusID); Database.AddInParameter(cmd, "@CreatedByMemberID", DbType.Int64, oTIssueEntity.CreatedByMemberID); Database.AddInParameter(cmd, "@CreateDate", DbType.DateTime, oTIssueEntity.CreateDate); Database.AddInParameter(cmd, "@Duration", DbType.Decimal, oTIssueEntity.Duration); Database.AddInParameter(cmd, "@ExpectedStartDate", DbType.DateTime, oTIssueEntity.ExpectedStartDate); Database.AddInParameter(cmd, "@ExpectedEndDate", DbType.DateTime, oTIssueEntity.ExpectedEndDate); Database.AddInParameter(cmd, "@ActualStartDate", DbType.DateTime, oTIssueEntity.ActualStartDate); Database.AddInParameter(cmd, "@ActualEndDate", DbType.DateTime, oTIssueEntity.ActualEndDate); Database.AddInParameter(cmd, "@NotifyBeforeMin", DbType.Int32, oTIssueEntity.NotifyBeforeMin); Database.AddInParameter(cmd, "@IsNotifyCompleted", DbType.Boolean, oTIssueEntity.IsNotifyCompleted); Database.AddInParameter(cmd, "@SupervisorEmployeeID", DbType.Int64, oTIssueEntity.SupervisorEmployeeID); Database.AddInParameter(cmd, "@AssignedToEmployeeID", DbType.Int64, oTIssueEntity.AssignedToEmployeeID); Database.AddInParameter(cmd, "@Remarks", DbType.String, oTIssueEntity.Remarks); Database.AddInParameter(cmd, "@ReferenceIssueID", DbType.Int64, oTIssueEntity.ReferenceIssueID); Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, oTIssueEntity.IsRemoved); Database.AddInParameter(cmd, "@SupervisorAgreed", DbType.Boolean, oTIssueEntity.SupervisorAgreed); Database.AddInParameter(cmd, "@ModifiedBySupervisorDateTime", DbType.DateTime, oTIssueEntity.ModifiedBySupervisorDateTime); Database.AddInParameter(cmd, "@IP", DbType.String, oTIssueEntity.IP); Database.AddInParameter(cmd, "@DTLDuration", DbType.String, oTIssueEntity.DTLDuration); Database.AddInParameter(cmd, "@ProjectID", DbType.Int64, oTIssueEntity.ProjectID); Database.AddInParameter(cmd, "@ProjectFloorID", DbType.Int64, oTIssueEntity.ProjectFloorID); Database.AddInParameter(cmd, "@ProjectFloorUnitID", DbType.Int64, oTIssueEntity.ProjectFloorUnitID); Database.AddInParameter(cmd, "@ProjectFloorUnitLocationID", DbType.Int64, oTIssueEntity.ProjectFloorUnitLocationID); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("OTIssueEntity already exists. Please specify another OTIssueEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("OTIssueEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("OTIssueEntity already exists. Please specify another OTIssueEntity."); } } } } return(returnCode); }
Int64 IOTIssueFacade.Add(OTIssueEntity oTIssueEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateOTIssueDataAccess().Add(oTIssueEntity, option, reqTran)); }
private OTIssueEntity BuildOTIssueEntity() { OTIssueEntity oTIssueEntity = CurrentOTIssueEntity; #region User Input if (ddlIssueCategoryID.Items.Count > 0) { if (ddlIssueCategoryID.SelectedValue == "0") { } else { oTIssueEntity.IssueCategoryID = Int64.Parse(ddlIssueCategoryID.SelectedValue); } } oTIssueEntity.Title = txtTitle.Text.Trim(); oTIssueEntity.Description = txtDescription.Text.Trim(); if (ddlIssuePriorityID.Items.Count > 0) { if (ddlIssuePriorityID.SelectedValue == "0") { } else { oTIssueEntity.IssuePriorityID = Int64.Parse(ddlIssuePriorityID.SelectedValue); } } if (!txtCompletionPercentage.Text.Trim().IsNullOrEmpty()) { oTIssueEntity.CompletionPercentage = Decimal.Parse(txtCompletionPercentage.Text.Trim()); } else { oTIssueEntity.CompletionPercentage = 0; } if (ddlIssueStatusID.Items.Count > 0) { if (ddlIssueStatusID.SelectedValue == "0") { } else { oTIssueEntity.IssueStatusID = Int64.Parse(ddlIssueStatusID.SelectedValue); } } if (!txtDuration.Text.Trim().IsNullOrEmpty()) { oTIssueEntity.Duration = Decimal.Parse(txtDuration.Text.Trim()); } else { oTIssueEntity.Duration = null; } if (txtExpectedStartDate.Text.Trim().IsNotNullOrEmpty()) { oTIssueEntity.ExpectedStartDate = MiscUtil.ParseToDateTimeJQueryUI(txtExpectedStartDate.Text); } else { oTIssueEntity.ExpectedStartDate = null; } if (txtExpectedEndDate.Text.Trim().IsNotNullOrEmpty()) { oTIssueEntity.ExpectedEndDate = MiscUtil.ParseToDateTimeJQueryUI(txtExpectedEndDate.Text); } else { oTIssueEntity.ExpectedEndDate = null; } if (txtActualStartDate.Text.Trim().IsNotNullOrEmpty()) { oTIssueEntity.ActualStartDate = MiscUtil.ParseToDateTimeJQueryUI(txtActualStartDate.Text); } else { oTIssueEntity.ActualStartDate = oTIssueEntity.ExpectedStartDate; } if (txtActualEndDate.Text.Trim().IsNotNullOrEmpty()) { oTIssueEntity.ActualEndDate = MiscUtil.ParseToDateTimeJQueryUI(txtActualEndDate.Text); } else { oTIssueEntity.ActualEndDate = oTIssueEntity.ExpectedEndDate; } if (!txtNotifyBeforeMin.Text.Trim().IsNullOrEmpty()) { oTIssueEntity.NotifyBeforeMin = Int32.Parse(txtNotifyBeforeMin.Text.Trim()); } else { oTIssueEntity.NotifyBeforeMin = null; } if (ddlSupervisorEmployeeID.Items.Count > 0) { if (ddlSupervisorEmployeeID.SelectedValue == "0") { } else { oTIssueEntity.SupervisorEmployeeID = Int64.Parse(ddlSupervisorEmployeeID.SelectedValue); } } if (ddlAssignedToEmployeeID.Items.Count > 0) { if (ddlAssignedToEmployeeID.SelectedValue == "0") { } else { oTIssueEntity.AssignedToEmployeeID = Int64.Parse(ddlAssignedToEmployeeID.SelectedValue); } } oTIssueEntity.SupervisorAgreed = true; oTIssueEntity.ModifiedBySupervisorDateTime = System.DateTime.Now; oTIssueEntity.IP = MiscUtil.GetLocalIP(); oTIssueEntity.Remarks = txtRemarks.Text.Trim(); #endregion User Input #region Manual Input if (oTIssueEntity.IsNew) { oTIssueEntity.IssueIdentityCategoryID = MasterDataConstants.IssueIdentityCategory.PROJECT_ADHOC_ISSUE; oTIssueEntity.CreatedByMemberID = this.CurrentMember.MemberID; oTIssueEntity.CreateDate = DateTime.Now; oTIssueEntity.IsNotifyCompleted = false; oTIssueEntity.IsRemoved = false; oTIssueEntity.ParentIssueID = null; if (ddlProjectID.Items.Count > 0) { if (ddlProjectID.SelectedValue == "0") { } else { oTIssueEntity.ReferenceID = Int64.Parse(ddlProjectID.SelectedValue); } } oTIssueEntity.ReferenceIssueID = null; } if (Action == "AddSubIssue") { oTIssueEntity.ParentIssueID = _ParentIssueID; } else if (Action == "AddReferenceIssue") { oTIssueEntity.ReferenceIssueID = _ReferenceIssueID; } #endregion Manual Input return(oTIssueEntity); }
private void PrepareEditView() { OTIssueEntity oTIssueEntity = CurrentOTIssueEntity; //if (!oTIssueEntity.IsNew) //{ // if (ddlIssueIdentityCategoryID.Items.Count > 0 && oTIssueEntity.IssueIdentityCategoryID != null) // { // ddlIssueIdentityCategoryID.SelectedValue = oTIssueEntity.IssueIdentityCategoryID.ToString(); // } // if (ddlIssueCategoryID.Items.Count > 0 && oTIssueEntity.IssueCategoryID != null) // { // ddlIssueCategoryID.SelectedValue = oTIssueEntity.IssueCategoryID.ToString(); // } // if (ddlParentIssueID.Items.Count > 0 && oTIssueEntity.ParentIssueID != null) // { // ddlParentIssueID.SelectedValue = oTIssueEntity.ParentIssueID.ToString(); // } // txtReferenceID.Text = oTIssueEntity.ReferenceID.ToString(); // txtTitle.Text = oTIssueEntity.Title.ToString(); // txtDescription.Text = oTIssueEntity.Description.ToString(); // if (ddlIssuePriorityID.Items.Count > 0 && oTIssueEntity.IssuePriorityID != null) // { // ddlIssuePriorityID.SelectedValue = oTIssueEntity.IssuePriorityID.ToString(); // } // txtCompletionPercentage.Text = oTIssueEntity.CompletionPercentage.ToString(); // if (ddlIssueStatusID.Items.Count > 0 && oTIssueEntity.IssueStatusID != null) // { // ddlIssueStatusID.SelectedValue = oTIssueEntity.IssueStatusID.ToString(); // } // if (ddlCreatedByMemberID.Items.Count > 0 && oTIssueEntity.CreatedByMemberID != null) // { // ddlCreatedByMemberID.SelectedValue = oTIssueEntity.CreatedByMemberID.ToString(); // } // txtCreateDate.Text = oTIssueEntity.CreateDate.ToStringDefault(); // txtDuration.Text = oTIssueEntity.Duration.ToString(); // txtExpectedStartDate.Text = oTIssueEntity.ExpectedStartDate.ToStringDefault(); // txtExpectedEndDate.Text = oTIssueEntity.ExpectedEndDate.ToStringDefault(); // txtActualStartDate.Text = oTIssueEntity.ActualStartDate.ToStringDefault(); // txtActualEndDate.Text = oTIssueEntity.ActualEndDate.ToStringDefault(); // txtNotifyBeforeMin.Text = oTIssueEntity.NotifyBeforeMin.ToString(); // chkIsNotifyCompleted.Checked = oTIssueEntity.IsNotifyCompleted; // txtRemarks.Text = oTIssueEntity.Remarks.ToString(); // if (ddlReferenceIssueID.Items.Count > 0 && oTIssueEntity.ReferenceIssueID != null) // { // ddlReferenceIssueID.SelectedValue = oTIssueEntity.ReferenceIssueID.ToString(); // } // chkIsRemoved.Checked = oTIssueEntity.IsRemoved; // btnSubmit.Text = "Update"; // btnAddNew.Visible = true; //} }
private void SaveHREmployeeEntity() { if (IsValid) { try { #region Member HRMemberEntity hRMemberEntity = BuildHRMemberEntity(); Int64 result = -1; if (hRMemberEntity.IsNew) { result = FCCHRMember.GetFacadeCreate().Add(hRMemberEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HRMemberEntity.FLD_NAME_MemberID, hRMemberEntity.MemberID.ToString(), SQLMatchType.Equal); result = FCCHRMember.GetFacadeCreate().Update(hRMemberEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } #endregion if (result > 0) { _MemberID = 0; _HRMemberEntity = new HRMemberEntity(); } if (result > 0) { HREmployeeEntity hREmployeeEntity = BuildHREmployeeEntity(); Int64 resultC = -1; if (hREmployeeEntity.IsNew) { hREmployeeEntity.MemberID = result; resultC = FCCHREmployee.GetFacadeCreate().Add(hREmployeeEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeEntity.FLD_NAME_EmployeeID, hREmployeeEntity.EmployeeID.ToString(), SQLMatchType.Equal); resultC = FCCHREmployee.GetFacadeCreate().Update(hREmployeeEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } #region Create Six Task For HR try { StringBuilder xmlStr = new StringBuilder(); Int64 employeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember); Int64 referenceID = 49; DateTime joinDate = (DateTime)hREmployeeEntity.JoinDate; String fe = "DepartmentID = " + MasterDataConstants.MDDepartment.HR_DEPARTMENTID + ""; IList <HREmployeeEntity> lst = FCCHREmployee.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression); #region Delete Old Task String filter = "IssueIdentityCategoryID = " + MasterDataConstants.MDIssueIdentityCategory.HRMETTINGWITHEMPLOYEE + " and SupervisorEmployeeID = " + hREmployeeEntity.EmployeeID + ""; IList <OTIssueEntity> issueList = FCCOTIssue.GetFacadeCreate().GetIL(null, null, String.Empty, filter, DatabaseOperationType.LoadWithFilterExpression); if (issueList != null && issueList.Count > 0) { OTIssueEntity oTIssueEntity = new OTIssueEntity(); FCCOTIssue.GetFacadeCreate().Delete(oTIssueEntity, filter, DatabaseOperationType.Delete, TransactionRequired.No); } #endregion String title = "Employee Name: " + hRMemberEntity.FirstName + " " + hRMemberEntity.MiddleName + " " + hRMemberEntity.LastName + ", Code: " + hREmployeeEntity.EmployeeCode + " join Date: " + hREmployeeEntity.JoinDate + " has metting with you"; xmlStr.Append("<m>"); if (lst != null && lst.Count > 0) { foreach (HREmployeeEntity e in lst) { for (int i = 1; i <= 6; i++) { String subXmlStr = null; subXmlStr = subXmlStr + "<i><a>" + title + "</a><b>" + hREmployeeEntity.EmployeeID + "</b><c>" + e.EmployeeID + "</c><d>" + CurrentMember.MemberID + "</d><e>" + referenceID + "</e><f>" + joinDate.AddDays(i * 30) + "</f><g>" + joinDate.AddDays((i * 30) + 1) + "</g></i>"; xmlStr.Append(subXmlStr.ToString()); } } } xmlStr.Append("</m>"); FCCBulkInsertXML.GetFacadeCreate().GetIL(xmlStr.ToString(), CommonConstants.CreateSixTaskForHR); MiscUtil.ShowMessage(lblMessage, "Six Task has created for HR Successfully.", false); } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, "An Error Occoured.", true); } #endregion if (resultC > 0) { _EmployeeID = 0; _HREmployeeEntity = new HREmployeeEntity(); PrepareInitialView(); BindHREmployeeList(); if (hREmployeeEntity.IsNew) { ResourceEntity resourceEntity = new ResourceEntity(); resourceEntity.ReferenceID = resultC; // means new employee id resourceEntity.ResourceCategoryID = MasterDataConstants.ResourceCategory.EMPLOYEE; FCCResource.GetFacadeCreate().Add(resourceEntity, DatabaseOperationType.Add, TransactionRequired.No); } if (hREmployeeEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Employee Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Employee Information has been updated successfully.", false); } } else { if (hREmployeeEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Employee Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Employee Information.", false); } } } else { if (hRMemberEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Member Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Member Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private OTIssueEntity BuildOTIssueEntity() { OTIssueEntity oTIssueEntity = CurrentOTIssueEntity; //if (ddlIssueIdentityCategoryID.Items.Count > 0) //{ // if (ddlIssueIdentityCategoryID.SelectedValue == "0") // { // } // else // { // oTIssueEntity.IssueIdentityCategoryID = Int64.Parse(ddlIssueIdentityCategoryID.SelectedValue); // } //} //if (ddlIssueCategoryID.Items.Count > 0) //{ // if (ddlIssueCategoryID.SelectedValue == "0") // { // } // else // { // oTIssueEntity.IssueCategoryID = Int64.Parse(ddlIssueCategoryID.SelectedValue); // } //} //if (ddlParentIssueID.Items.Count > 0) //{ // if (ddlParentIssueID.SelectedValue == "0") // { // oTIssueEntity.ParentIssueID = null; // } // else // { // oTIssueEntity.ParentIssueID = Int64.Parse(ddlParentIssueID.SelectedValue); // } //} //if (!txtReferenceID.Text.Trim().IsNullOrEmpty()) //{ // oTIssueEntity.ReferenceID = Int64.Parse(txtReferenceID.Text.Trim()); //} //else //{ // oTIssueEntity.ReferenceID = null; //} //oTIssueEntity.Title = txtTitle.Text.Trim(); //oTIssueEntity.Description = txtDescription.Text.Trim(); //if (ddlIssuePriorityID.Items.Count > 0) //{ // if (ddlIssuePriorityID.SelectedValue == "0") // { // } // else // { // oTIssueEntity.IssuePriorityID = Int64.Parse(ddlIssuePriorityID.SelectedValue); // } //} //if (!txtCompletionPercentage.Text.Trim().IsNullOrEmpty()) //{ // oTIssueEntity.CompletionPercentage = Decimal.Parse(txtCompletionPercentage.Text.Trim()); //} //else //{ // oTIssueEntity.CompletionPercentage = null; //} //if (ddlIssueStatusID.Items.Count > 0) //{ // if (ddlIssueStatusID.SelectedValue == "0") // { // } // else // { // oTIssueEntity.IssueStatusID = Int64.Parse(ddlIssueStatusID.SelectedValue); // } //} //if (ddlCreatedByMemberID.Items.Count > 0) //{ // if (ddlCreatedByMemberID.SelectedValue == "0") // { // } // else // { // oTIssueEntity.CreatedByMemberID = Int64.Parse(ddlCreatedByMemberID.SelectedValue); // } //} //if (txtCreateDate.Text.Trim().IsNotNullOrEmpty()) //{ // oTIssueEntity.CreateDate = MiscUtil.ParseToDateTime(txtCreateDate.Text); //} //else //{ // oTIssueEntity.CreateDate = null; //} //if (!txtDuration.Text.Trim().IsNullOrEmpty()) //{ // oTIssueEntity.Duration = Decimal.Parse(txtDuration.Text.Trim()); //} //else //{ // oTIssueEntity.Duration = null; //} //if (txtExpectedStartDate.Text.Trim().IsNotNullOrEmpty()) //{ // oTIssueEntity.ExpectedStartDate = MiscUtil.ParseToDateTime(txtExpectedStartDate.Text); //} //else //{ // oTIssueEntity.ExpectedStartDate = null; //} //if (txtExpectedEndDate.Text.Trim().IsNotNullOrEmpty()) //{ // oTIssueEntity.ExpectedEndDate = MiscUtil.ParseToDateTime(txtExpectedEndDate.Text); //} //else //{ // oTIssueEntity.ExpectedEndDate = null; //} //if (txtActualStartDate.Text.Trim().IsNotNullOrEmpty()) //{ // oTIssueEntity.ActualStartDate = MiscUtil.ParseToDateTime(txtActualStartDate.Text); //} //else //{ // oTIssueEntity.ActualStartDate = null; //} //if (txtActualEndDate.Text.Trim().IsNotNullOrEmpty()) //{ // oTIssueEntity.ActualEndDate = MiscUtil.ParseToDateTime(txtActualEndDate.Text); //} //else //{ // oTIssueEntity.ActualEndDate = null; //} //if (!txtNotifyBeforeMin.Text.Trim().IsNullOrEmpty()) //{ // oTIssueEntity.NotifyBeforeMin = Int32.Parse(txtNotifyBeforeMin.Text.Trim()); //} //else //{ // oTIssueEntity.NotifyBeforeMin = null; //} //oTIssueEntity.IsNotifyCompleted = chkIsNotifyCompleted.Checked; //oTIssueEntity.Remarks = txtRemarks.Text.Trim(); //if (ddlReferenceIssueID.Items.Count > 0) //{ // if (ddlReferenceIssueID.SelectedValue == "0") // { // oTIssueEntity.ReferenceIssueID = null; // } // else // { // oTIssueEntity.ReferenceIssueID = Int64.Parse(ddlReferenceIssueID.SelectedValue); // } //} //oTIssueEntity.IsRemoved = chkIsRemoved.Checked; return(oTIssueEntity); }
private Int64 UpdateTran(OTIssueEntity oTIssueEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.OTIssue_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, "@IssueID", DbType.Int64, oTIssueEntity.IssueID); db.AddInParameter(cmd, "@IssueIdentityCategoryID", DbType.Int64, oTIssueEntity.IssueIdentityCategoryID); db.AddInParameter(cmd, "@IssueCategoryID", DbType.Int64, oTIssueEntity.IssueCategoryID); db.AddInParameter(cmd, "@ParentIssueID", DbType.Int64, oTIssueEntity.ParentIssueID); db.AddInParameter(cmd, "@ReferenceID", DbType.Int64, oTIssueEntity.ReferenceID); db.AddInParameter(cmd, "@Title", DbType.String, oTIssueEntity.Title); db.AddInParameter(cmd, "@Description", DbType.String, oTIssueEntity.Description); db.AddInParameter(cmd, "@IssuePriorityID", DbType.Int64, oTIssueEntity.IssuePriorityID); db.AddInParameter(cmd, "@CompletionPercentage", DbType.Decimal, oTIssueEntity.CompletionPercentage); db.AddInParameter(cmd, "@IssueStatusID", DbType.Int64, oTIssueEntity.IssueStatusID); db.AddInParameter(cmd, "@CreatedByMemberID", DbType.Int64, oTIssueEntity.CreatedByMemberID); db.AddInParameter(cmd, "@CreateDate", DbType.DateTime, oTIssueEntity.CreateDate); db.AddInParameter(cmd, "@Duration", DbType.Decimal, oTIssueEntity.Duration); db.AddInParameter(cmd, "@ExpectedStartDate", DbType.DateTime, oTIssueEntity.ExpectedStartDate); db.AddInParameter(cmd, "@ExpectedEndDate", DbType.DateTime, oTIssueEntity.ExpectedEndDate); db.AddInParameter(cmd, "@ActualStartDate", DbType.DateTime, oTIssueEntity.ActualStartDate); db.AddInParameter(cmd, "@ActualEndDate", DbType.DateTime, oTIssueEntity.ActualEndDate); db.AddInParameter(cmd, "@NotifyBeforeMin", DbType.Int32, oTIssueEntity.NotifyBeforeMin); db.AddInParameter(cmd, "@IsNotifyCompleted", DbType.Boolean, oTIssueEntity.IsNotifyCompleted); db.AddInParameter(cmd, "@SupervisorEmployeeID", DbType.Int64, oTIssueEntity.SupervisorEmployeeID); db.AddInParameter(cmd, "@AssignedToEmployeeID", DbType.Int64, oTIssueEntity.AssignedToEmployeeID); db.AddInParameter(cmd, "@Remarks", DbType.String, oTIssueEntity.Remarks); db.AddInParameter(cmd, "@ReferenceIssueID", DbType.Int64, oTIssueEntity.ReferenceIssueID); db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, oTIssueEntity.IsRemoved); db.AddInParameter(cmd, "@SupervisorAgreed", DbType.Boolean, oTIssueEntity.SupervisorAgreed); db.AddInParameter(cmd, "@ModifiedBySupervisorDateTime", DbType.DateTime, oTIssueEntity.ModifiedBySupervisorDateTime); db.AddInParameter(cmd, "@IP", DbType.String, oTIssueEntity.IP); db.AddInParameter(cmd, "@DTLDuration", DbType.String, oTIssueEntity.DTLDuration); db.AddInParameter(cmd, "@ProjectID", DbType.Int64, oTIssueEntity.ProjectID); db.AddInParameter(cmd, "@ProjectFloorID", DbType.Int64, oTIssueEntity.ProjectFloorID); db.AddInParameter(cmd, "@ProjectFloorUnitID", DbType.Int64, oTIssueEntity.ProjectFloorUnitID); db.AddInParameter(cmd, "@ProjectFloorUnitLocationID", DbType.Int64, oTIssueEntity.ProjectFloorUnitLocationID); 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 btnAddNew_Click(object sender, EventArgs e) { _IssueID = 0; _OTIssueEntity = new OTIssueEntity(); PrepareInitialView(); }
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); } } }