コード例 #1
0
 public ProtocolForm(ProtocolsList form, XmlDocument header, string protocolDefinition, string candidates, string committee, string validateDefinition, string save, string OU, string licensePath, string version)
 {
     this.InitializeComponent();
     this.tooltipErrors = new ToolTip();
     this.isKLKCan = true;
     this.isKLK = true;
     this.isKLKPro = true;
     this.isKLKWali = true;
     this.xmlKandydaci = "";
     this.version = version;
     this.licensePath = licensePath;
     this.path = System.IO.Path.GetTempPath() + "KBW";
     this.controlsCanBeNull = new System.Collections.Generic.List<string>();
     this.codeWarning = "";
     this.wait = new WaitPanel("Wait3", base.Width, base.Height);
     base.Controls.Add(this.wait.getPanel());
     base.Controls[this.wait.getName()].BringToFront();
     this.form = form;
     this.OU = OU;
     form.wait.setWaitPanel("Trwa otwieranie formularza protokołu", "Proszę czekać");
     form.wait.setVisible(true);
     this.error = false;
     this.range = new System.Collections.Generic.Dictionary<string, ValidationRange>();
     this.lastControl = null;
     this.typeObw = "";
     this.correspondence = false;
     this.errorProvider1 = new KBWErrorProvider();
     this.errorProvider1.clearErrors();
     string[] p = protocolDefinition.Split(new char[]
     {
         '\\'
     });
     this.protocolDefinitionName = p[p.Length - 1].Replace('_', '/').Replace(".xml", "");
     string[] p2 = candidates.Split(new char[]
     {
         '\\'
     });
     this.candidatesName = p2[p2.Length - 1].Replace('_', '/').Replace(".xml", "");
     string[] p3 = committee.Split(new char[]
     {
         '\\'
     });
     this.committeeName = p3[p3.Length - 1].Replace('_', '/').Replace(".xml", "");
     string[] p4 = validateDefinition.Split(new char[]
     {
         '\\'
     });
     this.validateDefinitionName = p4[p4.Length - 1].Replace('_', '/').Replace(".xml", "");
     string[] p5 = this.committeeName.Split(new char[]
     {
         '-'
     });
     if (p5.Length > 2)
     {
         this.headerName = p5[0] + "-" + p5[1];
     }
     form.wait.setWaitPanel("Trwa otwieranie formularza protokołu - wczytywanie danych", "Proszę czekać");
     try
     {
         this.header = new XmlDocument();
         this.header = header;
         this.savePath = save;
         this.docxDefinition = protocolDefinition.Replace(".xml", ".docx");
         this.candDefinition = candidates;
         if (protocolDefinition != "")
         {
             this.protocolDefinition = new XmlDocument();
             if (System.IO.File.Exists(protocolDefinition))
             {
                 this.protocolDefinition.Load(protocolDefinition);
             }
             else
             {
                 this.isKLKPro = false;
             }
         }
         if (candidates != "")
         {
             this.candidates = new XmlDocument();
             if (System.IO.File.Exists(candidates))
             {
                 this.candidates.Load(candidates);
             }
             else
             {
                 this.isKLKCan = false;
             }
         }
         if (committee != "")
         {
             this.committee = new XmlDocument();
             if (System.IO.File.Exists(committee))
             {
                 this.committee.Load(committee);
             }
             else
             {
                 this.isKLK = false;
             }
         }
         if (validateDefinition != "")
         {
             this.validateDefinition = new XmlDocument();
             if (System.IO.File.Exists(validateDefinition))
             {
                 this.validateDefinition.Load(validateDefinition);
             }
             else
             {
                 this.isKLKWali = false;
             }
         }
         if (save != "")
         {
             this.save = new XmlDocument();
             if (System.IO.File.Exists(save))
             {
                 this.save.Load(save);
             }
         }
         string[] partfilepath = this.savePath.Split(new char[]
         {
             '\\'
         });
         string[] dataPath = partfilepath[partfilepath.Length - 1].Split(new char[]
         {
             '-'
         });
         string jns = dataPath[1].Replace("Jns", "");
         string inst = dataPath[3].Replace("Inst", "");
         string obwod = dataPath[2].Replace("Obw", "");
         this.instJNS = dataPath[4];
         string okreg = dataPath[5].Replace("Okr", "");
         okreg = okreg.Replace(".xml", "");
         string organNazwa = "";
         XmlNode headerRoot = header.SelectSingleNode("/akcja_wyborcza/jns");
         foreach (XmlNode xObwod in headerRoot)
         {
             if (xObwod.Attributes["nr"].InnerText == obwod)
             {
                 foreach (XmlNode xInst in xObwod)
                 {
                     if (xInst.Attributes["kod"].InnerText == inst)
                     {
                         foreach (XmlNode xobw in xInst)
                         {
                             if (xobw.Attributes["nr"].InnerText == okreg && System.Convert.ToInt32(xInst.Attributes["inst_jns"].InnerText) == System.Convert.ToInt32(this.instJNS))
                             {
                                 organNazwa = xInst.Attributes["organNazwa"].InnerText;
                                 break;
                             }
                         }
                     }
                 }
             }
         }
         if (inst == "WBP")
         {
             if (jns.Substring(0, 4) == "1465" && jns.Length == 6)
             {
                 if (candidates != "")
                 {
                     string candidates2 = candidates.Replace(jns + "-" + okreg + ".xml", "146501-1.xml");
                     this.candidates = new XmlDocument();
                     if (System.IO.File.Exists(candidates2))
                     {
                         this.candidates.Load(candidates2);
                         this.isKLKCan = true;
                     }
                     else
                     {
                         this.isKLKCan = false;
                     }
                 }
             }
         }
         if (inst == "RDA")
         {
             if (jns.Length < 6)
             {
                 while (jns.Length < 6)
                 {
                     jns = "0" + jns;
                 }
             }
             if (jns[2] == '7' || jns[2] == '6')
             {
                 if (jns.Substring(0, 4) == "1465" && organNazwa == "m.st.")
                 {
                     this.protocolDefinition = new XmlDocument();
                     string protocolDefinition2 = protocolDefinition.Replace(".xml", "_M.xml");
                     if (System.IO.File.Exists(protocolDefinition2))
                     {
                         this.protocolDefinition.Load(protocolDefinition2);
                         this.isKLKPro = true;
                     }
                     else
                     {
                         this.isKLKPro = false;
                     }
                     if (validateDefinition != "")
                     {
                         this.validateDefinition = new XmlDocument();
                         string validateDefinition2 = validateDefinition.Replace("_Walidacja.xml", "_M_Walidacja.xml");
                         if (System.IO.File.Exists(validateDefinition2))
                         {
                             this.validateDefinition.Load(validateDefinition2);
                             this.isKLKWali = true;
                         }
                         else
                         {
                             this.isKLKWali = false;
                         }
                     }
                     if (candidates != "")
                     {
                         string candidates2 = candidates.Replace(jns + "-" + okreg + ".xml", "146501-" + okreg + ".xml");
                         this.candidates = new XmlDocument();
                         if (System.IO.File.Exists(candidates2))
                         {
                             this.candidates.Load(candidates2);
                             this.isKLKCan = true;
                         }
                         else
                         {
                             this.isKLK = false;
                             this.isKLKCan = false;
                         }
                     }
                 }
                 if (jns.Substring(0, 4) != "1465")
                 {
                     if (protocolDefinition != "")
                     {
                         this.protocolDefinition = new XmlDocument();
                         string protocolDefinition2 = protocolDefinition.Replace(".xml", "_M.xml");
                         if (System.IO.File.Exists(protocolDefinition2))
                         {
                             this.protocolDefinition.Load(protocolDefinition2);
                             this.isKLKPro = true;
                         }
                         else
                         {
                             this.isKLKPro = false;
                         }
                     }
                     if (validateDefinition != "")
                     {
                         this.validateDefinition = new XmlDocument();
                         string validateDefinition2 = validateDefinition.Replace("_Walidacja.xml", "_M_Walidacja.xml");
                         if (System.IO.File.Exists(validateDefinition2))
                         {
                             this.validateDefinition.Load(validateDefinition2);
                             this.isKLKWali = true;
                         }
                         else
                         {
                             this.isKLKWali = false;
                         }
                     }
                 }
             }
             if (jns.Substring(0, 4) == "1465" && organNazwa == "Dzielnicy")
             {
                 if (protocolDefinition != "")
                 {
                     this.protocolDefinition = new XmlDocument();
                     string protocolDefinition2 = protocolDefinition.Replace(".xml", "_D.xml");
                     if (System.IO.File.Exists(protocolDefinition2))
                     {
                         this.protocolDefinition.Load(protocolDefinition2);
                         this.isKLKPro = true;
                     }
                     else
                     {
                         this.isKLKPro = false;
                     }
                 }
                 if (validateDefinition != "")
                 {
                     this.validateDefinition = new XmlDocument();
                     string validateDefinition2 = validateDefinition.Replace("_Walidacja.xml", "_D_Walidacja.xml");
                     if (System.IO.File.Exists(validateDefinition2))
                     {
                         this.validateDefinition.Load(validateDefinition2);
                         this.isKLKWali = true;
                     }
                     else
                     {
                         this.isKLKWali = false;
                     }
                 }
             }
         }
         if (this.isKLKCan)
         {
             this.deletedCandidates = this.countOfDeletedCandidate();
             if (this.isOneCandidate())
             {
                 this.deletedCandidates = 1;
                 if (protocolDefinition != "")
                 {
                     this.protocolDefinition = new XmlDocument();
                     string protocolDefinition2 = protocolDefinition.Replace(".xml", "_1.xml");
                     if (System.IO.File.Exists(protocolDefinition2))
                     {
                         this.protocolDefinition.Load(protocolDefinition2);
                         this.isKLKPro = true;
                     }
                     else
                     {
                         this.isKLKPro = false;
                     }
                 }
                 if (validateDefinition != "")
                 {
                     this.validateDefinition = new XmlDocument();
                     string validateDefinition2 = validateDefinition.Replace("_Walidacja.xml", "_1_Walidacja.xml");
                     if (System.IO.File.Exists(validateDefinition2))
                     {
                         this.validateDefinition.Load(validateDefinition2);
                         this.isKLKWali = true;
                     }
                     else
                     {
                         this.isKLKWali = false;
                     }
                 }
             }
         }
     }
     catch (XmlException e)
     {
         MessageBox.Show("Nieprawidłowy XML: " + e.Message, "Błąd");
     }
     bool go = false;
     if (this.isKLK && this.isKLKCan && this.isKLKPro && this.isKLKWali)
     {
         go = this.checkProtocol(this.save, this.savePath);
     }
     if (this.isKLK && this.isKLKCan && this.isKLKPro && this.isKLKWali)
     {
         if (go)
         {
             this.committeePanel.Visible = false;
             this.goodcertificate = false;
             this.countcandidatesoflist = new System.Collections.Generic.List<int[]>();
             this.lastValidators = new System.Collections.Generic.List<ValidationPatern>();
             this.candidatesRule = new System.Collections.Generic.Dictionary<string, string>();
             this.typeValidation = new System.Collections.Generic.Dictionary<string, string>();
             form.wait.setWaitPanel("Trwa otwieranie formularza protokołu - ładowanie nagłówka", "Proszę czekać");
             this.getHeader();
             form.wait.setWaitPanel("Trwa otwieranie formularza protokołu - ładowanie pierwszego kroku", "Proszę czekać");
             this.getCalculator();
             this.Form1panel.Visible = true;
             this.Form1panel.Width = 776;
             this.Form2panel.Visible = false;
             this.Form2panel.Width = 776;
             this.committeePanel.Visible = false;
             this.committeePanel.Width = 776;
             this.SummationPanel.Visible = false;
             this.SummationPanel.Width = 776;
             this.signPanel.Visible = false;
             this.signPanel.Width = 776;
             this.raportPanel.Visible = false;
             this.raportPanel.Width = 776;
             this.protocolHeader.Width = 776;
             this.protocolForm1.Enabled = true;
             this.protocolForm2.Enabled = false;
             this.protocolSummation.Enabled = false;
             this.protocolCommittee.Enabled = false;
             this.signProtocol.Enabled = false;
             this.currentStep = 1;
             this.personList.CellClick += new DataGridViewCellEventHandler(this.committee_CellClick);
             this.currentCommittee = false;
             this.clicNext = false;
             this.imported = false;
             this.web = new WebBrowser();
             this.web.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(ProtocolForm.webBrowser_DocumentCompleted);
             form.wait.setVisible(false);
             this.LicencesTable.CellClick += new DataGridViewCellEventHandler(this.getLicense_CellClick);
             this.codeBarText = "";
             this.codeBarCode = "";
         }
         else
         {
             MessageBox.Show("Nie jesteś uprowniony do wypełniana tego protokołu.", "Uwaga");
             base.Close();
         }
     }
     else
     {
         MessageBox.Show("Nie pobrano wszystkich plików klk.", "Uwaga");
         base.Close();
     }
 }
