Exemple #1
0
        public void InsertControls(params String[] formNameList)
        {
            for (int i = 0; i < formNameList.Length; i++)
            {
                InsertControlsBySingle(formNameList[i]);
            }

            sqlCon.UpdateDataTable("spr_user_controls");
        }
        private void bnLoad_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Xml Files (*.xml)|*.xml|All Files (*.*)|*.*";
            if (openFileDialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }
            //Удаляем связи между таблицами
            sqlCon.DoQuery("ALTER TABLE employee DROP CONSTRAINT fk_dep_id");
            sqlCon.DoQuery("ALTER TABLE spr_party_number DROP CONSTRAINT fk_dep_id2");
            //Удаляем содержимое справочников
            sqlCon.DoQuery("DELETE * FROM department");
            sqlCon.DoQuery("DELETE * FROM enum_department_type");
            sqlCon.GetDataTable("enum_department_type", "SELECT * FROM enum_department_type");
            sqlCon.GetDataTable("department", "SELECT * FROM department");
            DataTable ddt = sqlCon.GetDataTable("department", "SELECT * FROM department");
            //Загружаем данные из нового справочника
            FileInfo f = new FileInfo(openFileDialog.FileName);

            XmlDataDocument xml = new XmlDataDocument();

            xml.DataSet.ReadXmlSchema(Path.ChangeExtension(f.FullName, ".xsd"));
            xml.Load(f.FullName);

            sqlCon.MergeDataSet(xml.DataSet);

            sqlCon.UpdateDataTable("enum_department_type");
            sqlCon.UpdateDataTable("department");
            //Восстанавливаем связи между таблицами
            sqlCon.DoQuery("ALTER TABLE employee ADD CONSTRAINT fk_dep_id  FOREIGN KEY (department_id) REFERENCES department (id)");
            sqlCon.DoQuery("ALTER TABLE spr_party_number ADD CONSTRAINT fk_dep_id2  FOREIGN KEY (department_id) REFERENCES department (id)");

            dgRegion.DataSource = sqlCon.GetDataTable("region", "SELECT id, name FROM department WHERE higher='0'");;
        }
        private void SaveUserRol()
        {
            DataTable dt2update = sqlCon.GetDataTable("user_rol_access", "SELECT * FROM user_rol_access");
            DataTable dt        = ((DataView)dgControls.DataSource).Table;

            foreach (DataRow rowSrc in dt.Rows)
            {
                foreach (DataRow rowDst in dt2update.Rows)
                {
                    if (rowSrc["id"].ToString() == rowDst["id"].ToString())
                    {
                        rowDst["enabled"] = rowSrc["enabled"];
                    }
                }
            }

            sqlCon.UpdateDataTable("user_rol_access");
        }
