Int64 ICRMLandCurrentStatusDataAccess.Add(CRMLandCurrentStatusEntity cRMLandCurrentStatusEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private Int64 UpdateTran(CRMLandCurrentStatusEntity cRMLandCurrentStatusEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.CRMLandCurrentStatus_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, "@LandCurrentStatusID", DbType.Int64, cRMLandCurrentStatusEntity.LandCurrentStatusID);
                db.AddInParameter(cmd, "@LandBasicInfoID", DbType.Int64, cRMLandCurrentStatusEntity.LandBasicInfoID);
                db.AddInParameter(cmd, "@Ownership", DbType.String, cRMLandCurrentStatusEntity.Ownership);
                db.AddInParameter(cmd, "@Mutation", DbType.String, cRMLandCurrentStatusEntity.Mutation);
                db.AddInParameter(cmd, "@CurrentUsage", DbType.String, cRMLandCurrentStatusEntity.CurrentUsage);
                db.AddInParameter(cmd, "@CommercialPermit", DbType.String, cRMLandCurrentStatusEntity.CommercialPermit);
                db.AddInParameter(cmd, "@Tenant", DbType.String, cRMLandCurrentStatusEntity.Tenant);
                db.AddInParameter(cmd, "@LoanLiability", DbType.String, cRMLandCurrentStatusEntity.LoanLiability);
                db.AddInParameter(cmd, "@NOC", DbType.String, cRMLandCurrentStatusEntity.NOC);
                db.AddInParameter(cmd, "@Agreements", DbType.String, cRMLandCurrentStatusEntity.Agreements);
                db.AddInParameter(cmd, "@Litigation", DbType.String, cRMLandCurrentStatusEntity.Litigation);

                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);
        }
