예제 #1
0
        private void saveAll(object sender, EventArgs e)
        {
            try
            {
                Member member = new Member();
                User u = new User();
                String unionid = "D" + district_no.Text + "T" + thana_no.Text + "U" + union_no.Text +"";
                String cncid = "D" + district_no.Text + "T" + thana_no.Text + "U" + union_no.Text + "C" + cncbox.Text + "";
                String khanaid = "D" + district_no.Text + "T" + thana_no.Text + "U" + union_no.Text + "C" + cncbox.Text + "K" + khanabox.Text + "";
                //MessageBox.Show(khanaid);
                Khana k = new Khana();
                Cnc c = new Cnc ();

                bool cncexists = c.exist(cncid);
                if (cncexists == false)
                {
                    cncexists = c.insert(Convert.ToInt32(cncbox.Text),cncid,unionid);
                }
                if (cncexists)
                {
                    bool inserted = k.Insert(
                    Convert.ToInt32(khanabox.Text),
                    cncid,
                    userid,
                    Convert.ToInt32(chalabox.Text),
                    Convert.ToInt32(wallbox.Text),
                    Convert.ToInt32(floorbox.Text),
                    Convert.ToInt32(watersourcebox.Text),
                    Convert.ToInt32(evaluationbox.Text),
                    Convert.ToInt32(housevaluebox.Text),
                    Convert.ToInt32(totallandbox.Text),
                    Convert.ToInt32(landvaluebox.Text),
                    Convert.ToInt32(cowbox.Text),
                    Convert.ToInt32(goatbox.Text),
                    Convert.ToInt32(henbox.Text),
                    Convert.ToInt32(treebox.Text),
                    Convert.ToInt32(vegitablebox.Text),
                    Convert.ToInt32(monthscoveredbox.Text),
                    Convert.ToInt32(bedbox.Text),
                    Convert.ToInt32(chairbox.Text),
                    Convert.ToInt32(radiobox.Text),
                    Convert.ToInt32(tvbox.Text),
                    Convert.ToInt32(tubewellbox.Text),
                    Convert.ToInt32(gavibox.Text),
                    Convert.ToInt32(sagolbox.Text),
                    Convert.ToInt32(daylabourerbox.Text),
                    Convert.ToInt32(dayslabourbox.Text),
                    Convert.ToInt32(latrinebox.Text),
                    Convert.ToString(datacollectorbox.Text),
                    Convert.ToString(cnocnpbox.Text),
                    Convert.ToString(datebox.Text),
                    khanaid);
                    if (inserted)
                    {
                        //u.increaseKhanaCount(userid);
                        //khanacountbox.Text = u.getKhanaCount(userid).ToString();
                        int i = dataGridView1.RowCount - 1;
                        // MessageBox.Show(i.ToString());
                        for (int j = 0; j < i; j++)
                        {
                            int mother = 0;
                            float age = 0;
                            int day = 0, month = 0, year = 0;
                            float weights = 0;
                            int heights = 0;
                            int paritys = 0;
                            int maritalyear=88;
                            String memberid = "D" + district_no.Text + "T" + thana_no.Text + "U" + union_no.Text + "C" + cncbox.Text + "K" + khanabox.Text + "M" + Convert.ToInt32(dataGridView1[0, j].Value) + "";
                            if (dataGridView1[4, j].Value.ToString().Length > 0)
                            {
                                age = float.Parse(dataGridView1[4, j].Value.ToString());
                            }
                            String dob = Convert.ToString(dataGridView1[5, j].Value);
                            String[] dobs = dob.Split('/');
                            if (dobs[0].Length > 0)
                            {
                                day = Convert.ToInt32(dobs[0]);
                            }
                            if (dobs[1].Length > 0)
                            {
                                month = Convert.ToInt32(dobs[1]);
                            }
                            if (dobs[2].Length > 0)
                            {
                                year = Convert.ToInt32(dobs[2]);
                            }
                            if (dataGridView1[8, j].Value.ToString().Length > 0)
                            {
                                maritalyear= Convert.ToInt32(dataGridView1[8, j].Value);
                            }
                            if (dataGridView1[11, j].Value.ToString().Length > 0)
                            {
                                weights = float.Parse(dataGridView1[11, j].Value.ToString());
                            }
                            if (dataGridView1[12, j].Value.ToString().Length > 0)
                            {
                                heights = Convert.ToInt32(dataGridView1[12, j].Value);
                            }
                            if (dataGridView1[13, j].Value.ToString().Length > 0)
                            {
                                paritys = int.Parse( (dataGridView1[13, j].Value.ToString()));
                            }
                            if (dataGridView1[1, j].Value.ToString().Length > 0)
                            {
                                mother=Convert.ToInt32(dataGridView1[1, j].Value);
                            }
                            if (dobs[2].Length == 4)
                            {
                                if (Math.Abs(24121 - (year * 12 + month)) <= 24)
                                    age = age / 12;
                            }
                            if (dobs[2].Length == 2)
                            {
                                if (Math.Abs(121 - (year * 12 + month)) <= 24)
                                    age = age / 12;
                            }
                            if (dobs[2].Length == 1)
                            {
                                if (Math.Abs(121 - (year * 12 + month)) <= 24)
                                    age = age / 12;
                            }

                            bool Memberinserted = member.Insert(
                                memberid,
                                Convert.ToInt32(dataGridView1[0, j].Value),
                                mother,
                                Convert.ToString(dataGridView1[2, j].Value),
                                Convert.ToInt32(dataGridView1[3, j].Value),
                                age,
                                Convert.ToString(dataGridView1[5, j].Value),
                                Convert.ToInt32(dataGridView1[6, j].Value),
                                Convert.ToInt32(dataGridView1[7, j].Value),
                                maritalyear,
                                Convert.ToInt32(dataGridView1[9, j].Value),
                                weights/10,
                                heights,
                                paritys,
                                Convert.ToInt32(dataGridView1[10, j].Value),
                                khanaid);
                            if (!Memberinserted)
                            {
                                //u.increaseMemberCount(userid);

                            }
                        }

                        khanabox.Clear();
                        chalabox.Clear();
                        wallbox.Clear();
                        floorbox.Clear();
                        watersourcebox.Clear();
                        evaluationbox.Clear();
                        housevaluebox.Clear();
                        totallandbox.Clear();
                        landvaluebox.Clear();
                        cowbox.Clear();
                        goatbox.Clear();
                        henbox.Clear();
                        treebox.Clear();
                        vegitablebox.Clear();
                        monthscoveredbox.Clear();
                        bedbox.Clear();
                        chairbox.Clear();
                        radiobox.Clear();
                        tvbox.Clear();
                        tubewellbox.Clear();
                        gavibox.Clear();
                        sagolbox.Clear();
                        daylabourerbox.Clear();
                        dayslabourbox.Clear();
                        latrinebox.Clear();
                        datacollectorbox.Clear();
                        cnocnpbox.Clear();
                        datebox.Clear();
                        //membercountbox.Text = u.getMemberCount(userid).ToString();
                        dataGridView1.Rows.Clear();
                        khanabox.Select();
                        i = 0;
                    }
                }
                else
                {

                    k.delete(khanaid);
                    member.delete(khanaid);
                    MessageBox.Show("Please check your inputs again");
                }

            }
            catch (Exception ex) {
                editbutton_Click(sender, e);
                MessageBox.Show("Sorry all data you enter is not saved. \nThe data may not contain all required field . \nPlease re entry not saved information again and click DONE button.");

            }
        }
