/// <summary> /// this is function to make Description List from database /// </summary> /// <returns>list of DescriptionDetail</returns> public List <DescriptionDetail> makeDescriptionList() { List <DescriptionDetail> descList = new List <DescriptionDetail>(); int retVal = 0; DataSet ds = Sqlite.ExecuteSQLStatement(Query.getDescData(), ref retVal); for (int i = 0; i < retVal; i++) { DescriptionDetail descTemp = new DescriptionDetail(); //Description ID if (int.TryParse(ds.Tables[0].Rows[i].ItemArray[0].ToString(), out int id)) { descTemp.DescId = id; } //description name descTemp.name = ds.Tables[0].Rows[i].ItemArray[1].ToString(); //source id if (int.TryParse(ds.Tables[0].Rows[i].ItemArray[2].ToString(), out int sourceId)) { descTemp.sourceId = sourceId; } //description descTemp.description = ds.Tables[0].Rows[i].ItemArray[3].ToString(); //create date descTemp.sDate = ds.Tables[0].Rows[i].ItemArray[4].ToString(); //add to list descList.Add(descTemp); } return(descList); }
public string insertDesc(DescriptionDetail descDetail) { //string dt = DateTime.Parse(descDetail.date).ToString("yyyy-MM-dd"); //descDetail.date = descDetail.date.ToString("yyyy-MM-dd"); return("INSERT INTO Assignment (Name,Source_id, Description,CreationDate) " + "VALUES ('" + descDetail.name + "', " + descDetail.sourceId + ", '" + descDetail.description + "', '" + descDetail.sDate + "');"); //INSERT INTO "main"."Assignment"("Name", "Source_id", "Description", "CreationDate") VALUES('asdfsadf', 2, 'asdfsadfsdf', '2017-8-1') }
private void btnSave_Click(object sender, RoutedEventArgs e) { try { if (tbDesc.Text != "" && DescDate != null) { DescriptionDetail desc = new DescriptionDetail(); desc.date = DescDate.SelectedDate.Value; if (desc.date.Month < 10) { desc.sDate = desc.date.Year.ToString() + "-0" + desc.date.Month.ToString(); } else { desc.sDate = desc.date.Year.ToString() + "-" + desc.date.Month.ToString(); } if (desc.date.Day < 10) { desc.sDate += "-0" + desc.date.Day.ToString(); } else { desc.sDate += "-" + desc.date.Day.ToString(); } desc.description = tbDesc.Text; desc.name = tbName.Text; if (Int32.TryParse(tbSourceId.Text, out int sourId)) { desc.sourceId = sourId; } Sqlite.ExecuteNonQuery(Query.insertDesc(desc)); descDetail = desc; this.Hide(); } } catch (Exception ex) { //handle error method HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message); } }
public void addDescList(DescriptionDetail desc) { descList.Add(desc); }
public string updateDesc(DescriptionDetail detail) { return("UPDATE Assignment SET Name = '" + detail.name + "', Source_id = " + detail.sourceId + ", Description = '" + detail.description + "',CreationDate= '" + detail.sDate + "' WHERE(_id =" + detail.DescId + ");"); }