Int64 IBDProjectOtherInfoDataAccess.Add(BDProjectOtherInfoEntity bDProjectOtherInfoEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

                switch (reqTran)
                {
                case TransactionRequired.No:
                {
                    retValues = Add(bDProjectOtherInfoEntity, option);
                    break;
                }

                case TransactionRequired.Yes:
                {
                    retValues = AddTran(bDProjectOtherInfoEntity, option);
                    break;
                }

                default:
                {
                    retValues = -99;
                    break;
                }
                }

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private Int64 Update(BDProjectOtherInfoEntity bDProjectOtherInfoEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.BDProjectOtherInfo_SET";

            using (DbCommand cmd = Database.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option);
                AddOutputParameter(cmd);
                AddFilterExpressionParameter(cmd, filterExpression);

                Database.AddInParameter(cmd, "@ProjectOtherInfoID", DbType.Int64, bDProjectOtherInfoEntity.ProjectOtherInfoID);
                Database.AddInParameter(cmd, "@ProjectID", DbType.Int64, bDProjectOtherInfoEntity.ProjectID);
                Database.AddInParameter(cmd, "@TBA", DbType.Decimal, bDProjectOtherInfoEntity.TBA);
                Database.AddInParameter(cmd, "@TBAUnitID", DbType.Int64, bDProjectOtherInfoEntity.TBAUnitID);
                Database.AddInParameter(cmd, "@FAR", DbType.Decimal, bDProjectOtherInfoEntity.FAR);
                Database.AddInParameter(cmd, "@FARBonus", DbType.Decimal, bDProjectOtherInfoEntity.FARBonus);
                Database.AddInParameter(cmd, "@FIA", DbType.Decimal, bDProjectOtherInfoEntity.FIA);
                Database.AddInParameter(cmd, "@FIAUnitID", DbType.Int64, bDProjectOtherInfoEntity.FIAUnitID);
                Database.AddInParameter(cmd, "@FIAAchieved", DbType.Decimal, bDProjectOtherInfoEntity.FIAAchieved);
                Database.AddInParameter(cmd, "@FIAAchievedUnitID", DbType.Int64, bDProjectOtherInfoEntity.FIAAchievedUnitID);
                Database.AddInParameter(cmd, "@GSA", DbType.Decimal, bDProjectOtherInfoEntity.GSA);
                Database.AddInParameter(cmd, "@GSAUnitID", DbType.Int64, bDProjectOtherInfoEntity.GSAUnitID);
                Database.AddInParameter(cmd, "@MGCPercentages", DbType.Decimal, bDProjectOtherInfoEntity.MGCPercentages);
                Database.AddInParameter(cmd, "@MGCArea", DbType.Decimal, bDProjectOtherInfoEntity.MGCArea);
                Database.AddInParameter(cmd, "@MGCAreaUnitID", DbType.Int64, bDProjectOtherInfoEntity.MGCAreaUnitID);
                Database.AddInParameter(cmd, "@GroundCoverage", DbType.String, bDProjectOtherInfoEntity.GroundCoverage);
                Database.AddInParameter(cmd, "@DateOfAgreement", DbType.DateTime, bDProjectOtherInfoEntity.DateOfAgreement);
                Database.AddInParameter(cmd, "@DateOfHandover", DbType.DateTime, bDProjectOtherInfoEntity.DateOfHandover);
                Database.AddInParameter(cmd, "@DelayClause", DbType.String, bDProjectOtherInfoEntity.DelayClause);

                using (IDataReader reader = Database.ExecuteReader(cmd))
                {
                    returnCode = GetReturnCodeFromParameter(cmd);

                    switch (returnCode)
                    {
                    case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST:
                    {
                        throw new ArgumentException("BDProjectOtherInfoEntity already exists. Please specify another BDProjectOtherInfoEntity.");
                    }

                    case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION:
                    {
                        throw new ArgumentException("BDProjectOtherInfoEntity data already updated from different session.");
                    }

                    case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION:
                    {
                        throw new ArgumentException("BDProjectOtherInfoEntity already exists. Please specify another BDProjectOtherInfoEntity.");
                    }
                    }
                }
            }

            return(returnCode);
        }
        private void SaveBDProjectOtherInfoEntity()
        {
            if (IsValid)
            {
                try
                {
                    BDProjectOtherInfoEntity bDProjectOtherInfoEntity = BuildBDProjectOtherInfoEntity();

                    Int64 result = -1;

                    if (bDProjectOtherInfoEntity.IsNew)
                    {
                        result = FCCBDProjectOtherInfo.GetFacadeCreate().Add(bDProjectOtherInfoEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(BDProjectOtherInfoEntity.FLD_NAME_ProjectOtherInfoID, bDProjectOtherInfoEntity.ProjectOtherInfoID.ToString(), SQLMatchType.Equal);
                        result = FCCBDProjectOtherInfo.GetFacadeCreate().Update(bDProjectOtherInfoEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _ProjectOtherInfoID       = 0;
                        _BDProjectOtherInfoEntity = new BDProjectOtherInfoEntity();
                        PrepareInitialView();

                        if (bDProjectOtherInfoEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Project Other Info Information has been Updated successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Project Other Info Information has been updated successfully.", false);
                        }

                        PrepareEditView();
                    }
                    else
                    {
                        if (bDProjectOtherInfoEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Project Other Info Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Project Other Info Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
        private Int64 DeleteTran(BDProjectOtherInfoEntity bDProjectOtherInfoEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.BDProjectOtherInfo_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()
        {
            BDProjectOtherInfoEntity bDProjectOtherInfoEntity = CurrentBDProjectOtherInfoEntity;


            if (!bDProjectOtherInfoEntity.IsNew)
            {
                txtTBA.Text = bDProjectOtherInfoEntity.TBA.ToString();
                if (ddlTBAUnitID.Items.Count > 0 && bDProjectOtherInfoEntity.TBAUnitID != null)
                {
                    ddlTBAUnitID.SelectedValue = bDProjectOtherInfoEntity.TBAUnitID.ToString();
                }

                txtFAR.Text      = bDProjectOtherInfoEntity.FAR.ToString();
                txtFARBonus.Text = bDProjectOtherInfoEntity.FARBonus.ToString();
                txtFIA.Text      = bDProjectOtherInfoEntity.FIA.ToString();
                if (ddlFIAUnitID.Items.Count > 0 && bDProjectOtherInfoEntity.FIAUnitID != null)
                {
                    ddlFIAUnitID.SelectedValue = bDProjectOtherInfoEntity.FIAUnitID.ToString();
                }

                txtFIAAchieved.Text = bDProjectOtherInfoEntity.FIAAchieved.ToString();
                if (ddlFIAAchievedUnitID.Items.Count > 0 && bDProjectOtherInfoEntity.FIAAchievedUnitID != null)
                {
                    ddlFIAAchievedUnitID.SelectedValue = bDProjectOtherInfoEntity.FIAAchievedUnitID.ToString();
                }

                txtGSA.Text = bDProjectOtherInfoEntity.GSA.ToString();
                if (ddlGSAUnitID.Items.Count > 0 && bDProjectOtherInfoEntity.GSAUnitID != null)
                {
                    ddlGSAUnitID.SelectedValue = bDProjectOtherInfoEntity.GSAUnitID.ToString();
                }

                txtMGCPercentages.Text = bDProjectOtherInfoEntity.MGCPercentages.ToString();
                txtMGCArea.Text        = bDProjectOtherInfoEntity.MGCArea.ToString();
                if (ddlMGCAreaUnitID.Items.Count > 0 && bDProjectOtherInfoEntity.MGCAreaUnitID != null)
                {
                    ddlMGCAreaUnitID.SelectedValue = bDProjectOtherInfoEntity.MGCAreaUnitID.ToString();
                }

                txtGroundCoverage.Text  = bDProjectOtherInfoEntity.GroundCoverage.ToString();
                txtDateOfAgreement.Text = bDProjectOtherInfoEntity.DateOfAgreement.ToStringDefault();
                txtDateOfHandover.Text  = bDProjectOtherInfoEntity.DateOfHandover.ToStringDefault();
                txtDelayClause.Text     = bDProjectOtherInfoEntity.DelayClause.ToString();

                btnSubmit.Text = "Update";
            }
        }
        private Int64 Delete(BDProjectOtherInfoEntity bDProjectOtherInfoEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.BDProjectOtherInfo_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("BDProjectOtherInfoEntity already exists. Please specify another BDProjectOtherInfoEntity.");
                    }

                    case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION:
                    {
                        throw new ArgumentException("BDProjectOtherInfoEntity data already updated from different session.");
                    }

                    case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION:
                    {
                        throw new ArgumentException("BDProjectOtherInfoEntity already exists. Please specify another BDProjectOtherInfoEntity.");
                    }
                    }
                }
            }

            return(returnCode);
        }
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _ProjectOtherInfoID       = 0;
     _BDProjectOtherInfoEntity = new BDProjectOtherInfoEntity();
     PrepareInitialView();
 }
        private BDProjectOtherInfoEntity BuildBDProjectOtherInfoEntity()
        {
            BDProjectOtherInfoEntity bDProjectOtherInfoEntity = CurrentBDProjectOtherInfoEntity;

            bDProjectOtherInfoEntity.ProjectID = this.OverviewProjectID;

            if (!txtTBA.Text.Trim().IsNullOrEmpty())
            {
                bDProjectOtherInfoEntity.TBA = Decimal.Parse(txtTBA.Text.Trim());
            }
            else
            {
                bDProjectOtherInfoEntity.TBA = null;
            }

            if (ddlTBAUnitID.Items.Count > 0)
            {
                if (ddlTBAUnitID.SelectedValue == "0")
                {
                    bDProjectOtherInfoEntity.TBAUnitID = null;
                }
                else
                {
                    bDProjectOtherInfoEntity.TBAUnitID = Int64.Parse(ddlTBAUnitID.SelectedValue);
                }
            }

            if (!txtFAR.Text.Trim().IsNullOrEmpty())
            {
                bDProjectOtherInfoEntity.FAR = Decimal.Parse(txtFAR.Text.Trim());
            }
            else
            {
                bDProjectOtherInfoEntity.FAR = null;
            }

            if (!txtFARBonus.Text.Trim().IsNullOrEmpty())
            {
                bDProjectOtherInfoEntity.FARBonus = Decimal.Parse(txtFARBonus.Text.Trim());
            }
            else
            {
                bDProjectOtherInfoEntity.FARBonus = null;
            }

            if (!txtFIA.Text.Trim().IsNullOrEmpty())
            {
                bDProjectOtherInfoEntity.FIA = Decimal.Parse(txtFIA.Text.Trim());
            }
            else
            {
                bDProjectOtherInfoEntity.FIA = null;
            }

            if (ddlFIAUnitID.Items.Count > 0)
            {
                if (ddlFIAUnitID.SelectedValue == "0")
                {
                    bDProjectOtherInfoEntity.FIAUnitID = null;
                }
                else
                {
                    bDProjectOtherInfoEntity.FIAUnitID = Int64.Parse(ddlFIAUnitID.SelectedValue);
                }
            }

            if (!txtFIAAchieved.Text.Trim().IsNullOrEmpty())
            {
                bDProjectOtherInfoEntity.FIAAchieved = Decimal.Parse(txtFIAAchieved.Text.Trim());
            }
            else
            {
                bDProjectOtherInfoEntity.FIAAchieved = null;
            }

            if (ddlFIAAchievedUnitID.Items.Count > 0)
            {
                if (ddlFIAAchievedUnitID.SelectedValue == "0")
                {
                    bDProjectOtherInfoEntity.FIAAchievedUnitID = null;
                }
                else
                {
                    bDProjectOtherInfoEntity.FIAAchievedUnitID = Int64.Parse(ddlFIAAchievedUnitID.SelectedValue);
                }
            }

            if (!txtGSA.Text.Trim().IsNullOrEmpty())
            {
                bDProjectOtherInfoEntity.GSA = Decimal.Parse(txtGSA.Text.Trim());
            }
            else
            {
                bDProjectOtherInfoEntity.GSA = null;
            }

            if (ddlGSAUnitID.Items.Count > 0)
            {
                if (ddlGSAUnitID.SelectedValue == "0")
                {
                    bDProjectOtherInfoEntity.GSAUnitID = null;
                }
                else
                {
                    bDProjectOtherInfoEntity.GSAUnitID = Int64.Parse(ddlGSAUnitID.SelectedValue);
                }
            }

            if (!txtMGCPercentages.Text.Trim().IsNullOrEmpty())
            {
                bDProjectOtherInfoEntity.MGCPercentages = Decimal.Parse(txtMGCPercentages.Text.Trim());
            }
            else
            {
                bDProjectOtherInfoEntity.MGCPercentages = null;
            }

            if (!txtMGCArea.Text.Trim().IsNullOrEmpty())
            {
                bDProjectOtherInfoEntity.MGCArea = Decimal.Parse(txtMGCArea.Text.Trim());
            }
            else
            {
                bDProjectOtherInfoEntity.MGCArea = null;
            }

            if (ddlMGCAreaUnitID.Items.Count > 0)
            {
                if (ddlMGCAreaUnitID.SelectedValue == "0")
                {
                    bDProjectOtherInfoEntity.MGCAreaUnitID = null;
                }
                else
                {
                    bDProjectOtherInfoEntity.MGCAreaUnitID = Int64.Parse(ddlMGCAreaUnitID.SelectedValue);
                }
            }

            bDProjectOtherInfoEntity.GroundCoverage = txtGroundCoverage.Text.Trim();
            if (txtDateOfAgreement.Text.Trim().IsNotNullOrEmpty())
            {
                bDProjectOtherInfoEntity.DateOfAgreement = MiscUtil.ParseToDateTime(txtDateOfAgreement.Text);
            }
            else
            {
                bDProjectOtherInfoEntity.DateOfAgreement = null;
            }

            if (txtDateOfHandover.Text.Trim().IsNotNullOrEmpty())
            {
                bDProjectOtherInfoEntity.DateOfHandover = MiscUtil.ParseToDateTime(txtDateOfHandover.Text);
            }
            else
            {
                bDProjectOtherInfoEntity.DateOfHandover = null;
            }

            bDProjectOtherInfoEntity.DelayClause = txtDelayClause.Text.Trim();

            return(bDProjectOtherInfoEntity);
        }
        private Int64 UpdateTran(BDProjectOtherInfoEntity bDProjectOtherInfoEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.BDProjectOtherInfo_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, "@ProjectOtherInfoID", DbType.Int64, bDProjectOtherInfoEntity.ProjectOtherInfoID);
                db.AddInParameter(cmd, "@ProjectID", DbType.Int64, bDProjectOtherInfoEntity.ProjectID);
                db.AddInParameter(cmd, "@TBA", DbType.Decimal, bDProjectOtherInfoEntity.TBA);
                db.AddInParameter(cmd, "@TBAUnitID", DbType.Int64, bDProjectOtherInfoEntity.TBAUnitID);
                db.AddInParameter(cmd, "@FAR", DbType.Decimal, bDProjectOtherInfoEntity.FAR);
                db.AddInParameter(cmd, "@FARBonus", DbType.Decimal, bDProjectOtherInfoEntity.FARBonus);
                db.AddInParameter(cmd, "@FIA", DbType.Decimal, bDProjectOtherInfoEntity.FIA);
                db.AddInParameter(cmd, "@FIAUnitID", DbType.Int64, bDProjectOtherInfoEntity.FIAUnitID);
                db.AddInParameter(cmd, "@FIAAchieved", DbType.Decimal, bDProjectOtherInfoEntity.FIAAchieved);
                db.AddInParameter(cmd, "@FIAAchievedUnitID", DbType.Int64, bDProjectOtherInfoEntity.FIAAchievedUnitID);
                db.AddInParameter(cmd, "@GSA", DbType.Decimal, bDProjectOtherInfoEntity.GSA);
                db.AddInParameter(cmd, "@GSAUnitID", DbType.Int64, bDProjectOtherInfoEntity.GSAUnitID);
                db.AddInParameter(cmd, "@MGCPercentages", DbType.Decimal, bDProjectOtherInfoEntity.MGCPercentages);
                db.AddInParameter(cmd, "@MGCArea", DbType.Decimal, bDProjectOtherInfoEntity.MGCArea);
                db.AddInParameter(cmd, "@MGCAreaUnitID", DbType.Int64, bDProjectOtherInfoEntity.MGCAreaUnitID);
                db.AddInParameter(cmd, "@GroundCoverage", DbType.String, bDProjectOtherInfoEntity.GroundCoverage);
                db.AddInParameter(cmd, "@DateOfAgreement", DbType.DateTime, bDProjectOtherInfoEntity.DateOfAgreement);
                db.AddInParameter(cmd, "@DateOfHandover", DbType.DateTime, bDProjectOtherInfoEntity.DateOfHandover);
                db.AddInParameter(cmd, "@DelayClause", DbType.String, bDProjectOtherInfoEntity.DelayClause);

                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);
        }
Example #10
0
 Int64 IBDProjectOtherInfoFacade.Delete(BDProjectOtherInfoEntity bDProjectOtherInfoEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateBDProjectOtherInfoDataAccess().Delete(bDProjectOtherInfoEntity, filterExpression, option, reqTran));
 }
Example #11
0
 Int64 IBDProjectOtherInfoFacade.Add(BDProjectOtherInfoEntity bDProjectOtherInfoEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateBDProjectOtherInfoDataAccess().Add(bDProjectOtherInfoEntity, option, reqTran));
 }