Example #1
0
        Int64 IBDProjectAdditionalInfoDataAccess.Delete(BDProjectAdditionalInfoEntity bDProjectAdditionalInfoEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

                switch (reqTran)
                {
                case TransactionRequired.No:
                {
                    retValues = Delete(bDProjectAdditionalInfoEntity, filterExpression, option);
                    break;
                }

                case TransactionRequired.Yes:
                {
                    retValues = DeleteTran(bDProjectAdditionalInfoEntity, filterExpression, option);
                    break;
                }

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        private void SaveBDProjectAdditionalInfoEntity()
        {
            if (IsValid)
            {
                try
                {
                    BDProjectAdditionalInfoEntity bDProjectAdditionalInfoEntity = BuildBDProjectAdditionalInfoEntity();

                    Int64 result = -1;

                    if (bDProjectAdditionalInfoEntity.IsNew)
                    {
                        result = FCCBDProjectAdditionalInfo.GetFacadeCreate().Add(bDProjectAdditionalInfoEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(BDProjectAdditionalInfoEntity.FLD_NAME_ProjectAdditionalInfoID, bDProjectAdditionalInfoEntity.ProjectAdditionalInfoID.ToString(), SQLMatchType.Equal);
                        result = FCCBDProjectAdditionalInfo.GetFacadeCreate().Update(bDProjectAdditionalInfoEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _ProjectAdditionalInfoID       = 0;
                        _BDProjectAdditionalInfoEntity = new BDProjectAdditionalInfoEntity();
                        PrepareInitialView();
                        PrepareEditView();
                        BindBDProjectAdditionalInfoList();

                        if (bDProjectAdditionalInfoEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Project Additional Info Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Project Additional Info Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (bDProjectAdditionalInfoEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Project Additional Info Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Project Additional Info Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Example #3
0
        private Int64 DeleteTran(BDProjectAdditionalInfoEntity bDProjectAdditionalInfoEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.BDProjectAdditionalInfo_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);
        }
Example #4
0
        private Int64 Delete(BDProjectAdditionalInfoEntity bDProjectAdditionalInfoEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.BDProjectAdditionalInfo_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("BDProjectAdditionalInfoEntity already exists. Please specify another BDProjectAdditionalInfoEntity.");
                    }

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

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

            return(returnCode);
        }
Example #5
0
 Int64 IBDProjectAdditionalInfoFacade.Delete(BDProjectAdditionalInfoEntity bDProjectAdditionalInfoEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateBDProjectAdditionalInfoDataAccess().Delete(bDProjectAdditionalInfoEntity, filterExpression, option, reqTran));
 }
Example #6
0
 Int64 IBDProjectAdditionalInfoFacade.Add(BDProjectAdditionalInfoEntity bDProjectAdditionalInfoEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateBDProjectAdditionalInfoDataAccess().Add(bDProjectAdditionalInfoEntity, option, reqTran));
 }
Example #7
0
        private BDProjectAdditionalInfoEntity BuildBDProjectAdditionalInfoEntity()
        {
            BDProjectAdditionalInfoEntity bDProjectAdditionalInfoEntity = CurrentBDProjectAdditionalInfoEntity;

            bDProjectAdditionalInfoEntity.ProjectID = OverviewProjectID;

            if (!txtNumberOfStorey.Text.Trim().IsNullOrEmpty())
            {
                bDProjectAdditionalInfoEntity.NumberOfStorey = Decimal.Parse(txtNumberOfStorey.Text.Trim());
            }

            if (!txtNumberOfBlock.Text.Trim().IsNullOrEmpty())
            {
                bDProjectAdditionalInfoEntity.NumberOfBlock = Decimal.Parse(txtNumberOfBlock.Text.Trim());
            }
            else
            {
                bDProjectAdditionalInfoEntity.NumberOfBlock = null;
            }

            if (!txtTypicalFloorArea.Text.Trim().IsNullOrEmpty())
            {
                bDProjectAdditionalInfoEntity.TypicalFloorArea = Decimal.Parse(txtTypicalFloorArea.Text.Trim());
            }
            else
            {
                bDProjectAdditionalInfoEntity.TypicalFloorArea = null;
            }

            if (ddlTypicalFloorAreaUnitID.Items.Count > 0)
            {
                if (ddlTypicalFloorAreaUnitID.SelectedValue == "0")
                {
                    bDProjectAdditionalInfoEntity.TypicalFloorAreaUnitID = null;
                }
                else
                {
                    bDProjectAdditionalInfoEntity.TypicalFloorAreaUnitID = Int64.Parse(ddlTypicalFloorAreaUnitID.SelectedValue);
                }
            }

            if (!txtGCArchieved.Text.Trim().IsNullOrEmpty())
            {
                bDProjectAdditionalInfoEntity.GCArchieved = Decimal.Parse(txtGCArchieved.Text.Trim());
            }
            else
            {
                bDProjectAdditionalInfoEntity.GCArchieved = null;
            }

            if (!txtNumberOfBasement.Text.Trim().IsNullOrEmpty())
            {
                bDProjectAdditionalInfoEntity.NumberOfBasement = Decimal.Parse(txtNumberOfBasement.Text.Trim());
            }
            else
            {
                bDProjectAdditionalInfoEntity.NumberOfBasement = null;
            }

            if (!txtNumberOfResidentialFloor.Text.Trim().IsNullOrEmpty())
            {
                bDProjectAdditionalInfoEntity.NumberOfResidentialFloor = Decimal.Parse(txtNumberOfResidentialFloor.Text.Trim());
            }
            else
            {
                bDProjectAdditionalInfoEntity.NumberOfResidentialFloor = null;
            }

            if (!txtNumberOfCommercialFloor.Text.Trim().IsNullOrEmpty())
            {
                bDProjectAdditionalInfoEntity.NumberOfCommercialFloor = Decimal.Parse(txtNumberOfCommercialFloor.Text.Trim());
            }
            else
            {
                bDProjectAdditionalInfoEntity.NumberOfCommercialFloor = null;
            }

            if (!txtNoOfResidentialUnitPerFloor.Text.Trim().IsNullOrEmpty())
            {
                bDProjectAdditionalInfoEntity.NoOfResidentialUnitPerFloor = Decimal.Parse(txtNoOfResidentialUnitPerFloor.Text.Trim());
            }
            else
            {
                bDProjectAdditionalInfoEntity.NoOfResidentialUnitPerFloor = null;
            }

            bDProjectAdditionalInfoEntity.Facing = txtFacing.Text.Trim();
            if (!txtTotalNumberOfUnit.Text.Trim().IsNullOrEmpty())
            {
                bDProjectAdditionalInfoEntity.TotalNumberOfUnit = Decimal.Parse(txtTotalNumberOfUnit.Text.Trim());
            }
            else
            {
                bDProjectAdditionalInfoEntity.TotalNumberOfUnit = null;
            }

            if (!txtNumberOfPenthouse.Text.Trim().IsNullOrEmpty())
            {
                bDProjectAdditionalInfoEntity.NumberOfPenthouse = Decimal.Parse(txtNumberOfPenthouse.Text.Trim());
            }
            else
            {
                bDProjectAdditionalInfoEntity.NumberOfPenthouse = null;
            }

            if (!txtNumberOfStair.Text.Trim().IsNullOrEmpty())
            {
                bDProjectAdditionalInfoEntity.NumberOfStair = Decimal.Parse(txtNumberOfStair.Text.Trim());
            }
            else
            {
                bDProjectAdditionalInfoEntity.NumberOfStair = null;
            }

            if (ddlCoolingSystemID.Items.Count > 0)
            {
                if (ddlCoolingSystemID.SelectedValue == "0")
                {
                    bDProjectAdditionalInfoEntity.CoolingSystem = null;
                }
                else
                {
                    bDProjectAdditionalInfoEntity.CoolingSystem = ddlCoolingSystemID.SelectedItem.ToString();
                }
            }

            if (ddlGeyserSystemID.Items.Count > 0)
            {
                if (ddlGeyserSystemID.SelectedValue == "0")
                {
                    bDProjectAdditionalInfoEntity.GeyserSystem = null;
                }
                else
                {
                    bDProjectAdditionalInfoEntity.GeyserSystem = ddlGeyserSystemID.SelectedItem.ToString();
                }
            }

            bDProjectAdditionalInfoEntity.PositionAtBuilding = txtPositionAtBuilding.Text.Trim();
            bDProjectAdditionalInfoEntity.PositionAtBuildingForCommercial = txtPositionAtBuildingForCommercial.Text.Trim();
            bDProjectAdditionalInfoEntity.FacilitiesAtMezzanineFloor      = txtFacilitiesAtMezzanineFloor.Text.Trim();
            bDProjectAdditionalInfoEntity.FacilitiesAtRoofFloor           = txtFacilitiesAtRoofFloor.Text.Trim();
            bDProjectAdditionalInfoEntity.ApprovalRequired = txtApprovalRequired.Text.Trim();

            if (!txtGroundFloorHeight.Text.Trim().IsNullOrEmpty())
            {
                bDProjectAdditionalInfoEntity.GroundFloorHeight = Decimal.Parse(txtGroundFloorHeight.Text.Trim());
            }
            else
            {
                bDProjectAdditionalInfoEntity.GroundFloorHeight = null;
            }

            if (!txtTypicalFloorHeight.Text.Trim().IsNullOrEmpty())
            {
                bDProjectAdditionalInfoEntity.TypicalFloorHeight = Decimal.Parse(txtTypicalFloorHeight.Text.Trim());
            }
            else
            {
                bDProjectAdditionalInfoEntity.TypicalFloorHeight = null;
            }

            if (ddlGroundFloorHeightUnitInFeetID.Items.Count > 0)
            {
                if (ddlGroundFloorHeightUnitInFeetID.SelectedValue == "0")
                {
                    bDProjectAdditionalInfoEntity.GroundFloorHeightUnitInFeetID = null;
                }
                else
                {
                    bDProjectAdditionalInfoEntity.GroundFloorHeightUnitInFeetID = Int64.Parse(ddlGroundFloorHeightUnitInFeetID.SelectedValue);
                }
            }

            if (ddlTypicalFloorHeightUnitInchID.Items.Count > 0)
            {
                if (ddlTypicalFloorHeightUnitInchID.SelectedValue == "0")
                {
                    bDProjectAdditionalInfoEntity.TypicalFloorHeightUnitInchID = null;
                }
                else
                {
                    bDProjectAdditionalInfoEntity.TypicalFloorHeightUnitInchID = Int64.Parse(ddlTypicalFloorHeightUnitInchID.SelectedValue);
                }
            }

            if (txtGroundFloorHeightInch.Text.Trim().IsNotNullOrEmpty())
            {
                bDProjectAdditionalInfoEntity.GroundFloorHeightInch = Decimal.Parse(txtGroundFloorHeightInch.Text);
            }
            else
            {
                bDProjectAdditionalInfoEntity.GroundFloorHeightInch = null;
            }

            if (txtTypicalFloorHeightFeet.Text.Trim().IsNotNullOrEmpty())
            {
                bDProjectAdditionalInfoEntity.TypicalFloorHeightFeet = Decimal.Parse(txtTypicalFloorHeightFeet.Text);
            }
            else
            {
                bDProjectAdditionalInfoEntity.TypicalFloorHeightFeet = null;
            }

            if (ddlGroundFloorHeightUnitInInchID.Items.Count > 0)
            {
                if (ddlGroundFloorHeightUnitInInchID.SelectedValue == "0")
                {
                    bDProjectAdditionalInfoEntity.GroundFloorHeightUnitInInchID = null;
                }
                else
                {
                    bDProjectAdditionalInfoEntity.GroundFloorHeightUnitInInchID = Int64.Parse(ddlGroundFloorHeightUnitInInchID.SelectedValue);
                }
            }

            if (ddlTypicalFloorHeightUnitFeetID.Items.Count > 0)
            {
                if (ddlTypicalFloorHeightUnitFeetID.SelectedValue == "0")
                {
                    bDProjectAdditionalInfoEntity.TypicalFloorHeightUnitFeetID = null;
                }
                else
                {
                    bDProjectAdditionalInfoEntity.TypicalFloorHeightUnitFeetID = Int64.Parse(ddlTypicalFloorHeightUnitFeetID.SelectedValue);
                }
            }

            return(bDProjectAdditionalInfoEntity);
        }
Example #8
0
        private void PrepareEditView()
        {
            BDProjectAdditionalInfoEntity bDProjectAdditionalInfoEntity = CurrentBDProjectAdditionalInfoEntity;


            if (!bDProjectAdditionalInfoEntity.IsNew)
            {
                txtNumberOfStorey.Text   = bDProjectAdditionalInfoEntity.NumberOfStorey.ToString();
                txtNumberOfBlock.Text    = bDProjectAdditionalInfoEntity.NumberOfBlock.ToString();
                txtTypicalFloorArea.Text = bDProjectAdditionalInfoEntity.TypicalFloorArea.ToString();
                if (ddlTypicalFloorAreaUnitID.Items.Count > 0 && bDProjectAdditionalInfoEntity.TypicalFloorAreaUnitID != null)
                {
                    ddlTypicalFloorAreaUnitID.SelectedValue = bDProjectAdditionalInfoEntity.TypicalFloorAreaUnitID.ToString();
                }

                txtGCArchieved.Text                     = bDProjectAdditionalInfoEntity.GCArchieved.ToString();
                txtNumberOfBasement.Text                = bDProjectAdditionalInfoEntity.NumberOfBasement.ToString();
                txtNumberOfResidentialFloor.Text        = bDProjectAdditionalInfoEntity.NumberOfResidentialFloor.ToString();
                txtPositionAtBuilding.Text              = bDProjectAdditionalInfoEntity.PositionAtBuilding.ToString();
                txtNumberOfCommercialFloor.Text         = bDProjectAdditionalInfoEntity.NumberOfCommercialFloor.ToString();
                txtPositionAtBuildingForCommercial.Text = bDProjectAdditionalInfoEntity.PositionAtBuildingForCommercial.ToString();
                txtNoOfResidentialUnitPerFloor.Text     = bDProjectAdditionalInfoEntity.NoOfResidentialUnitPerFloor.ToString();
                txtFacing.Text            = bDProjectAdditionalInfoEntity.Facing.ToString();
                txtTotalNumberOfUnit.Text = bDProjectAdditionalInfoEntity.TotalNumberOfUnit.ToString();
                txtNumberOfPenthouse.Text = bDProjectAdditionalInfoEntity.NumberOfPenthouse.ToString();
                txtNumberOfStair.Text     = bDProjectAdditionalInfoEntity.NumberOfStair.ToString();

                if (bDProjectAdditionalInfoEntity.CoolingSystem.IsNullOrEmpty())
                {
                    ddlCoolingSystemID.Text = "Please Select";
                }
                else
                {
                    if (ddlCoolingSystemID.Items.Count > 0 && bDProjectAdditionalInfoEntity.CoolingSystem != null)
                    {
                        ddlCoolingSystemID.SelectedValue = bDProjectAdditionalInfoEntity.CoolingSystem.ToString();
                    }
                }

                if (bDProjectAdditionalInfoEntity.GeyserSystem.IsNullOrEmpty())
                {
                    ddlGeyserSystemID.Text = "Please Select";
                }
                else
                {
                    if (ddlGeyserSystemID.Items.Count > 0 && bDProjectAdditionalInfoEntity.GeyserSystem != null)
                    {
                        ddlGeyserSystemID.Text = bDProjectAdditionalInfoEntity.GeyserSystem.ToString();
                    }
                }

                txtFacilitiesAtMezzanineFloor.Text = bDProjectAdditionalInfoEntity.FacilitiesAtMezzanineFloor.ToString();
                txtFacilitiesAtRoofFloor.Text      = bDProjectAdditionalInfoEntity.FacilitiesAtRoofFloor.ToString();
                txtApprovalRequired.Text           = bDProjectAdditionalInfoEntity.ApprovalRequired.ToString();
                txtGroundFloorHeight.Text          = bDProjectAdditionalInfoEntity.GroundFloorHeight.ToString();
                txtTypicalFloorHeight.Text         = bDProjectAdditionalInfoEntity.TypicalFloorHeight.ToString();

                txtGroundFloorHeightInch.Text  = bDProjectAdditionalInfoEntity.GroundFloorHeightInch.ToString();
                txtTypicalFloorHeightFeet.Text = bDProjectAdditionalInfoEntity.TypicalFloorHeightFeet.ToString();

                if (ddlGroundFloorHeightUnitInFeetID.Items.Count > 0 && bDProjectAdditionalInfoEntity.GroundFloorHeightUnitInFeetID != null)
                {
                    if (ddlGroundFloorHeightUnitInFeetID.Items.Count > 0 && bDProjectAdditionalInfoEntity.GroundFloorHeightUnitInFeetID != null)
                    {
                        ddlGroundFloorHeightUnitInFeetID.Text = bDProjectAdditionalInfoEntity.GroundFloorHeightUnitInFeetID.ToString();
                    }
                }
                else
                {
                    ddlGroundFloorHeightUnitInFeetID.Text = "Please Select";
                }

                if (ddlTypicalFloorHeightUnitInchID.Items.Count > 0 && bDProjectAdditionalInfoEntity.TypicalFloorHeightUnitInchID != null)
                {
                    if (ddlTypicalFloorHeightUnitInchID.Items.Count > 0 && bDProjectAdditionalInfoEntity.TypicalFloorHeightUnitInchID != null)
                    {
                        ddlTypicalFloorHeightUnitInchID.Text = bDProjectAdditionalInfoEntity.TypicalFloorHeightUnitInchID.ToString();
                    }
                }
                else
                {
                    ddlTypicalFloorHeightUnitInchID.Text = "Please Select";
                }

                if (ddlGroundFloorHeightUnitInInchID.Items.Count > 0 && bDProjectAdditionalInfoEntity.GroundFloorHeightUnitInInchID != null)
                {
                    if (ddlGroundFloorHeightUnitInInchID.Items.Count > 0 && bDProjectAdditionalInfoEntity.GroundFloorHeightUnitInInchID != null)
                    {
                        ddlGroundFloorHeightUnitInInchID.Text = bDProjectAdditionalInfoEntity.GroundFloorHeightUnitInInchID.ToString();
                    }
                }
                else
                {
                    ddlGroundFloorHeightUnitInInchID.Text = "Please Select";
                }

                if (ddlTypicalFloorHeightUnitFeetID.Items.Count > 0 && bDProjectAdditionalInfoEntity.TypicalFloorHeightUnitFeetID != null)
                {
                    if (ddlTypicalFloorHeightUnitFeetID.Items.Count > 0 && bDProjectAdditionalInfoEntity.TypicalFloorHeightUnitFeetID != null)
                    {
                        ddlTypicalFloorHeightUnitFeetID.Text = bDProjectAdditionalInfoEntity.TypicalFloorHeightUnitFeetID.ToString();
                    }
                }
                else
                {
                    ddlTypicalFloorHeightUnitFeetID.Text = "Please Select";
                }

                btnSubmit.Text = "Update";
            }
        }
Example #9
0
        private Int64 Add(BDProjectAdditionalInfoEntity bDProjectAdditionalInfoEntity, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.BDProjectAdditionalInfo_SET";

            using (DbCommand cmd = Database.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option);
                AddOutputParameter(cmd);
                AddNullPrimaryKeyParameter(cmd, "ProjectAdditionalInfoID");

                Database.AddInParameter(cmd, "@ProjectID", DbType.Int64, bDProjectAdditionalInfoEntity.ProjectID);
                Database.AddInParameter(cmd, "@NumberOfStorey", DbType.Decimal, bDProjectAdditionalInfoEntity.NumberOfStorey);
                Database.AddInParameter(cmd, "@NumberOfBlock", DbType.Decimal, bDProjectAdditionalInfoEntity.NumberOfBlock);
                Database.AddInParameter(cmd, "@TypicalFloorArea", DbType.Decimal, bDProjectAdditionalInfoEntity.TypicalFloorArea);
                Database.AddInParameter(cmd, "@TypicalFloorAreaUnitID", DbType.Int64, bDProjectAdditionalInfoEntity.TypicalFloorAreaUnitID);
                Database.AddInParameter(cmd, "@GCArchieved", DbType.Decimal, bDProjectAdditionalInfoEntity.GCArchieved);
                Database.AddInParameter(cmd, "@NumberOfBasement", DbType.Decimal, bDProjectAdditionalInfoEntity.NumberOfBasement);
                Database.AddInParameter(cmd, "@NumberOfResidentialFloor", DbType.Decimal, bDProjectAdditionalInfoEntity.NumberOfResidentialFloor);
                Database.AddInParameter(cmd, "@NumberOfCommercialFloor", DbType.Decimal, bDProjectAdditionalInfoEntity.NumberOfCommercialFloor);
                Database.AddInParameter(cmd, "@NoOfResidentialUnitPerFloor", DbType.Decimal, bDProjectAdditionalInfoEntity.NoOfResidentialUnitPerFloor);
                Database.AddInParameter(cmd, "@Facing", DbType.String, bDProjectAdditionalInfoEntity.Facing);
                Database.AddInParameter(cmd, "@TotalNumberOfUnit", DbType.Decimal, bDProjectAdditionalInfoEntity.TotalNumberOfUnit);
                Database.AddInParameter(cmd, "@NumberOfPenthouse", DbType.Decimal, bDProjectAdditionalInfoEntity.NumberOfPenthouse);
                Database.AddInParameter(cmd, "@NumberOfStair", DbType.Decimal, bDProjectAdditionalInfoEntity.NumberOfStair);
                Database.AddInParameter(cmd, "@PositionAtBuilding", DbType.String, bDProjectAdditionalInfoEntity.PositionAtBuilding);
                Database.AddInParameter(cmd, "@CoolingSystem", DbType.String, bDProjectAdditionalInfoEntity.CoolingSystem);
                Database.AddInParameter(cmd, "@GeyserSystem", DbType.String, bDProjectAdditionalInfoEntity.GeyserSystem);
                Database.AddInParameter(cmd, "@FacilitiesAtMezzanineFloor", DbType.String, bDProjectAdditionalInfoEntity.FacilitiesAtMezzanineFloor);
                Database.AddInParameter(cmd, "@FacilitiesAtRoofFloor", DbType.String, bDProjectAdditionalInfoEntity.FacilitiesAtRoofFloor);
                Database.AddInParameter(cmd, "@ApprovalRequired", DbType.String, bDProjectAdditionalInfoEntity.ApprovalRequired);
                Database.AddInParameter(cmd, "@PositionAtBuildingForCommercial", DbType.String, bDProjectAdditionalInfoEntity.PositionAtBuildingForCommercial);
                Database.AddInParameter(cmd, "@GroundFloorHeight", DbType.Decimal, bDProjectAdditionalInfoEntity.GroundFloorHeight);
                Database.AddInParameter(cmd, "@TypicalFloorHeight", DbType.Decimal, bDProjectAdditionalInfoEntity.TypicalFloorHeight);
                Database.AddInParameter(cmd, "@GroundFloorHeightUnitInFeetID", DbType.Int64, bDProjectAdditionalInfoEntity.GroundFloorHeightUnitInFeetID);
                Database.AddInParameter(cmd, "@TypicalFloorHeightUnitInchID", DbType.Int64, bDProjectAdditionalInfoEntity.TypicalFloorHeightUnitInchID);
                Database.AddInParameter(cmd, "@GroundFloorHeightInch", DbType.Decimal, bDProjectAdditionalInfoEntity.GroundFloorHeightInch);
                Database.AddInParameter(cmd, "@GroundFloorHeightUnitInInchID", DbType.Int64, bDProjectAdditionalInfoEntity.GroundFloorHeightUnitInInchID);
                Database.AddInParameter(cmd, "@TypicalFloorHeightFeet", DbType.Decimal, bDProjectAdditionalInfoEntity.TypicalFloorHeightFeet);
                Database.AddInParameter(cmd, "@TypicalFloorHeightUnitFeetID", DbType.Int64, bDProjectAdditionalInfoEntity.TypicalFloorHeightUnitFeetID);

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

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

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

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

            return(returnCode);
        }
Example #10
0
        private Int64 UpdateTran(BDProjectAdditionalInfoEntity bDProjectAdditionalInfoEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.BDProjectAdditionalInfo_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, "@ProjectAdditionalInfoID", DbType.Int64, bDProjectAdditionalInfoEntity.ProjectAdditionalInfoID);
                db.AddInParameter(cmd, "@ProjectID", DbType.Int64, bDProjectAdditionalInfoEntity.ProjectID);
                db.AddInParameter(cmd, "@NumberOfStorey", DbType.Decimal, bDProjectAdditionalInfoEntity.NumberOfStorey);
                db.AddInParameter(cmd, "@NumberOfBlock", DbType.Decimal, bDProjectAdditionalInfoEntity.NumberOfBlock);
                db.AddInParameter(cmd, "@TypicalFloorArea", DbType.Decimal, bDProjectAdditionalInfoEntity.TypicalFloorArea);
                db.AddInParameter(cmd, "@TypicalFloorAreaUnitID", DbType.Int64, bDProjectAdditionalInfoEntity.TypicalFloorAreaUnitID);
                db.AddInParameter(cmd, "@GCArchieved", DbType.Decimal, bDProjectAdditionalInfoEntity.GCArchieved);
                db.AddInParameter(cmd, "@NumberOfBasement", DbType.Decimal, bDProjectAdditionalInfoEntity.NumberOfBasement);
                db.AddInParameter(cmd, "@NumberOfResidentialFloor", DbType.Decimal, bDProjectAdditionalInfoEntity.NumberOfResidentialFloor);
                db.AddInParameter(cmd, "@NumberOfCommercialFloor", DbType.Decimal, bDProjectAdditionalInfoEntity.NumberOfCommercialFloor);
                db.AddInParameter(cmd, "@NoOfResidentialUnitPerFloor", DbType.Decimal, bDProjectAdditionalInfoEntity.NoOfResidentialUnitPerFloor);
                db.AddInParameter(cmd, "@Facing", DbType.String, bDProjectAdditionalInfoEntity.Facing);
                db.AddInParameter(cmd, "@TotalNumberOfUnit", DbType.Decimal, bDProjectAdditionalInfoEntity.TotalNumberOfUnit);
                db.AddInParameter(cmd, "@NumberOfPenthouse", DbType.Decimal, bDProjectAdditionalInfoEntity.NumberOfPenthouse);
                db.AddInParameter(cmd, "@NumberOfStair", DbType.Decimal, bDProjectAdditionalInfoEntity.NumberOfStair);
                db.AddInParameter(cmd, "@PositionAtBuilding", DbType.String, bDProjectAdditionalInfoEntity.PositionAtBuilding);
                db.AddInParameter(cmd, "@CoolingSystem", DbType.String, bDProjectAdditionalInfoEntity.CoolingSystem);
                db.AddInParameter(cmd, "@GeyserSystem", DbType.String, bDProjectAdditionalInfoEntity.GeyserSystem);
                db.AddInParameter(cmd, "@FacilitiesAtMezzanineFloor", DbType.String, bDProjectAdditionalInfoEntity.FacilitiesAtMezzanineFloor);
                db.AddInParameter(cmd, "@FacilitiesAtRoofFloor", DbType.String, bDProjectAdditionalInfoEntity.FacilitiesAtRoofFloor);
                db.AddInParameter(cmd, "@ApprovalRequired", DbType.String, bDProjectAdditionalInfoEntity.ApprovalRequired);
                db.AddInParameter(cmd, "@PositionAtBuildingForCommercial", DbType.String, bDProjectAdditionalInfoEntity.PositionAtBuildingForCommercial);
                db.AddInParameter(cmd, "@GroundFloorHeight", DbType.Decimal, bDProjectAdditionalInfoEntity.GroundFloorHeight);
                db.AddInParameter(cmd, "@TypicalFloorHeight", DbType.Decimal, bDProjectAdditionalInfoEntity.TypicalFloorHeight);
                db.AddInParameter(cmd, "@GroundFloorHeightUnitInFeetID", DbType.Int64, bDProjectAdditionalInfoEntity.GroundFloorHeightUnitInFeetID);
                db.AddInParameter(cmd, "@TypicalFloorHeightUnitInchID", DbType.Int64, bDProjectAdditionalInfoEntity.TypicalFloorHeightUnitInchID);
                db.AddInParameter(cmd, "@TypicalFloorHeightUnitInchID", DbType.Int64, bDProjectAdditionalInfoEntity.TypicalFloorHeightUnitInchID);
                db.AddInParameter(cmd, "@GroundFloorHeightInch", DbType.Decimal, bDProjectAdditionalInfoEntity.GroundFloorHeightInch);
                db.AddInParameter(cmd, "@GroundFloorHeightUnitInInchID", DbType.Int64, bDProjectAdditionalInfoEntity.GroundFloorHeightUnitInInchID);
                db.AddInParameter(cmd, "@TypicalFloorHeightFeet", DbType.Decimal, bDProjectAdditionalInfoEntity.TypicalFloorHeightFeet);
                db.AddInParameter(cmd, "@TypicalFloorHeightUnitFeetID", DbType.Int64, bDProjectAdditionalInfoEntity.TypicalFloorHeightUnitFeetID);

                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);
        }