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

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

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

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

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

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        private void SaveACTaxTypeEntity()
        {
            if (IsValid)
            {
                try
                {
                    ACTaxTypeEntity aCTaxTypeEntity = BuildACTaxTypeEntity();

                    Int64 result = -1;

                    if (aCTaxTypeEntity.IsNew)
                    {
                        result = FCCACTaxType.GetFacadeCreate().Add(aCTaxTypeEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(ACTaxTypeEntity.FLD_NAME_TaxTypeID, aCTaxTypeEntity.TaxTypeID.ToString(), SQLMatchType.Equal);
                        result = FCCACTaxType.GetFacadeCreate().Update(aCTaxTypeEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _TaxTypeID       = 0;
                        _ACTaxTypeEntity = new ACTaxTypeEntity();
                        PrepareInitialView();
                        BindACTaxTypeList();

                        if (aCTaxTypeEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "A CTax Type Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "A CTax Type Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (aCTaxTypeEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add A CTax Type Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update A CTax Type Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
コード例 #4
0
        private Int64 UpdateTran(ACTaxTypeEntity aCTaxTypeEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.ACTaxType_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, "@TaxTypeID", DbType.Int64, aCTaxTypeEntity.TaxTypeID);
                db.AddInParameter(cmd, "@Name", DbType.String, aCTaxTypeEntity.Name);
                db.AddInParameter(cmd, "@Rate", DbType.Decimal, aCTaxTypeEntity.Rate);
                db.AddInParameter(cmd, "@Description", DbType.String, aCTaxTypeEntity.Description);
                db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, aCTaxTypeEntity.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);
        }
コード例 #5
0
        protected void lvACTaxType_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 TaxTypeID;

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

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

                    PrepareEditView();

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

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(ACTaxTypeEntity.FLD_NAME_TaxTypeID, TaxTypeID.ToString(), SQLMatchType.Equal);

                        ACTaxTypeEntity aCTaxTypeEntity = new ACTaxTypeEntity();


                        result = FCCACTaxType.GetFacadeCreate().Delete(aCTaxTypeEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _TaxTypeID       = 0;
                            _ACTaxTypeEntity = new ACTaxTypeEntity();
                            PrepareInitialView();
                            BindACTaxTypeList();

                            MiscUtil.ShowMessage(lblMessage, "A CTax Type has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete A CTax Type.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
コード例 #6
0
        private ACTaxTypeEntity BuildACTaxTypeEntity()
        {
            ACTaxTypeEntity aCTaxTypeEntity = CurrentACTaxTypeEntity;

            aCTaxTypeEntity.Name = txtName.Text.Trim();
            if (!txtRate.Text.Trim().IsNullOrEmpty())
            {
                aCTaxTypeEntity.Rate = Decimal.Parse(txtRate.Text.Trim());
            }

            aCTaxTypeEntity.Description = txtDescription.Text.Trim();
            aCTaxTypeEntity.IsRemoved   = chkIsRemoved.Checked;


            return(aCTaxTypeEntity);
        }
コード例 #7
0
        private void PrepareEditView()
        {
            ACTaxTypeEntity aCTaxTypeEntity = CurrentACTaxTypeEntity;


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

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

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

                Database.AddInParameter(cmd, "@TaxTypeID", DbType.Int64, aCTaxTypeEntity.TaxTypeID);
                Database.AddInParameter(cmd, "@Name", DbType.String, aCTaxTypeEntity.Name);
                Database.AddInParameter(cmd, "@Rate", DbType.Decimal, aCTaxTypeEntity.Rate);
                Database.AddInParameter(cmd, "@Description", DbType.String, aCTaxTypeEntity.Description);
                Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, aCTaxTypeEntity.IsRemoved);

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

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

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

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

            return(returnCode);
        }
コード例 #9
0
 Int64 IACTaxTypeFacade.Delete(ACTaxTypeEntity aCTaxTypeEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateACTaxTypeDataAccess().Delete(aCTaxTypeEntity, filterExpression, option, reqTran));
 }
コード例 #10
0
 Int64 IACTaxTypeFacade.Add(ACTaxTypeEntity aCTaxTypeEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateACTaxTypeDataAccess().Add(aCTaxTypeEntity, option, reqTran));
 }
コード例 #11
0
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _TaxTypeID       = 0;
     _ACTaxTypeEntity = new ACTaxTypeEntity();
     PrepareInitialView();
 }