public static void UploadSong(HttpContext context) { HttpPostedFile file = context.Request.Files["Filedata"]; string uploadPath = HttpContext.Current.Server.MapPath("\\ProductPic" + "\\"); long ID = Convert.ToInt64(context.Request["ID"].ToString()); Maticsoft.Model.ProductColor model = new Maticsoft.Model.ProductColor(); DataSet ds = new DataSet(); if (file != null) { if (!Directory.Exists(uploadPath)) { Directory.CreateDirectory(uploadPath); } string extName = file.FileName.Substring(file.FileName.LastIndexOf(".")); string time = DateTime.Now.ToString("yyyyMMddhhmmssf"); string name = "temp_" + time + extName; file.SaveAs(uploadPath + "temp_" + time + extName); model.ID = ID; model.Image = name; ds = new Maticsoft.BLL.ProductColor().UpdateImageByProc(model, "Update3"); //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失 context.Response.Write(context.Request.Params["type"] + "-temp_" + time + extName); } else { context.Response.Write("0"); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.ProductColor GetModel(long ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,ParentID,Code,Name,Enabled,Status,Remark,Value0,Value1,Value2,Value3,Value4,Value5,Value6,Value7,Value8,Value9,CreateUser,CreateDate,UpdateUser,UpdateDate from ProductColor "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.BigInt) }; parameters[0].Value = ID; Maticsoft.Model.ProductColor model = new Maticsoft.Model.ProductColor(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public long Add(Maticsoft.Model.ProductColor model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ProductColor("); strSql.Append("ParentID,Code,Name,Enabled,Status,Remark,Value0,Value1,Value2,Value3,Value4,Value5,Value6,Value7,Value8,Value9,CreateUser,CreateDate,UpdateUser,UpdateDate)"); strSql.Append(" values ("); strSql.Append("@ParentID,@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("@ParentID", SqlDbType.BigInt, 8), 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, -1), new SqlParameter("@Value0", SqlDbType.NVarChar, -1), new SqlParameter("@Value1", SqlDbType.NVarChar, -1), new SqlParameter("@Value2", SqlDbType.NVarChar, -1), new SqlParameter("@Value3", SqlDbType.NVarChar, -1), new SqlParameter("@Value4", SqlDbType.NVarChar, -1), new SqlParameter("@Value5", SqlDbType.NVarChar, -1), new SqlParameter("@Value6", SqlDbType.NVarChar, -1), new SqlParameter("@Value7", SqlDbType.NVarChar, -1), new SqlParameter("@Value8", SqlDbType.NVarChar, -1), new SqlParameter("@Value9", SqlDbType.NVarChar, -1), 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.ParentID; parameters[1].Value = model.Code; parameters[2].Value = model.Name; parameters[3].Value = model.Enabled; parameters[4].Value = model.Status; parameters[5].Value = model.Remark; parameters[6].Value = model.Value0; parameters[7].Value = model.Value1; parameters[8].Value = model.Value2; parameters[9].Value = model.Value3; parameters[10].Value = model.Value4; parameters[11].Value = model.Value5; parameters[12].Value = model.Value6; parameters[13].Value = model.Value7; parameters[14].Value = model.Value8; parameters[15].Value = model.Value9; parameters[16].Value = model.CreateUser; parameters[17].Value = model.CreateDate; parameters[18].Value = model.UpdateUser; parameters[19].Value = model.UpdateDate; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt64(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.ProductColor DataRowToModel(DataRow row) { Maticsoft.Model.ProductColor model = new Maticsoft.Model.ProductColor(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = long.Parse(row["ID"].ToString()); } if (row["ParentID"] != null && row["ParentID"].ToString() != "") { model.ParentID = long.Parse(row["ParentID"].ToString()); } if (row["Code"] != null) { model.Code = row["Code"].ToString(); } if (row["Name"] != null) { model.Name = row["Name"].ToString(); } if (row["Enabled"] != null && row["Enabled"].ToString() != "") { if ((row["Enabled"].ToString() == "1") || (row["Enabled"].ToString().ToLower() == "true")) { model.Enabled = true; } else { model.Enabled = false; } } if (row["Status"] != null && row["Status"].ToString() != "") { model.Status = int.Parse(row["Status"].ToString()); } if (row["Remark"] != null) { model.Remark = row["Remark"].ToString(); } if (row["Value0"] != null) { model.Value0 = row["Value0"].ToString(); } if (row["Value1"] != null) { model.Value1 = row["Value1"].ToString(); } if (row["Value2"] != null) { model.Value2 = row["Value2"].ToString(); } if (row["Value3"] != null) { model.Value3 = row["Value3"].ToString(); } if (row["Value4"] != null) { model.Value4 = row["Value4"].ToString(); } if (row["Value5"] != null) { model.Value5 = row["Value5"].ToString(); } if (row["Value6"] != null) { model.Value6 = row["Value6"].ToString(); } if (row["Value7"] != null) { model.Value7 = row["Value7"].ToString(); } if (row["Value8"] != null) { model.Value8 = row["Value8"].ToString(); } if (row["Value9"] != null) { model.Value9 = row["Value9"].ToString(); } if (row["CreateUser"] != null) { model.CreateUser = row["CreateUser"].ToString(); } if (row["CreateDate"] != null && row["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(row["CreateDate"].ToString()); } if (row["UpdateUser"] != null) { model.UpdateUser = row["UpdateUser"].ToString(); } if (row["UpdateDate"] != null && row["UpdateDate"].ToString() != "") { model.UpdateDate = DateTime.Parse(row["UpdateDate"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.ProductColor model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ProductColor set "); strSql.Append("ParentID=@ParentID,"); 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("CreateUser=@CreateUser,"); strSql.Append("CreateDate=@CreateDate,"); strSql.Append("UpdateUser=@UpdateUser,"); strSql.Append("UpdateDate=@UpdateDate"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ParentID", SqlDbType.BigInt, 8), 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, -1), new SqlParameter("@Value0", SqlDbType.NVarChar, -1), new SqlParameter("@Value1", SqlDbType.NVarChar, -1), new SqlParameter("@Value2", SqlDbType.NVarChar, -1), new SqlParameter("@Value3", SqlDbType.NVarChar, -1), new SqlParameter("@Value4", SqlDbType.NVarChar, -1), new SqlParameter("@Value5", SqlDbType.NVarChar, -1), new SqlParameter("@Value6", SqlDbType.NVarChar, -1), new SqlParameter("@Value7", SqlDbType.NVarChar, -1), new SqlParameter("@Value8", SqlDbType.NVarChar, -1), new SqlParameter("@Value9", SqlDbType.NVarChar, -1), new SqlParameter("@CreateUser", SqlDbType.NVarChar, 50), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@UpdateUser", SqlDbType.NVarChar, 50), new SqlParameter("@UpdateDate", SqlDbType.DateTime), new SqlParameter("@ID", SqlDbType.BigInt, 8) }; parameters[0].Value = model.ParentID; parameters[1].Value = model.Code; parameters[2].Value = model.Name; parameters[3].Value = model.Enabled; parameters[4].Value = model.Status; parameters[5].Value = model.Remark; parameters[6].Value = model.Value0; parameters[7].Value = model.Value1; parameters[8].Value = model.Value2; parameters[9].Value = model.Value3; parameters[10].Value = model.Value4; parameters[11].Value = model.Value5; parameters[12].Value = model.Value6; parameters[13].Value = model.Value7; parameters[14].Value = model.Value8; parameters[15].Value = model.Value9; parameters[16].Value = model.CreateUser; parameters[17].Value = model.CreateDate; parameters[18].Value = model.UpdateUser; parameters[19].Value = model.UpdateDate; parameters[20].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }