Exemplo n.º 1
0
        public static void GenerateVies(IDataBaseContext context, int month, int year, DeclarConfigModel model)
        {
            Dictionary <string, string> declar = new Dictionary <string, string>();
            var firma = ConfigTempoSinglenton.GetInstance().CurrentFirma;

            declar.Add("data", string.Format("{0:D2}/{1:D4}", month, year));
            declar.Add("firma", firma.Name);
            declar.Add("address", firma.Address);
            declar.Add("tel", firma.Telefon);
            declar.Add("dds", firma.DDSnum);
            declar.Add("iddds", firma.Bulstad);
            declar.Add("city", firma.CityName);
            declar.Add("p", firma.PresentorYN == 1 ? "X" : " ");
            declar.Add("pr", firma.PresentorYN == 0 ? "X" : " ");
            declar.Add("zip", firma.Zip);
            declar.Add("egn", firma.EGN);
            declar.Add("address1", firma.Address2);
            if (firma.PresentorYN == 0)
            {
                declar.Add("mol", firma.NameBoss);
            }
            else
            {
                declar.Add("mol", firma.Names);
            }
            string actual;

            actual = DeklarviewModel.ReturnViesDeclar(declar, context.GetVies(month, year, declar));
            var path = AppDomain.CurrentDomain.BaseDirectory + "Vies1.txt";

            using (StreamWriter sw = new StreamWriter(path))
            {
                sw.Write(actual);
            }
            Process.Start(path);
        }
Exemplo n.º 2
0
        public static void GenerateViesF(IDataBaseContext context, int month, int year, DeclarConfigModel model)
        {
            Dictionary <string, string> declar = new Dictionary <string, string>();
            var firma = ConfigTempoSinglenton.GetInstance().CurrentFirma;

            declar.Add("data", string.Format("{0:D2}/{1}", month, year));
            declar.Add("firma", firma.Name);
            declar.Add("address", firma.Address);
            declar.Add("tel", firma.Telefon);
            declar.Add("dds", firma.DDSnum);
            declar.Add("iddds", firma.Bulstad);
            declar.Add("city", firma.CityName);
            declar.Add("p", firma.PresentorYN == 1 ? "X" : " ");
            declar.Add("pr", firma.PresentorYN == 0 ? "X" : " ");
            declar.Add("zip", firma.Zip);
            declar.Add("egn", firma.EGN);
            declar.Add("address1", firma.Address2);
            if (firma.PresentorYN == 0)
            {
                declar.Add("mol", firma.NameBoss);
                declar.Add("presentor", "A");
            }
            else
            {
                declar.Add("mol", firma.Names);
                declar.Add("presentor", "R");
            }

            var           path = AppDomain.CurrentDomain.BaseDirectory + "VIES.TXT";
            var           list = context.GetVies(month, year, declar);
            StringBuilder sb   = new StringBuilder();

            sb.AppendFormat("{0,3}", "VHR");              //1
            sb.AppendFormat("{0,7}", declar["data"]);     //2
            sb.AppendFormat("{0,5}", declar["count"]);    //3
            sb.AppendLine();
            sb.AppendFormat("{0,3}", "VDR");
            sb.AppendFormat("{0,-15}", declar["egn"]);
            sb.AppendFormat("{0,-150}", declar["mol"]);
            sb.AppendFormat("{0,-50}", declar["city"]);
            sb.AppendFormat("{0,4}", declar["zip"]);
            sb.AppendFormat("{0,-150}", declar["address1"]);
            sb.AppendFormat("{0,1}", declar["presentor"]);
            sb.AppendLine();
            sb.AppendFormat("{0,3}", "VTR");
            sb.AppendFormat("{0,-15}", declar["dds"]);
            sb.AppendFormat("{0,-150}", declar["mol"]);
            sb.AppendFormat("{0,-200}", declar["address"]);
            sb.AppendLine();
            sb.AppendFormat("{0,3}", "TTR");
            sb.AppendFormat("{0,12}", declar["sumak1k2k3"]);
            sb.AppendFormat("{0,12}", declar["sumak3"]);
            sb.AppendLine();
            foreach (var l in list)
            {
                sb.AppendFormat("VIR{0,5}{1,-15}{2,12}{3,12}{4,12}{5,7}", l.PorNom, l.Name, l.K3, l.K4, l.K5, " ");
                sb.AppendLine();
            }
            Encoding srcEncodingFormat = Encoding.UTF8;
            Encoding dstEncodingFormat = Encoding.GetEncoding("windows-1251");

            byte[] originalByteString  = srcEncodingFormat.GetBytes(sb.ToString());
            byte[] convertedByteString = Encoding.Convert(srcEncodingFormat, dstEncodingFormat, originalByteString);
            string finalString         = dstEncodingFormat.GetString(convertedByteString);

            using (StreamWriter sw = new StreamWriter(path, false, dstEncodingFormat))
            {
                sw.Write(finalString);
            }
            //Process.Start(path);
        }