Int64 IHREmployeeContactInfoDataAccess.Add(HREmployeeContactInfoEntity hREmployeeContactInfoEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private Int64 UpdateTran(HREmployeeContactInfoEntity hREmployeeContactInfoEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.HREmployeeContactInfo_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, "@EmployeeContactInfoID", DbType.Int64, hREmployeeContactInfoEntity.EmployeeContactInfoID);
                db.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeContactInfoEntity.EmployeeID);
                db.AddInParameter(cmd, "@EmployeeContactTypeID", DbType.Int64, hREmployeeContactInfoEntity.EmployeeContactTypeID);
                db.AddInParameter(cmd, "@ContactInfo", DbType.String, hREmployeeContactInfoEntity.ContactInfo);
                db.AddInParameter(cmd, "@Description", DbType.String, hREmployeeContactInfoEntity.Description);
                db.AddInParameter(cmd, "@Remarks", DbType.String, hREmployeeContactInfoEntity.Remarks);

                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);
        }
示例#3
0
        private void SaveHREmployeeContactInfoEntity()
        {
            if (IsValid)
            {
                try
                {
                    HREmployeeContactInfoEntity hREmployeeContactInfoEntity = BuildHREmployeeContactInfoEntity();

                    Int64 result = -1;

                    if (hREmployeeContactInfoEntity.IsNew)
                    {
                        result = FCCHREmployeeContactInfo.GetFacadeCreate().Add(hREmployeeContactInfoEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeContactInfoEntity.FLD_NAME_EmployeeContactInfoID, hREmployeeContactInfoEntity.EmployeeContactInfoID.ToString(), SQLMatchType.Equal);
                        result = FCCHREmployeeContactInfo.GetFacadeCreate().Update(hREmployeeContactInfoEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _EmployeeContactInfoID       = 0;
                        _HREmployeeContactInfoEntity = new HREmployeeContactInfoEntity();
                        PrepareInitialView();
                        BindHREmployeeContactInfoList();

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

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

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

                    PrepareEditView();

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

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeContactInfoEntity.FLD_NAME_EmployeeContactInfoID, EmployeeContactInfoID.ToString(), SQLMatchType.Equal);

                        HREmployeeContactInfoEntity hREmployeeContactInfoEntity = new HREmployeeContactInfoEntity();


                        result = FCCHREmployeeContactInfo.GetFacadeCreate().Delete(hREmployeeContactInfoEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _EmployeeContactInfoID       = 0;
                            _HREmployeeContactInfoEntity = new HREmployeeContactInfoEntity();
                            PrepareInitialView();
                            BindHREmployeeContactInfoList();

                            MiscUtil.ShowMessage(lblMessage, "Employee Contact Info has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Employee Contact Info.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
        private Int64 Update(HREmployeeContactInfoEntity hREmployeeContactInfoEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.HREmployeeContactInfo_SET";

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

                Database.AddInParameter(cmd, "@EmployeeContactInfoID", DbType.Int64, hREmployeeContactInfoEntity.EmployeeContactInfoID);
                Database.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeContactInfoEntity.EmployeeID);
                Database.AddInParameter(cmd, "@EmployeeContactTypeID", DbType.Int64, hREmployeeContactInfoEntity.EmployeeContactTypeID);
                Database.AddInParameter(cmd, "@ContactInfo", DbType.String, hREmployeeContactInfoEntity.ContactInfo);
                Database.AddInParameter(cmd, "@Description", DbType.String, hREmployeeContactInfoEntity.Description);
                Database.AddInParameter(cmd, "@Remarks", DbType.String, hREmployeeContactInfoEntity.Remarks);

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

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

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

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

            return(returnCode);
        }
示例#6
0
        private void PrepareEditView()
        {
            HREmployeeContactInfoEntity hREmployeeContactInfoEntity = CurrentHREmployeeContactInfoEntity;


            if (!hREmployeeContactInfoEntity.IsNew)
            {
                if (ddlEmployeeContactTypeID.Items.Count > 0 && hREmployeeContactInfoEntity.EmployeeContactTypeID != null)
                {
                    ddlEmployeeContactTypeID.SelectedValue = hREmployeeContactInfoEntity.EmployeeContactTypeID.ToString();
                }

                txtContactInfo.Text = hREmployeeContactInfoEntity.ContactInfo.ToString();
                txtDescription.Text = hREmployeeContactInfoEntity.Description.ToString();
                txtRemarks.Text     = hREmployeeContactInfoEntity.Remarks.ToString();

                btnSubmit.Text    = "Update";
                btnAddNew.Visible = true;
            }
        }
示例#7
0
        private HREmployeeContactInfoEntity BuildHREmployeeContactInfoEntity()
        {
            HREmployeeContactInfoEntity hREmployeeContactInfoEntity = CurrentHREmployeeContactInfoEntity;


            hREmployeeContactInfoEntity.EmployeeID = OverviewEmployeeID;

            if (ddlEmployeeContactTypeID.Items.Count > 0)
            {
                if (ddlEmployeeContactTypeID.SelectedValue == "0")
                {
                }
                else
                {
                    hREmployeeContactInfoEntity.EmployeeContactTypeID = Int64.Parse(ddlEmployeeContactTypeID.SelectedValue);
                }
            }

            hREmployeeContactInfoEntity.ContactInfo = txtContactInfo.Text.Trim();
            hREmployeeContactInfoEntity.Description = txtDescription.Text.Trim();
            hREmployeeContactInfoEntity.Remarks     = txtRemarks.Text.Trim();

            return(hREmployeeContactInfoEntity);
        }
示例#8
0
 Int64 IHREmployeeContactInfoFacade.Delete(HREmployeeContactInfoEntity hREmployeeContactInfoEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateHREmployeeContactInfoDataAccess().Delete(hREmployeeContactInfoEntity, filterExpression, option, reqTran));
 }
示例#9
0
 Int64 IHREmployeeContactInfoFacade.Add(HREmployeeContactInfoEntity hREmployeeContactInfoEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateHREmployeeContactInfoDataAccess().Add(hREmployeeContactInfoEntity, option, reqTran));
 }
示例#10
0
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _EmployeeContactInfoID       = 0;
     _HREmployeeContactInfoEntity = new HREmployeeContactInfoEntity();
     PrepareInitialView();
 }