コード例 #1
0
        Int64 IAPStatusDataAccess.Delete(APStatusEntity aPStatusEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        Int64 IAPStatusDataAccess.Add(APStatusEntity aPStatusEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        private void SaveAPStatusEntity()
        {
            if (IsValid)
            {
                try
                {
                    APStatusEntity aPStatusEntity = BuildAPStatusEntity();

                    Int64 result = -1;

                    if (aPStatusEntity.IsNew)
                    {
                        result = FCCAPStatus.GetFacadeCreate().Add(aPStatusEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(APStatusEntity.FLD_NAME_APStatusID, aPStatusEntity.APStatusID.ToString(), SQLMatchType.Equal);
                        result = FCCAPStatus.GetFacadeCreate().Update(aPStatusEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _APStatusID     = 0;
                        _APStatusEntity = new APStatusEntity();
                        PrepareInitialView();
                        BindAPStatusList();

                        if (aPStatusEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "A PStatus Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "A PStatus Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (aPStatusEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add A PStatus Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update A PStatus Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
コード例 #4
0
        private APStatusEntity BuildAPStatusEntity()
        {
            APStatusEntity aPStatusEntity = CurrentAPStatusEntity;

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


            return(aPStatusEntity);
        }
コード例 #5
0
        private Int64 UpdateTran(APStatusEntity aPStatusEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.APStatus_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, "@APStatusID", DbType.Int64, aPStatusEntity.APStatusID);
                db.AddInParameter(cmd, "@Name", DbType.String, aPStatusEntity.Name);
                db.AddInParameter(cmd, "@Description", DbType.String, aPStatusEntity.Description);
                db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, aPStatusEntity.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);
        }
コード例 #6
0
        protected void lvAPStatus_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 APStatusID;

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

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

                    PrepareEditView();

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

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(APStatusEntity.FLD_NAME_APStatusID, APStatusID.ToString(), SQLMatchType.Equal);

                        APStatusEntity aPStatusEntity = new APStatusEntity();


                        result = FCCAPStatus.GetFacadeCreate().Delete(aPStatusEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _APStatusID     = 0;
                            _APStatusEntity = new APStatusEntity();
                            PrepareInitialView();
                            BindAPStatusList();

                            MiscUtil.ShowMessage(lblMessage, "A PStatus has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete A PStatus.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
コード例 #7
0
        private void PrepareEditView()
        {
            APStatusEntity aPStatusEntity = CurrentAPStatusEntity;


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

                btnSubmit.Text    = "Update";
                btnAddNew.Visible = true;
            }
        }
コード例 #8
0
        private Int64 Update(APStatusEntity aPStatusEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.APStatus_SET";

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

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

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

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

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

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

            return(returnCode);
        }
コード例 #9
0
 Int64 IAPStatusFacade.Delete(APStatusEntity aPStatusEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateAPStatusDataAccess().Delete(aPStatusEntity, filterExpression, option, reqTran));
 }
コード例 #10
0
 Int64 IAPStatusFacade.Add(APStatusEntity aPStatusEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateAPStatusDataAccess().Add(aPStatusEntity, option, reqTran));
 }
コード例 #11
0
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _APStatusID     = 0;
     _APStatusEntity = new APStatusEntity();
     PrepareInitialView();
 }