在c#&中创建搜索按钮按钮检索图像

时间:2015-04-05 21:55:06

标签: c# sql-server function search button

我有这个来源,我想创建一个搜索按钮,以找到id&名字和日期和非常重要(检索图像
&安培;
另一个搜索按钮,用于查找迄今为止记录的名称 例如21/2/2012& 2012/1/3 找到迄今为止的所有记录。

namespace _2015 { public partial class import : Form { public import() { InitializeComponent(); }

    private void bt_save_Click(object sender, EventArgs e)
    {
        byte[] imagebt = null;
        FileStream fstream = new FileStream(this.txt_ipath.Text, FileMode.Open, FileAccess.Read);
        BinaryReader br = new BinaryReader(fstream);
        imagebt = br.ReadBytes((int)fstream.Length);




        string constring = "Data Source=SKYNET-PC;Initial Catalog=2015;Integrated Security=True";
        string Query = "insert into t_import (id,name,barwar,imgc)" + "values('" + this.t_id.Text + "','" + this.t_name.Text + "','"+this.dt1.Text+"',@IMG); ";
        SqlConnection condatabase = new SqlConnection(constring);
        SqlCommand cmddatabase = new SqlCommand(Query, condatabase);
        SqlDataReader myreader;
        try
        {
            condatabase.Open();
            {

                cmddatabase.Parameters.Add(new SqlParameter("@IMG",imagebt));
                myreader = cmddatabase.ExecuteReader();


                MessageBox.Show("پاشەکەوت کرا");
                while (myreader.Read())
                {


                }
            }

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

    private void update_Click(object sender, EventArgs e)
    {
        string constring = "Data Source=SKYNET-PC;Initial Catalog=2015;Integrated Security=True";
        string Query = "update t_import set id='" + this.t_id.Text + "',name='" + this.t_name.Text + "' where id='"+this.t_id.Text+"' ; ";
        SqlConnection condatabase = new SqlConnection(constring);
        SqlCommand cmddatabase = new SqlCommand(Query, condatabase);
        SqlDataReader myreader;
        try
        {
            condatabase.Open();
            {
                myreader = cmddatabase.ExecuteReader();
                MessageBox.Show("بە سەرکەوتوویی نوێ کرایەوە");
                while (myreader.Read())
                {

            }
            }
        }

catch (Exception ex) { MessageBox.Show(ex.Message);

} } private void bt_delete_Click(object sender, EventArgs e) { string constring = "Data Source=SKYNET-PC;Initial Catalog=2015;Integrated Security=True"; string Query = "delete from t_import where id='" + this.t_id.Text + "' ; "; SqlConnection condatabase = new SqlConnection(constring); SqlCommand cmddatabase = new SqlCommand(Query, condatabase); SqlDataReader myreader; try { condatabase.Open(); { myreader = cmddatabase.ExecuteReader(); MessageBox.Show("بە سەرکەوتوویی سردرایەوە"); while (myreader.Read()) { } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void browse_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "JPG Files(*.jpg)|*.jpg|PNG Files(*.PNG)|*.png|All Files (*.*)|(*.*)"; if (dlg.ShowDialog() == DialogResult.OK) { string picpath = dlg.FileName.ToString(); txt_ipath.Text = picpath; pictureBox1.ImageLocation = picpath; } } private void pictureBox1_Click(object sender, EventArgs e) { } private void dt1_ValueChanged(object sender, EventArgs e) { } private void comboBox1_TextChanged(object sender, EventArgs e) { }

}     }

0 个答案:

没有答案