Exemple #4
0
        //Процедура загрузки
        public Boolean DownloadData(DataTable dt_buf)
        {
            DataTable             dtSrc = sqlConSrc.GetDataTable("spec");
            DataTable             dtDst = sqlConDst.GetDataTable("spec", "SELECT * FROM spec");
            Dictionary <int, int> dictSprNat;
            Dictionary <int, int> dictSprProf;
            Dictionary <int, int> dictSprEdu;
            Dictionary <int, int> dictSprMS;
            Dictionary <int, int> dictSprParty;
            Dictionary <int, int> dictSprDegree;
            Dictionary <int, int> dictSprBT;
            Dictionary <int, int> dictSprPerf;
            Dictionary <int, int> dictSprPT;
            Dictionary <int, int> dictSprRelR;
            Dictionary <int, int> dictSprProfY;
            Dictionary <int, int> dictSprEmpl;
            Dictionary <int, int> dictSprWT;

            Dictionary <int, int> dictSpec;

            Boolean alignStatus =
                AlignSpr("spr_nation", out dictSprNat, AlignMode.dialog) &
                AlignSpr("spr_profession", out dictSprProf, AlignMode.dialog) &
                AlignSpr("spr_edu", out dictSprEdu, AlignMode.dialog) &
                AlignSpr("spr_mstatus", out dictSprMS, AlignMode.dialog) &
                AlignSpr("spr_party_number", out dictSprParty, AlignMode.add) &
                AlignSpr("spr_degree", out dictSprDegree, AlignMode.dialog) &
                AlignSpr("spr_bonus_type", out dictSprBT, AlignMode.dialog) &
                AlignSpr("spr_performers", out dictSprPerf, AlignMode.dialog) &
                AlignSpr("spr_penalty_type", out dictSprPT, AlignMode.dialog) &
                AlignSpr("spr_release_reason", out dictSprRelR, AlignMode.dialog) &
                AlignSpr("spr_profilact_ychet", out dictSprProfY, AlignMode.dialog) &
                AlignSpr("employee", out dictSprEmpl, AlignMode.add) &
                AlignSpr("spr_work_type", out dictSprWT, AlignMode.dialog);

            if (!alignStatus)
            {
                return(false);
            }

            ReplaceSprID(dtSrc, "nation_id", dictSprNat);
            ReplaceSprID(dtSrc, "profession_id", dictSprProf);
            ReplaceSprID(dtSrc, "edu_id", dictSprEdu);
            ReplaceSprID(dtSrc, "mstatus_id", dictSprMS);
            ReplaceSprID(dtSrc, "party_id", dictSprParty);

            ArrayList idList = new ArrayList();

            GetNotSelected(dtSrc, dt_buf, idList);

            CompareTables(dtSrc, dtDst, idList, "first_name", "last_name", "patronymic", "birthdate");

            int count = RemoveByFilter(dtSrc, "id", idList);

            //MessageBox.Show("Сообщение", "Информация о " +count.ToString()+ " абонентах не была загружена " );

            FixRowState(dtSrc);
            MergeTables(dtSrc, dtDst);
            sqlConDst.UpdateDataTable("spec");

            CopyFoto(tempDir, GetDBDirPath(), dtSrc);

            GetDict(dtSrc, dtDst, out dictSpec);

            //relations
            dtSrc = sqlConSrc.GetDataTable("relations");
            dtDst = sqlConDst.GetDataTable("relations", "SELECT * FROM relations");

            count = RemoveByFilter(dtSrc, "id_spec", idList);

            ReplaceSprID(dtSrc, "degree_id", dictSprDegree);
            ReplaceSprID(dtSrc, "id_spec", dictSpec);

            FixRowState(dtSrc);
            MergeTables(dtSrc, dtDst);
            sqlConDst.UpdateDataTable("relations");

            //bonus
            dtSrc = sqlConSrc.GetDataTable("bonus");
            dtDst = sqlConDst.GetDataTable("bonus", "SELECT * FROM bonus");

            RemoveByFilter(dtSrc, "id_spec", idList);
            ReplaceSprID(dtSrc, "bonus_type_id", dictSprBT);
            ReplaceSprID(dtSrc, "performer_id", dictSprPerf);
            ReplaceSprID(dtSrc, "id_spec", dictSpec);

            FixRowState(dtSrc);
            MergeTables(dtSrc, dtDst);
            sqlConDst.UpdateDataTable("bonus");

            //penalty
            dtSrc = sqlConSrc.GetDataTable("penalty");
            dtDst = sqlConDst.GetDataTable("penalty", "SELECT * FROM penalty");

            RemoveByFilter(dtSrc, "id_spec", idList);
            ReplaceSprID(dtSrc, "penalty_type_id", dictSprPT);
            ReplaceSprID(dtSrc, "id_spec", dictSpec);

            FixRowState(dtSrc);
            MergeTables(dtSrc, dtDst);
            sqlConDst.UpdateDataTable("penalty");

            //party
            dtSrc = sqlConSrc.GetDataTable("party");
            dtDst = sqlConDst.GetDataTable("party", "SELECT * FROM party");

            RemoveByFilter(dtSrc, "id_spec", idList);
            //AlignSpr("spr_party_number", out dictSpr, AlignMode.add);
            ReplaceSprID(dtSrc, "party_number_id", dictSprParty);
            ReplaceSprID(dtSrc, "id_spec", dictSpec);

            FixRowState(dtSrc);
            MergeTables(dtSrc, dtDst);
            sqlConDst.UpdateDataTable("party");

            //spec_psycho
            dtSrc = sqlConSrc.GetDataTable("spec_psycho");
            dtDst = sqlConDst.GetDataTable("spec_psycho", "SELECT * FROM spec_psycho");

            RemoveByFilter(dtSrc, "id_spec", idList);
            ReplaceSprID(dtSrc, "id_spec", dictSpec);

            FixRowState(dtSrc);
            MergeTables(dtSrc, dtDst);
            sqlConDst.UpdateDataTable("spec_psycho");

            //psycho_char
            dtSrc = sqlConSrc.GetDataTable("psycho_char");
            dtDst = sqlConDst.GetDataTable("psycho_char", "SELECT * FROM psycho_char");

            RemoveByFilter(dtSrc, "id_spec", idList);
            ReplaceSprID(dtSrc, "id_spec", dictSpec);

            FixRowState(dtSrc);
            MergeTables(dtSrc, dtDst);
            sqlConDst.UpdateDataTable("psycho_char");

            //prev_conv
            dtSrc = sqlConSrc.GetDataTable("prev_conv");
            dtDst = sqlConDst.GetDataTable("prev_conv", "SELECT * FROM prev_conv");

            RemoveByFilter(dtSrc, "id_spec", idList);
            ReplaceSprID(dtSrc, "release_reason_id", dictSprRelR);
            ReplaceSprID(dtSrc, "id_spec", dictSpec);

            FixRowState(dtSrc);
            MergeTables(dtSrc, dtDst);
            sqlConDst.UpdateDataTable("prev_conv");

            //profilact_ychet
            dtSrc = sqlConSrc.GetDataTable("profilact_ychet");
            dtDst = sqlConDst.GetDataTable("profilact_ychet", "SELECT * FROM profilact_ychet");

            RemoveByFilter(dtSrc, "id_spec", idList);
            ReplaceSprID(dtSrc, "id_profilact_ychet", dictSprProfY);
            ReplaceSprID(dtSrc, "id_spec", dictSpec);

            FixRowState(dtSrc);
            MergeTables(dtSrc, dtDst);
            sqlConDst.UpdateDataTable("profilact_ychet");

            //ivr
            dtSrc = sqlConSrc.GetDataTable("ivr");
            dtDst = sqlConDst.GetDataTable("ivr", "SELECT * FROM ivr");

            RemoveByFilter(dtSrc, "id_spec", idList);
            ReplaceSprID(dtSrc, "employee_id", dictSprEmpl);
            ReplaceSprID(dtSrc, "work_type", dictSprWT);
            ReplaceSprID(dtSrc, "id_spec", dictSpec);

            FixRowState(dtSrc);
            MergeTables(dtSrc, dtDst);
            sqlConDst.UpdateDataTable("ivr");

            //resolution
            dtSrc = sqlConSrc.GetDataTable("resolution");
            dtDst = sqlConDst.GetDataTable("resolution", "SELECT * FROM resolution");

            RemoveByFilter(dtSrc, "id_spec", idList);
            ReplaceSprID(dtSrc, "id_spec", dictSpec);

            FixRowState(dtSrc);
            MergeTables(dtSrc, dtDst);
            sqlConDst.UpdateDataTable("resolution");

            //results
            dtSrc = sqlConSrc.GetDataTable("results");
            dtDst = sqlConDst.GetDataTable("results", "SELECT * FROM results");

            RemoveByFilter(dtSrc, "id_spec", idList);
            ReplaceSprID(dtSrc, "id_spec", dictSpec);

            FixRowState(dtSrc);
            MergeTables(dtSrc, dtDst);
            sqlConDst.UpdateDataTable("results");

            if (idList.Count > 0)
            {
                MessageBox.Show("Информация о " + idList.Count.ToString() + " абонентах не была загружена ", "Сообщение");
            }
            return(true);
        }