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

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        Int64 ICRMMDLandLocationDataAccess.Add(CRMMDLandLocationEntity cRMMDLandLocationEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void SaveCRMMDLandLocationEntity()
        {
            if (IsValid)
            {
                try
                {
                    CRMMDLandLocationEntity cRMMDLandLocationEntity = BuildCRMMDLandLocationEntity();

                    Int64 result = -1;

                    if (cRMMDLandLocationEntity.IsNew)
                    {
                        result = FCCCRMMDLandLocation.GetFacadeCreate().Add(cRMMDLandLocationEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(CRMMDLandLocationEntity.FLD_NAME_LandLocationID, cRMMDLandLocationEntity.LandLocationID.ToString(), SQLMatchType.Equal);
                        result = FCCCRMMDLandLocation.GetFacadeCreate().Update(cRMMDLandLocationEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _LandLocationID          = 0;
                        _CRMMDLandLocationEntity = new CRMMDLandLocationEntity();
                        PrepareInitialView();
                        BindCRMMDLandLocationList();

                        if (cRMMDLandLocationEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "C RMLand Location Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "C RMLand Location Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (cRMMDLandLocationEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add C RMLand Location Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update C RMLand Location Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
        private CRMMDLandLocationEntity BuildCRMMDLandLocationEntity()
        {
            CRMMDLandLocationEntity cRMMDLandLocationEntity = CurrentCRMMDLandLocationEntity;

            cRMMDLandLocationEntity.Name        = txtName.Text.Trim();
            cRMMDLandLocationEntity.Description = txtDescription.Text.Trim();
            cRMMDLandLocationEntity.IsRemoved   = chkIsRemoved.Checked;


            return(cRMMDLandLocationEntity);
        }
Example #5
0
        private Int64 UpdateTran(CRMMDLandLocationEntity cRMMDLandLocationEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.CRMMDLandLocation_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, "@LandLocationID", DbType.Int64, cRMMDLandLocationEntity.LandLocationID);
                db.AddInParameter(cmd, "@Name", DbType.String, cRMMDLandLocationEntity.Name);
                db.AddInParameter(cmd, "@Description", DbType.String, cRMMDLandLocationEntity.Description);
                db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, cRMMDLandLocationEntity.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);
        }
        protected void lvCRMMDLandLocation_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 LandLocationID;

            Int64.TryParse(e.CommandArgument.ToString(), out LandLocationID);

            if (LandLocationID > 0)
            {
                if (string.Equals(e.CommandName, "EditItem"))
                {
                    _LandLocationID = LandLocationID;

                    PrepareEditView();

                    cpeEditor.Collapsed   = false;
                    cpeEditor.ClientState = "false";
                }
                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(CRMMDLandLocationEntity.FLD_NAME_LandLocationID, LandLocationID.ToString(), SQLMatchType.Equal);

                        CRMMDLandLocationEntity cRMMDLandLocationEntity = new CRMMDLandLocationEntity();


                        result = FCCCRMMDLandLocation.GetFacadeCreate().Delete(cRMMDLandLocationEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _LandLocationID          = 0;
                            _CRMMDLandLocationEntity = new CRMMDLandLocationEntity();
                            PrepareInitialView();
                            BindCRMMDLandLocationList();

                            MiscUtil.ShowMessage(lblMessage, "C RMLand Location has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete C RMLand Location.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
        private void PrepareEditView()
        {
            CRMMDLandLocationEntity cRMMDLandLocationEntity = CurrentCRMMDLandLocationEntity;


            if (!cRMMDLandLocationEntity.IsNew)
            {
                txtName.Text         = cRMMDLandLocationEntity.Name.ToString();
                txtDescription.Text  = cRMMDLandLocationEntity.Description.ToString();
                chkIsRemoved.Checked = cRMMDLandLocationEntity.IsRemoved;

                btnSubmit.Text    = "Update";
                btnAddNew.Visible = true;
            }
        }
Example #8
0
        private Int64 Update(CRMMDLandLocationEntity cRMMDLandLocationEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.CRMMDLandLocation_SET";

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

                Database.AddInParameter(cmd, "@LandLocationID", DbType.Int64, cRMMDLandLocationEntity.LandLocationID);
                Database.AddInParameter(cmd, "@Name", DbType.String, cRMMDLandLocationEntity.Name);
                Database.AddInParameter(cmd, "@Description", DbType.String, cRMMDLandLocationEntity.Description);
                Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, cRMMDLandLocationEntity.IsRemoved);

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

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

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

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

            return(returnCode);
        }
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _LandLocationID          = 0;
     _CRMMDLandLocationEntity = new CRMMDLandLocationEntity();
     PrepareInitialView();
 }
Example #10
0
 Int64 ICRMMDLandLocationFacade.Delete(CRMMDLandLocationEntity cRMMDLandLocationEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateCRMMDLandLocationDataAccess().Delete(cRMMDLandLocationEntity, filterExpression, option, reqTran));
 }
Example #11
0
 Int64 ICRMMDLandLocationFacade.Add(CRMMDLandLocationEntity cRMMDLandLocationEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateCRMMDLandLocationDataAccess().Add(cRMMDLandLocationEntity, option, reqTran));
 }