Пример #1
0
        /// <summary>
        /// Efetua a escrita do Registro 10 do arquivo.
        /// </summary>
        /// <param name="validarCampos">true ou false para realizar a validação dos dados.</param>
        /// <returns>String</returns>
        public string EscreverRegistro10(bool validarCampos = true)
        {
            if (validarCampos)
            {
                // Validar campos
            }

            var r10 = new string(' ', 126);

            try
            {
                r10 = r10.PreencherValorNaLinha(1, 2, TIPO.PadLeft(2, ' '));
                r10 = r10.PreencherValorNaLinha(3, 16, CGCMF.PadLeft(14, ' '));
                r10 = r10.PreencherValorNaLinha(17, 30, IE.PadRight(14, ' '));
                r10 = r10.PreencherValorNaLinha(31, 65, NOME.Length > 35 ? NOME.Substring(0, 35) : NOME.PadRight(35, ' '));
                r10 = r10.PreencherValorNaLinha(66, 95, MUNICIPIO.Length > 30 ? MUNICIPIO.Substring(0, 30) : MUNICIPIO.PadRight(30, ' '));
                r10 = r10.PreencherValorNaLinha(96, 97, UF.PadRight(2, ' '));
                r10 = r10.PreencherValorNaLinha(98, 107, FAX.PadLeft(10, '0'));
                r10 = r10.PreencherValorNaLinha(108, 115, DT_INI);
                r10 = r10.PreencherValorNaLinha(116, 123, DT_FIN);
                r10 = r10.PreencherValorNaLinha(124, 124, COD_ID_ESTRUT.PadRight(1, '3'));
                r10 = r10.PreencherValorNaLinha(125, 125, COD_ID_NAT_OPE.PadRight(1, '3'));
                r10 = r10.PreencherValorNaLinha(126, 126, COD_FIN.PadRight(1, '1'));

                return(r10);
            }
            catch (Exception e)
            {
                throw new Exception("Falha ao gerar registro tipo 10." + Environment.NewLine + e.Message);
            }
        }
Пример #2
0
 void loadCutomer()
 {
     try
     {
         customerList = new List <Custmor>();
         string custID, compName, contactName, contactTitle, address, city, province, country, POSTALCODE, phone, FAX;
         string sql = "Select custID,compName,contactName,contactTitle,address,city,province,country,POSTALCODE,phone,FAX from tblCustomerInfo";
         if (cn.State != ConnectionState.Open)
         {
             cn.Open();
         }
         cmd = new SqlCommand(sql, cn);
         using (SqlDataReader rdr = cmd.ExecuteReader())
         {
             while (rdr.Read())
             {
                 custID       = rdr[0].ToString();
                 custID       = custID.Replace(" ", "");
                 compName     = rdr[1].ToString();
                 compName     = compName.Replace(" ", "");
                 contactName  = rdr[2].ToString();
                 contactName  = contactName.Replace(" ", "");
                 contactTitle = rdr[3].ToString();
                 contactTitle = contactTitle.Replace(" ", "");
                 address      = rdr[4].ToString();
                 city         = rdr[5].ToString();
                 city         = city.Replace(" ", "");
                 province     = rdr[6].ToString();
                 province     = province.Replace(" ", "");
                 country      = rdr[7].ToString();
                 POSTALCODE   = rdr[8].ToString();
                 phone        = rdr[9].ToString();
                 FAX          = rdr[10].ToString();
                 FAX          = FAX.Replace(" ", "");
                 customerList.Add(new Custmor(custID, compName, contactName, contactTitle, address, city, province, country, POSTALCODE, phone, FAX));
             }
         }
         cn.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }