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

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        private void PrepareEditView()
        {
            HREmployeeAddressInfoEntity hREmployeeAddressInfoEntity = CurrentHREmployeeAddressInfoEntity;


            if (!hREmployeeAddressInfoEntity.IsNew)
            {
                if (ddlEmployeeAddressTypeID.Items.Count > 0 && hREmployeeAddressInfoEntity.EmployeeAddressTypeID != null)
                {
                    ddlEmployeeAddressTypeID.SelectedValue = hREmployeeAddressInfoEntity.EmployeeAddressTypeID.ToString();
                }

                if (ddlCountryID.Items.Count > 0 && hREmployeeAddressInfoEntity.CountryID != null)
                {
                    ddlCountryID.SelectedValue = hREmployeeAddressInfoEntity.CountryID.ToString();
                }

                if (ddlCityID.Items.Count > 0 && hREmployeeAddressInfoEntity.CityID != null)
                {
                    ddlCityID.SelectedValue = hREmployeeAddressInfoEntity.CityID.ToString();
                }

                txtAddressLine1.Text = hREmployeeAddressInfoEntity.AddressLine1.ToString();
                txtAddressLine2.Text = hREmployeeAddressInfoEntity.AddressLine2.ToString();
                txtZipCode.Text      = hREmployeeAddressInfoEntity.ZipCode.ToString();

                btnSubmit.Text    = "Update";
                btnAddNew.Visible = true;
            }
        }
