/// <summary> /// 获取 映射名称 /// </summary> /// <param name="dt"></param> /// <returns></returns> public static string GetMappName(this dataType dt) { /* * Class -->Type 继承MemberInfo * 类中属性-->PropertyInfo 继承MemberInfo * 类中字段-->FieldInfo 继承MemberInfo */ FieldInfo type = typeof(dataType).GetField(dt.ToString()); return(type.GetAttributeName()); }
public void AddData(Anime anime, dataType datatype = 0) { anime.episodes = null; //string data = Enum.GetName(typeof(dataType), datatype); string data = datatype.ToString(); SQLiteCommand command = new SQLiteCommand(string.Format("INSERT INTO {0}(content,episodeurl) VALUES(@content,@episodeurl)", data), con); command.Parameters.AddWithValue("content", anime.ToString()); command.Parameters.AddWithValue("episodeurl", anime.episode.episodeurl); try { command.ExecuteNonQuery(); } catch (Exception) { } }
public bool UpdateData(Anime anime, dataType type = 0) { SQLiteCommand command = new SQLiteCommand(string.Format("UPDATE {0} SET content=@content WHERE episodeurl=@episodeurl", type.ToString()), con); command.Parameters.AddWithValue("content", anime.ToString()); command.Parameters.AddWithValue("episodeurl", anime.episode.episodeurl); Trace.WriteLine(command.CommandText + command.Parameters.ToString()); int rows = command.ExecuteNonQuery(); return(rows > 0); }
private bool addData(dataType type) { void addDatabase(string query) { conn.Open(); try { using (SqlCommand command = new SqlCommand(query, conn)) { command.ExecuteNonQuery(); MessageBox.Show(type.ToString() + " başarıyla eklendi."); } } catch { MessageBox.Show("Kişiyi Eklerken Hata Oluştu"); } conn.Close(); } if (type == dataType.student) { if (!String.IsNullOrEmpty(TB_studentNo.Text) || !String.IsNullOrEmpty(TB_name.Text) || !String.IsNullOrEmpty(TB_lastName.Text) || !String.IsNullOrEmpty(TB_birthYear.Text) || !String.IsNullOrEmpty(TB_birthPlace.Text)) { addDatabase("INSERT INTO studentInformations(studentNo, name,lastName,birthYear,birthPlace) VALUES('" + TB_studentNo.Text + "','" + TB_name.Text + "', '" + TB_lastName.Text + "', '" + TB_birthYear.Text + "','" + TB_birthPlace.Text + "')"); } else { MessageBox.Show("Lütfen değerleri boş girmeyiniz !", "Uyarı !", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (type == dataType.lesson) { addDatabase("INSERT INTO lessons(studentNo, bm100,bm200,bm300) VALUES('" + TB_lessonsStudentNo.Text + "','" + Convert.ToInt16(CLB_studentLessons.GetItemChecked(0)) + "', '" + Convert.ToInt16(CLB_studentLessons.GetItemChecked(1)) + "', '" + Convert.ToInt16(CLB_studentLessons.GetItemChecked(2)) + "')"); } else { TextBox bm100 = new TextBox(), bm200 = new TextBox(), bm300 = new TextBox(); bm100.Text = "0.0"; bm200.Text = "0.0"; bm300.Text = "0.0"; foreach (Control c in addNewResultGroup.Controls) { if (c is TextBox) { TextBox txt = (TextBox)c; if (txt.Name == "TB_BM100") { bm100 = txt; } if (txt.Name == "TB_BM200") { bm200 = txt; } if (txt.Name == "TB_BM300") { bm300 = txt; } } } addDatabase("INSERT INTO examsResults(studentNo, bm100,bm200,bm300) VALUES('" + TB_resultsStudentNo.Text + "'," + Convert.ToDouble(bm100.Text) + ", " + Convert.ToDouble(bm200.Text) + ", " + Convert.ToDouble(bm300.Text) + ")"); } return(true); }