예제 #2
0
        private void editToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            try
            {
                Khana k = new Khana();
                Member m = new Member();
                //User u = new User();
                String khanaid = "D" + district_no.Text + "T" + thana_no.Text + "U" + union_no.Text + "C" + cncbox.Text + "K" + khanabox.Text + "";
                if (k.getUserId(khanaid) == userbox.Text)
                {
                    save.Visible = false;
                    dataGridView1.Rows.Clear();
                    String[] info = k.getAll(khanaid);
                    chalabox.Text = info[0];
                    wallbox.Text = info[1];
                    floorbox.Text = info[2];
                    housevaluebox.Text = info[3];
                    totallandbox.Text = info[4];
                    landvaluebox.Text = info[5];
                    cowbox.Text = info[6];
                    goatbox.Text = info[7];
                    henbox.Text = info[8];
                    treebox.Text = info[9];
                    vegitablebox.Text = info[10];
                    monthscoveredbox.Text = info[11];
                    bedbox.Text = info[12];
                    chairbox.Text = info[13];
                    radiobox.Text = info[14];
                    tvbox.Text = info[15];
                    tubewellbox.Text = info[16];
                    gavibox.Text = info[17];
                    sagolbox.Text = info[18];
                    daylabourerbox.Text = info[19];
                    dayslabourbox.Text = info[20];
                    watersourcebox.Text = info[21];
                    latrinebox.Text = info[22];
                    evaluationbox.Text = info[23];
                    datacollectorbox.Text = info[24];
                    cnocnpbox.Text = info[25];
                    datebox.Text = info[26];
                    String[,] meminfo = m.getAll(khanaid);
                    //MessageBox.Show(meminfo.Length.ToString());
                    int i = 0;
                    int j = 0;
                    while (meminfo[i, 0] != null)
                    {
                        dataGridView1.Rows.Add();
                        while (j < 14)
                        {

                            dataGridView1[j, i].Value = meminfo[i, j];
                            j++;
                        }
                        j = 0;
                        i++;
                    }
                    done.Visible = true;

                }
                else { MessageBox.Show("Sorry you are not entered this information"); }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #3
0
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                Member member = new Member();
                User u = new User();
                String cncid = "D" + district_no.Text + "T" + thana_no.Text + "U" + union_no.Text + "C" + cncbox.Text + "";
                String khanaid = "D" + district_no.Text + "T" + thana_no.Text + "U" + union_no.Text + "C" + cncbox.Text + "K" + khanabox.Text + "";
                //MessageBox.Show(khanaid);
                Khana k = new Khana();
                k.Insert(
                Convert.ToInt32(khanabox.Text),
                cncid,
                userid,
                Convert.ToInt32(chalabox.Text),
                Convert.ToInt32(wallbox.Text),
                Convert.ToInt32(floorbox.Text),
                Convert.ToInt32(watersourcebox.Text),
                Convert.ToInt32(evaluationbox.Text),
                Convert.ToInt32(housevaluebox.Text),
                Convert.ToInt32(totallandbox.Text),
                Convert.ToInt32(landvaluebox.Text),
                Convert.ToInt32(cowbox.Text),
                Convert.ToInt32(goatbox.Text),
                Convert.ToInt32(henbox.Text),
                Convert.ToInt32(treebox.Text),
                Convert.ToInt32(vegitablebox.Text),
                Convert.ToInt32(monthscoveredbox.Text),
                Convert.ToInt32(bedbox.Text),
                Convert.ToInt32(chairbox.Text),
                Convert.ToInt32(radiobox.Text),
                Convert.ToInt32(tvbox.Text),
                Convert.ToInt32(tubewellbox.Text),
                Convert.ToInt32(gavibox.Text),
                Convert.ToInt32(sagolbox.Text),
                Convert.ToInt32(daylabourerbox.Text),
                Convert.ToInt32(dayslabourbox.Text),
                Convert.ToInt32(latrinebox.Text),
                Convert.ToString(datacollectorbox.Text),
                Convert.ToString(cnocnpbox.Text),
                Convert.ToString(datebox.Text),
                khanaid);
                u.increaseKhanaCount(userid);
                khanacountbox.Text = u.getKhanaCount(userid).ToString();

                for (int j = 0; j < i; j++)
                {
                    String memberid = "D" + district_no.Text + "T" + thana_no.Text + "U" + union_no.Text + "C" + cncbox.Text + "K" + khanabox.Text + "M" + Convert.ToInt32(dataGridView1[0, j].Value) + "";

                    member.Insert(
                        memberid,
                        Convert.ToInt32(dataGridView1[0, j].Value),
                        Convert.ToInt32(dataGridView1[1, j].Value),
                        Convert.ToString(dataGridView1[2, j].Value),
                        Convert.ToInt32(dataGridView1[3, j].Value),
                        Convert.ToInt32(dataGridView1[4, j].Value),
                        Convert.ToString(dataGridView1[5, j].Value),
                        Convert.ToInt32(dataGridView1[6, j].Value),
                        Convert.ToInt32(dataGridView1[7, j].Value),
                        Convert.ToInt32(dataGridView1[8, j].Value),
                        Convert.ToInt32(dataGridView1[9, j].Value),
                        float.Parse(dataGridView1[11, j].Value.ToString()),
                        Convert.ToInt32(dataGridView1[12, j].Value),
                        Convert.ToInt32(dataGridView1[13, j].Value),
                        Convert.ToInt32(dataGridView1[10, j].Value),
                        khanaid);
                    u.increaseMemberCount(userid);
                    membercountbox.Text = u.getMemberCount(userid).ToString();

                }
                khanabox.Clear();
                chalabox.Clear();
                wallbox.Clear();
                floorbox.Clear();
                watersourcebox.Clear();
                evaluationbox.Clear();
                housevaluebox.Clear();
                totallandbox.Clear();
                landvaluebox.Clear();
                cowbox.Clear();
                goatbox.Clear();
                henbox.Clear();
                treebox.Clear();
                vegitablebox.Clear();
                monthscoveredbox.Clear();
                bedbox.Clear();
                chairbox.Clear();
                radiobox.Clear();
                tvbox.Clear();
                tubewellbox.Clear();
                gavibox.Clear();
                sagolbox.Clear();
                daylabourerbox.Clear();
                dayslabourbox.Clear();
                latrinebox.Clear();
                datacollectorbox.Clear();
                cnocnpbox.Clear();
                datebox.Clear();
                dataGridView1.Rows.Clear();
                i = 0;

            }
            catch (Exception ex) { }
        }
