コード例 #1
0
        public CRSalesman GetSalesman(short oid)
        {
            var con = new SQLiteConnection(cs);

            con.Open();

            var cmd = new SQLiteCommand(con)
            {
                CommandText = $"select * from CR_Salesman where Sman_Cd = {oid} limit 1"
            };

            var rdr        = cmd.ExecuteReader();
            var crSalesman = new CRSalesman();

            while (rdr.Read())
            {
                crSalesman.Sman_Cd  = rdr.GetInt16(0);
                crSalesman.NameEn   = rdr.GetString(1);
                crSalesman.NameAr   = rdr.GetString(2);
                crSalesman.Locat_Cd = rdr.GetInt16(3);
            }

            cmd.Dispose();
            con.Close();
            con.Dispose();

            return(crSalesman);
        }
コード例 #2
0
        private CRSalesman GetSalesman(short oid)
        {
            try
            {
                var cs = @ConfigurationManager.ConnectionStrings["slconnection"].ConnectionString;

                var con = new SQLiteConnection(cs);
                con.Open();

                var cmd = new SQLiteCommand(con)
                {
                    CommandText = $"select * from CR_Salesman where Sman_Cd = {oid} limit 1"
                };

                var rdr        = cmd.ExecuteReader();
                var crSalesman = new CRSalesman();

                while (rdr.Read())
                {
                    crSalesman.Sman_Cd  = rdr.GetInt16(0);
                    crSalesman.NameEn   = rdr.GetString(1);
                    crSalesman.NameAr   = rdr.GetString(2);
                    crSalesman.Locat_Cd = rdr.GetInt16(3);
                }

                cmd.Dispose();
                con.Close();
                con.Dispose();

                return(crSalesman);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }
        }