private void ShowPic(SclerteInfo si) { if (si != null) { imgContent.Source = new BitmapImage(new Uri(si.SleritePicUrl)); } }
public List<SclerteInfo> QuerySclerteInfo(long partientId) { List<SclerteInfo> list = new List<SclerteInfo>(); string strSQL = string.Format("select * from SclerteInfo where PatientId={0}", partientId); using (DbDataReader dbDataReader = DbHelperSQLite.ExecuteReader(strSQL)) { while (dbDataReader.Read()) { SclerteInfo sclerteInfo = new SclerteInfo(); object obj = dbDataReader["ScleriteId"]; if (obj != null && obj != DBNull.Value) { sclerteInfo.ScleriteId = Convert.ToInt64(obj); } obj = dbDataReader["PatientId"]; if (obj != null && obj != DBNull.Value) { sclerteInfo.PatientId = Convert.ToInt64(obj); } sclerteInfo.SleritePicUrl = string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, dbDataReader["SleritePicUrl"]); sclerteInfo.SleriteNote = dbDataReader["SleriteNote"].ToString(); sclerteInfo.Title = dbDataReader["Title"].ToString(); list.Add(sclerteInfo); } } return list; }
public bool EditSclerteInfo(SclerteInfo model) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("update SclerteInfo set "); stringBuilder.Append("PatientId=@PatientId,"); stringBuilder.Append("SleritePicUrl=@SleritePicUrl,"); stringBuilder.Append("SleriteNote=@SleriteNote,"); stringBuilder.Append("Title=@Title"); stringBuilder.Append(" where ScleriteId=@ScleriteId"); SQLiteParameter[] array = new SQLiteParameter[] { new SQLiteParameter("@PatientId", DbType.Int64), new SQLiteParameter("@SleritePicUrl", DbType.String), new SQLiteParameter("@SleriteNote", DbType.String), new SQLiteParameter("@Title", DbType.String), new SQLiteParameter("@ScleriteId", DbType.Int64) }; array[0].Value = model.PatientId; array[1].Value = model.SleritePicUrl; array[2].Value = model.SleriteNote; array[3].Value = model.Title; array[4].Value = model.ScleriteId; int num = DbHelperSQLite.ExecuteSql(stringBuilder.ToString(), array); return num > 0; }
public bool DeleteSclerteInfo(SclerteInfo model) { try { File.Delete(model.SleritePicUrl); } catch { } model.SleritePicUrl = null; string sQLString = string.Format("DELETE FROM [SclerteInfo] where ScleriteId={0}", model.ScleriteId); return DbHelperSQLite.ExecuteSql(sQLString) > 0; }
public long AddSclerteInfo(SclerteInfo model) { DateTime now = DateTime.Now; string text = string.Format("Pic\\{0}\\{1}\\{2}\\{3}", new object[] { now.Year, now.Month, model.PatientId, Path.GetFileName(model.SleritePicUrl) }); string text2 = AppDomain.CurrentDomain.BaseDirectory + text; if (File.Exists(text2)) { UMessageBox.Show("图片上传出错!", "已有相同文件(名)存在!", MessageBoxButton.OK); } else { string directoryName = Path.GetDirectoryName(text2); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } File.Copy(model.SleritePicUrl, text2); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("insert into SclerteInfo("); stringBuilder.Append("PatientId,SleritePicUrl,SleriteNote,Title)"); stringBuilder.Append(" values ("); stringBuilder.Append("@PatientId,@SleritePicUrl,@SleriteNote,@Title)"); stringBuilder.Append(";select LAST_INSERT_ROWID()"); SQLiteParameter[] array = new SQLiteParameter[] { new SQLiteParameter("@PatientId", DbType.Int64), new SQLiteParameter("@SleritePicUrl", DbType.String), new SQLiteParameter("@SleriteNote", DbType.String), new SQLiteParameter("@Title", DbType.String) }; array[0].Value = model.PatientId; array[1].Value = text; array[2].Value = model.SleriteNote; array[3].Value = model.Title; object single = DbHelperSQLite.GetSingle(stringBuilder.ToString(), array); return Convert.ToInt64(single); }
public FrmEditSclerte() { InitializeComponent(); SclerteValue = new SclerteInfo(); }