private void PrepareEditView()
        {
            HREmployeeDrivingLicenseInformationEntity hREmployeeDrivingLicenseInformationEntity = CurrentHREmployeeDrivingLicenseInformationEntity;


            if (!hREmployeeDrivingLicenseInformationEntity.IsNew)
            {
                if (ddlDrivingLicenseCategoryID.Items.Count > 0 && hREmployeeDrivingLicenseInformationEntity.DrivingLicenseCategoryID != null)
                {
                    ddlDrivingLicenseCategoryID.SelectedValue = hREmployeeDrivingLicenseInformationEntity.DrivingLicenseCategoryID.ToString();
                }

                txtLicenseNumber.Text = hREmployeeDrivingLicenseInformationEntity.LicenseNumber.ToString();
                if (ddlCountryID.Items.Count > 0 && hREmployeeDrivingLicenseInformationEntity.CountryID != null)
                {
                    ddlCountryID.SelectedValue = hREmployeeDrivingLicenseInformationEntity.CountryID.ToString();
                }

                txtCityName.Text            = hREmployeeDrivingLicenseInformationEntity.CityName.ToString();
                txtIssuedDate.Text          = hREmployeeDrivingLicenseInformationEntity.IssuedDate.ToStringDefault();
                txtExpiryDate.Text          = hREmployeeDrivingLicenseInformationEntity.ExpiryDate.ToStringDefault();
                txtRenewDate.Text           = hREmployeeDrivingLicenseInformationEntity.RenewDate.ToStringDefault();
                txtIssueAuthority.Text      = hREmployeeDrivingLicenseInformationEntity.IssueAuthority.ToString();
                txtRemarks.Text             = hREmployeeDrivingLicenseInformationEntity.Remarks.ToString();
                chkIsDefaultLicense.Checked = hREmployeeDrivingLicenseInformationEntity.IsDefaultLicense;

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

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

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

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

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

            Database db = DatabaseFactory.CreateDatabase();

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

                db.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeDrivingLicenseInformationEntity.EmployeeID);
                db.AddInParameter(cmd, "@DrivingLicenseCategoryID", DbType.Int64, hREmployeeDrivingLicenseInformationEntity.DrivingLicenseCategoryID);
                db.AddInParameter(cmd, "@LicenseNumber", DbType.String, hREmployeeDrivingLicenseInformationEntity.LicenseNumber);
                db.AddInParameter(cmd, "@CountryID", DbType.Int64, hREmployeeDrivingLicenseInformationEntity.CountryID);
                db.AddInParameter(cmd, "@CityName", DbType.String, hREmployeeDrivingLicenseInformationEntity.CityName);
                db.AddInParameter(cmd, "@IssuedDate", DbType.DateTime, hREmployeeDrivingLicenseInformationEntity.IssuedDate);
                db.AddInParameter(cmd, "@ExpiryDate", DbType.DateTime, hREmployeeDrivingLicenseInformationEntity.ExpiryDate);
                db.AddInParameter(cmd, "@RenewDate", DbType.DateTime, hREmployeeDrivingLicenseInformationEntity.RenewDate);
                db.AddInParameter(cmd, "@IsDefaultLicense", DbType.Boolean, hREmployeeDrivingLicenseInformationEntity.IsDefaultLicense);
                db.AddInParameter(cmd, "@IssueAuthority", DbType.String, hREmployeeDrivingLicenseInformationEntity.IssueAuthority);
                db.AddInParameter(cmd, "@Remarks", DbType.String, hREmployeeDrivingLicenseInformationEntity.Remarks);

                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);
        }
        private void SaveHREmployeeDrivingLicenseInformationEntity()
        {
            if (IsValid)
            {
                try
                {
                    HREmployeeDrivingLicenseInformationEntity hREmployeeDrivingLicenseInformationEntity = BuildHREmployeeDrivingLicenseInformationEntity();

                    Int64 result = -1;

                    if (hREmployeeDrivingLicenseInformationEntity.IsNew)
                    {
                        result = FCCHREmployeeDrivingLicenseInformation.GetFacadeCreate().Add(hREmployeeDrivingLicenseInformationEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeDrivingLicenseInformationEntity.FLD_NAME_EmployeeDrivingLicenseInformationID, hREmployeeDrivingLicenseInformationEntity.EmployeeDrivingLicenseInformationID.ToString(), SQLMatchType.Equal);
                        result = FCCHREmployeeDrivingLicenseInformation.GetFacadeCreate().Update(hREmployeeDrivingLicenseInformationEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _EmployeeDrivingLicenseInformationID       = 0;
                        _HREmployeeDrivingLicenseInformationEntity = new HREmployeeDrivingLicenseInformationEntity();
                        PrepareInitialView();
                        BindHREmployeeDrivingLicenseInformationList();

                        if (hREmployeeDrivingLicenseInformationEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Employee Driving License Information Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Employee Driving License Information Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (hREmployeeDrivingLicenseInformationEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Employee Driving License Information Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Employee Driving License Information Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
        protected void lvHREmployeeDrivingLicenseInformation_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 EmployeeDrivingLicenseInformationID;

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

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

                    PrepareEditView();

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

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeDrivingLicenseInformationEntity.FLD_NAME_EmployeeDrivingLicenseInformationID, EmployeeDrivingLicenseInformationID.ToString(), SQLMatchType.Equal);

                        HREmployeeDrivingLicenseInformationEntity hREmployeeDrivingLicenseInformationEntity = new HREmployeeDrivingLicenseInformationEntity();


                        result = FCCHREmployeeDrivingLicenseInformation.GetFacadeCreate().Delete(hREmployeeDrivingLicenseInformationEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _EmployeeDrivingLicenseInformationID       = 0;
                            _HREmployeeDrivingLicenseInformationEntity = new HREmployeeDrivingLicenseInformationEntity();
                            PrepareInitialView();
                            BindHREmployeeDrivingLicenseInformationList();

                            MiscUtil.ShowMessage(lblMessage, "Employee Driving License Information has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Employee Driving License Information.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
        private Int64 DeleteTran(HREmployeeDrivingLicenseInformationEntity hREmployeeDrivingLicenseInformationEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.HREmployeeDrivingLicenseInformation_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 Update(HREmployeeDrivingLicenseInformationEntity hREmployeeDrivingLicenseInformationEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.HREmployeeDrivingLicenseInformation_SET";

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

                Database.AddInParameter(cmd, "@EmployeeDrivingLicenseInformationID", DbType.Int64, hREmployeeDrivingLicenseInformationEntity.EmployeeDrivingLicenseInformationID);
                Database.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeDrivingLicenseInformationEntity.EmployeeID);
                Database.AddInParameter(cmd, "@DrivingLicenseCategoryID", DbType.Int64, hREmployeeDrivingLicenseInformationEntity.DrivingLicenseCategoryID);
                Database.AddInParameter(cmd, "@LicenseNumber", DbType.String, hREmployeeDrivingLicenseInformationEntity.LicenseNumber);
                Database.AddInParameter(cmd, "@CountryID", DbType.Int64, hREmployeeDrivingLicenseInformationEntity.CountryID);
                Database.AddInParameter(cmd, "@CityName", DbType.String, hREmployeeDrivingLicenseInformationEntity.CityName);
                Database.AddInParameter(cmd, "@IssuedDate", DbType.DateTime, hREmployeeDrivingLicenseInformationEntity.IssuedDate);
                Database.AddInParameter(cmd, "@ExpiryDate", DbType.DateTime, hREmployeeDrivingLicenseInformationEntity.ExpiryDate);
                Database.AddInParameter(cmd, "@RenewDate", DbType.DateTime, hREmployeeDrivingLicenseInformationEntity.RenewDate);
                Database.AddInParameter(cmd, "@IsDefaultLicense", DbType.Boolean, hREmployeeDrivingLicenseInformationEntity.IsDefaultLicense);
                Database.AddInParameter(cmd, "@IssueAuthority", DbType.String, hREmployeeDrivingLicenseInformationEntity.IssueAuthority);
                Database.AddInParameter(cmd, "@Remarks", DbType.String, hREmployeeDrivingLicenseInformationEntity.Remarks);

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

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

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

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

            return(returnCode);
        }
        private Int64 Delete(HREmployeeDrivingLicenseInformationEntity hREmployeeDrivingLicenseInformationEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.HREmployeeDrivingLicenseInformation_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("HREmployeeDrivingLicenseInformationEntity already exists. Please specify another HREmployeeDrivingLicenseInformationEntity.");
                    }

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

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

            return(returnCode);
        }
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _EmployeeDrivingLicenseInformationID       = 0;
     _HREmployeeDrivingLicenseInformationEntity = new HREmployeeDrivingLicenseInformationEntity();
     PrepareInitialView();
 }
        private HREmployeeDrivingLicenseInformationEntity BuildHREmployeeDrivingLicenseInformationEntity()
        {
            HREmployeeDrivingLicenseInformationEntity hREmployeeDrivingLicenseInformationEntity = CurrentHREmployeeDrivingLicenseInformationEntity;


            hREmployeeDrivingLicenseInformationEntity.EmployeeID = OverviewEmployeeID;

            if (ddlDrivingLicenseCategoryID.Items.Count > 0)
            {
                if (ddlDrivingLicenseCategoryID.SelectedValue == "0")
                {
                }
                else
                {
                    hREmployeeDrivingLicenseInformationEntity.DrivingLicenseCategoryID = Int64.Parse(ddlDrivingLicenseCategoryID.SelectedValue);
                }
            }

            hREmployeeDrivingLicenseInformationEntity.LicenseNumber = txtLicenseNumber.Text.Trim();
            if (ddlCountryID.Items.Count > 0)
            {
                if (ddlCountryID.SelectedValue == "0")
                {
                }
                else
                {
                    hREmployeeDrivingLicenseInformationEntity.CountryID = Int64.Parse(ddlCountryID.SelectedValue);
                }
            }

            hREmployeeDrivingLicenseInformationEntity.CityName = txtCityName.Text.Trim();
            if (txtIssuedDate.Text.Trim().IsNotNullOrEmpty())
            {
                hREmployeeDrivingLicenseInformationEntity.IssuedDate = MiscUtil.ParseToDateTime(txtIssuedDate.Text);
            }

            if (txtExpiryDate.Text.Trim().IsNotNullOrEmpty())
            {
                hREmployeeDrivingLicenseInformationEntity.ExpiryDate = MiscUtil.ParseToDateTime(txtExpiryDate.Text);
            }
            else
            {
                hREmployeeDrivingLicenseInformationEntity.ExpiryDate = null;
            }

            if (txtRenewDate.Text.Trim().IsNotNullOrEmpty())
            {
                hREmployeeDrivingLicenseInformationEntity.RenewDate = MiscUtil.ParseToDateTime(txtRenewDate.Text);
            }
            else
            {
                hREmployeeDrivingLicenseInformationEntity.RenewDate = null;
            }

            if (txtIssueAuthority.Text.Trim().IsNotNullOrEmpty())
            {
                hREmployeeDrivingLicenseInformationEntity.IssueAuthority = txtIssueAuthority.Text.Trim();
            }
            else
            {
                hREmployeeDrivingLicenseInformationEntity.IssueAuthority = null;
            }

            if (txtRemarks.Text.Trim().IsNotNullOrEmpty())
            {
                hREmployeeDrivingLicenseInformationEntity.Remarks = txtRemarks.Text.Trim();
            }
            else
            {
                hREmployeeDrivingLicenseInformationEntity.Remarks = null;
            }

            hREmployeeDrivingLicenseInformationEntity.IsDefaultLicense = chkIsDefaultLicense.Checked;


            return(hREmployeeDrivingLicenseInformationEntity);
        }
Ejemplo n.º 11
0
 Int64 IHREmployeeDrivingLicenseInformationFacade.Delete(HREmployeeDrivingLicenseInformationEntity hREmployeeDrivingLicenseInformationEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateHREmployeeDrivingLicenseInformationDataAccess().Delete(hREmployeeDrivingLicenseInformationEntity, filterExpression, option, reqTran));
 }
Ejemplo n.º 12
0
 Int64 IHREmployeeDrivingLicenseInformationFacade.Add(HREmployeeDrivingLicenseInformationEntity hREmployeeDrivingLicenseInformationEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateHREmployeeDrivingLicenseInformationDataAccess().Add(hREmployeeDrivingLicenseInformationEntity, option, reqTran));
 }