예제 #4
0
        private void done_Click(object sender, EventArgs e)
        {
            String khanaid = "D" + district_no.Text + "T" + thana_no.Text + "U" + union_no.Text + "C" + cncbox.Text + "K" + khanabox.Text + "";
            try
            {
                Member m = new Member();
                Khana k = new Khana();
                DialogResult dr = MessageBox.Show("Are you sure to change information?", "Confirmation", MessageBoxButtons.YesNo);
                if (dr == DialogResult.Yes)
                {
                    bool deleted = m.delete(khanaid);
                    if (deleted)
                    {
                        bool d = k.delete(khanaid);
                        if (d)
                        {
                            saveAll(sender, e);
                            save.Visible = true;
                            done.Visible = false;
                        }
                    }
                }

            }
            catch (Exception ex)
            {

            }
        }
예제 #5
0
        private void editbutton_Click(object sender, EventArgs e)
        {
            try
            {
                Khana k = new Khana();
                String khanaid = "D" + district_no.Text + "T" + thana_no.Text + "U" + union_no.Text + "C" + cncbox.Text + "K" + khanabox.Text + "";
                dataGridView1.Rows.Clear();
                String []info= k.getAll(khanaid);
                chalabox.Text = info[0];
                wallbox.Text = info[1];
                floorbox.Text = info[2];
                housevaluebox.Text = info[3];
                totallandbox.Text = info[4];
                landvaluebox.Text = info[5];
                cowbox.Text = info[6];
                goatbox.Text = info[7];
                henbox.Text = info[8];
                treebox.Text = info[9];
                vegitablebox.Text = info[10];
                monthscoveredbox.Text=info[11];
                bedbox.Text=info[12];
                chairbox.Text=info[13];

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