示例#1
0
        private void PrepareEditView()
        {
            HREmployeeFamilyInfoEntity hREmployeeFamilyInfoEntity = CurrentHREmployeeFamilyInfoEntity;


            if (!hREmployeeFamilyInfoEntity.IsNew)
            {
                if (ddlFamilyRelationTypeID.Items.Count > 0 && hREmployeeFamilyInfoEntity.FamilyRelationTypeID != null)
                {
                    ddlFamilyRelationTypeID.SelectedValue = hREmployeeFamilyInfoEntity.FamilyRelationTypeID.ToString();
                }

                txtFirstName.Text      = hREmployeeFamilyInfoEntity.FirstName.ToString();
                txtMiddleName.Text     = hREmployeeFamilyInfoEntity.MiddleName.ToString();
                txtLastName.Text       = hREmployeeFamilyInfoEntity.LastName.ToString();
                txtProfession.Text     = hREmployeeFamilyInfoEntity.Profession.ToString();
                chkIsDependent.Checked = hREmployeeFamilyInfoEntity.IsDependent;
                if (ddlLastEducationAcquired.Items.Count > 0 && hREmployeeFamilyInfoEntity.LastEducationAcquired != null)
                {
                    ddlLastEducationAcquired.SelectedValue = hREmployeeFamilyInfoEntity.LastEducationAcquired.ToString();
                }

                chkIsEmployed.Checked = hREmployeeFamilyInfoEntity.IsEmployed;
                txtAge.Text           = hREmployeeFamilyInfoEntity.Age.ToString();
                txtEmailAddress.Text  = hREmployeeFamilyInfoEntity.EmailAddress.ToString();
                txtPhone.Text         = hREmployeeFamilyInfoEntity.Phone.ToString();

                btnSubmit.Text    = "Update";
                btnAddNew.Visible = true;
            }
        }
        Int64 IHREmployeeFamilyInfoDataAccess.Add(HREmployeeFamilyInfoEntity hREmployeeFamilyInfoEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private Int64 AddTran(HREmployeeFamilyInfoEntity hREmployeeFamilyInfoEntity, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.HREmployeeFamilyInfo_SET";

            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand cmd = db.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option, db);
                AddOutputParameter(cmd, db);
                AddNullPrimaryKeyParameter(cmd, "HREmployeeFamilyInfoID", db);

                db.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeFamilyInfoEntity.EmployeeID);
                db.AddInParameter(cmd, "@FamilyRelationTypeID", DbType.Int64, hREmployeeFamilyInfoEntity.FamilyRelationTypeID);
                db.AddInParameter(cmd, "@FirstName", DbType.String, hREmployeeFamilyInfoEntity.FirstName);
                db.AddInParameter(cmd, "@MiddleName", DbType.String, hREmployeeFamilyInfoEntity.MiddleName);
                db.AddInParameter(cmd, "@LastName", DbType.String, hREmployeeFamilyInfoEntity.LastName);
                db.AddInParameter(cmd, "@Profession", DbType.String, hREmployeeFamilyInfoEntity.Profession);
                db.AddInParameter(cmd, "@IsDependent", DbType.Boolean, hREmployeeFamilyInfoEntity.IsDependent);
                db.AddInParameter(cmd, "@LastEducationAcquired", DbType.Int64, hREmployeeFamilyInfoEntity.LastEducationAcquired);
                db.AddInParameter(cmd, "@IsEmployed", DbType.Boolean, hREmployeeFamilyInfoEntity.IsEmployed);
                db.AddInParameter(cmd, "@Age", DbType.Decimal, hREmployeeFamilyInfoEntity.Age);
                db.AddInParameter(cmd, "@EmailAddress", DbType.String, hREmployeeFamilyInfoEntity.EmailAddress);
                db.AddInParameter(cmd, "@Phone", DbType.String, hREmployeeFamilyInfoEntity.Phone);

                DbConnection connection = db.CreateConnection();
                connection.Open();
                DbTransaction transaction = connection.BeginTransaction();

                try
                {
                    returnCode = db.ExecuteNonQuery(cmd, transaction);

                    returnCode = GetReturnCodeFromParameter(cmd, db);

                    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 SaveHREmployeeFamilyInfoEntity()
        {
            if (IsValid)
            {
                try
                {
                    HREmployeeFamilyInfoEntity hREmployeeFamilyInfoEntity = BuildHREmployeeFamilyInfoEntity();

                    Int64 result = -1;

                    if (hREmployeeFamilyInfoEntity.IsNew)
                    {
                        result = FCCHREmployeeFamilyInfo.GetFacadeCreate().Add(hREmployeeFamilyInfoEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeFamilyInfoEntity.FLD_NAME_HREmployeeFamilyInfoID, hREmployeeFamilyInfoEntity.HREmployeeFamilyInfoID.ToString(), SQLMatchType.Equal);
                        result = FCCHREmployeeFamilyInfo.GetFacadeCreate().Update(hREmployeeFamilyInfoEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _HREmployeeFamilyInfoID     = 0;
                        _HREmployeeFamilyInfoEntity = new HREmployeeFamilyInfoEntity();
                        PrepareInitialView();
                        BindHREmployeeFamilyInfoList();

                        if (hREmployeeFamilyInfoEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Employee Family Info Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Employee Family Info Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (hREmployeeFamilyInfoEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Employee Family Info Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Employee Family Info Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
示例#5
0
        protected void lvHREmployeeFamilyInfo_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 HREmployeeFamilyInfoID;

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

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

                    PrepareEditView();

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

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeFamilyInfoEntity.FLD_NAME_HREmployeeFamilyInfoID, HREmployeeFamilyInfoID.ToString(), SQLMatchType.Equal);

                        HREmployeeFamilyInfoEntity hREmployeeFamilyInfoEntity = new HREmployeeFamilyInfoEntity();


                        result = FCCHREmployeeFamilyInfo.GetFacadeCreate().Delete(hREmployeeFamilyInfoEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _HREmployeeFamilyInfoID     = 0;
                            _HREmployeeFamilyInfoEntity = new HREmployeeFamilyInfoEntity();
                            PrepareInitialView();
                            BindHREmployeeFamilyInfoList();

                            MiscUtil.ShowMessage(lblMessage, "Employee Family Info has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Employee Family Info.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
示例#6
0
        private HREmployeeFamilyInfoEntity BuildHREmployeeFamilyInfoEntity()
        {
            HREmployeeFamilyInfoEntity hREmployeeFamilyInfoEntity = CurrentHREmployeeFamilyInfoEntity;


            hREmployeeFamilyInfoEntity.EmployeeID = OverviewEmployeeID;

            if (ddlFamilyRelationTypeID.Items.Count > 0)
            {
                if (ddlFamilyRelationTypeID.SelectedValue == "0")
                {
                }
                else
                {
                    hREmployeeFamilyInfoEntity.FamilyRelationTypeID = Int64.Parse(ddlFamilyRelationTypeID.SelectedValue);
                }
            }

            hREmployeeFamilyInfoEntity.FirstName   = txtFirstName.Text.Trim();
            hREmployeeFamilyInfoEntity.MiddleName  = txtMiddleName.Text.Trim();
            hREmployeeFamilyInfoEntity.LastName    = txtLastName.Text.Trim();
            hREmployeeFamilyInfoEntity.Profession  = txtProfession.Text.Trim();
            hREmployeeFamilyInfoEntity.IsDependent = chkIsDependent.Checked;

            if (ddlLastEducationAcquired.Items.Count > 0)
            {
                if (ddlLastEducationAcquired.SelectedValue == "0")
                {
                }
                else
                {
                    hREmployeeFamilyInfoEntity.LastEducationAcquired = Int64.Parse(ddlLastEducationAcquired.SelectedValue);
                }
            }

            hREmployeeFamilyInfoEntity.IsEmployed = chkIsEmployed.Checked;

            if (!txtAge.Text.Trim().IsNullOrEmpty())
            {
                hREmployeeFamilyInfoEntity.Age = Decimal.Parse(txtAge.Text.Trim());
            }
            else
            {
                hREmployeeFamilyInfoEntity.Age = null;
            }

            hREmployeeFamilyInfoEntity.EmailAddress = txtEmailAddress.Text.Trim();
            hREmployeeFamilyInfoEntity.Phone        = txtPhone.Text.Trim();

            return(hREmployeeFamilyInfoEntity);
        }
        private Int64 Update(HREmployeeFamilyInfoEntity hREmployeeFamilyInfoEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.HREmployeeFamilyInfo_SET";

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

                Database.AddInParameter(cmd, "@HREmployeeFamilyInfoID", DbType.Int64, hREmployeeFamilyInfoEntity.HREmployeeFamilyInfoID);
                Database.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeFamilyInfoEntity.EmployeeID);
                Database.AddInParameter(cmd, "@FamilyRelationTypeID", DbType.Int64, hREmployeeFamilyInfoEntity.FamilyRelationTypeID);
                Database.AddInParameter(cmd, "@FirstName", DbType.String, hREmployeeFamilyInfoEntity.FirstName);
                Database.AddInParameter(cmd, "@MiddleName", DbType.String, hREmployeeFamilyInfoEntity.MiddleName);
                Database.AddInParameter(cmd, "@LastName", DbType.String, hREmployeeFamilyInfoEntity.LastName);
                Database.AddInParameter(cmd, "@Profession", DbType.String, hREmployeeFamilyInfoEntity.Profession);
                Database.AddInParameter(cmd, "@IsDependent", DbType.Boolean, hREmployeeFamilyInfoEntity.IsDependent);
                Database.AddInParameter(cmd, "@LastEducationAcquired", DbType.Int64, hREmployeeFamilyInfoEntity.LastEducationAcquired);
                Database.AddInParameter(cmd, "@IsEmployed", DbType.Boolean, hREmployeeFamilyInfoEntity.IsEmployed);
                Database.AddInParameter(cmd, "@Age", DbType.Decimal, hREmployeeFamilyInfoEntity.Age);
                Database.AddInParameter(cmd, "@EmailAddress", DbType.String, hREmployeeFamilyInfoEntity.EmailAddress);
                Database.AddInParameter(cmd, "@Phone", DbType.String, hREmployeeFamilyInfoEntity.Phone);

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

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

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

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

            return(returnCode);
        }
        private Int64 DeleteTran(HREmployeeFamilyInfoEntity hREmployeeFamilyInfoEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.HREmployeeFamilyInfo_SET";

            Database db = DatabaseFactory.CreateDatabase();


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


                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);
        }
        private Int64 Delete(HREmployeeFamilyInfoEntity hREmployeeFamilyInfoEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.HREmployeeFamilyInfo_SET";

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


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

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

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

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

            return(returnCode);
        }
示例#10
0
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _HREmployeeFamilyInfoID     = 0;
     _HREmployeeFamilyInfoEntity = new HREmployeeFamilyInfoEntity();
     PrepareInitialView();
 }
示例#11
0
 Int64 IHREmployeeFamilyInfoFacade.Delete(HREmployeeFamilyInfoEntity hREmployeeFamilyInfoEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateHREmployeeFamilyInfoDataAccess().Delete(hREmployeeFamilyInfoEntity, filterExpression, option, reqTran));
 }
示例#12
0
 Int64 IHREmployeeFamilyInfoFacade.Add(HREmployeeFamilyInfoEntity hREmployeeFamilyInfoEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateHREmployeeFamilyInfoDataAccess().Add(hREmployeeFamilyInfoEntity, option, reqTran));
 }