Пример #1
0
        Int64 IHREmployeeJobDescriptionDataAccess.Add(HREmployeeJobDescriptionEntity hREmployeeJobDescriptionEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        private void SaveHREmployeeJobDescriptionEntity()
        {
            if (IsValid)
            {
                try
                {
                    HREmployeeJobDescriptionEntity hREmployeeJobDescriptionEntity = BuildHREmployeeJobDescriptionEntity();

                    Int64 result = -1;

                    if (hREmployeeJobDescriptionEntity.IsNew)
                    {
                        result = FCCHREmployeeJobDescription.GetFacadeCreate().Add(hREmployeeJobDescriptionEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeJobDescriptionEntity.FLD_NAME_EmployeeJobDescriptionID, hREmployeeJobDescriptionEntity.EmployeeJobDescriptionID.ToString(), SQLMatchType.Equal);
                        result = FCCHREmployeeJobDescription.GetFacadeCreate().Update(hREmployeeJobDescriptionEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _EmployeeJobDescriptionID       = result;
                        _HREmployeeJobDescriptionEntity = CurrentHREmployeeJobDescriptionEntity;
                        PrepareEditView();
                        BindHREmployeeJobDescriptionList();

                        if (hREmployeeJobDescriptionEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Employee Job Description Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Employee Job Description Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (hREmployeeJobDescriptionEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Employee Job Description Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Employee Job Description Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Пример #3
0
        private Int64 UpdateTran(HREmployeeJobDescriptionEntity hREmployeeJobDescriptionEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.HREmployeeJobDescription_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, "@EmployeeJobDescriptionID", DbType.Int64, hREmployeeJobDescriptionEntity.EmployeeJobDescriptionID);
                db.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeJobDescriptionEntity.EmployeeID);
                db.AddInParameter(cmd, "@Description", DbType.String, hREmployeeJobDescriptionEntity.Description);
                db.AddInParameter(cmd, "@Remarks", DbType.String, hREmployeeJobDescriptionEntity.Remarks);
                db.AddInParameter(cmd, "@CreateDate", DbType.DateTime, hREmployeeJobDescriptionEntity.CreateDate);

                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);
        }
Пример #4
0
        private void PrepareEditView()
        {
            HREmployeeJobDescriptionEntity hREmployeeJobDescriptionEntity = CurrentHREmployeeJobDescriptionEntity;


            if (!hREmployeeJobDescriptionEntity.IsNew)
            {
                txtDescription.Text = hREmployeeJobDescriptionEntity.Description.ToString();
                txtRemarks.Text     = hREmployeeJobDescriptionEntity.Remarks.ToString();

                btnSubmit.Text = "Update";
            }
        }
Пример #5
0
        private HREmployeeJobDescriptionEntity BuildHREmployeeJobDescriptionEntity()
        {
            HREmployeeJobDescriptionEntity hREmployeeJobDescriptionEntity = CurrentHREmployeeJobDescriptionEntity;


            hREmployeeJobDescriptionEntity.EmployeeID = OverviewEmployeeID;

            hREmployeeJobDescriptionEntity.Description = txtDescription.Text.Trim();
            hREmployeeJobDescriptionEntity.Remarks     = txtRemarks.Text.Trim();

            hREmployeeJobDescriptionEntity.CreateDate = System.DateTime.Now;


            return(hREmployeeJobDescriptionEntity);
        }
Пример #6
0
        private Int64 Update(HREmployeeJobDescriptionEntity hREmployeeJobDescriptionEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.HREmployeeJobDescription_SET";

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

                Database.AddInParameter(cmd, "@EmployeeJobDescriptionID", DbType.Int64, hREmployeeJobDescriptionEntity.EmployeeJobDescriptionID);
                Database.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeJobDescriptionEntity.EmployeeID);
                Database.AddInParameter(cmd, "@Description", DbType.String, hREmployeeJobDescriptionEntity.Description);
                Database.AddInParameter(cmd, "@Remarks", DbType.String, hREmployeeJobDescriptionEntity.Remarks);
                Database.AddInParameter(cmd, "@CreateDate", DbType.DateTime, hREmployeeJobDescriptionEntity.CreateDate);

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

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

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

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

            return(returnCode);
        }
 Int64 IHREmployeeJobDescriptionFacade.Delete(HREmployeeJobDescriptionEntity hREmployeeJobDescriptionEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateHREmployeeJobDescriptionDataAccess().Delete(hREmployeeJobDescriptionEntity, filterExpression, option, reqTran));
 }
 Int64 IHREmployeeJobDescriptionFacade.Add(HREmployeeJobDescriptionEntity hREmployeeJobDescriptionEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateHREmployeeJobDescriptionDataAccess().Add(hREmployeeJobDescriptionEntity, option, reqTran));
 }