예제 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static int Add(yny_005.Model.C_Supplier model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into C_Supplier(");
            strSql.Append("Type,Name,SHCode,UserCode,ZQDate,ZZValue,TelName,Tel,Address,Remark,QCMoney,OverMoney,IsDelete,CreateDate,Spare1,Spare2,Spare3)");
            strSql.Append(" values (");
            strSql.Append("@Type,@Name,@SHCode,@UserCode,@ZQDate,@ZZValue,@TelName,@Tel,@Address,@Remark,@QCMoney,@OverMoney,@IsDelete,@CreateDate,@Spare1,@Spare2,@Spare3)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Type",       SqlDbType.Int,          4),
                new SqlParameter("@Name",       SqlDbType.VarChar,     50),
                new SqlParameter("@SHCode",     SqlDbType.VarChar,     50),
                new SqlParameter("@UserCode",   SqlDbType.VarChar,     50),
                new SqlParameter("@ZQDate",     SqlDbType.Int,          4),
                new SqlParameter("@ZZValue",    SqlDbType.VarChar,    250),
                new SqlParameter("@TelName",    SqlDbType.VarChar,     50),
                new SqlParameter("@Tel",        SqlDbType.VarChar,     50),
                new SqlParameter("@Address",    SqlDbType.VarChar,    250),
                new SqlParameter("@Remark",     SqlDbType.VarChar,   1000),
                new SqlParameter("@QCMoney",    SqlDbType.Decimal,      9),
                new SqlParameter("@OverMoney",  SqlDbType.Decimal,      9),
                new SqlParameter("@IsDelete",   SqlDbType.Int,          4),
                new SqlParameter("@CreateDate", SqlDbType.DateTime),
                new SqlParameter("@Spare1",     SqlDbType.VarChar,    250),
                new SqlParameter("@Spare2",     SqlDbType.VarChar,    250),
                new SqlParameter("@Spare3",     SqlDbType.VarChar, 250)
            };
            parameters[0].Value  = model.Type;
            parameters[1].Value  = model.Name;
            parameters[2].Value  = model.SHCode;
            parameters[3].Value  = model.UserCode;
            parameters[4].Value  = model.ZQDate;
            parameters[5].Value  = model.ZZValue;
            parameters[6].Value  = model.TelName;
            parameters[7].Value  = model.Tel;
            parameters[8].Value  = model.Address;
            parameters[9].Value  = model.Remark;
            parameters[10].Value = model.QCMoney;
            parameters[11].Value = model.OverMoney;
            parameters[12].Value = model.IsDelete;
            parameters[13].Value = model.CreateDate;
            parameters[14].Value = model.Spare1;
            parameters[15].Value = model.Spare2;
            parameters[16].Value = model.Spare3;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static yny_005.Model.C_Supplier GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,Type,Name,SHCode,UserCode,ZQDate,ZZValue,TelName,Tel,Address,Remark,QCMoney,OverMoney,IsDelete,CreateDate,Spare1,Spare2,Spare3 from C_Supplier ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public static yny_005.Model.C_Supplier DataRowToModel(DataRow row)
 {
     yny_005.Model.C_Supplier model = new yny_005.Model.C_Supplier();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["Type"] != null && row["Type"].ToString() != "")
         {
             model.Type = int.Parse(row["Type"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["SHCode"] != null)
         {
             model.SHCode = row["SHCode"].ToString();
         }
         if (row["UserCode"] != null)
         {
             model.UserCode = row["UserCode"].ToString();
         }
         if (row["ZQDate"] != null && row["ZQDate"].ToString() != "")
         {
             model.ZQDate = int.Parse(row["ZQDate"].ToString());
         }
         if (row["ZZValue"] != null)
         {
             model.ZZValue = row["ZZValue"].ToString();
         }
         if (row["TelName"] != null)
         {
             model.TelName = row["TelName"].ToString();
         }
         if (row["Tel"] != null)
         {
             model.Tel = row["Tel"].ToString();
         }
         if (row["Address"] != null)
         {
             model.Address = row["Address"].ToString();
         }
         if (row["Remark"] != null)
         {
             model.Remark = row["Remark"].ToString();
         }
         if (row["QCMoney"] != null && row["QCMoney"].ToString() != "")
         {
             model.QCMoney = decimal.Parse(row["QCMoney"].ToString());
         }
         if (row["OverMoney"] != null && row["OverMoney"].ToString() != "")
         {
             model.OverMoney = decimal.Parse(row["OverMoney"].ToString());
         }
         if (row["IsDelete"] != null && row["IsDelete"].ToString() != "")
         {
             model.IsDelete = int.Parse(row["IsDelete"].ToString());
         }
         if (row["CreateDate"] != null && row["CreateDate"].ToString() != "")
         {
             model.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
         }
         if (row["Spare1"] != null)
         {
             model.Spare1 = row["Spare1"].ToString();
         }
         if (row["Spare2"] != null)
         {
             model.Spare2 = row["Spare2"].ToString();
         }
         if (row["Spare3"] != null)
         {
             model.Spare3 = row["Spare3"].ToString();
         }
     }
     return(model);
 }
예제 #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static Hashtable Update(yny_005.Model.C_Supplier model, Hashtable MyHs)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update C_Supplier set ");
            strSql.Append("Type=@Type,");
            strSql.Append("Name=@Name,");
            strSql.Append("SHCode=@SHCode,");
            strSql.Append("UserCode=@UserCode,");
            strSql.Append("ZQDate=@ZQDate,");
            strSql.Append("ZZValue=@ZZValue,");
            strSql.Append("TelName=@TelName,");
            strSql.Append("Tel=@Tel,");
            strSql.Append("Address=@Address,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("QCMoney=@QCMoney,");
            strSql.Append("OverMoney=@OverMoney,");
            strSql.Append("IsDelete=@IsDelete,");
            strSql.Append("CreateDate=@CreateDate,");
            strSql.Append("Spare1=@Spare1,");
            strSql.Append("Spare2=@Spare2,");
            strSql.Append("Spare3=@Spare3");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Type",       SqlDbType.Int,          4),
                new SqlParameter("@Name",       SqlDbType.VarChar,     50),
                new SqlParameter("@SHCode",     SqlDbType.VarChar,     50),
                new SqlParameter("@UserCode",   SqlDbType.VarChar,     50),
                new SqlParameter("@ZQDate",     SqlDbType.Int,          4),
                new SqlParameter("@ZZValue",    SqlDbType.VarChar,    250),
                new SqlParameter("@TelName",    SqlDbType.VarChar,     50),
                new SqlParameter("@Tel",        SqlDbType.VarChar,     50),
                new SqlParameter("@Address",    SqlDbType.VarChar,    250),
                new SqlParameter("@Remark",     SqlDbType.VarChar,   1000),
                new SqlParameter("@QCMoney",    SqlDbType.Decimal,      9),
                new SqlParameter("@OverMoney",  SqlDbType.Decimal,      9),
                new SqlParameter("@IsDelete",   SqlDbType.Int,          4),
                new SqlParameter("@CreateDate", SqlDbType.DateTime),
                new SqlParameter("@Spare1",     SqlDbType.VarChar,    250),
                new SqlParameter("@Spare2",     SqlDbType.VarChar,    250),
                new SqlParameter("@Spare3",     SqlDbType.VarChar,    250),
                new SqlParameter("@ID",         SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.Type;
            parameters[1].Value  = model.Name;
            parameters[2].Value  = model.SHCode;
            parameters[3].Value  = model.UserCode;
            parameters[4].Value  = model.ZQDate;
            parameters[5].Value  = model.ZZValue;
            parameters[6].Value  = model.TelName;
            parameters[7].Value  = model.Tel;
            parameters[8].Value  = model.Address;
            parameters[9].Value  = model.Remark;
            parameters[10].Value = model.QCMoney;
            parameters[11].Value = model.OverMoney;
            parameters[12].Value = model.IsDelete;
            parameters[13].Value = model.CreateDate;
            parameters[14].Value = model.Spare1;
            parameters[15].Value = model.Spare2;
            parameters[16].Value = model.Spare3;
            parameters[17].Value = model.ID;
            MyHs.Add(strSql.ToString(), parameters);
            return(MyHs);
        }