private void GetCompanyAddress()
        {
            string             _companyNo = ConfigurationManager.GetConfiguration().CompanyNo;
            MAS_COMPANY        cData      = new MAS_COMPANY();
            Mas_Company_Manage manage     = new Mas_Company_Manage();

            cData = manage.GetMasCompanyByID(_companyNo);

            txtContactAdd.Text = cData.CompanyAddressTH;
        }
Beispiel #2
0
        public MAS_COMPANY GetCompanyByID(string CompanyNo)
        {
            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

            MAS_COMPANY dataRet = new MAS_COMPANY();

            try
            {
                string strQuery = "SELECT [CompanyNo],[CompanyNameTH],[CompanyNameEN],[CompanyAddressTH] " +
                                  "FROM  [tb_mas_Company] WHERE [IsActive] = 1 and CompanyNo = @CompanyNo ";

                SqlCommand command = new SqlCommand(strQuery, _conn);
                command.Parameters.AddWithValue("@CompanyNo", CompanyNo);

                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        MAS_COMPANY data = new MAS_COMPANY();

                        if (!DBNull.Value.Equals(reader["CompanyNo"]))
                        {
                            data.CompanyNo = (Int64)reader["CompanyNo"];
                        }
                        if (!DBNull.Value.Equals(reader["CompanyNameTH"]))
                        {
                            data.CompanyNameTH = (string)reader["CompanyNameTH"];
                        }
                        if (!DBNull.Value.Equals(reader["CompanyNameEN"]))
                        {
                            data.CompanyNameEN = (string)reader["CompanyNameEN"];
                        }

                        if (!DBNull.Value.Equals(reader["CompanyAddressTH"]))
                        {
                            data.CompanyAddressTH = (string)reader["CompanyAddressTH"];
                        }

                        dataRet = data;
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                logger.Error(sqlEx);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
            }

            return(dataRet);
        }
Beispiel #3
0
        public List <MAS_COMPANY> ListCompanyName()
        {
            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

            List <MAS_COMPANY> lRet = new List <MAS_COMPANY>();

            try
            {
                string strQuery = "SELECT [CompanyNo],[CompanyNameTH],[CompanyNameEN] " +
                                  "FROM  [tb_mas_Company] WHERE [IsActive] = 1 ";

                SqlCommand command = new SqlCommand(strQuery, _conn);
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        MAS_COMPANY data = new MAS_COMPANY();

                        if (!DBNull.Value.Equals(reader["CompanyNo"]))
                        {
                            data.CompanyNo = (Int64)reader["CompanyNo"];
                        }
                        if (!DBNull.Value.Equals(reader["CompanyNameTH"]))
                        {
                            data.CompanyNameTH = (string)reader["CompanyNameTH"];
                        }
                        if (!DBNull.Value.Equals(reader["CompanyNameEN"]))
                        {
                            data.CompanyNameEN = (string)reader["CompanyNameEN"];
                        }

                        lRet.Add(data);
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                logger.Error(sqlEx);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
            }

            return(lRet);
        }
Beispiel #4
0
        public MAS_COMPANY GetMasCompanyByID(string CompanyNo)
        {
            IDbConnection conn = null;
            MAS_COMPANY   ret  = new MAS_COMPANY();

            try
            {
                //SET CONNECTION
                conn = ConnectionFactory.GetConnection();
                conn.ConnectionString = ConfigurationManager.GetConfiguration().DbConnectionString;

                //OPEN CONNECTION
                conn.Open();

                Mas_CompanyBL bl = new Mas_CompanyBL(conn);
                ret = bl.GetCompanyByID(CompanyNo);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
            }
            finally
            {
                if (conn != null)
                {
                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }
                    conn.Dispose();
                }
            }

            return(ret);
        }