Beispiel #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.ProductSeries GetModel(string name)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,Code,Name,Enabled,Status,Remark,Value0,Value1,Value2,Value3,Value4,Value5,Value6,Value7,Value8,Value9,CreateUser,CreateDate,UpdateUser,UpdateDate from ProductSeries ");
            strSql.Append(" where Name=@name");
            SqlParameter[] parameters =
            {
                new SqlParameter("@name", SqlDbType.NVarChar)
            };
            parameters[0].Value = name;

            Maticsoft.Model.ProductSeries model = new Maticsoft.Model.ProductSeries();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Code"] != null && ds.Tables[0].Rows[0]["Code"].ToString() != "")
                {
                    model.Code = ds.Tables[0].Rows[0]["Code"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Name"] != null && ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Enabled"] != null && ds.Tables[0].Rows[0]["Enabled"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Enabled"].ToString() == "1") || (ds.Tables[0].Rows[0]["Enabled"].ToString().ToLower() == "true"))
                    {
                        model.Enabled = true;
                    }
                    else
                    {
                        model.Enabled = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["Status"] != null && ds.Tables[0].Rows[0]["Status"].ToString() != "")
                {
                    model.Status = int.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Value0"] != null && ds.Tables[0].Rows[0]["Value0"].ToString() != "")
                {
                    model.Value0 = ds.Tables[0].Rows[0]["Value0"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Value1"] != null && ds.Tables[0].Rows[0]["Value1"].ToString() != "")
                {
                    model.Value1 = ds.Tables[0].Rows[0]["Value1"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Value2"] != null && ds.Tables[0].Rows[0]["Value2"].ToString() != "")
                {
                    model.Value2 = ds.Tables[0].Rows[0]["Value2"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Value3"] != null && ds.Tables[0].Rows[0]["Value3"].ToString() != "")
                {
                    model.Value3 = ds.Tables[0].Rows[0]["Value3"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Value4"] != null && ds.Tables[0].Rows[0]["Value4"].ToString() != "")
                {
                    model.Value4 = ds.Tables[0].Rows[0]["Value4"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Value5"] != null && ds.Tables[0].Rows[0]["Value5"].ToString() != "")
                {
                    model.Value5 = ds.Tables[0].Rows[0]["Value5"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Value6"] != null && ds.Tables[0].Rows[0]["Value6"].ToString() != "")
                {
                    model.Value6 = ds.Tables[0].Rows[0]["Value6"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Value7"] != null && ds.Tables[0].Rows[0]["Value7"].ToString() != "")
                {
                    model.Value7 = ds.Tables[0].Rows[0]["Value7"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Value8"] != null && ds.Tables[0].Rows[0]["Value8"].ToString() != "")
                {
                    model.Value8 = ds.Tables[0].Rows[0]["Value8"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Value9"] != null && ds.Tables[0].Rows[0]["Value9"].ToString() != "")
                {
                    model.Value9 = ds.Tables[0].Rows[0]["Value9"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CreateUser"] != null && ds.Tables[0].Rows[0]["CreateUser"].ToString() != "")
                {
                    model.CreateUser = ds.Tables[0].Rows[0]["CreateUser"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CreateDate"] != null && ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UpdateUser"] != null && ds.Tables[0].Rows[0]["UpdateUser"].ToString() != "")
                {
                    model.UpdateUser = ds.Tables[0].Rows[0]["UpdateUser"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UpdateDate"] != null && ds.Tables[0].Rows[0]["UpdateDate"].ToString() != "")
                {
                    model.UpdateDate = DateTime.Parse(ds.Tables[0].Rows[0]["UpdateDate"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(Maticsoft.Model.ProductSeries model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ProductSeries(");
            strSql.Append("Code,Name,Enabled,Status,Remark,Value0,Value1,Value2,Value3,Value4,Value5,Value6,Value7,Value8,Value9,CreateUser,CreateDate,UpdateUser,UpdateDate)");
            strSql.Append(" values (");
            strSql.Append("@Code,@Name,@Enabled,@Status,@Remark,@Value0,@Value1,@Value2,@Value3,@Value4,@Value5,@Value6,@Value7,@Value8,@Value9,@CreateUser,@CreateDate,@UpdateUser,@UpdateDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Code",       SqlDbType.NVarChar,  50),
                new SqlParameter("@Name",       SqlDbType.NVarChar,  50),
                new SqlParameter("@Enabled",    SqlDbType.Bit,        1),
                new SqlParameter("@Status",     SqlDbType.Int,        4),
                new SqlParameter("@Remark",     SqlDbType.NVarChar),
                new SqlParameter("@Value0",     SqlDbType.NVarChar),
                new SqlParameter("@Value1",     SqlDbType.NVarChar),
                new SqlParameter("@Value2",     SqlDbType.NVarChar),
                new SqlParameter("@Value3",     SqlDbType.NVarChar),
                new SqlParameter("@Value4",     SqlDbType.NVarChar),
                new SqlParameter("@Value5",     SqlDbType.NVarChar),
                new SqlParameter("@Value6",     SqlDbType.NVarChar),
                new SqlParameter("@Value7",     SqlDbType.NVarChar),
                new SqlParameter("@Value8",     SqlDbType.NVarChar),
                new SqlParameter("@Value9",     SqlDbType.NVarChar),
                new SqlParameter("@CreateUser", SqlDbType.NVarChar,  50),
                new SqlParameter("@CreateDate", SqlDbType.DateTime),
                new SqlParameter("@UpdateUser", SqlDbType.NVarChar,  50),
                new SqlParameter("@UpdateDate", SqlDbType.DateTime)
            };
            parameters[0].Value  = model.Code;
            parameters[1].Value  = model.Name;
            parameters[2].Value  = model.Enabled;
            parameters[3].Value  = model.Status;
            parameters[4].Value  = model.Remark;
            parameters[5].Value  = model.Value0;
            parameters[6].Value  = model.Value1;
            parameters[7].Value  = model.Value2;
            parameters[8].Value  = model.Value3;
            parameters[9].Value  = model.Value4;
            parameters[10].Value = model.Value5;
            parameters[11].Value = model.Value6;
            parameters[12].Value = model.Value7;
            parameters[13].Value = model.Value8;
            parameters[14].Value = model.Value9;
            parameters[15].Value = model.CreateUser;
            parameters[16].Value = model.CreateDate;
            parameters[17].Value = model.UpdateUser;
            parameters[18].Value = model.UpdateDate;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }
Beispiel #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.ProductSeries model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ProductSeries set ");
            strSql.Append("Code=@Code,");
            strSql.Append("Name=@Name,");
            strSql.Append("Enabled=@Enabled,");
            strSql.Append("Status=@Status,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("Value0=@Value0,");
            strSql.Append("Value1=@Value1,");
            strSql.Append("Value2=@Value2,");
            strSql.Append("Value3=@Value3,");
            strSql.Append("Value4=@Value4,");
            strSql.Append("Value5=@Value5,");
            strSql.Append("Value6=@Value6,");
            strSql.Append("Value7=@Value7,");
            strSql.Append("Value8=@Value8,");
            strSql.Append("Value9=@Value9,");
            strSql.Append("UpdateUser=@UpdateUser,");
            strSql.Append("UpdateDate=@UpdateDate");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Code",       SqlDbType.NVarChar,  50),
                new SqlParameter("@Name",       SqlDbType.NVarChar,  50),
                new SqlParameter("@Enabled",    SqlDbType.Bit,        1),
                new SqlParameter("@Status",     SqlDbType.Int,        4),
                new SqlParameter("@Remark",     SqlDbType.NVarChar),
                new SqlParameter("@Value0",     SqlDbType.NVarChar),
                new SqlParameter("@Value1",     SqlDbType.NVarChar),
                new SqlParameter("@Value2",     SqlDbType.NVarChar),
                new SqlParameter("@Value3",     SqlDbType.NVarChar),
                new SqlParameter("@Value4",     SqlDbType.NVarChar),
                new SqlParameter("@Value5",     SqlDbType.NVarChar),
                new SqlParameter("@Value6",     SqlDbType.NVarChar),
                new SqlParameter("@Value7",     SqlDbType.NVarChar),
                new SqlParameter("@Value8",     SqlDbType.NVarChar),
                new SqlParameter("@Value9",     SqlDbType.NVarChar),
                new SqlParameter("@UpdateUser", SqlDbType.NVarChar,  50),
                new SqlParameter("@UpdateDate", SqlDbType.DateTime),
                new SqlParameter("@ID",         SqlDbType.BigInt, 8)
            };
            parameters[0].Value  = model.Code;
            parameters[1].Value  = model.Name;
            parameters[2].Value  = model.Enabled;
            parameters[3].Value  = model.Status;
            parameters[4].Value  = model.Remark;
            parameters[5].Value  = model.Value0;
            parameters[6].Value  = model.Value1;
            parameters[7].Value  = model.Value2;
            parameters[8].Value  = model.Value3;
            parameters[9].Value  = model.Value4;
            parameters[10].Value = model.Value5;
            parameters[11].Value = model.Value6;
            parameters[12].Value = model.Value7;
            parameters[13].Value = model.Value8;
            parameters[14].Value = model.Value9;
            parameters[15].Value = model.UpdateUser;
            parameters[16].Value = model.UpdateDate;
            parameters[17].Value = model.ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }