private void btnAddResult_Click(object sender, EventArgs e) { if (this.txtResult.Text.Trim().Length == 0) { MessageBox.Show("请输入成绩!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ResultInsert result = new ResultInsert( this.Stu.StudentNo, Convert.ToInt32(this.cboSub.SelectedValue) , Convert.ToInt32(this.txtResult.Text), this.picExamDate.Value ); try { if (ResultBLL.AddResult(result)) { MessageBox.Show("添加成功!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); ShowStudentResultSeach(); } else { MessageBox.Show("添加失败!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("添加出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
protected void btnYuce_Click(object sender, EventArgs e) { ResultBLL bll = new ResultBLL(); long start = Environment.TickCount; DataSet ds = bll.GetResult1(DateTime.Parse(txtDate.Text), txtFlightno.Text, txtDepAir.Text, txtArrAir.Text); long end = Environment.TickCount; string result = "|"; for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { result += " " + ds.Tables[0].Rows[0][i].ToString() + " |"; } Page.ClientScript.RegisterStartupScript(GetType(), "", "alert('" + result + "\\n共花费了" + (end - start) + "毫秒')", true); }
//使用重写ToString()方法显示ListView public void ShowStudentResult() { this.listView1.Items.Clear(); try { List <Result> results = ResultBLL.GetResultByStu(this.Stu.StudentNo); foreach (Result r in results) { ListViewItem lv = new ListViewItem(r.Student.ToString()); lv.SubItems.AddRange(new string [] { r.Subject.ToString(), r.StudentResult.ToString(), r.ExamDate.ToString() }); this.listView1.Items.Add(lv); } } catch (Exception ex) { MessageBox.Show("查询学生成绩出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; ResultBLL bll = new ResultBLL(); string flightno = context.Request["flightno"].ToString(); DateTime date = DateTime.Parse(context.Request["time"].ToString()); string depair = context.Request["depair"].ToString(); string arrair = context.Request["arrair"].ToString(); try { DataSet ds = bll.GetResult1(date, flightno, depair, arrair); string json = Newtonsoft.Json.JsonConvert.SerializeObject(ds.Tables[0], new Newtonsoft.Json.Converters.DataTableConverter()); context.Response.Write(json); } catch (Exception) { context.Response.Write("输入有误,请重新输入!"); } }
private void RetryResult(string RFID, string MemberID, string OldRemarks) { try { string path = ReadText.ReadFilePath("datapath"); string pathSyncApplication = AppDomain.CurrentDomain.BaseDirectory + "SyncApplication"; string dateString = this.DateRelease.Year.ToString() + this.DateRelease.Month.ToString().PadLeft(2, '0') + this.DateRelease.Day.ToString().PadLeft(2, '0'); string resultDirectory = path + "\\result\\" + dateString; string resultLogs = pathSyncApplication + "\\resultlogs.txt"; string resultFileName = resultDirectory + "\\" + MemberID + "\\" + RFID + ".txt"; if (File.Exists(resultFileName)) { string[] resultdetails = ReadText.ReadTextFile(resultFileName); BusinessLayer.ResultBLL entryBll = new ResultBLL(); //sample ECLOCK 0001 15204188 19/07/05 07:48:18 String ResultStringFormat = "ECLOCK " + resultdetails[0] + " " + resultdetails[1] + " " + resultdetails[3] + " " + resultdetails[4]; DomainObjects.Result dObject = new DomainObjects.Result { ClubName = ClubName, SMSContent = ResultStringFormat, ActionFrom = "E-Clock Apps" }; DataSet dtResult = new DataSet(); dtResult = entryBll.EclockResultSave(dObject); if (dtResult.Tables.Count > 0) { if (dtResult.Tables[0].Rows.Count > 0) { String Remarks = dtResult.Tables[0].Rows[0]["Remarks"].ToString(); if (Remarks.ToUpper() != "SUCCESS") { String LogContents = MemberID + "|" + RFID + "|" + resultdetails[3] + "|" + Remarks + "|"; string removeFromLogsPath = pathSyncApplication + "\\resultlogs.txt"; if (!CheckRemarks(LogContents, removeFromLogsPath)) { if (File.Exists(resultLogs)) { using (StreamWriter sw = File.AppendText(resultLogs)) { sw.WriteLine(LogContents); } } else { using (StreamWriter sw = File.CreateText(resultLogs)) { sw.WriteLine(LogContents); } } } } else { //string pathSyncApplication = AppDomain.CurrentDomain.BaseDirectory + "SyncApplication"; string removeFromLogsPath = pathSyncApplication + "\\resultlogs.txt"; String removeFromLogs = MemberID + "|" + RFID + "|" + resultdetails[3] + "|" + OldRemarks + "|"; UpdateLogs(removeFromLogs, removeFromLogsPath); MessageBox.Show("Eclock entry sync to database.", "Eclock Sync"); } } } } ReadResultLogs(); } catch (Exception ex) { throw ex; } }
private static void SyncResultToDatabase() { try { string path = DataPath; string dateString = DateRelease; string rootApplicationDirectory = AppDomain.CurrentDomain.BaseDirectory; string resultDirectory = path + "result\\" + dateString; string resultLogs = rootApplicationDirectory + "resultlogs.txt"; //delete log file if (File.Exists(resultLogs)) { File.Delete(resultLogs); } if (Directory.Exists(resultDirectory)) { String[] filelist = Directory.GetFiles(resultDirectory); foreach (var item in filelist) { string filepath = item; string[] filename = filepath.Split('\\'); if (File.Exists(filepath)) { string[] resultList = ReadText.ReadTextFile(filepath); string[] memberid = filename[filename.Length - 1].Split('.'); //result is value is RFID foreach (var result in resultList) { string resultFileName = resultDirectory + "\\" + memberid[0] + "\\" + result + ".txt"; if (File.Exists(resultFileName)) { string[] resultdetails = ReadText.ReadTextFile(resultFileName); BusinessLayer.ResultBLL entryBll = new ResultBLL(); //sample ECLOCK 0001 15204188 19/07/05 07:48:18 String ResultStringFormat = "ECLOCK " + resultdetails[0] + " " + resultdetails[1] + " " + resultdetails[3] + " " + resultdetails[4]; DomainObjects.Result dObject = new DomainObjects.Result { ClubName = ClubName, SMSContent = ResultStringFormat, ActionFrom = "E-Clock Apps" }; DataSet dtResult = new DataSet(); dtResult = entryBll.EclockResultSave(dObject); if (dtResult.Tables.Count > 0) { if (dtResult.Tables[0].Rows.Count > 0) { String Remarks = dtResult.Tables[0].Rows[0]["Remarks"].ToString(); if (!Remarks.ToUpper().Contains("SUCCESS")) { //string[] rdetails = Remarks.Split('|'); String LogContents = memberid[0] + "|" + result + "|" + resultdetails[3] + "|" + Remarks + "|"; Console.WriteLine("----------------"); Console.WriteLine(memberid[0]); Console.WriteLine(result); Console.WriteLine(resultdetails[0]); Console.WriteLine(Remarks); Console.WriteLine("----------------"); if (File.Exists(resultLogs)) { using (StreamWriter sw = File.AppendText(resultLogs)) { sw.WriteLine(LogContents); } } else { using (StreamWriter sw = File.CreateText(resultLogs)) { sw.WriteLine(LogContents); } } } else { string[] rdetails = Remarks.Split('|'); //String LogContents = memberid[0] + "|" + result + "|" + resultdetails[3] + "|" + Remarks + "|"; Console.WriteLine("----------------"); Console.WriteLine(memberid[0]); Console.WriteLine(result); Console.WriteLine(resultdetails[0]); Console.WriteLine(rdetails[1]); //distance Console.WriteLine(rdetails[2]); //flight Console.WriteLine(rdetails[3]); //speed Console.WriteLine(rdetails[0]); //remarks Console.WriteLine("----------------"); if (File.Exists(resultFileName)) { string[] resultdetail = new string[] { rdetails[2], rdetails[3] }; resultdetails = resultdetails.Concat(resultdetail).Distinct().ToArray(); //string[] datacol = { MemberID, item, value[1], value[2], value[3] }; System.IO.File.WriteAllLines(resultFileName, resultdetails); //memberpigeonlist //using (StreamWriter sw = File.AppendText(resultFileName)) //{ // sw.WriteLine(rdetails[2]); //} //using (StreamWriter sw = File.AppendText(resultFileName)) //{ // sw.WriteLine(rdetails[3]); //} } } } } } } } } } } catch (Exception ex) { throw ex; } }