public static void CarInRecordBMember(string intID, string strCarType, string strLicense, string strRandKey, string strImageD, string strImageL, string BackupDirectory, string guardhouse) { DateTime now = DateTime.Now; string folder = now.Month.ToString(); string strFile = BackupDirectory + "\\" + folder; if (!Directory.Exists(strFile)) { Directory.CreateDirectory(strFile); } strFile = strFile + "\\InBackup_" + now.ToString("ddMMyyyy") + ".csv"; string strHeader = "sql,no,id,cartype,license,rankey,picdiv,piclic,datein,userin,guardhouse"; string sql = "INSERT INTO recordin VALUES (";// strImageL = strImageL.Replace("\\", "\\\\"); strImageD = strImageD.Replace("\\", "\\\\"); //sql += RecordNo.ToString() + "," + intID.ToString() + "," + strCarType + ",'" + strLicense + "','" + strRandKey + "','" + strImageD + "','" + strImageL + "',NOW()," + user.ID + "," + proID.ToString() + ");"; //Mac 2014/10/13 sql += RecordNo2.ToString() + "," + intID + "," + strCarType + ",(SELECT license FROM member WHERE cardid = " + intID + "),'" + strRandKey + "','" + strImageD + "','" + strImageL + "'," + now.ToString("yyyy-MM-dd HH:mm:ss") + "," + 1 + "," + 0 + ",'" + guardhouse + "');"; //Mac 2014/10/13 //string strRecord = RecordNo.ToString() + "," + intID.ToString() + "," + strCarType + "," + strLicense + "," + strRandKey + "," + strImageD + "," + strImageL + "," + now.ToString() + "," + user.ID + ")";// if (!File.Exists(strFile)) { StreamWriter sw = File.CreateText(strFile); sw.WriteLine(strHeader); sw.WriteLine(sql); sw.Flush(); sw.Close(); } else { FileStream MyFileStream = new FileStream(strFile, FileMode.Append, FileAccess.Write, FileShare.Read); StreamWriter sw = new StreamWriter(MyFileStream); sw.WriteLine(sql); sw.Close(); MyFileStream.Close(); } }
static public bool CarInRecordMember(string intID, string strCarType, string strLicense, string strRandKey, string strImageD, string strImageL, string guardhouse)// Bitmap bmL, Bitmap bmD { try { getRecordNo(); RecordNo2++; string sql = "INSERT INTO recordin (no,id,cartype,license,rankey,picdiv,piclic,datein,userin,guardhouse) VALUES (";// strImageL = strImageL.Replace("\\", "\\\\"); strImageD = strImageD.Replace("\\", "\\\\"); sql += RecordNo2.ToString() + "," + intID + "," + strCarType + ",(SELECT license FROM member WHERE cardid = " + intID + "),'" + strRandKey + "','" + strImageD + "','" + strImageL + "',NOW()," + 1 + ",'" + guardhouse + "')";// if (db.SaveData(sql) == "") { return(true); } else { return(false); } } catch (Exception e) { return(false); } }
private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e) { SerialPort sp = (SerialPort)sender; int dataInt = sp.ReadByte(); string dataString = Convert.ToString(dataInt, 2).PadLeft(8, '0'); if (dataString[0] == '1') { connectBoard = true; } if (dataString[2] == '1') { picLoop.Image = active[0];//Loop loopDetect = true; } else { picLoop.Image = deactive[0]; loopDetect = false; if (ready) { ready = false; if (writeBlock) { writeBlock = false; } readError = 0; dispenserControl.callBack(); Thread.Sleep(3000); tmReader.Enabled = true; } } if (dataString[3] == '1')//Red Btn { playSound(3); if (rdBack.Checked) { takePhotoBack(true); } if (rdFore.Checked) { takePhotoFore(true); } if (ledDisplay.sendData) { ledDisplay.setText("Pls.wait officers were coming in", 3); } picRed.Image = active[1]; } else { picRed.Image = deactive[1]; } if (dataString[4] == '1') { picGreen.Image = active[2]; //Green Btn } else { picGreen.Image = deactive[2]; } if (dataString[5] == '1') { picReadOk.Image = active[3]; // Read OK } else { picReadOk.Image = deactive[3]; } if (dataString[6] == '1') { picLow.Image = active[4]; //Low } else { picLow.Image = deactive[4]; } if (dataString[7] == '1') { picEmpty.Image = active[5]; //Empty } else { picEmpty.Image = deactive[5]; } if (dataString[1] == '1') {//Ready State // playSound(4); if (rdBack.Checked) { takePhotoBack(false); } if (rdFore.Checked) { takePhotoFore(false); } if (ledDisplay.sendData) { ledDisplay.setText("PullCard", 3); } ready = true; Thread.Sleep(1000); // SetText7("บัตรพร้อมหยิบ"); } Console.WriteLine(dataString); if (client.Connect2Server(txtSendData.Text, 8100)) { client.Send2Server(dataString); } if (dataString[5] == '0' && ready) { //ดึงบัตร //Save Data if (CarInRecord(intIDV.ToString(), "0", "NO", "", strFileD, strFileL)) { tmReader.Enabled = false; string sql = "UPDATE card" + typeCard + " SET no =" + RecordNo2.ToString(); sql += " WHERE name=" + intIDV.ToString(); db.SaveData(sql); CarInRecordB(intIDV.ToString(), "0", "NO", "", strFileD, strFileL, txtBackupDir.Text); ready = false; if (ledDisplay.sendData) { ledDisplay.setText("Welcome", 3); } playSound(1); dispenserControl.liftOut(); dispenserControl.portHandle.Write("W\r"); Thread.Sleep(3000); writeBlock = false; if (ledDisplay.sendData) { ledDisplay.setText("Creative Innovation Technology", 3); } tmReader.Enabled = true; } // label13.Text = "ReadOK "; } if (dataString[2] == '1') { if (!loopSpeaking) { playSound(2); if (ledDisplay.sendData) { ledDisplay.setText("Press Green Button", 3); } loopSpeaking = true; } } else { if (loopSpeaking) { if (ledDisplay.sendData) { ledDisplay.setText("Creative Innovation Technology", 3); } } loopSpeaking = false; } }
private void tmReaderMember_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { if (mifaMember.chkCard()) { tmReaderMember.Enabled = false; mifaMember.setLED(0); mifaMember.setSound(1); Thread.Sleep(200); mifaMember.setLED(1); mifaMember.setSound(1); string strId = mifaMember.Init1(); if (strId != "" && loopDetect) { uint intID = Convert.ToUInt32(strId, 16); if (checkCardM(intID)) { if (CardLevelM > 1) { DataTable dt = db.LoadData("select cartype, license from member where cardid = " + intID.ToString()); if (dt != null && dt.Rows.Count > 0) { if (rdBack.Checked) { takePhotoBack(false); } if (rdFore.Checked) { takePhotoFore(false); } if (CarInRecordMember(intID.ToString(), dt.Rows[0].ItemArray[0].ToString() , dt.Rows[0].ItemArray[1].ToString(), "", strFileD, strFileL, "")) { string sql = "UPDATE card" + typeCardM + " SET no =" + RecordNo2.ToString(); sql += " WHERE name=" + intID.ToString(); db.SaveData(sql); CarInRecordBMember(intID.ToString(), dt.Rows[0].ItemArray[0].ToString() , dt.Rows[0].ItemArray[1].ToString(), "", strFileD, strFileL, txtBackupDir.Text, ""); playSound(1); if (ledDisplay.sendData) { ledDisplay.setText("Welcome", 3); } dispenserControl.liftOut(); } } if (ledDisplay.sendData) { ledDisplay.setText("Creative Innovation Technology", 3); } Thread.Sleep(2000); } } } tmReaderMember.Enabled = true; } }