예제 #1
0
        public static Boolean CreateConfigFile(ConfigFile configFile, Boolean isConfigMod)
        {
            FileInfo fi = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string fipath = fi.DirectoryName;
            if (isConfigMod)
            {
                if (File.Exists(Path.Combine(fipath, "IsfuConfig.cfg")))
                {
                    File.Delete(Path.Combine(fipath, "IsfuConfig.cfg"));
                }
            }
            try
            {
                StreamWriter sw = new StreamWriter(Path.Combine(fipath, "IsfuConfig.cfg"), true, System.Text.Encoding.UTF8);

                sw.WriteLine(configFile.SecGeneral);
                sw.WriteLine(configFile.ConnectionString);
                sw.WriteLine(configFile.ServerUrl);
                sw.WriteLine(configFile.LogFileActive);
                sw.WriteLine(configFile.SaveXMLActive);
                sw.WriteLine(configFile.DateIsActive);

                sw.WriteLine(configFile.Separator);

                sw.WriteLine(configFile.SecSalon);
                sw.WriteLine(configFile.VATNumber);
                sw.WriteLine(configFile.BusinessPremiseMark);
                sw.WriteLine(configFile.CadastralNumber);
                sw.WriteLine(configFile.BuildingNumber);
                sw.WriteLine(configFile.BuildingSectionNumber);
                sw.WriteLine(configFile.Street);
                sw.WriteLine(configFile.HouseNumber);
                sw.WriteLine(configFile.HouseNumberExtra);
                sw.WriteLine(configFile.PostalCode);
                sw.WriteLine(configFile.Town);
                sw.WriteLine(configFile.District);
                sw.WriteLine(configFile.MovableBusinessPremise);
                sw.WriteLine(configFile.SpecialNotes);
                sw.WriteLine(configFile.PremiseMark);
                sw.WriteLine(configFile.BillingDeviceMark);
                sw.WriteLine(configFile.VATSoftware);
                sw.WriteLine(configFile.NameAndAdressOfSoftwareSupplier);
                sw.WriteLine(configFile.PCeasedOperation);

                sw.WriteLine(configFile.Separator);

                sw.WriteLine(configFile.SalesBookInvoice);
                sw.WriteLine(configFile.SetNumber);
                sw.WriteLine(configFile.SerialNumber);

                sw.WriteLine(configFile.Separator);

                sw.WriteLine(configFile.SecSoloConfig);
                sw.WriteLine(configFile.OperatorVAT);
                sw.WriteLine(configFile.OperatorCode);

                sw.WriteLine(configFile.Separator);

                sw.WriteLine(configFile.SecCertificate);
                sw.WriteLine(configFile.Certificate);

                sw.Close();
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while registering config file! " + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return true;
            }
        }
예제 #2
0
        private void btnSaveConfig_Click(object sender, EventArgs e)
        {
            state = false;

            ConfigFile configFile = new ConfigFile();

            configFile.ConnectionString = txtConnectString.Text;
            configFile.ServerUrl = txtURL.Text;
            configFile.LogFileActive = Convert.ToString(chkLog.Checked);
            configFile.SaveXMLActive = Convert.ToString(chkSaveXML.Checked);
            configFile.DateIsActive = string.Format("{0}:yyyy.mm.dd", dtpActive);

            configFile.VATNumber = txtVATNumber.Text;
            configFile.BusinessPremiseMark = txtBuisnessPremise.Text;
            configFile.CadastralNumber = txtCadastralNumber.Text;
            configFile.BuildingNumber = txtBuildingNumber.Text;
            configFile.BuildingSectionNumber = txtBuildingSectionNumber.Text;
            configFile.Street = txtStreet.Text;
            configFile.HouseNumber = txtHouseNumber.Text;
            configFile.HouseNumberExtra = txtHouseNumberExtra.Text;
            configFile.PostalCode = txtPostalcode.Text;
            configFile.Town = txtTown.Text;
            configFile.District = txtDistrict.Text;
            configFile.MovableBusinessPremise = txtMovableBuisnessPremise.Text;
            configFile.SpecialNotes = txtNote.Text;
            configFile.PremiseMark = txtPremiseMark.Text;
            configFile.BillingDeviceMark = txtBillingDeviceMark.Text;
            configFile.VATSoftware = txtVatNumberSoftwareSupplier.Text;
            configFile.NameAndAdressOfSoftwareSupplier = txtNameAndAdressSoftwareSupplier.Text;
            configFile.PCeasedOperation = Convert.ToString(chkPCO.Checked);

            configFile.SalesBookInvoice = txtSalesBookInvoice.Text;
            configFile.SetNumber = txtSetNumber.Text;
            configFile.SerialNumber = txtSerialNumber.Text;

            configFile.OperatorVAT = txtVATOperator.Text;
            configFile.OperatorCode = txtCodeOperator.Text;
            configFile.Certificate = txtCertificate.Text;

            VerifyData();

            if (state == true) return;

            LogFile.CreateConfigFile(configFile, true);

            Application.Exit();
        }