Ejemplo n.º 1
0
        private void SaveMDSalaryDeducationCategoryEntity()
        {
            if (IsValid)
            {
                try
                {
                    MDSalaryDeducationCategoryEntity mDSalaryDeducationCategoryEntity = BuildMDSalaryDeducationCategoryEntity();

                    Int64 result = -1;

                    if (mDSalaryDeducationCategoryEntity.IsNew)
                    {
                        result = FCCMDSalaryDeducationCategory.GetFacadeCreate().Add(mDSalaryDeducationCategoryEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDSalaryDeducationCategoryEntity.FLD_NAME_SalaryDeducationCategoryID, mDSalaryDeducationCategoryEntity.SalaryDeducationCategoryID.ToString(), SQLMatchType.Equal);
                        result = FCCMDSalaryDeducationCategory.GetFacadeCreate().Update(mDSalaryDeducationCategoryEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _SalaryDeducationCategoryID       = 0;
                        _MDSalaryDeducationCategoryEntity = new MDSalaryDeducationCategoryEntity();
                        PrepareInitialView();
                        BindMDSalaryDeducationCategoryList();

                        if (mDSalaryDeducationCategoryEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Salary Deducation Category Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Salary Deducation Category Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (mDSalaryDeducationCategoryEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Salary Deducation Category Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Salary Deducation Category Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
        private Int64 UpdateTran(MDSalaryDeducationCategoryEntity mDSalaryDeducationCategoryEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.MDSalaryDeducationCategory_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, "@SalaryDeducationCategoryID", DbType.Int64, mDSalaryDeducationCategoryEntity.SalaryDeducationCategoryID);
                db.AddInParameter(cmd, "@Name", DbType.String, mDSalaryDeducationCategoryEntity.Name);
                db.AddInParameter(cmd, "@Description", DbType.String, mDSalaryDeducationCategoryEntity.Description);
                db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, mDSalaryDeducationCategoryEntity.IsRemoved);

                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);
        }
Ejemplo n.º 3
0
        protected void lvMDSalaryDeducationCategory_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 SalaryDeducationCategoryID;

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

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

                    PrepareEditView();

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

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(MDSalaryDeducationCategoryEntity.FLD_NAME_SalaryDeducationCategoryID, SalaryDeducationCategoryID.ToString(), SQLMatchType.Equal);

                        MDSalaryDeducationCategoryEntity mDSalaryDeducationCategoryEntity = new MDSalaryDeducationCategoryEntity();


                        result = FCCMDSalaryDeducationCategory.GetFacadeCreate().Delete(mDSalaryDeducationCategoryEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _SalaryDeducationCategoryID       = 0;
                            _MDSalaryDeducationCategoryEntity = new MDSalaryDeducationCategoryEntity();
                            PrepareInitialView();
                            BindMDSalaryDeducationCategoryList();

                            MiscUtil.ShowMessage(lblMessage, "Salary Deducation Category has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Salary Deducation Category.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private MDSalaryDeducationCategoryEntity BuildMDSalaryDeducationCategoryEntity()
        {
            MDSalaryDeducationCategoryEntity mDSalaryDeducationCategoryEntity = CurrentMDSalaryDeducationCategoryEntity;

            //if (!txtSalaryDeducationCategoryID.Text.Trim().IsNullOrEmpty())
            //{
            //    mDSalaryDeducationCategoryEntity.SalaryDeducationCategoryID = Int64.Parse(txtSalaryDeducationCategoryID.Text.Trim());
            //}

            mDSalaryDeducationCategoryEntity.Name        = txtName.Text.Trim();
            mDSalaryDeducationCategoryEntity.Description = txtDescription.Text.Trim();
            mDSalaryDeducationCategoryEntity.IsRemoved   = chkIsRemoved.Checked;


            return(mDSalaryDeducationCategoryEntity);
        }
Ejemplo n.º 5
0
        private void PrepareEditView()
        {
            MDSalaryDeducationCategoryEntity mDSalaryDeducationCategoryEntity = CurrentMDSalaryDeducationCategoryEntity;


            if (!mDSalaryDeducationCategoryEntity.IsNew)
            {
                //txtSalaryDeducationCategoryID.Text = mDSalaryDeducationCategoryEntity.SalaryDeducationCategoryID.ToString();
                txtName.Text         = mDSalaryDeducationCategoryEntity.Name.ToString();
                txtDescription.Text  = mDSalaryDeducationCategoryEntity.Description.ToString();
                chkIsRemoved.Checked = mDSalaryDeducationCategoryEntity.IsRemoved;

                btnSubmit.Text    = "Update";
                btnAddNew.Visible = true;
            }
        }
        private Int64 Update(MDSalaryDeducationCategoryEntity mDSalaryDeducationCategoryEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.MDSalaryDeducationCategory_SET";

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

                Database.AddInParameter(cmd, "@SalaryDeducationCategoryID", DbType.Int64, mDSalaryDeducationCategoryEntity.SalaryDeducationCategoryID);
                Database.AddInParameter(cmd, "@Name", DbType.String, mDSalaryDeducationCategoryEntity.Name);
                Database.AddInParameter(cmd, "@Description", DbType.String, mDSalaryDeducationCategoryEntity.Description);
                Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, mDSalaryDeducationCategoryEntity.IsRemoved);

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

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

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

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

            return(returnCode);
        }
 Int64 IMDSalaryDeducationCategoryFacade.Delete(MDSalaryDeducationCategoryEntity mDSalaryDeducationCategoryEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateMDSalaryDeducationCategoryDataAccess().Delete(mDSalaryDeducationCategoryEntity, filterExpression, option, reqTran));
 }
 Int64 IMDSalaryDeducationCategoryFacade.Add(MDSalaryDeducationCategoryEntity mDSalaryDeducationCategoryEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateMDSalaryDeducationCategoryDataAccess().Add(mDSalaryDeducationCategoryEntity, option, reqTran));
 }
Ejemplo n.º 9
0
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _SalaryDeducationCategoryID       = 0;
     _MDSalaryDeducationCategoryEntity = new MDSalaryDeducationCategoryEntity();
     PrepareInitialView();
 }