Пример #1
0
        public virtual bool DeleteModelByModel(User.UserModel user, TBase_Model model, ref string strError)
        {
            try
            {
                int bResult = 0;
                int iOut    = 0;

                OracleParameter[] param = new OracleParameter[] {
                    new OracleParameter("@bResult", bResult),
                    new OracleParameter("@ErrorMsg", OracleDbType.NVarchar2, 100),
                    new OracleParameter("@ID", OracleDBHelper.ToDBValue(model.ID)),

                    new OracleParameter("@Deleter", OracleDBHelper.ToDBValue(user.UserNo))
                };

                param[0].Direction = System.Data.ParameterDirection.Output;
                param[1].Direction = System.Data.ParameterDirection.Output;

                int i = OracleDBHelper.RunProcedure(this.GetDeleteProcedureName(), param, out iOut);
                strError = param[1].Value.ToString();
                if (i == -1)//(int)param[0].Value == -1
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #2
0
        public bool TransferModelByProcedure(User.UserModel user, ref TBase_Model model, string ProcedureName, OracleParameter[] param, ref string strError)
        {
            try
            {
                bool succ = false;
                //int iRows = 0;
                int iOut = 0;

                //把creater、createTime、modifyer等信息填到model中去.
                AddModelOperatorInfo(user, ref model);

                int i = OracleDBHelper.RunProcedure(ProcedureName, param, out iOut);
                if ((int)param[0].Value == -1)
                {
                    strError = param[1].Value.ToString();
                }
                else
                {
                    succ = true;
                    int modelID = (int)param[2].Value;
                    //model.ID = (int)param[2].Value;
                    model = GetModelByID(modelID);
                    if (model == null)
                    {
                        throw new Exception("GetModelByID(modelID)出错,没有找到相符的记录,可能是视图有错误!");
                    }
                }
                return(succ);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #3
0
        /// <summary>
        /// 修改状态
        /// </summary>
        /// <param name="user"></param>
        /// <param name="model"></param>
        /// <param name="NewStatus"></param>
        /// <param name="strError"></param>
        /// <returns></returns>
        public bool UpdateModelStatus(User.UserModel user, ref TBase_Model model, int NewStatus, ref string strError, bool NeedReturnModel)
        {
            try
            {
                int iRows = 0;
                int iOut  = 0;

                OracleParameter[] param = new OracleParameter[] {
                    new OracleParameter("@Rows", iRows),
                    new OracleParameter("@ErrorMsg", OracleDbType.NVarchar2, 100),
                    new OracleParameter("@ID", OracleDBHelper.ToDBValue(GetUpdateModelStatusID(user, model, NewStatus))),

                    new OracleParameter("@NewStatus", OracleDBHelper.ToDBValue(NewStatus)),
                    new OracleParameter("@Auditor", OracleDBHelper.ToDBValue(user.UserNo)),
                    new OracleParameter("@AuditorTime", OracleDBHelper.ToDBValue(DateTime.Now)),
                    new OracleParameter("@TerminateReasonID", OracleDBHelper.ToDBValue(model.TerminateReasonID)),
                    new OracleParameter("@TerminateReason", OracleDBHelper.ToDBValue(model.TerminateReason)),
                    new OracleParameter("@RowVersion", OracleDBHelper.ToDBValue(DateTime.Now))
                };

                param[0].Direction = System.Data.ParameterDirection.Output;
                param[1].Direction = System.Data.ParameterDirection.Output;

                int i = OracleDBHelper.RunProcedure(this.GetUpdateStatusProcedureName(), param, out iOut);
                strError = param[1].Value.ToString();
                if ((int)param[0].Value == -1)
                {
                    return(false);
                }
                else
                {
                    if (NeedReturnModel)
                    {
                        model = GetModelByID(model.ID);
                        if (model == null)
                        {
                            throw new Exception("GetModelByID(modelID)出错,没有找到相符的记录,可能是视图有错误!");
                        }
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #4
0
        public static int CheckRepeatValue(string TableName, string ColumnName, object Value, int ID, string IDColumnName = "ID")
        {
            try
            {
                if (Value == null)
                {
                    return(0);
                }
                //if (string.IsNullOrEmpty(value.ToString())) return 0;

                int    iOut = 0;
                string strError;
                int    RepeatNum = 0;

                OracleParameter[] param = new OracleParameter[] {
                    new OracleParameter("@ErrorMsg", OracleDbType.NVarchar2, 100),
                    new OracleParameter("@RepeatNum", System.Data.SqlDbType.Int),
                    new OracleParameter("@TableName", OracleDBHelper.ToDBValue(TableName)),
                    new OracleParameter("@ColumnName", OracleDBHelper.ToDBValue(ColumnName)),
                    new OracleParameter("@Value", OracleDBHelper.ToDBValue(Value)),
                    new OracleParameter("@IDColumnName", OracleDBHelper.ToDBValue(IDColumnName)),
                    new OracleParameter("@ID", OracleDBHelper.ToDBValue(ID)),
                };

                param[0].Direction = System.Data.ParameterDirection.Output;
                param[1].Direction = System.Data.ParameterDirection.Output;

                int i = OracleDBHelper.RunProcedure("P_Check_RepeatValue", param, out iOut);
                strError  = param[0].Value.ToString();
                RepeatNum = Convert.ToInt32(param[1].Value);
                return(RepeatNum);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }