Ejemplo n.º 1
0
        Int64 IMDPayCycleDataAccess.Delete(MDPayCycleEntity mDPayCycleEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        Int64 IMDPayCycleDataAccess.Add(MDPayCycleEntity mDPayCycleEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
        private MDPayCycleEntity BuildMDPayCycleEntity()
        {
            MDPayCycleEntity mDPayCycleEntity = CurrentMDPayCycleEntity;

            mDPayCycleEntity.Name      = txtName.Text.Trim();
            mDPayCycleEntity.IsRemoved = chkIsRemoved.Checked;


            return(mDPayCycleEntity);
        }
Ejemplo n.º 4
0
        private void SaveMDPayCycleEntity()
        {
            if (IsValid)
            {
                try
                {
                    MDPayCycleEntity mDPayCycleEntity = BuildMDPayCycleEntity();

                    Int64 result = -1;

                    if (mDPayCycleEntity.IsNew)
                    {
                        result = FCCMDPayCycle.GetFacadeCreate().Add(mDPayCycleEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDPayCycleEntity.FLD_NAME_PayCycleID, mDPayCycleEntity.PayCycleID.ToString(), SQLMatchType.Equal);
                        result = FCCMDPayCycle.GetFacadeCreate().Update(mDPayCycleEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _PayCycleID       = 0;
                        _MDPayCycleEntity = new MDPayCycleEntity();
                        PrepareInitialView();
                        BindMDPayCycleList();

                        if (mDPayCycleEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Pay Cycle Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Pay Cycle Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (mDPayCycleEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Pay Cycle Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Pay Cycle Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Ejemplo n.º 5
0
        private Int64 UpdateTran(MDPayCycleEntity mDPayCycleEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.MDPayCycle_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, "@PayCycleID", DbType.Int64, mDPayCycleEntity.PayCycleID);
                db.AddInParameter(cmd, "@Name", DbType.String, mDPayCycleEntity.Name);
                db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, mDPayCycleEntity.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);
        }
Ejemplo n.º 6
0
        protected void lvMDPayCycle_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 PayCycleID;

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

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

                    PrepareEditView();

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

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(MDPayCycleEntity.FLD_NAME_PayCycleID, PayCycleID.ToString(), SQLMatchType.Equal);

                        MDPayCycleEntity mDPayCycleEntity = new MDPayCycleEntity();


                        result = FCCMDPayCycle.GetFacadeCreate().Delete(mDPayCycleEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _PayCycleID       = 0;
                            _MDPayCycleEntity = new MDPayCycleEntity();
                            PrepareInitialView();
                            BindMDPayCycleList();

                            MiscUtil.ShowMessage(lblMessage, "Pay Cycle has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Pay Cycle.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private void PrepareEditView()
        {
            MDPayCycleEntity mDPayCycleEntity = CurrentMDPayCycleEntity;


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

                btnSubmit.Text    = "Update";
                btnAddNew.Visible = true;
            }
        }
Ejemplo n.º 8
0
        private Int64 Update(MDPayCycleEntity mDPayCycleEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.MDPayCycle_SET";

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

                Database.AddInParameter(cmd, "@PayCycleID", DbType.Int64, mDPayCycleEntity.PayCycleID);
                Database.AddInParameter(cmd, "@Name", DbType.String, mDPayCycleEntity.Name);
                Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, mDPayCycleEntity.IsRemoved);

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

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

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

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

            return(returnCode);
        }
Ejemplo n.º 9
0
 Int64 IMDPayCycleFacade.Delete(MDPayCycleEntity mDPayCycleEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateMDPayCycleDataAccess().Delete(mDPayCycleEntity, filterExpression, option, reqTran));
 }
Ejemplo n.º 10
0
 Int64 IMDPayCycleFacade.Add(MDPayCycleEntity mDPayCycleEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateMDPayCycleDataAccess().Add(mDPayCycleEntity, option, reqTran));
 }
Ejemplo n.º 11
0
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _PayCycleID       = 0;
     _MDPayCycleEntity = new MDPayCycleEntity();
     PrepareInitialView();
 }