private static String GetIntoLibSQL() { IList intolibs = IntoLibData.GetAllIntoLibRecs(); StringBuilder sbResult = new StringBuilder(); foreach (object o in intolibs) { IntoLib il = o as IntoLib; StringBuilder sb = new StringBuilder(); sb.Append("insert into intolib (User,InputTime,PumpName,PumpType,DrawType,FileName,Version,ProductNo) values "); sb.Append("('" + il.User + "'"); sb.Append(",'" + il.InputTime.ToString() + "'"); sb.Append(",'" + il.PumpName + "'"); sb.Append(",'" + il.PumpType + "'"); sb.Append(",'" + il.DrawType + "'"); sb.Append(",'" + il.FileName + "'"); sb.Append("," + il.Version); sb.Append(",'" + il.ProductNo + "'"); sb.Append(");"); string queryText = sb.ToString(); sbResult.Append(Environment.NewLine); sbResult.Append(queryText); sbResult.Append(Environment.NewLine); } return(sbResult.ToString());; }
private void FillList(IList PumpList) { listView1.Items.Clear(); foreach (object o in PumpList) { IntoLib il = o as IntoLib; ListViewItem item = new ListViewItem(); item.Text = il.id.ToString(); item.SubItems.Add(il.InputTime.ToString()); item.SubItems.Add(il.User); item.SubItems.Add(il.PumpType); item.SubItems.Add(il.PumpName); item.SubItems.Add(il.DrawType); item.SubItems.Add(il.FileName); listView1.Items.Add(item); } }
private void button1_Click(object sender, EventArgs e) { ISession session = ThreadLocalSession.CurrentSession(); IDbConnection conn = session.Connection; //IQuery query=session.CreateQuery(textBox1.Text); //IList list=query.List(); string strTemp = ""; if (rbToday.Checked) { strTemp = "select * from intolib where to_days(inputtime) = to_days(now())"; } if (rbWeek.Checked) { strTemp = "select * from intolib where week(inputtime,1) = week(now(),1) and year(inputtime) = year(now())"; } if (rbMonth.Checked) { strTemp = "select * from intolib where month(inputtime) = month(curdate()) and year(inputtime) = year(now())"; } //string strSql = "select * from intolib where datesub(currentdate(),interval 1 " + strTemp + ")<=inputtime"; string strSql = strTemp; if (rbLastMonth.Checked) { strSql = "select * from intolib where month(inputtime)=month(curdate())-1 and year(inputtime)=year(now())"; } if (rbAll.Checked) { strSql = "select * from intolib"; } //SqlDataAdapter adapter = new SqlDataAdapter(strSql, conn); ISQLQuery adapter = session.CreateSQLQuery(strSql); //DataTable dt = new DataTable(); //adapter.Fill(dt); IList intolibs = adapter.AddEntity(typeof(IntoLib)).List(); ThreadLocalSession.CloseCurrentSession(); listView1.Items.Clear(); foreach (object o in intolibs) { IntoLib il = o as IntoLib; ListViewItem item = new ListViewItem(); item.Text = il.id.ToString(); item.SubItems.Add(il.InputTime.ToString()); item.SubItems.Add(il.User); item.SubItems.Add(il.PumpType); item.SubItems.Add(il.PumpName); item.SubItems.Add(il.DrawType); item.SubItems.Add(il.FileName); item.SubItems.Add(il.Version.ToString()); listView1.Items.Add(item); } }