Int64 IBDProjectDataAccess.Delete(BDProjectEntity bDProjectEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Delete(bDProjectEntity, filterExpression, option); break; } case TransactionRequired.Yes: { retValues = DeleteTran(bDProjectEntity, filterExpression, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
Int64 IBDProjectDataAccess.Add(BDProjectEntity bDProjectEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(bDProjectEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(bDProjectEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void BuildProjectCodeByProjectID() { if (ddlProjectID != null && ddlProjectID.SelectedValue != "0") { BDProjectEntity lstProject = FCCBDProject.GetFacadeCreate().GetByID(Int64.Parse(ddlProjectID.SelectedValue.ToString())); txtProjectCode.Text = lstProject.ProjectCode.ToString(); MiscUtil.PopulateCMBillByProject(ddlBillID, true, Int64.Parse(ddlProjectID.SelectedValue.ToString())); } }
private Int64 Update(BDProjectEntity bDProjectEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.BDProject_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@ProjectID", DbType.Int64, bDProjectEntity.ProjectID); Database.AddInParameter(cmd, "@OperatorID", DbType.Int64, bDProjectEntity.OperatorID); Database.AddInParameter(cmd, "@ZoneID", DbType.Int64, bDProjectEntity.ZoneID); Database.AddInParameter(cmd, "@ProjectCode", DbType.String, bDProjectEntity.ProjectCode); Database.AddInParameter(cmd, "@ProjectName", DbType.String, bDProjectEntity.ProjectName); Database.AddInParameter(cmd, "@LandAreaKatha", DbType.Decimal, bDProjectEntity.LandAreaKatha); Database.AddInParameter(cmd, "@LandAreaSft", DbType.Decimal, bDProjectEntity.LandAreaSft); Database.AddInParameter(cmd, "@RoadWidth", DbType.Decimal, bDProjectEntity.RoadWidth); Database.AddInParameter(cmd, "@RoadWidthUnitID", DbType.Int64, bDProjectEntity.RoadWidthUnitID); Database.AddInParameter(cmd, "@NoOfStoried", DbType.Int32, bDProjectEntity.NoOfStoried); Database.AddInParameter(cmd, "@NoOfBasement", DbType.Int32, bDProjectEntity.NoOfBasement); Database.AddInParameter(cmd, "@Description", DbType.String, bDProjectEntity.Description); Database.AddInParameter(cmd, "@BSC", DbType.String, bDProjectEntity.BSC); Database.AddInParameter(cmd, "@ClientPercentage", DbType.Decimal, bDProjectEntity.ClientPercentage); Database.AddInParameter(cmd, "@CompanyPercentage", DbType.Decimal, bDProjectEntity.CompanyPercentage); Database.AddInParameter(cmd, "@ProjectCategoryID", DbType.Int64, bDProjectEntity.ProjectCategoryID); Database.AddInParameter(cmd, "@ProjectStatusID", DbType.Int64, bDProjectEntity.ProjectStatusID); Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, bDProjectEntity.IsRemoved); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("BDProjectEntity already exists. Please specify another BDProjectEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("BDProjectEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("BDProjectEntity already exists. Please specify another BDProjectEntity."); } } } } return(returnCode); }
private void SaveBDProjectEntity() { if (IsValid) { try { BDProjectEntity bDProjectEntity = BuildBDProjectEntity(); Int64 result = -1; if (bDProjectEntity.IsNew) { result = FCCBDProject.GetFacadeCreate().Add(bDProjectEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(BDProjectEntity.FLD_NAME_ProjectID, bDProjectEntity.ProjectID.ToString(), SQLMatchType.Equal); result = FCCBDProject.GetFacadeCreate().Update(bDProjectEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _ProjectID = 0; _BDProjectEntity = new BDProjectEntity(); PrepareInitialView(); BindBDProjectList(); if (bDProjectEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Project Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Project Information has been updated successfully.", false); } } else { if (bDProjectEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Project Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Project Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private REQRequisitionEntity BuildREQRequisitionEntity() { REQRequisitionEntity rEQRequisitionEntity = CurrentREQRequisitionEntity; if (rEQRequisitionEntity.IsNew) { if (ddlProjectID.Items.Count > 0) { if (ddlProjectID.SelectedValue == "0") { } else { rEQRequisitionEntity.ProjectID = Int64.Parse(ddlProjectID.SelectedValue); } } } BDProjectEntity _bDProjectEntity = FCCBDProject.GetFacadeCreate().GetByID(rEQRequisitionEntity.ProjectID); if (_bDProjectEntity != null && txtRequisitionNo.Text.ToString() == MasterDataConstants.AutoAssigned.DEFAULT_AUTO_ASSIGNED) { rEQRequisitionEntity.RequisitionNo = _bDProjectEntity.ProjectCode; } else if (_bDProjectEntity != null && txtRequisitionNo.Text.ToString() != MasterDataConstants.AutoAssigned.DEFAULT_AUTO_ASSIGNED) { rEQRequisitionEntity.RequisitionNo = txtRequisitionNo.Text.ToString(); } if (txtRequisitionDate.Text.Trim().IsNotNullOrEmpty()) { rEQRequisitionEntity.RequisitionDate = MiscUtil.ParseToDateTime(txtRequisitionDate.Text); } rEQRequisitionEntity.Remarks = txtRemarks.Text.Trim(); if (ddlRequisitionStatusID.Items.Count > 0) { if (ddlRequisitionStatusID.SelectedValue == "0") { } else { rEQRequisitionEntity.RequisitionStatusID = Int64.Parse(ddlRequisitionStatusID.SelectedValue); } } rEQRequisitionEntity.IsCashPayment = chkIsCashPayment.Checked; rEQRequisitionEntity.IsAccountsMadePayment = false; rEQRequisitionEntity.IsRCS = chkIsRCS.Checked; return(rEQRequisitionEntity); }
protected void lvBDProject_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 ProjectID; Int64.TryParse(e.CommandArgument.ToString(), out ProjectID); if (ProjectID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _ProjectID = ProjectID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(BDProjectEntity.FLD_NAME_ProjectID, ProjectID.ToString(), SQLMatchType.Equal); BDProjectEntity bDProjectEntity = new BDProjectEntity(); result = FCCBDProject.GetFacadeCreate().Delete(bDProjectEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _ProjectID = 0; _BDProjectEntity = new BDProjectEntity(); PrepareInitialView(); BindBDProjectList(); MiscUtil.ShowMessage(lblMessage, "Project has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Project.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 DeleteTran(BDProjectEntity bDProjectEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.BDProject_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 Int64 Delete(BDProjectEntity bDProjectEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.BDProject_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("BDProjectEntity already exists. Please specify another BDProjectEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("BDProjectEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("BDProjectEntity already exists. Please specify another BDProjectEntity."); } } } } return(returnCode); }
private void PrepareEditView() { BDProjectEntity bDProjectEntity = CurrentBDProjectEntity; if (!bDProjectEntity.IsNew) { if (ddlOperatorID.Items.Count > 0 && bDProjectEntity.OperatorID != null) { ddlOperatorID.SelectedValue = bDProjectEntity.OperatorID.ToString(); } if (ddlZoneID.Items.Count > 0 && bDProjectEntity.ZoneID != null) { ddlZoneID.SelectedValue = bDProjectEntity.ZoneID.ToString(); } txtProjectCode.Text = bDProjectEntity.ProjectCode.ToString(); txtProjectName.Text = bDProjectEntity.ProjectName.ToString(); txtDescription.Text = bDProjectEntity.Description.ToString(); txtBSC.Text = bDProjectEntity.BSC.ToString(); txtCompanyPercentage.Text = bDProjectEntity.CompanyPercentage.ToString(); if (ddlProjectCategoryID.Items.Count > 0 && bDProjectEntity.ProjectCategoryID != null) { ddlProjectCategoryID.SelectedValue = bDProjectEntity.ProjectCategoryID.ToString(); } if (ddlProjectStatusID.Items.Count > 0 && bDProjectEntity.ProjectStatusID != null) { ddlProjectStatusID.SelectedValue = bDProjectEntity.ProjectStatusID.ToString(); } chkIsRemoved.Checked = bDProjectEntity.IsRemoved; btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
protected void btnAddNew_Click(object sender, EventArgs e) { _ProjectID = 0; _BDProjectEntity = new BDProjectEntity(); PrepareInitialView(); }
private BDProjectEntity BuildBDProjectEntity() { BDProjectEntity bDProjectEntity = CurrentBDProjectEntity; if (ddlOperatorID.Items.Count > 0) { if (ddlOperatorID.SelectedValue == "0") { } else { bDProjectEntity.OperatorID = Int64.Parse(ddlOperatorID.SelectedValue); } } if (ddlZoneID.Items.Count > 0) { if (ddlZoneID.SelectedValue == "0") { } else { bDProjectEntity.ZoneID = Int64.Parse(ddlZoneID.SelectedValue); } } bDProjectEntity.ProjectCode = txtProjectCode.Text.Trim(); bDProjectEntity.ProjectName = txtProjectName.Text.Trim(); bDProjectEntity.LandAreaKatha = null; bDProjectEntity.LandAreaSft = null; bDProjectEntity.RoadWidth = null; bDProjectEntity.RoadWidthUnitID = null; bDProjectEntity.NoOfStoried = null; bDProjectEntity.NoOfBasement = null; bDProjectEntity.Description = txtDescription.Text.Trim(); bDProjectEntity.BSC = txtBSC.Text.Trim(); bDProjectEntity.ClientPercentage = null; if (!txtCompanyPercentage.Text.Trim().IsNullOrEmpty()) { bDProjectEntity.CompanyPercentage = Decimal.Parse(txtCompanyPercentage.Text.Trim()); } else { bDProjectEntity.CompanyPercentage = null; } if (ddlProjectCategoryID.Items.Count > 0) { if (ddlProjectCategoryID.SelectedValue == "0") { } else { bDProjectEntity.ProjectCategoryID = Int64.Parse(ddlProjectCategoryID.SelectedValue); } } if (ddlProjectStatusID.Items.Count > 0) { if (ddlProjectStatusID.SelectedValue == "0") { } else { bDProjectEntity.ProjectStatusID = Int64.Parse(ddlProjectStatusID.SelectedValue); } } bDProjectEntity.IsRemoved = chkIsRemoved.Checked; return(bDProjectEntity); }
protected void lvACCPrePayableStatementDetail_ItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { ListViewDataItem dataItem = (ListViewDataItem)e.Item; ACCPostPayableStatementDetailEntity ent = (ACCPostPayableStatementDetailEntity)dataItem.DataItem; Label lblProjectNameLV = (Label)e.Item.FindControl("lblProjectNameLV"); Label lblVendorCategoryNameLV = (Label)e.Item.FindControl("lblVendorCategoryNameLV"); Label lblVendorCategoryIDLV = (Label)e.Item.FindControl("lblVendorCategoryIDLV"); Label lblVendorIDLV = (Label)e.Item.FindControl("lblVendorIDLV"); Label lblVendorNameLV = (Label)e.Item.FindControl("lblVendorNameLV"); Label lblProjectIDLV = (Label)e.Item.FindControl("lblProjectIDLV"); DropDownList ddlACCPayableApprovalStatusIDLV = (DropDownList)e.Item.FindControl("ddlACCPayableApprovalStatusIDLV"); DropDownList ddlACCPayablePaymentStatusIDLV = (DropDownList)e.Item.FindControl("ddlACCPayablePaymentStatusIDLV"); DropDownList ddlPayableClassificationIDLV = (DropDownList)e.Item.FindControl("ddlPayableClassificationIDLV"); DropDownList ddlAccountPaybleStatementDetailCategoryIDLV = (DropDownList)e.Item.FindControl("ddlAccountPaybleStatementDetailCategoryIDLV"); CheckBox chkPartyReconcileLV = (CheckBox)e.Item.FindControl("chkPartyReconcileLV"); if (lblProjectIDLV != null) { BDProjectEntity _bDProjectEntity = FCCBDProject.GetFacadeCreate().GetByID(Int64.Parse(lblProjectIDLV.Text)); if (_bDProjectEntity != null) { lblProjectNameLV.Text = _bDProjectEntity.ProjectName + " (" + _bDProjectEntity.ProjectCode + ")"; } } MiscUtil.PopulateMDACCPayablePaymentStatus(ddlACCPayablePaymentStatusIDLV, false); MiscUtil.PopulateMDACCPayableApprovalStatus(ddlACCPayableApprovalStatusIDLV, false); MiscUtil.PopulateMDPayableClassification(ddlPayableClassificationIDLV, false); MiscUtil.PopulateMDAccountPaybleStatementDetailCategory(ddlAccountPaybleStatementDetailCategoryIDLV, false); _PostPayableStatementDetailID = ent.PostPayableStatementDetailID; if (ent.PartyReconcile == true) { chkPartyReconcileLV.Checked = true; } else { chkPartyReconcileLV.Checked = false; } Int64 vendorID; Int64.TryParse(lblVendorIDLV.Text.ToString(), out vendorID); switch (lblVendorCategoryIDLV.Text) { case MasterDataConstants.CM_Bill_VendorCategory.CONSULTANT: CMConsultantEntity _cmConsultantEntity = FCCCMConsultant.GetFacadeCreate().GetByID(vendorID); lblVendorCategoryNameLV.Text = "CONSULTANT"; lblVendorNameLV.Text = _cmConsultantEntity.Name; break; case MasterDataConstants.CM_Bill_VendorCategory.CONTRACTOR: CMContractorEntity _cMContractorEntity = FCCCMContractor.GetFacadeCreate().GetByID(vendorID); lblVendorCategoryNameLV.Text = "CONTRACTOR"; lblVendorNameLV.Text = _cMContractorEntity.Name; break; case MasterDataConstants.CM_Bill_VendorCategory.VENDOR: PRMSupplierEntity _pRMSupplierEntity = FCCPRMSupplier.GetFacadeCreate().GetByID(vendorID); lblVendorCategoryNameLV.Text = "VENDOR"; lblVendorNameLV.Text = _pRMSupplierEntity.SupplierName; break; } if (ddlACCPayableApprovalStatusIDLV != null && ddlACCPayableApprovalStatusIDLV.Items.Count > 0) { ddlACCPayableApprovalStatusIDLV.SelectedValue = ent.ACCPayableApprovalStatusID.ToString(); } if (ddlACCPayablePaymentStatusIDLV != null && ddlACCPayablePaymentStatusIDLV.Items.Count > 0) { ddlACCPayablePaymentStatusIDLV.SelectedValue = ent.ACCPayablePaymentStatusID.ToString(); } if (ddlPayableClassificationIDLV != null && ddlPayableClassificationIDLV.Items.Count > 0) { ddlPayableClassificationIDLV.SelectedValue = ent.PayableClassificationID.ToString(); } if (ddlAccountPaybleStatementDetailCategoryIDLV != null && ddlAccountPaybleStatementDetailCategoryIDLV.Items.Count > 0) { ddlAccountPaybleStatementDetailCategoryIDLV.SelectedValue = ent.AccountPaybleStatementDetailCategoryID.ToString(); } ddlACCPayableApprovalStatusIDLV.Enabled = false; } }
private Int64 UpdateTran(BDProjectEntity bDProjectEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.BDProject_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, "@ProjectID", DbType.Int64, bDProjectEntity.ProjectID); db.AddInParameter(cmd, "@OperatorID", DbType.Int64, bDProjectEntity.OperatorID); db.AddInParameter(cmd, "@ZoneID", DbType.Int64, bDProjectEntity.ZoneID); db.AddInParameter(cmd, "@ProjectCode", DbType.String, bDProjectEntity.ProjectCode); db.AddInParameter(cmd, "@ProjectName", DbType.String, bDProjectEntity.ProjectName); db.AddInParameter(cmd, "@LandAreaKatha", DbType.Decimal, bDProjectEntity.LandAreaKatha); db.AddInParameter(cmd, "@LandAreaSft", DbType.Decimal, bDProjectEntity.LandAreaSft); db.AddInParameter(cmd, "@RoadWidth", DbType.Decimal, bDProjectEntity.RoadWidth); db.AddInParameter(cmd, "@RoadWidthUnitID", DbType.Int64, bDProjectEntity.RoadWidthUnitID); db.AddInParameter(cmd, "@NoOfStoried", DbType.Int32, bDProjectEntity.NoOfStoried); db.AddInParameter(cmd, "@NoOfBasement", DbType.Int32, bDProjectEntity.NoOfBasement); db.AddInParameter(cmd, "@Description", DbType.String, bDProjectEntity.Description); db.AddInParameter(cmd, "@BSC", DbType.String, bDProjectEntity.BSC); db.AddInParameter(cmd, "@ClientPercentage", DbType.Decimal, bDProjectEntity.ClientPercentage); db.AddInParameter(cmd, "@CompanyPercentage", DbType.Decimal, bDProjectEntity.CompanyPercentage); db.AddInParameter(cmd, "@ProjectCategoryID", DbType.Int64, bDProjectEntity.ProjectCategoryID); db.AddInParameter(cmd, "@ProjectStatusID", DbType.Int64, bDProjectEntity.ProjectStatusID); db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, bDProjectEntity.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); }
Int64 IBDProjectFacade.Delete(BDProjectEntity bDProjectEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateBDProjectDataAccess().Delete(bDProjectEntity, filterExpression, option, reqTran)); }
Int64 IBDProjectFacade.Add(BDProjectEntity bDProjectEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateBDProjectDataAccess().Add(bDProjectEntity, option, reqTran)); }