示例#1
0
 private void b_save_Click(object sender, EventArgs e)
 {
     if (tb_fullName.Text.Trim() != "")
     {
         if (idDep == 0)
         {
             departmentsTableAdapter1.Insert(
                 (int)cb_parent.SelectedValue,
                 tb_fullName.Text.Trim(),
                 tb_shortName.Text.Trim(),
                 DateTime.Now
                 );
         }
         else
         {
             ProfDataSet.DepartmentsDataTable dt = new ProfDataSet.DepartmentsDataTable();
             departmentsTableAdapter1.FillById(dt, idDep);
             DataRow dr = dt.Rows[0];
             dr["fullName"]  = tb_fullName.Text.Trim();
             dr["shortName"] = tb_shortName.Text.Trim();
             dr["idParent"]  = cb_parent.SelectedValue;
             departmentsTableAdapter1.Update(dr);
         }
         loadDepartmentsGrid();
         dgv.CurrentCell = dgv.Rows[dgv.Rows.Count - 1].Cells[1];
         MessageBox.Show("Информация сохранена!");
     }
     else
     {
         MessageBox.Show("Заполните поле \"Полное наименование\"!");
     }
 }
示例#2
0
        private void b_delete_Click(object sender, EventArgs e)
        {
            if (idDep > 0)
            {
                ProfDataSet.DepartmentsDataTable dt = new ProfDataSet.DepartmentsDataTable();
                departmentsTableAdapter1.FillByDepChild(dt, idDep);
                ProfDataSet.PeopleDepartmentDataTable dtp = new ProfDataSet.PeopleDepartmentDataTable();
                peopleDepartmentTableAdapter1.FillByDep(dtp, idDep);
                int childDep    = dt.Rows.Count;
                int countPeople = dtp.Rows.Count;
                if (childDep == 0)
                {
                    if (countPeople == 0)
                    {
                        departmentsTableAdapter1.DeleteByDep(idDep);

                        MessageBox.Show("Информация удалена!");
                        loadDepartmentsGrid();
                    }
                    else
                    {
                        MessageBox.Show("Вы не можете удалить данное подразделение, т.к. у него есть члены профсоюза!");
                    }
                }
                else
                {
                    MessageBox.Show("Вы не можете удалить данное подразделение, т.к. у него есть дочерние подразделения!");
                }
            }
            else
            {
                MessageBox.Show("Не выбрано подразделение!");
            }
        }
示例#3
0
 private void dgv_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     idDep = (int)dgv[0, e.RowIndex].Value;
     ProfDataSet.DepartmentsDataTable dt = new ProfDataSet.DepartmentsDataTable();
     departmentsTableAdapter1.FillById(dt, idDep);
     tb_fullName.Text        = dt.Rows[0]["fullName"].ToString();
     tb_shortName.Text       = dt.Rows[0]["shortName"].ToString();
     cb_parent.SelectedValue = (int)dt.Rows[0]["idParent"];
 }