コード例 #2
0
 public ProtocolForm()
 {
     this.path = System.IO.Path.GetTempPath() + "KBW";
     this.licensePath = "";
     this.lastControl = null;
     this.controlsCanBeNull = new System.Collections.Generic.List<string>();
     this.InitializeComponent();
     this.codeWarning = "";
     this.typeObw = "";
     this.headerName = "";
     this.committeeName = "";
     this.candidatesName = "";
     this.protocolDefinitionName = "";
     this.validateDefinitionName = "";
     this.docxDefinition = "";
     this.protocolDefinition = new XmlDocument();
     this.candidates = new XmlDocument();
     this.committee = new XmlDocument();
     this.validateDefinition = new XmlDocument();
     this.header = new XmlDocument();
     this.lastValidators = new System.Collections.Generic.List<ValidationPatern>();
     this.countcandidatesoflist = new System.Collections.Generic.List<int[]>();
     this.candidatesRule = new System.Collections.Generic.Dictionary<string, string>();
     this.errorProvider1 = new KBWErrorProvider();
     this.error = false;
     this.range = new System.Collections.Generic.Dictionary<string, ValidationRange>();
     this.personList.Visible = false;
     this.committeePanel.Visible = false;
     this.currentStep = 1;
     this.goodcertificate = false;
     this.personList.CellClick += new DataGridViewCellEventHandler(this.committee_CellClick);
     this.currentCommittee = false;
     this.clicNext = false;
     this.imported = false;
     this.wait = new WaitPanel("Wait3", base.Width, base.Height);
     this.form = null;
     this.typeValidation = new System.Collections.Generic.Dictionary<string, string>();
     this.codeBarText = "";
     this.codeBarCode = "";
     this.xmlKandydaci = "";
 }