Beispiel #1
0
        public IList <T_truckType> ListMaker(string tempsql, SqlParameter[] sps)
        {
            DataTable           dt   = returnDt(tempsql, sps, false);
            IList <T_truckType> list = new List <T_truckType>();

            foreach (DataRow dr in dt.Rows)
            {
                T_truckType model = new T_truckType();
                model.typeCode   = dr["typeCode"].ToString();
                model.NOTE5      = dr["NOTE5"].ToString();
                model.typeName   = dr["typeName"].ToString();
                model.parentCode = dr["parentCode"].ToString();
                model.status     = dr["status"].ToString();
                model.IsLastNode = dr["IsLastNode"].ToString();
                float fHigherPerPoint = 0;
                float.TryParse(dr["HigherPerPoint"].ToString(), out fHigherPerPoint);
                model.HigherPerPoint = fHigherPerPoint;
                float fRebatePoint = 0;
                float.TryParse(dr["RebatePoint"].ToString(), out fRebatePoint);
                model.RebatePoint = fRebatePoint;
                model.NOTE1       = dr["NOTE1"].ToString();
                model.NOTE2       = dr["NOTE2"].ToString();
                model.NOTE3       = dr["NOTE3"].ToString();
                model.NOTE4       = dr["NOTE4"].ToString();
                float fDeductionPoint = 0;
                float.TryParse(dr["DeductionPoint"].ToString(), out fDeductionPoint);
                model.DeductionPoint = fDeductionPoint;

                list.Add(model);
            }
            return(list);
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(T_truckType model, SqlTransaction tran)
        {
            Delete(model.typeCode, tran);
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_truckType(");
            strSql.Append("typeCode,NOTE5,typeName,parentCode,status,IsLastNode,HigherPerPoint,RebatePoint,NOTE1,NOTE2,NOTE3,NOTE4,DeductionPoint");
            strSql.Append(") values (");
            strSql.Append("@typeCode,@NOTE5,@typeName,@parentCode,@status,@IsLastNode,@HigherPerPoint,@RebatePoint,@NOTE1,@NOTE2,@NOTE3,@NOTE4,@DeductionPoint");
            strSql.Append(") ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@typeCode",       SqlDbType.NVarChar, 50),
                new SqlParameter("@NOTE5",          SqlDbType.NVarChar, 50),
                new SqlParameter("@typeName",       SqlDbType.NVarChar, 50),
                new SqlParameter("@parentCode",     SqlDbType.NVarChar, 50),
                new SqlParameter("@status",         SqlDbType.Char,      1),
                new SqlParameter("@IsLastNode",     SqlDbType.Char,      1),
                new SqlParameter("@HigherPerPoint", SqlDbType.Float),
                new SqlParameter("@RebatePoint",    SqlDbType.Float),
                new SqlParameter("@NOTE1",          SqlDbType.NVarChar, 50),
                new SqlParameter("@NOTE2",          SqlDbType.NVarChar, 50),
                new SqlParameter("@NOTE3",          SqlDbType.NVarChar, 50),
                new SqlParameter("@NOTE4",          SqlDbType.NVarChar, 50),
                new SqlParameter("@DeductionPoint", SqlDbType.NVarChar, 50)
            };

            parameters[0].Value = SqlNull(model.typeCode);

            parameters[1].Value = SqlNull(model.NOTE5);

            parameters[2].Value = SqlNull(model.typeName);

            parameters[3].Value = SqlNull(model.parentCode);

            parameters[4].Value = SqlNull(model.status);

            parameters[5].Value = SqlNull(model.IsLastNode);
            parameters[6].Value = SqlNull(model.HigherPerPoint);
            parameters[7].Value = SqlNull(model.RebatePoint);

            parameters[8].Value = SqlNull(model.NOTE1);

            parameters[9].Value = SqlNull(model.NOTE2);

            parameters[10].Value = SqlNull(model.NOTE3);

            parameters[11].Value = SqlNull(model.NOTE4);

            parameters[12].Value = SqlNull(model.DeductionPoint);


            return(DataHelper.ExcuteNonQuery(strSql.ToString(), tran, parameters, false));
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="tran"></param>
        /// <returns></returns>

        public int updatemodel(T_truckType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(@"update T_truckType set NOTE5=@NOTE5,typeName=@typeName,parentCode=@parentCode,status=@status,
IsLastNode=@IsLastNode,HigherPerPoint=@HigherPerPoint,RebatePoint=@RebatePoint,NOTE1=@NOTE1,NOTE2=@NOTE2,NOTE3=@NOTE3,NOTE4=@NOTE4,DeductionPoint=@DeductionPoint
 where typeCode=@typeCode");

            SqlParameter[] parameters =
            {
                new SqlParameter("@typeCode",       SqlDbType.NVarChar, 50),
                new SqlParameter("@NOTE5",          SqlDbType.NVarChar, 50),
                new SqlParameter("@typeName",       SqlDbType.NVarChar, 50),
                new SqlParameter("@parentCode",     SqlDbType.NVarChar, 50),
                new SqlParameter("@status",         SqlDbType.Char,      1),
                new SqlParameter("@IsLastNode",     SqlDbType.Char,      1),
                new SqlParameter("@HigherPerPoint", SqlDbType.Float),
                new SqlParameter("@RebatePoint",    SqlDbType.Float),
                new SqlParameter("@NOTE1",          SqlDbType.NVarChar, 50),
                new SqlParameter("@NOTE2",          SqlDbType.NVarChar, 50),
                new SqlParameter("@NOTE3",          SqlDbType.NVarChar, 50),
                new SqlParameter("@NOTE4",          SqlDbType.NVarChar, 50),
                new SqlParameter("@DeductionPoint", SqlDbType.NVarChar, 50)
            };

            parameters[0].Value = SqlNull(model.typeCode);

            parameters[1].Value = SqlNull(model.NOTE5);

            parameters[2].Value = SqlNull(model.typeName);

            parameters[3].Value = SqlNull(model.parentCode);

            parameters[4].Value = SqlNull(model.status);

            parameters[5].Value = SqlNull(model.IsLastNode);
            parameters[6].Value = SqlNull(model.HigherPerPoint);
            parameters[7].Value = SqlNull(model.RebatePoint);

            parameters[8].Value = SqlNull(model.NOTE1);

            parameters[9].Value = SqlNull(model.NOTE2);

            parameters[10].Value = SqlNull(model.NOTE3);

            parameters[11].Value = SqlNull(model.NOTE4);

            parameters[12].Value = SqlNull(model.DeductionPoint);


            return(DataHelper.ExcuteNonQuery(strSql.ToString(), parameters, false));
        }
Beispiel #4
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="modelTruckType"></param>
 /// <returns></returns>
 public int Upd(T_truckType modelTruckType, out string strmsg)
 {
     try
     {
         strmsg = "";
         return(dalTruckType.updatemodel(modelTruckType));
     }
     catch (Exception ex)
     {
         strmsg = ex.Message;
         return(0);
     }
 }
Beispiel #5
0
 public int Add(T_truckType modelTruckType, out string strMsg)
 {
     try
     {
         strMsg = "";
         return(dalTruckType.Add(modelTruckType));
     }
     catch (Exception ex)
     {
         strMsg = ex.Message;
         return(0);
     }
 }
Beispiel #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public T_truckType GetModel(string typeCode)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(sql);
            strSql.Append(" where typeCode=@typeCode ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@typeCode", typeCode)
            };


            T_truckType model = new T_truckType();

            using (SqlDataReader dr = DataHelper.GetDataReader(strSql.ToString(), parameters))
            {
                if (dr.Read())
                {
                    model.typeCode   = dr["typeCode"].ToString();
                    model.NOTE5      = dr["NOTE5"].ToString();
                    model.typeName   = dr["typeName"].ToString();
                    model.parentCode = dr["parentCode"].ToString();
                    model.status     = dr["status"].ToString();
                    model.IsLastNode = dr["IsLastNode"].ToString();
                    float fHigherPerPoint = 0;
                    float.TryParse(dr["HigherPerPoint"].ToString(), out fHigherPerPoint);
                    model.HigherPerPoint = fHigherPerPoint;
                    float fRebatePoint = 0;
                    float.TryParse(dr["RebatePoint"].ToString(), out fRebatePoint);
                    model.RebatePoint = fRebatePoint;
                    model.NOTE1       = dr["NOTE1"].ToString();
                    model.NOTE2       = dr["NOTE2"].ToString();
                    model.NOTE3       = dr["NOTE3"].ToString();
                    model.NOTE4       = dr["NOTE4"].ToString();
                    float fDeductionPoint = 0;
                    float.TryParse(dr["DeductionPoint"].ToString(), out fDeductionPoint);
                    model.DeductionPoint = fDeductionPoint;

                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="strCode"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public int Delete(string strCode, out string msg)
        {
            try
            {
                //先获取model以操作上级节点
                T_truckType modelTruckType = this.GetModel(strCode);
                msg = "";
                int iRel = dalTruckType.Delete(strCode);
                if (iRel < 1)
                {
                    throw new Exception("删除车辆类型时失败!");
                }

                //删除车辆对应关系
                new T_TruckTypeCorrespondBLL().DeleteByTruckTypeCode(strCode);

                //判断父节点的子节点数量 如果为零 则修改状态为末节点
                if (modelTruckType != null && modelTruckType.parentCode != "0")
                {
                    int childrenCount = this.dalTruckType.GetAllChildren(modelTruckType.parentCode).Count;
                    if (childrenCount == 0)
                    {
                        string         strUp = "update T_truckType set IsLastNode='1' where typeCode=@typeCode";
                        SqlParameter[] arrSp = new SqlParameter[] { new SqlParameter("@typeCode", modelTruckType.parentCode) };
                        int            iRel2 = DataHelper.ExcuteNonQuery(strUp, arrSp, false);
                        if (iRel2 < 1)
                        {
                            throw new Exception("在修改父节点状态时出现异常!");
                        }
                    }
                    else
                    {
                        throw new Exception("该节点下有子节点,不允许删除!");
                    }
                }
                return(1);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return(-1);
            }
        }
Beispiel #8
0
        public int Add(T_truckType model)
        {
            using (SqlConnection conn = new SqlConnection(DataHelper.constr))
            {
                conn.Open();
                SqlTransaction tran = conn.BeginTransaction();
                try
                {
                    int iRel = Add(model, tran);

                    tran.Commit();
                    return(iRel);
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
            }
        }