Ejemplo n.º 3
0
        private void SaveCRMLandCurrentStatusEntity()
        {
            if (IsValid)
            {
                try
                {
                    CRMLandCurrentStatusEntity cRMLandCurrentStatusEntity = BuildCRMLandCurrentStatusEntity();

                    Int64 result = -1;

                    if (cRMLandCurrentStatusEntity.IsNew)
                    {
                        result = FCCCRMLandCurrentStatus.GetFacadeCreate().Add(cRMLandCurrentStatusEntity, DatabaseOperationType.Add, TransactionRequired.No);

                        String navUrl = UrlHelper.BuildSecureUrl("~/CRM/CRMLandOwner.aspx", string.Empty, UrlConstants.OVERVIEW_LAND_BASIC_INFO_ID, CRMLandBasicInfoID.ToString()).ToString();
                        Response.Redirect(navUrl);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(CRMLandCurrentStatusEntity.FLD_NAME_LandCurrentStatusID, cRMLandCurrentStatusEntity.LandCurrentStatusID.ToString(), SQLMatchType.Equal);
                        result = FCCCRMLandCurrentStatus.GetFacadeCreate().Update(cRMLandCurrentStatusEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _CRMLandCurrentStatusEntity = CurrentCRMLandCurrentStatusEntity;
                        PrepareEditView();
                        BindCRMLandCurrentStatusList();

                        if (cRMLandCurrentStatusEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Land Current Status Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Land Current Status Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (cRMLandCurrentStatusEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Land Current Status Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Land Current Status Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
        private Int64 DeleteTran(CRMLandCurrentStatusEntity cRMLandCurrentStatusEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.CRMLandCurrentStatus_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 Update(CRMLandCurrentStatusEntity cRMLandCurrentStatusEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.CRMLandCurrentStatus_SET";

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

                Database.AddInParameter(cmd, "@LandCurrentStatusID", DbType.Int64, cRMLandCurrentStatusEntity.LandCurrentStatusID);
                Database.AddInParameter(cmd, "@LandBasicInfoID", DbType.Int64, cRMLandCurrentStatusEntity.LandBasicInfoID);
                Database.AddInParameter(cmd, "@Ownership", DbType.String, cRMLandCurrentStatusEntity.Ownership);
                Database.AddInParameter(cmd, "@Mutation", DbType.String, cRMLandCurrentStatusEntity.Mutation);
                Database.AddInParameter(cmd, "@CurrentUsage", DbType.String, cRMLandCurrentStatusEntity.CurrentUsage);
                Database.AddInParameter(cmd, "@CommercialPermit", DbType.String, cRMLandCurrentStatusEntity.CommercialPermit);
                Database.AddInParameter(cmd, "@Tenant", DbType.String, cRMLandCurrentStatusEntity.Tenant);
                Database.AddInParameter(cmd, "@LoanLiability", DbType.String, cRMLandCurrentStatusEntity.LoanLiability);
                Database.AddInParameter(cmd, "@NOC", DbType.String, cRMLandCurrentStatusEntity.NOC);
                Database.AddInParameter(cmd, "@Agreements", DbType.String, cRMLandCurrentStatusEntity.Agreements);
                Database.AddInParameter(cmd, "@Litigation", DbType.String, cRMLandCurrentStatusEntity.Litigation);

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

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

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

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

            return(returnCode);
        }
Ejemplo n.º 6
0
        private CRMLandCurrentStatusEntity BuildCRMLandCurrentStatusEntity()
        {
            CRMLandCurrentStatusEntity cRMLandCurrentStatusEntity = CurrentCRMLandCurrentStatusEntity;

            cRMLandCurrentStatusEntity.LandBasicInfoID = CRMLandBasicInfoID;

            cRMLandCurrentStatusEntity.Ownership        = txtOwnership.Text.Trim();
            cRMLandCurrentStatusEntity.Mutation         = txtMutation.Text.Trim();
            cRMLandCurrentStatusEntity.CurrentUsage     = txtCurrentUsage.Text.Trim();
            cRMLandCurrentStatusEntity.CommercialPermit = txtCommercialPermit.Text.Trim();
            cRMLandCurrentStatusEntity.Tenant           = txtTenant.Text.Trim();
            cRMLandCurrentStatusEntity.LoanLiability    = txtLoanLiability.Text.Trim();
            cRMLandCurrentStatusEntity.NOC        = txtNOC.Text.Trim();
            cRMLandCurrentStatusEntity.Agreements = txtAgreements.Text.Trim();
            cRMLandCurrentStatusEntity.Litigation = txtLitigation.Text.Trim();

            return(cRMLandCurrentStatusEntity);
        }
Ejemplo n.º 7
0
        private void PrepareEditView()
        {
            CRMLandCurrentStatusEntity cRMLandCurrentStatusEntity = CurrentCRMLandCurrentStatusEntity;


            if (!cRMLandCurrentStatusEntity.IsNew)
            {
                txtOwnership.Text        = cRMLandCurrentStatusEntity.Ownership.ToString();
                txtMutation.Text         = cRMLandCurrentStatusEntity.Mutation.ToString();
                txtCurrentUsage.Text     = cRMLandCurrentStatusEntity.CurrentUsage.ToString();
                txtCommercialPermit.Text = cRMLandCurrentStatusEntity.CommercialPermit.ToString();
                txtTenant.Text           = cRMLandCurrentStatusEntity.Tenant.ToString();
                txtLoanLiability.Text    = cRMLandCurrentStatusEntity.LoanLiability.ToString();
                txtNOC.Text        = cRMLandCurrentStatusEntity.NOC.ToString();
                txtAgreements.Text = cRMLandCurrentStatusEntity.Agreements.ToString();
                txtLitigation.Text = cRMLandCurrentStatusEntity.Litigation.ToString();

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

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

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

            return(returnCode);
        }
Ejemplo n.º 9
0
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _LandCurrentStatusID        = 0;
     _CRMLandCurrentStatusEntity = new CRMLandCurrentStatusEntity();
     PrepareInitialView();
 }
Ejemplo n.º 10
0
 Int64 ICRMLandCurrentStatusFacade.Delete(CRMLandCurrentStatusEntity cRMLandCurrentStatusEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateCRMLandCurrentStatusDataAccess().Delete(cRMLandCurrentStatusEntity, filterExpression, option, reqTran));
 }
Ejemplo n.º 11
0
 Int64 ICRMLandCurrentStatusFacade.Add(CRMLandCurrentStatusEntity cRMLandCurrentStatusEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateCRMLandCurrentStatusDataAccess().Add(cRMLandCurrentStatusEntity, option, reqTran));
 }