Пример #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            int k = 0;

            if (textBox2.Text.Length > 0 && comboBox1.Text.Length > 0 && comboBox2.Text.Length > 0 && textBox7.Text.Length > 0)
            {
                if (comboBox2.Text == "materials")
                {
                    if (comboBox4.Text.Length > 0 && textBox12.Text.Length > 0 && textBox13.Text.Length > 0)
                    {
                        if (radioButton4.Checked == true)
                        {
                            mat_con_lab = new String[] { radioButton4.Text, textBox10.Text, "", comboBox4.Text, textBox12.Text, textBox13.Text, "", "", "", "", "", "", "" }
                        }
                        ;
                        else
                        {
                            mat_con_lab = new String[] { radioButton5.Text, "", comboBox8.Text, comboBox4.Text, textBox12.Text, textBox13.Text, "", "", "", "", "", "", "" }
                        };
                    }
                    else
                    {
                        k = 1;
                    }
                }
                else if (comboBox2.Text == "labour charge")
                {
                    if ((comboBox6.Text.Length > 0 && textBox3.Text.Length > 0) || (textBox11.Text.Length > 0 && comboBox5.Text.Length > 0 && textBox14.Text.Length > 0 && textBox5.Text.Length > 0))
                    {
                        if (radioButton7.Checked == true)
                        {
                            mat_con_lab = new String[] { "", "", "", "", "", "", comboBox6.Text, textBox3.Text, "", "", "", "", "sub contract" }
                        }
                        ;
                        else
                        {
                            mat_con_lab = new String[] { "", "", "", "", "", "", "", "", comboBox5.Text, textBox5.Text, textBox11.Text, textBox14.Text, "daily wages" }
                        };
                    }
                    else
                    {
                        k = 1;
                    }
                }
                else
                {
                    if (comboBox3.Text.Length > 0)
                    {
                        mat_con_lab = new String[] { "", "", "", comboBox3.Text, "", "", "", "", "", "", "", "", "" };
                    }
                    else
                    {
                        k = 1;
                    }
                }
                if (radioButton2.Checked == true)
                {
                    if (textBox1.Text.Length == 0 && textBox8.Text.Length == 0 && textBox9.Text.Length == 0)
                    {
                        k = 1;
                    }
                    sql   = "insert into addexdetails (date,name,exacc,item,des,amnt,bnkname,chqno,chqdt,mthd,mat_trans_mat_pur,frm_shop,frm_site,mat_quan,mat_unit,nam_contract ,typ_wrk,subcont_dwage, d_wage, d_num, d_name, d_cat) values ('" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "','" + comboBox1.Text + "','" + comboBox2.Text + "','" + mat_con_lab[3] + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + textBox1.Text + "','CHECK','" + mat_con_lab[0] + "','" + mat_con_lab[1] + "','" + mat_con_lab[2] + "','" + mat_con_lab[4] + "','" + mat_con_lab[5] + "','" + mat_con_lab[6] + "','" + mat_con_lab[7] + "','" + mat_con_lab[12] + "','" + mat_con_lab[11] + "','" + mat_con_lab[10] + "','" + mat_con_lab[9] + "','" + mat_con_lab[8] + "');";
                    print = new string[] { dateTimePicker1.Value.ToString("dd-MM-yyyy"), comboBox1.Text, textBox7.Text, "CHECK", comboBox2.Text, comboBox3.Text, textBox9.Text, textBox1.Text, textBox8.Text };
                }
                else if (radioButton3.Checked == true)
                {
                    if (textBox8.Text.Length == 0)
                    {
                        k = 1;
                    }
                    sql   = "insert into addexdetails (date,name,exacc,item,des,amnt,bnkname,mthd,mat_trans_mat_pur,frm_shop,frm_site,mat_quan,mat_unit,nam_contract ,typ_wrk,subcont_dwage, d_wage, d_num, d_name, d_cat) values ('" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "','" + comboBox1.Text + "','" + comboBox2.Text + "','" + mat_con_lab[3] + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','BANK','" + mat_con_lab[0] + "','" + mat_con_lab[1] + "','" + mat_con_lab[2] + "','" + mat_con_lab[4] + "','" + mat_con_lab[5] + "','" + mat_con_lab[6] + "','" + mat_con_lab[7] + "','" + mat_con_lab[12] + "','" + mat_con_lab[11] + "','" + mat_con_lab[10] + "','" + mat_con_lab[9] + "','" + mat_con_lab[8] + "');";
                    print = new string[] { dateTimePicker1.Value.ToString("dd-MM-yyyy"), comboBox1.Text, textBox7.Text, "BANK", comboBox2.Text, comboBox3.Text, textBox8.Text };
                }
                else
                {
                    sql   = "insert into addexdetails (date,name,exacc,item,des,amnt,mthd,mat_trans_mat_pur,frm_shop,frm_site,mat_quan,mat_unit,nam_contract,typ_wrk,subcont_dwage, d_wage, d_num, d_name, d_cat) values ('" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "','" + comboBox1.Text + "','" + comboBox2.Text + "','" + mat_con_lab[3] + "','" + textBox6.Text + "','" + textBox7.Text + "','CASH','" + mat_con_lab[0] + "','" + mat_con_lab[1] + "','" + mat_con_lab[2] + "','" + mat_con_lab[4] + "','" + mat_con_lab[5] + "','" + mat_con_lab[6] + "','" + mat_con_lab[7] + "','" + mat_con_lab[12] + "','" + mat_con_lab[11] + "','" + mat_con_lab[10] + "','" + mat_con_lab[9] + "','" + mat_con_lab[8] + "');";
                    print = new string[] { dateTimePicker1.Value.ToString("dd-MM-yyyy"), comboBox1.Text, textBox7.Text, "CASH", comboBox2.Text, comboBox3.Text };
                }
                if (k == 0)
                {
                    using (SQLiteConnection cnn = new SQLiteConnection(dbConnection))
                    {
                        SQLiteCommand sqlCmd = new SQLiteCommand(sql, cnn);
                        cnn.Open();
                        int a = sqlCmd.ExecuteNonQuery();

                        textBox6.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = ""; textBox1.Text = "";
                        textBox2.Text = "";

                        combo_load();
                        imainhd_load();
                        comboBox2_SelectedIndexChanged(null, null);
                        //comboBox2.ResetText();
                        if (q == 1)
                        {
                            MessageBox.Show("SAVED SUCCEFULLY");
                        }
                        else
                        {
                            Form16 form16 = new Form16(print, mat_con_lab);
                            form16.ShowDialog();
                        }
                        q = 1;
                    }
                }
                else
                {
                    MessageBox.Show("Completely Fill data");
                }
            }
            else
            {
                MessageBox.Show("Completely Fill data");
            }
        }
