myconnection a = new myconnection();
if (a.open())
{
dt.Clear();
MemoryStream ms = new MemoryStream();
pictureBox2.Image.Save(ms, pictureBox2.Image.RawFormat);
byte[] arrPic = ms.GetBuffer();
ms.Close();
a.com.CommandText = "select * from tb_receive_letter where id='" + txtnumber.Text + "' or codearchive='" + txtbaygani.Text + "'";
a.com.Connection = a.con;
a.da = new SqlDataAdapter(a.com);
a.da.Fill(dt);
if (dt.Rows.Count != 0)
{
MessageBox.Show("شماره نامه یا کد بایگانی تکراری است", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
if (MessageBox.Show("آیا از ثبت اطلاعات اطمینان دارید؟", "توجه", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
a.com.CommandText = "insert into tb_receive_letter (id,date,appendix,organization,statement,following ,actions,back,type,description,signature,codearchi ve,picorganization) values ('" + txtnumber.Text + "','" + irDateTimePicker1.Text + "','" + txtpeyvast.Text + "','" + txtsazman.Text + "','" + txtsharh.Text + "','" + txtpeyro.Text + "','" + txteghdam.Text + "','" + txtbazgasht.Text + "','" + cmbnoe.Text + "','" + txttozih.Text + "','" + txtemza.Text + "','" + txtbaygani.Text + "',@picorganization)";
a.com.Connection = a.con;
a.com.Parameters.Add("@picorganization", SqlDbType.VarBinary).Value = arrPic;
a.com.ExecuteNonQuery();
MessageBox.Show("اطلاعات با موفقیت ثبت گردید", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Information);
label8.Visible = false;
radioButton1.Checked = false;
radioButton2.Checked = false;
txtbazgasht.Text = "";
txtbaygani.Text = "";
txtemail.Text = "";
txteghdam.Text = "";
txtnumber.Text = "";
txtpeyvast.Text = "";
txtpeyro.Text = "";
txtsazman.Text = "";
txtsharh.Text = "";
txttozih.Text = "";
cmbnoe.Text = "";
txtemza.Text = "";
pictureBox1.Image = null;
pictureBox2.Image = null;
}
}
}