private void buttonLogin_Click(object sender, EventArgs e) { ModuleClass.MyMeans MyClass = new ModuleClass.MyMeans(); if (textName.Text != "" & textPass.Text != "") { SqlDataReader temDR = MyClass.getcom("select * from Table_Login where Name='" + textName.Text.Trim() + "'and Password='******'"); bool ifcom = temDR.Read(); //用Read方法读取数据 if (ifcom) { ModuleClass.MyMeans.Login_Name = textName.Text.Trim(); ModuleClass.MyMeans.Login_ID = temDR.GetString(0); ModuleClass.MyMeans.My_con.Close(); ModuleClass.MyMeans.My_con.Dispose(); // ModuleClass.MyMeans.Login_n = (int)(this.Tag); MessageBox.Show("登录成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); MainForm fm = new MainForm(); fm.ShowDialog(); } else { MessageBox.Show("用户名或密码错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textName.Text = ""; textPass.Text = ""; } MyClass.con_close(); } else { MessageBox.Show("请将登录信息填写完整!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
// // // //加载窗体 // // private void unionpay_charge_Load(object sender, EventArgs e) { ModuleClass.MyMeans MyData = new ModuleClass.MyMeans(); SqlDataReader ucDR = MyData.getcom("select * from Table_Cars where License_Plate='" + label_lincensenum_c.Text + "'"); bool ifcom = ucDR.Read(); label_outtime_c.Text = ucDR["Outprt_Time"].ToString(); label_intime_c.Text = ucDR["Inport_Time"].ToString(); //从数据库获取入场时间 label_cartype_c.Text = ucDR["Car_Type"].ToString(); label_area_c.Text = ucDR["Area_Type"].ToString(); DateTime out_time = Convert.ToDateTime(ucDR["Outprt_Time"].ToString()); DateTime in_time = Convert.ToDateTime(ucDR["Inport_Time"].ToString()); label7_sumtime.Text = Ts(in_time, out_time).Days.ToString() + "天" + Ts(in_time, out_time).Hours.ToString() + "小时" + Ts(in_time, out_time).Minutes.ToString() + "分钟" + Ts(in_time, out_time).Seconds.ToString() + "秒"; //获取停车时间 //获取收费金额 label_chargenum.Text = amount_of_money(Ts(in_time, out_time), ucDR["Car_Type"].ToString(), ucDR["Area_Type"].ToString()).ToString() + "元"; InitPort();//在窗体加载时初始化串口 }
private void button_out_Click(object sender, EventArgs e) { if (textbox_licnese_plate.Text == "") { MessageBox.Show("请输入车牌号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { ModuleClass.MyMeans MyData = new ModuleClass.MyMeans(); SqlDataReader temDR = MyData.getcom("select * from Table_Cars where License_Plate='" + textbox_licnese_plate.Text.Trim() + "'"); bool ifcom = temDR.Read(); if (!ifcom) { MessageBox.Show("停车场无此车辆", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { In_time_label.Text = temDR["Inport_Time"].ToString(); Out_time_label.Text = System.DateTime.Now.ToString(); label_license_num.Text = temDR["License_Plate"].ToString(); label_name.Text = temDR["Owner_Name"].ToString(); label_cartype.Text = temDR["Car_Type"].ToString(); label_ID.Text = temDR["Card_ID"].ToString(); label_Area.Text = temDR["Area_Type"].ToString(); //更新界面车辆信息 MyData.getsqlcom("update Table_Cars set Outprt_Time='" + System.DateTime.Now.ToString() + "' where License_Plate='" + textbox_licnese_plate.Text.Trim() + "'"); //初始化数据库 存图片 // string picturepath = @"F:\unionpay\IMG_8439.JPG"; // FileStream fs = new FileStream(picturepath, FileMode.Open, FileAccess.Read); // SqlCommand cmd = new SqlCommand("update Table_Cars(Inport_Image) values(@Inport_Image"); // fs.Position = 0; // BinaryReader br = new BinaryReader(fs); // byte[] imgByTesin = br.ReadBytes((int)fs.Length); // cmd.Parameters.Add("@Inport_Image", SqlDbType.Image).Value = imgByTesin; //////***************存储图片存疑???????????? // MyData.getsqlcom("update Table_Cars set Inport_Image='" + imgByTesin + "' where License_Plate='" + textbox_licnese_plate.Text.Trim() + "'"); // //读取图片 // Byte[] myByte = new Byte[0]; // myByte = (Byte[])temDR["Inport_Image"]; // if (myByte == null) // { // MessageBox.Show("未查询到图片", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // } // else { // MessageBox.Show(myByte, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // MemoryStream ms = new MemoryStream(myByte); // pictureBox_in.Image = System.Drawing.Image.FromStream(ms,true); // this.pictureBox_in.SizeMode = PictureBoxSizeMode.Zoom; } // unionpay_charge fm = new unionpay_charge(); fm.label_lincensenum_c.Text = textbox_licnese_plate.Text.Trim();//向子窗口传值 // fm.label_outtime_c.Text = Out_time_label.Text; ModuleClass.MyMeans.My_con.Close(); ModuleClass.MyMeans.My_con.Dispose(); MyData.con_close(); fm.Show(); } } }