Пример #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            int k = 0;

            if (textBox2.Text.Length > 0 && textBox5.Text.Length > 0 && comboBox2.Text.Length > 0 && textBox7.Text.Length > 0)
            {
                if (comboBox2.Text == "materials")
                {
                    if (comboBox4.Text.Length > 0 && textBox12.Text.Length > 0 && textBox13.Text.Length > 0)
                    {
                        if (radioButton4.Checked == true)
                        {
                            mat_con_lab = new String[] { radioButton4.Text, textBox10.Text, "", comboBox4.Text, textBox12.Text, textBox13.Text, "", "", "", "", "", "", "" }
                        }
                        ;
                        else
                        {
                            mat_con_lab = new String[] { radioButton5.Text, "", comboBox8.Text, comboBox4.Text, textBox12.Text, textBox13.Text, "", "", "", "", "", "", "" }
                        };
                    }
                    else
                    {
                        k = 1;
                    }
                }
                else if (comboBox2.Text == "labour charge")
                {
                    if ((comboBox6.Text.Length > 0 && textBox4.Text.Length > 0) || (textBox11.Text.Length > 0 && comboBox5.Text.Length > 0 && textBox14.Text.Length > 0 && textBox5.Text.Length > 0))
                    {
                        if (radioButton7.Checked == true)
                        {
                            mat_con_lab = new String[] { "", "", "", "", "", "", comboBox6.Text, textBox4.Text, "", "", "", "", "sub contract" }
                        }
                        ;
                        else
                        {
                            mat_con_lab = new String[] { "", "", "", "", "", "", "", "", comboBox5.Text, textBox5.Text, textBox11.Text, textBox14.Text, "daily wages" }
                        };
                    }
                    else
                    {
                        k = 1;
                    }
                }
                else
                {
                    if (comboBox3.Text.Length > 0)
                    {
                        mat_con_lab = new String[] { "", "", "", comboBox3.Text, "", "", "", "", "", "", "", "", "" };
                    }
                    else
                    {
                        k = 1;
                    }
                }
                if (radioButton2.Checked == true)
                {
                    if (textBox1.Text.Length == 0 && textBox8.Text.Length == 0 && textBox9.Text.Length == 0)
                    {
                        k = 1;
                    }
                    sql   = "update  addexdetails set  date ='" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "',name ='" + textBox5.Text + "',exacc ='" + comboBox2.Text + "',item ='" + mat_con_lab[3] + "',des ='" + textBox6.Text + "',amnt ='" + textBox7.Text + "',bnkname ='" + textBox8.Text + "',chqno ='" + textBox9.Text + "',chqdt ='" + textBox1.Text + "',mthd ='CHECK',mat_trans_mat_pur ='" + mat_con_lab[0] + "',frm_shop ='" + mat_con_lab[1] + "',frm_site= '" + mat_con_lab[2] + "',mat_quan='" + mat_con_lab[4] + "',mat_unit ='" + mat_con_lab[5] + "',nam_contract = '" + mat_con_lab[6] + "' ,typ_wrk = '" + mat_con_lab[7] + "',subcont_dwage = '" + mat_con_lab[12] + "', d_wage = '" + mat_con_lab[11] + "', d_num = '" + mat_con_lab[10] + "', d_name = '" + mat_con_lab[9] + "', d_cat = '" + mat_con_lab[8] + "' where id ='" + row.Cells[0].Value.ToString() + "'";
                    print = new string[] { dateTimePicker1.Value.ToString("dd-MM-yyyy"), textBox2.Text, textBox7.Text, "CHECK", comboBox2.Text, comboBox3.Text, textBox9.Text, textBox1.Text, textBox8.Text };
                }
                else if (radioButton3.Checked == true)
                {
                    if (textBox8.Text.Length == 0)
                    {
                        k = 1;
                    }
                    sql   = "update  addexdetails set  date ='" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "',name ='" + textBox5.Text + "',exacc ='" + comboBox2.Text + "',item ='" + mat_con_lab[3] + "',des ='" + textBox6.Text + "',amnt ='" + textBox7.Text + "',bnkname ='" + textBox8.Text + "',mthd ='BANK',mat_trans_mat_pur ='" + mat_con_lab[0] + "',frm_shop ='" + mat_con_lab[1] + "',frm_site= '" + mat_con_lab[2] + "',mat_quan='" + mat_con_lab[4] + "',mat_unit ='" + mat_con_lab[5] + "',nam_contract = '" + mat_con_lab[6] + "' ,typ_wrk = '" + mat_con_lab[7] + "',subcont_dwage = '" + mat_con_lab[12] + "', d_wage = '" + mat_con_lab[11] + "', d_num = '" + mat_con_lab[10] + "', d_name = '" + mat_con_lab[9] + "', d_cat = '" + mat_con_lab[8] + "' where id ='" + row.Cells[0].Value.ToString() + "'";
                    print = new string[] { dateTimePicker1.Value.ToString("dd-MM-yyyy"), textBox2.Text, textBox7.Text, "BANK", comboBox2.Text, comboBox3.Text, textBox8.Text };
                }
                else
                {
                    sql   = "update  addexdetails set  date ='" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "',name ='" + textBox5.Text + "',exacc ='" + comboBox2.Text + "',item ='" + mat_con_lab[3] + "',des ='" + textBox6.Text + "',amnt ='" + textBox7.Text + "',mthd ='CASH',mat_trans_mat_pur ='" + mat_con_lab[0] + "',frm_shop ='" + mat_con_lab[1] + "',frm_site= '" + mat_con_lab[2] + "',mat_quan='" + mat_con_lab[4] + "',mat_unit ='" + mat_con_lab[5] + "',nam_contract = '" + mat_con_lab[6] + "' ,typ_wrk = '" + mat_con_lab[7] + "',subcont_dwage = '" + mat_con_lab[12] + "', d_wage = '" + mat_con_lab[11] + "', d_num = '" + mat_con_lab[10] + "', d_name = '" + mat_con_lab[9] + "', d_cat = '" + mat_con_lab[8] + "' where id ='" + row.Cells[0].Value.ToString() + "'";
                    print = new string[] { dateTimePicker1.Value.ToString("dd-MM-yyyy"), textBox2.Text, textBox7.Text, "CASH", comboBox2.Text, comboBox3.Text };
                }
                if (k == 0)
                {
                    using (SQLiteConnection cnn = new SQLiteConnection(dbConnection))
                    {
                        SQLiteCommand sqlCmd = new SQLiteCommand(sql, cnn);
                        cnn.Open();
                        int a = sqlCmd.ExecuteNonQuery();
                        if (q == 1)
                        {
                            MessageBox.Show("SAVED SUCCESSFULLY");
                        }
                        else
                        {
                            Form16 form16 = new Form16(print, mat_con_lab);
                            form16.ShowDialog();
                        }
                        q = 1;
                    }
                }
                else
                {
                    MessageBox.Show("Completely Fill data");
                }
            }
            else
            {
                MessageBox.Show("Completely Fill data");
            }
        }