Int64 IMDApprovalRuleDesignationMapDataAccess.Add(MDApprovalRuleDesignationMapEntity mDApprovalRuleDesignationMapEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        private void SaveMDApprovalRuleDesignationMapEntity()
        {
            if (IsValid)
            {
                try
                {
                    MDApprovalRuleDesignationMapEntity mDApprovalRuleDesignationMapEntity = BuildMDApprovalRuleDesignationMapEntity();

                    Int64 result = -1;

                    if (mDApprovalRuleDesignationMapEntity.IsNew)
                    {
                        result = FCCMDApprovalRuleDesignationMap.GetFacadeCreate().Add(mDApprovalRuleDesignationMapEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDApprovalRuleDesignationMapEntity.FLD_NAME_ApprovalRuleDesignationMapID, mDApprovalRuleDesignationMapEntity.ApprovalRuleDesignationMapID.ToString(), SQLMatchType.Equal);
                        result = FCCMDApprovalRuleDesignationMap.GetFacadeCreate().Update(mDApprovalRuleDesignationMapEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _ApprovalRuleDesignationMapID       = 0;
                        _MDApprovalRuleDesignationMapEntity = new MDApprovalRuleDesignationMapEntity();
                        PrepareInitialView();
                        BindMDApprovalRuleDesignationMapList();

                        if (mDApprovalRuleDesignationMapEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Approval Rule Designation Map Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Approval Rule Designation Map Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (mDApprovalRuleDesignationMapEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Approval Rule Designation Map Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Approval Rule Designation Map Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
        private Int64 UpdateTran(MDApprovalRuleDesignationMapEntity mDApprovalRuleDesignationMapEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.MDApprovalRuleDesignationMap_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, "@ApprovalRuleDesignationMapID", DbType.Int64, mDApprovalRuleDesignationMapEntity.ApprovalRuleDesignationMapID);
                db.AddInParameter(cmd, "@ApprovalRuleID", DbType.Int64, mDApprovalRuleDesignationMapEntity.ApprovalRuleID);
                db.AddInParameter(cmd, "@DesignationID", DbType.Int64, mDApprovalRuleDesignationMapEntity.DesignationID);
                db.AddInParameter(cmd, "@SequeenceNo", DbType.Int32, mDApprovalRuleDesignationMapEntity.SequeenceNo);

                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);
        }
Exemplo n.º 4
0
        protected void lvMDApprovalRuleDesignationMap_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 ApprovalRuleDesignationMapID;

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

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

                    PrepareEditView();

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

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(MDApprovalRuleDesignationMapEntity.FLD_NAME_ApprovalRuleDesignationMapID, ApprovalRuleDesignationMapID.ToString(), SQLMatchType.Equal);

                        MDApprovalRuleDesignationMapEntity mDApprovalRuleDesignationMapEntity = new MDApprovalRuleDesignationMapEntity();


                        result = FCCMDApprovalRuleDesignationMap.GetFacadeCreate().Delete(mDApprovalRuleDesignationMapEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _ApprovalRuleDesignationMapID       = 0;
                            _MDApprovalRuleDesignationMapEntity = new MDApprovalRuleDesignationMapEntity();
                            PrepareInitialView();
                            BindMDApprovalRuleDesignationMapList();

                            MiscUtil.ShowMessage(lblMessage, "Approval Rule Designation Map has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Approval Rule Designation Map.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
Exemplo n.º 5
0
        private MDApprovalRuleDesignationMapEntity BuildMDApprovalRuleDesignationMapEntity()
        {
            MDApprovalRuleDesignationMapEntity mDApprovalRuleDesignationMapEntity = CurrentMDApprovalRuleDesignationMapEntity;

            if (ddlDesignationID.Items.Count > 0)
            {
                if (ddlDesignationID.SelectedValue == "0")
                {
                }
                else
                {
                    mDApprovalRuleDesignationMapEntity.DesignationID = Int64.Parse(ddlDesignationID.SelectedValue);
                }
            }

            if (mDApprovalRuleDesignationMapEntity.IsNew)
            {
                mDApprovalRuleDesignationMapEntity.ApprovalRuleID = CurrentApprovalRuleID;


                #region Build XML String

                StringBuilder xmlStr    = new StringBuilder();
                String        subXmlStr = String.Empty;
                xmlStr.Append("<m>");

                subXmlStr = subXmlStr + "<i><a>" + CurrentApprovalRuleID + "</a></i>";

                xmlStr.Append(subXmlStr.ToString());
                xmlStr.Append("</m>");

                #endregion

                DataTable dt = FCCCommonDA_SP.GetFacadeCreate().GetDT(xmlStr.ToString(), CommonConstants.NEXT_SEQUENCENO_APPROVALRULE_DESIGNATIONMAP);

                Int32 nextSequenceID = 999;

                if (dt.Rows.Count > 0)
                {
                    nextSequenceID = (Int32)dt.Rows[0]["MaxID"];
                }

                mDApprovalRuleDesignationMapEntity.SequeenceNo = nextSequenceID;
            }


            return(mDApprovalRuleDesignationMapEntity);
        }
Exemplo n.º 6
0
        private void PrepareEditView()
        {
            MDApprovalRuleDesignationMapEntity mDApprovalRuleDesignationMapEntity = CurrentMDApprovalRuleDesignationMapEntity;


            if (!mDApprovalRuleDesignationMapEntity.IsNew)
            {
                if (ddlDesignationID.Items.Count > 0 && mDApprovalRuleDesignationMapEntity.DesignationID != null)
                {
                    ddlDesignationID.SelectedValue = mDApprovalRuleDesignationMapEntity.DesignationID.ToString();
                }

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

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

                Database.AddInParameter(cmd, "@ApprovalRuleDesignationMapID", DbType.Int64, mDApprovalRuleDesignationMapEntity.ApprovalRuleDesignationMapID);
                Database.AddInParameter(cmd, "@ApprovalRuleID", DbType.Int64, mDApprovalRuleDesignationMapEntity.ApprovalRuleID);
                Database.AddInParameter(cmd, "@DesignationID", DbType.Int64, mDApprovalRuleDesignationMapEntity.DesignationID);
                Database.AddInParameter(cmd, "@SequeenceNo", DbType.Int32, mDApprovalRuleDesignationMapEntity.SequeenceNo);

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

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

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

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

            return(returnCode);
        }
Exemplo n.º 8
0
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _ApprovalRuleDesignationMapID       = 0;
     _MDApprovalRuleDesignationMapEntity = new MDApprovalRuleDesignationMapEntity();
     PrepareInitialView();
 }
Exemplo n.º 9
0
 Int64 IMDApprovalRuleDesignationMapFacade.Delete(MDApprovalRuleDesignationMapEntity mDApprovalRuleDesignationMapEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateMDApprovalRuleDesignationMapDataAccess().Delete(mDApprovalRuleDesignationMapEntity, filterExpression, option, reqTran));
 }
Exemplo n.º 10
0
 Int64 IMDApprovalRuleDesignationMapFacade.Add(MDApprovalRuleDesignationMapEntity mDApprovalRuleDesignationMapEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateMDApprovalRuleDesignationMapDataAccess().Add(mDApprovalRuleDesignationMapEntity, option, reqTran));
 }