示例#4
0
        private void B_import_Click(object sender, EventArgs e)
        {
            if (cb_dep.SelectedItem.ToString() == "")
            {
                MessageBox.Show("Для импорта данных, требуется выбрать базовое подразделение, куда они будут загружены!");
            }
            else
            {
                int idPerson = 0;
                progressBar1.Value   = 0;
                progressBar1.Maximum = dgv2.Rows.Count;
                for (int i = 0; i < dgv2.Rows.Count; i++)
                {
                    string ssp = "";
                    string ssv = "";
                    idDep = (int)cb_dep.SelectedValue;

                    if (dgv2.Rows[i].Cells[1].Value.ToString().Trim() != "")
                    {
                        ssp = dgv2.Rows[i].Cells[1].Value.ToString().Trim();

                        ProfDataSet.DepartmentsDataTable ddt = new ProfDataSet.DepartmentsDataTable();
                        departmentsTableAdapter1.FillByFullName(ddt, ssp);

                        if (ddt.Rows.Count == 0)
                        {
                            ProfDataSet.DepartmentsRow dr = ddt.NewDepartmentsRow();
                            dr.idParent  = idDep;
                            dr.fullName  = ssp;
                            dr.shortName = ssp;
                            departmentsTableAdapter1.Update(dr);
                            idDep = dr.id;
                        }
                        else
                        {
                            idDep = (int)ddt.Rows[0]["id"];
                        }
                    }
                    if (dgv2.Rows[i].Cells[2].Value.ToString().Trim() != "")
                    {
                        ssv = dgv2.Rows[i].Cells[2].Value.ToString().Trim();

                        ProfDataSet.DepartmentsDataTable ddt = new ProfDataSet.DepartmentsDataTable();
                        departmentsTableAdapter1.FillByFullName(ddt, ssp);

                        if (ddt.Rows.Count == 0)
                        {
                            ProfDataSet.DepartmentsRow dr = ddt.NewDepartmentsRow();
                            dr.idParent  = idDep;
                            dr.fullName  = ssv;
                            dr.shortName = ssv;
                            departmentsTableAdapter1.Update(dr);
                            idDep = dr.id;
                        }
                        else
                        {
                            idDep = (int)ddt.Rows[0]["id"];
                        }
                    }

                    string   fam = cryptoStr(dgv2.Rows[i].Cells[3].Value.ToString().Trim());
                    string   nam = cryptoStr(dgv2.Rows[i].Cells[4].Value.ToString().Trim());
                    string   otc = cryptoStr(dgv2.Rows[i].Cells[5].Value.ToString().Trim());
                    string   pn  = dgv2.Rows[i].Cells[9].Value.ToString().Trim();
                    DateTime dt  = DateTime.Parse(dgv2.Rows[i].Cells[7].Value.ToString().Trim());


                    ProfDataSet.PeopleDataTable pdt = new ProfDataSet.PeopleDataTable();
                    peopleTableAdapter1.FillByFIO(pdt, fam, nam, otc, pn);

                    if (pdt.Rows.Count == 0)
                    {
                        ProfDataSet.PeopleRow p = pdt.NewPeopleRow();
                        p.famil            = cryptoStr(dgv2.Rows[i].Cells[3].Value.ToString().Trim());
                        p.name             = cryptoStr(dgv2.Rows[i].Cells[4].Value.ToString().Trim());
                        p.otch             = cryptoStr(dgv2.Rows[i].Cells[5].Value.ToString().Trim());
                        p.gender           = dgv2.Rows[i].Cells[6].Value.ToString().Trim() != "" ? dgv2.Rows[i].Cells[6].Value.ToString().Trim() : "Муж";
                        p.birthday         = dgv2.Rows[i].Cells[7].Value.ToString().Trim() != "" ? DateTime.Parse(dgv2.Rows[i].Cells[7].Value.ToString().Trim()) : DateTime.Parse("01.01.1970");
                        p.phone            = cryptoStr(dgv2.Rows[i].Cells[8].Value.ToString().Trim());
                        p.numProfTicket    = dgv2.Rows[i].Cells[9].Value.ToString().Trim();
                        p.dateEnter        = dgv2.Rows[i].Cells[10].Value.ToString().Trim() != "" ? DateTime.Parse(dgv2.Rows[i].Cells[10].Value.ToString().Trim()) : DateTime.Parse("01.01.1970");
                        p.isPensioner      = (bool)dgv2.Rows[i].Cells[11].Value ? "T" : "F";
                        p.startTrudYearStr = dgv2.Rows[i].Cells[12].Value.ToString().Trim() != "" ? dgv2.Rows[i].Cells[12].Value.ToString().Trim() : "";
                        p.typeDoc          = cryptoStr(dgv2.Rows[i].Cells[13].Value.ToString().Trim());
                        p.pasp_ser         = cryptoStr(dgv2.Rows[i].Cells[14].Value.ToString().Trim());
                        p.pasp_num         = cryptoStr(dgv2.Rows[i].Cells[15].Value.ToString().Trim());
                        p.pasp_date        = dgv2.Rows[i].Cells[16].Value.ToString().Trim() != "" ? DateTime.Parse(dgv2.Rows[i].Cells[16].Value.ToString().Trim()) : DateTime.Parse("01.01.1970");
                        p.pasp_issue       = cryptoStr(dgv2.Rows[i].Cells[17].Value.ToString().Trim());
                        p.propiska         = cryptoStr(dgv2.Rows[i].Cells[18].Value.ToString().Trim());
                        p.activity         = dgv2.Rows[i].Cells[19].Value.ToString().Trim();
                        p.socialWork       = dgv2.Rows[i].Cells[20].Value.ToString().Trim();
                        p.hobbies          = dgv2.Rows[i].Cells[21].Value.ToString().Trim();

                        p.type     = rb_w.Checked ? "W" : rb_s.Checked ? "S" : "";
                        p.isProf   = "T";
                        p.dateExit = DateTime.Parse("01.01.1970");
                        peopleTableAdapter1.Update(p);
                        idPerson = p.id;
                        peopleDepartmentTableAdapter1.Insert(idPerson, idDep, DateTime.Now);
                    }
                    progressBar1.Value++;
                }

                MessageBox.Show("Все данные загружены в БД!");
            }
        }