Пример #3
0
        private Int64 UpdateTran(HREmployeeAddressInfoEntity hREmployeeAddressInfoEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.HREmployeeAddressInfo_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, "@EmployeeAddressInfoID", DbType.Int64, hREmployeeAddressInfoEntity.EmployeeAddressInfoID);
                db.AddInParameter(cmd, "@EmployeeAddressTypeID", DbType.Int64, hREmployeeAddressInfoEntity.EmployeeAddressTypeID);
                db.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeAddressInfoEntity.EmployeeID);
                db.AddInParameter(cmd, "@CountryID", DbType.Int64, hREmployeeAddressInfoEntity.CountryID);
                db.AddInParameter(cmd, "@CityID", DbType.Int64, hREmployeeAddressInfoEntity.CityID);
                db.AddInParameter(cmd, "@AddressLine1", DbType.String, hREmployeeAddressInfoEntity.AddressLine1);
                db.AddInParameter(cmd, "@AddressLine2", DbType.String, hREmployeeAddressInfoEntity.AddressLine2);
                db.AddInParameter(cmd, "@ZipCode", DbType.String, hREmployeeAddressInfoEntity.ZipCode);

                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 SaveHREmployeeAddressInfoEntity()
        {
            if (IsValid)
            {
                try
                {
                    HREmployeeAddressInfoEntity hREmployeeAddressInfoEntity = BuildHREmployeeAddressInfoEntity();

                    Int64 result = -1;

                    if (hREmployeeAddressInfoEntity.IsNew)
                    {
                        result = FCCHREmployeeAddressInfo.GetFacadeCreate().Add(hREmployeeAddressInfoEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeAddressInfoEntity.FLD_NAME_EmployeeAddressInfoID, hREmployeeAddressInfoEntity.EmployeeAddressInfoID.ToString(), SQLMatchType.Equal);
                        result = FCCHREmployeeAddressInfo.GetFacadeCreate().Update(hREmployeeAddressInfoEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _EmployeeAddressInfoID       = 0;
                        _HREmployeeAddressInfoEntity = new HREmployeeAddressInfoEntity();
                        PrepareInitialView();
                        BindHREmployeeAddressInfoList();

                        if (hREmployeeAddressInfoEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Employee Address Info Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Employee Address Info Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (hREmployeeAddressInfoEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Employee Address Info Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Employee Address Info Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Пример #5
0
        protected void lvHREmployeeAddressInfo_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 EmployeeAddressInfoID;

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

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

                    PrepareEditView();

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

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeAddressInfoEntity.FLD_NAME_EmployeeAddressInfoID, EmployeeAddressInfoID.ToString(), SQLMatchType.Equal);

                        HREmployeeAddressInfoEntity hREmployeeAddressInfoEntity = new HREmployeeAddressInfoEntity();


                        result = FCCHREmployeeAddressInfo.GetFacadeCreate().Delete(hREmployeeAddressInfoEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _EmployeeAddressInfoID       = 0;
                            _HREmployeeAddressInfoEntity = new HREmployeeAddressInfoEntity();
                            PrepareInitialView();
                            BindHREmployeeAddressInfoList();

                            MiscUtil.ShowMessage(lblMessage, "Employee Address Info has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Employee Address Info.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
Пример #6
0
        private HREmployeeAddressInfoEntity BuildHREmployeeAddressInfoEntity()
        {
            HREmployeeAddressInfoEntity hREmployeeAddressInfoEntity = CurrentHREmployeeAddressInfoEntity;

            if (ddlEmployeeAddressTypeID.Items.Count > 0)
            {
                if (ddlEmployeeAddressTypeID.SelectedValue == "0")
                {
                }
                else
                {
                    hREmployeeAddressInfoEntity.EmployeeAddressTypeID = Int64.Parse(ddlEmployeeAddressTypeID.SelectedValue);
                }
            }


            hREmployeeAddressInfoEntity.EmployeeID = OverviewEmployeeID;

            if (ddlCountryID.Items.Count > 0)
            {
                if (ddlCountryID.SelectedValue == "0")
                {
                    hREmployeeAddressInfoEntity.CountryID = null;
                }
                else
                {
                    hREmployeeAddressInfoEntity.CountryID = Int64.Parse(ddlCountryID.SelectedValue);
                }
            }

            if (ddlCityID.Items.Count > 0)
            {
                if (ddlCityID.SelectedValue == "0")
                {
                    hREmployeeAddressInfoEntity.CityID = null;
                }
                else
                {
                    hREmployeeAddressInfoEntity.CityID = Int64.Parse(ddlCityID.SelectedValue);
                }
            }

            hREmployeeAddressInfoEntity.AddressLine1 = txtAddressLine1.Text.Trim();
            hREmployeeAddressInfoEntity.AddressLine2 = txtAddressLine2.Text.Trim();
            hREmployeeAddressInfoEntity.ZipCode      = txtZipCode.Text.Trim();

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

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

                Database.AddInParameter(cmd, "@EmployeeAddressInfoID", DbType.Int64, hREmployeeAddressInfoEntity.EmployeeAddressInfoID);
                Database.AddInParameter(cmd, "@EmployeeAddressTypeID", DbType.Int64, hREmployeeAddressInfoEntity.EmployeeAddressTypeID);
                Database.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeAddressInfoEntity.EmployeeID);
                Database.AddInParameter(cmd, "@CountryID", DbType.Int64, hREmployeeAddressInfoEntity.CountryID);
                Database.AddInParameter(cmd, "@CityID", DbType.Int64, hREmployeeAddressInfoEntity.CityID);
                Database.AddInParameter(cmd, "@AddressLine1", DbType.String, hREmployeeAddressInfoEntity.AddressLine1);
                Database.AddInParameter(cmd, "@AddressLine2", DbType.String, hREmployeeAddressInfoEntity.AddressLine2);
                Database.AddInParameter(cmd, "@ZipCode", DbType.String, hREmployeeAddressInfoEntity.ZipCode);

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

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

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

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

            return(returnCode);
        }
Пример #8
0
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _EmployeeAddressInfoID       = 0;
     _HREmployeeAddressInfoEntity = new HREmployeeAddressInfoEntity();
     PrepareInitialView();
 }
 Int64 IHREmployeeAddressInfoFacade.Delete(HREmployeeAddressInfoEntity hREmployeeAddressInfoEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateHREmployeeAddressInfoDataAccess().Delete(hREmployeeAddressInfoEntity, filterExpression, option, reqTran));
 }
 Int64 IHREmployeeAddressInfoFacade.Add(HREmployeeAddressInfoEntity hREmployeeAddressInfoEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateHREmployeeAddressInfoDataAccess().Add(hREmployeeAddressInfoEntity, option, reqTran));
 }