Beispiel #1
0
        public static List <string> GetPrintEinvoiceNumbersByPrintNo(string printNo)
        {
            List <string> invoiceList = new List <string>();

            Repositoies.SaveMesagesToTextFile("取號開始:" + printNo);
            var data = PrintEinvoiceSqlHandler(printNo);

            Repositoies.SaveMesagesToTextFile("取號結束:" + printNo);

            return(data);
        }
Beispiel #2
0
        public static List <string> PrintEinvoiceSqlHandler(string printNo)
        {
            List <string> result = new List <string>();

            try
            {
                string connectionString = @"Data Source=192.168.1.4;Initial Catalog=NavisionNew;User ID=sa;Password=sasasasa";
                string queryString      =
                    @"  select * from [Rinnai$VAT Print Number] where [Print No] =@printNo  order by [VAT No] ";

                List <SqlParameter> sqlParameters = new List <SqlParameter>();
                sqlParameters.Add(new SqlParameter()
                {
                    ParameterName = "@printNo", Value = printNo
                });
                Repositoies.SaveMesagesToTextFile("取號資料庫連線開始:" + printNo);

                using (SqlConnection connection =
                           new SqlConnection(connectionString))
                {
                    SqlCommand command = new SqlCommand(queryString, connection);
                    command.Parameters.AddRange(sqlParameters.ToArray());

                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
                    DataTable     dt     = new DataTable();
                    dt.Load(reader);
                    if (dt.Rows.Count == 0)
                    {
                        Repositoies.SaveMesagesToTextFile("取得筆數0筆:");
                        throw new Exception(string.Format("列印序號:{0} 查無發票號碼!", printNo));
                    }
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        result.Add(dt.Rows[i]["VAT No"].ToString());
                    }
                }
                Repositoies.SaveMesagesToTextFile("取號資料庫連線結束:" + printNo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            result = result.Distinct().ToList();
            return(result);
        }