private void butt_ok_Click(object sender, EventArgs e) { MemoryStream stream = new MemoryStream(); pictureBoxLogo.Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] picbyte = stream.ToArray(); SqlCommand command = new SqlCommand(); command.Connection = objConnection; command.CommandType = CommandType.Text; command.CommandText = "UPDATE Tab_Shrkat SET name_shrkat=@name_shrkat, mahale_sabt=@mahale_sabt, noe_shrkat=@noe_shrkat, phone=@phone, sabt=@sabt, idposti=@idposti, address=@address, image_byte=@image_byte, kod_kargah=@kod_kargah, radif_peyman=@radif_peyman, nameshobe_bime=@nameshobe_bime, name_kargah=@name_kargah, kod_shemely=@kod_shemely, nerkhe_bime=@nerkhe_bime, sh_parvande=@sh_parvande, kod_shobe=@kod_shobe, noeasliepardakhtkonande=@noeasliepardakhtkonande, noefareiepardakhtkonande=@noefareiepardakhtkonande, name_shobe=@name_shobe, nahve_maliyat=@nahve_maliyat, pardakht_name=@pardakht_name, pardakht_family=@pardakht_family, pardakht_codemelli=@pardakht_codemelli, kod_egtesady=@kod_egtesady, nahve_pardakht=@nahve_pardakht, emza1_name=@emza1_name, emza1_family=@emza1_family, emza1_codemelli=@emza1_codemelli, emza1_semat=@emza1_semat, kod_TFN=@kod_TFN, kod_TIN=@kod_TIN, uuser=@uuser, udate=@udate, utime=@utime, upc=@upc WHERE (tmpid = " + id_group.ToString() + ")"; command.Parameters.AddWithValue("@name_shrkat", textBox1.Text); command.Parameters.AddWithValue("@mahale_sabt", textBox2.Text); command.Parameters.AddWithValue("@noe_shrkat", textBox3.Text); command.Parameters.AddWithValue("@phone", textBox4.Text); command.Parameters.AddWithValue("@sabt", textBox5.Text); command.Parameters.AddWithValue("@idposti", textBox6.Text); command.Parameters.AddWithValue("@address", textBox7.Text); command.Parameters.AddWithValue("@image_byte", picbyte); command.Parameters.AddWithValue("@kod_kargah", textBox8.Text); command.Parameters.AddWithValue("@radif_peyman", textBox9.Text); command.Parameters.AddWithValue("@nameshobe_bime", textBox10.Text); command.Parameters.AddWithValue("@name_kargah", textBox11.Text); command.Parameters.AddWithValue("@kod_shemely", textBox12.Text); command.Parameters.AddWithValue("@nerkhe_bime", textBox13.Text); command.Parameters.AddWithValue("@sh_parvande", textBox14.Text); command.Parameters.AddWithValue("@kod_shobe", textBox15.Text); command.Parameters.AddWithValue("@noeasliepardakhtkonande", db_Combo1.SelectedValue); command.Parameters.AddWithValue("@noefareiepardakhtkonande", db_Combo2.SelectedValue); command.Parameters.AddWithValue("@name_shobe", textBox16.Text); command.Parameters.AddWithValue("@nahve_maliyat", db_Combo3.SelectedValue); command.Parameters.AddWithValue("@pardakht_name", textBox17.Text); command.Parameters.AddWithValue("@pardakht_family", textBox18.Text); command.Parameters.AddWithValue("@pardakht_codemelli", textBox19.Text); command.Parameters.AddWithValue("@kod_egtesady", textBox20.Text); command.Parameters.AddWithValue("@nahve_pardakht", db_Combo4.SelectedValue); command.Parameters.AddWithValue("@emza1_name", textBox21.Text); command.Parameters.AddWithValue("@emza1_family", textBox22.Text); command.Parameters.AddWithValue("@emza1_codemelli", textBox23.Text); command.Parameters.AddWithValue("@emza1_semat", textBox24.Text); command.Parameters.AddWithValue("@kod_TFN", textBox25.Text); command.Parameters.AddWithValue("@kod_TIN", textBox26.Text); command.Parameters.AddWithValue("@uuser", "."); command.Parameters.AddWithValue("@udate", Database.u_date()); command.Parameters.AddWithValue("@utime", Database.u_time()); command.Parameters.AddWithValue("@upc", Database.u_pc()); objConnection.Open(); command.ExecuteNonQuery(); objConnection.Close(); command.Dispose(); MessageBox.Show(" اطلاعات با موفقیت ثبت شد ", "", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); }
//private void Bind_2_Grid_Good() //{ // string Qry = ""; // string[] Search_Data; // int i; // bool first = true; // if (textBox5.Text.Trim() == "") // Qry = "SELECT [tmpid]as[ردیف],[hogog]AS[حقوق],[shahr]as[عنوان],[mablag]as[مبلغ],[maliat]as[مالیات],[maliat_darsad]as[درصد مالیات],[bimeh_karfarma]as[بیمه کارفرما],[karfarma_darsad]as[درصد بیمه کارفرما],[bimeh_personel]as[بیمه پرسنل],[personel_dasad]as[درصد بیمه پرسنل],[bimeh_bikari]as[بیمه بیکاری],[bikari_darsad]as[درصد بیمه بیکاری],[noe]as[نوع] FROM [Tbl_hogog]"; // else // { // Search_Data = textBox5.Text.Split(' '); // Qry = "SELECT [tmpid]as[ردیف],[hogog]AS[حقوق],[shahr]as[عنوان],[mablag]as[مبلغ],[maliat]as[مالیات],[maliat_darsad]as[درصد مالیات],[bimeh_karfarma]as[بیمه کارفرما],[karfarma_darsad]as[درصد بیمه کارفرما],[bimeh_personel]as[بیمه پرسنل],[personel_dasad]as[درصد بیمه پرسنل],[bimeh_bikari]as[بیمه بیکاری],[bikari_darsad]as[درصد بیمه بیکاری],[noe]as[نوع] FROM [Tbl_hogog] WHERE ("; // for (i = 0; i < Search_Data.Length; i++) // { // if (Search_Data[i].Trim() != "") // { // if (first == false) // Qry += "And"; // Qry += "("; // if (database.Is_Numeric(Search_Data[i])) // { // Qry += "([tmpid] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([hogog] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([shahr] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([mablag] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([personel_dasad] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([maliat_darsad] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([karfarma_darsad] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([bikari_darsad] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([noe] like '%" + Search_Data[i] + "%')"; // } // else // { // Qry += "([tmpid] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([hogog] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([shahr] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([mablag] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([personel_dasad] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([maliat_darsad] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([karfarma_darsad] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([bikari_darsad] like '%" + Search_Data[i] + "%')"; // Qry += "Or ([noe] like '%" + Search_Data[i] + "%')"; // } // Qry += ")"; // first = false; // } // } // Qry += ")"; // } // database.Connection_Open(); // database.Fill(Qry, objDataSet, "Tbl_hogog", true); // database.Connection_Close(); // dataGridView1.DataSource = objDataSet.Tables["Tbl_hogog"]; //} //private void but_serch_Click(object sender, EventArgs e) //{ // // Bind_2_Grid_Good(); // String[] arrserarch; // arrserarch = new String[22]; // String[] arrserarch1; // arrserarch1 = new String[22]; // if (comboBox1.Text != "") // { // arrserarch[1] = " (hogog ='" + comboBox1.Text + "') AND "; // arrserarch1[1] = " ({Tbl_hogog.hogog} Like '" + comboBox1.Text + "') AND "; // } // if (comboBox3.Text != "") // { // arrserarch[2] = " (noe = '" + comboBox3.Text + "') AND "; // arrserarch1[2] = " ({Tbl_hogog.noe} Like '" + comboBox3.Text + "') AND "; // } // if (textBox1.Text != "") // { // arrserarch[3] = " (shahr= '" + textBox1.Text + "') AND "; // arrserarch1[3] = " ({Tbl_hogog.shahr} = '" + textBox1.Text + "') AND "; // } // if (textBox4.Text != "") // { // arrserarch[4] = " (mablag= '" + textBox4.Text + "') AND "; // arrserarch1[4] = " ({Tbl_hogog.mablag} = '" + textBox4.Text + "') AND "; // } // arrserarch[0] = arrserarch[1] + arrserarch[2] + arrserarch[3] + arrserarch[4] + arrserarch[5] + arrserarch[6]; // arrserarch1[0] = arrserarch1[1] + arrserarch1[2] + arrserarch1[3] + arrserarch1[4] + arrserarch1[5] + arrserarch1[6]; // objDataSet.Clear(); // if (arrserarch[0] == "") // { // database.Connection_Open(); // database.Fill("SELECT * FROM Tbl_hogog", objDataSet, "Tbl_hogog", true); // database.Connection_Close(); // dataGridView1.DataSource = objDataSet.Tables["Tbl_hogog"]; // } // else // { // arrserarch[0] = arrserarch[0].Substring(1, arrserarch[0].Length - 5); // arrserarch1[0] = arrserarch1[0].Substring(1, arrserarch1[0].Length - 5); // database.Connection_Open(); // database.Fill("SELECT * FROM Tbl_hogog WHERE " + arrserarch[0], objDataSet, "Tbl_hogog", true); // database.Connection_Close(); // dataGridView1.DataSource = objDataSet.Tables["Tbl_hogog"]; // } //} private void butt_ok_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex == -1) { MessageBox.Show("لطفا نوع کسورات و مزایا را وارد نمایید", "", MessageBoxButtons.OK, MessageBoxIcon.Error); comboBox1.Focus(); return; } if (comboBox3.SelectedIndex == -1) { MessageBox.Show("لطفا نوع را وارد نمایید", "", MessageBoxButtons.OK, MessageBoxIcon.Error); comboBox3.Focus(); return; } if (textBox1.Text == "") { MessageBox.Show("لطفا عنوان را وارد نمایید", "", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Focus(); return; } if (textBox4.Text == "") { MessageBox.Show("لطفا مبلغ را وارد نمایید", "", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox4.Focus(); return; } if (textBox2.Text == "") { MessageBox.Show("لطفا کد حسابداری را وارد نمایید", "", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox2.Focus(); return; } if (textBox3.Text == "") { MessageBox.Show("لطفا بیمه کارفرما را وارد نمایید", "", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox3.Focus(); return; } if (textBox7.Text == "") { MessageBox.Show("لطفا بیمه پرسنل را وارد نمایید", "", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox7.Focus(); return; } if (textBox6.Text == "") { MessageBox.Show("لطفا بیمه بیکاری را وارد نمایید", "", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox6.Focus(); return; } if (label3.Text == "ADD") { SqlCommand insert1 = new SqlCommand(); insert1.Connection = objConnection; objConnection.Open(); insert1.CommandText = "INSERT INTO [Tbl_hogog] ([hogog],[shahr],[mablag],[noe],[maliat],[bimeh_karfarma],[karfarma_darsad],[personel_dasad],[bikari_darsad],[uuser],[udate],[utime],[upc],IDnoe,idAccounting) Values (@hogog,@shahr,@mablag,@noe,@maliat,@bimeh_karfarma,@karfarma_darsad,@personel_dasad,@bikari_darsad,@uuser,@udate,@utime,@upc,@IDnoe,@idAccounting)"; insert1.CommandType = CommandType.Text; insert1.Parameters.AddWithValue("@hogog", comboBox1.Text); insert1.Parameters.AddWithValue("@shahr", textBox1.Text); insert1.Parameters.AddWithValue("@mablag", textBox4.Text); insert1.Parameters.AddWithValue("@IDnoe", comboBox3.SelectedIndex); insert1.Parameters.AddWithValue("@noe", comboBox3.Text); insert1.Parameters.AddWithValue("@maliat", checkBox1.Checked); insert1.Parameters.AddWithValue("@bimeh_karfarma", checkBox2.Checked); insert1.Parameters.AddWithValue("@karfarma_darsad", textBox3.Text); insert1.Parameters.AddWithValue("@bikari_darsad", textBox7.Text); insert1.Parameters.AddWithValue("@personel_dasad", textBox6.Text); insert1.Parameters.AddWithValue("@idAccounting", textBox2.Text); insert1.Parameters.AddWithValue("@uuser", ""); insert1.Parameters.AddWithValue("@udate", database.u_date()); insert1.Parameters.AddWithValue("@utime", database.u_time()); insert1.Parameters.AddWithValue("@upc", database.u_pc()); if (insert1.ExecuteNonQuery() > 0) { MessageBox.Show("ثبت با موفقیت انجام شد", "پيغام", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("خطا در ثبت", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error); } insert1.Dispose(); objConnection.Close(); delete(); } if (label3.Text == "EDIT") { SqlCommand insert1 = new SqlCommand(); insert1.Connection = objConnection; objConnection.Open(); insert1.CommandText = "UPDATE Tbl_hogog SET hogog=@hogog ,shahr=@shahr ,mablag=@mablag ,noe=@noe ,maliat=@maliat ,bimeh_karfarma=@bimeh_karfarma ,karfarma_darsad=@karfarma_darsad ,personel_dasad=@personel_dasad ,bikari_darsad=@bikari_darsad ,uuser=@uuser ,udate=@udate ,utime=@utime ,upc=@upc ,IDnoe=@IDnoe ,idAccounting=@idAccounting WHERE (tmpid = '" + label6.Text + "')"; insert1.CommandType = CommandType.Text; insert1.Parameters.AddWithValue("@hogog", comboBox1.Text); insert1.Parameters.AddWithValue("@shahr", textBox1.Text); insert1.Parameters.AddWithValue("@mablag", textBox4.Text); insert1.Parameters.AddWithValue("@IDnoe", comboBox3.SelectedIndex); insert1.Parameters.AddWithValue("@noe", comboBox3.Text); insert1.Parameters.AddWithValue("@maliat", checkBox1.Checked); insert1.Parameters.AddWithValue("@bimeh_karfarma", checkBox2.Checked); insert1.Parameters.AddWithValue("@karfarma_darsad", textBox3.Text); insert1.Parameters.AddWithValue("@bikari_darsad", textBox7.Text); insert1.Parameters.AddWithValue("@personel_dasad", textBox6.Text); insert1.Parameters.AddWithValue("@idAccounting", textBox2.Text); insert1.Parameters.AddWithValue("@uuser", ""); insert1.Parameters.AddWithValue("@udate", database.u_date()); insert1.Parameters.AddWithValue("@utime", database.u_time()); insert1.Parameters.AddWithValue("@upc", database.u_pc()); if (insert1.ExecuteNonQuery() > 0) { MessageBox.Show("اطلاعات با موفقیت ویرایش شد", "پيغام", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("خطا در ثبت", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error); } insert1.Dispose(); objConnection.Close(); delete(); } database.Connection_Open(); database.Fill("SELECT * FROM Tbl_hogog", objDataSet, "Tbl_hogog", true); database.Connection_Close(); dataGridView1.DataSource = objDataSet; dataGridView1.DataMember = "Tbl_hogog"; Grid_Amin(); }