code2 2007. 4. 27. 00:45

using System;
using System.Collections.Generic;
using System.Text;

using System.Data;
using System.Data.SqlClient;
using System.EnterpriseServices;
using FrameWork;
using PosDsl;

namespace PosDsl
{
    [JustInTimeActivation(true)]
    [Transaction(TransactionOption.NotSupported)]

    public class Buy_NTx : DBConnection
    {
        // 거래처명으로 거래처 코드 가져오기
        public string GetConCode(string conName)
        {
            SqlConnection con = new SqlConnection(ConnString);
            con.Open();

            string sqlQuery = "select * from ConnectionTbl where conOfficeName = '" + conName + "';";
            SqlCommand com = new SqlCommand(sqlQuery, con);
            object con_code = com.ExecuteScalar();

            return con_code.ToString();

        }


        // 전체 매입내역 목록 출력
        public BuyConData BuyLoad()
        {
            BuyConData buy = new BuyConData();
            string SqlQuery = "select * from BuyTbl";
            SqlHelper.FillDataset(Conn, CommandType.Text, SqlQuery, buy, new string[] { buy.BuyTbl.TableName });

            return buy;
        }

        // 매입내역 조회
        public BuyConData GetBuy(int Code, string conOfficeName)
        {
            if (Code == 0)
            {
                SqlConnection con = new SqlConnection(ConnString);
                con.Open();

                BuyConData buy = new BuyConData();
                string SqlQuery2 = "select * from ConnectionTbl where conOfficeName='" + conOfficeName + "';";

                SqlCommand com = new SqlCommand(SqlQuery2, con);
                object con_code = com.ExecuteScalar();

                string SqlQuery = "select * from BuyTbl where conCode='" + con_code.ToString() + "';";
                SqlHelper.FillDataset(Conn, CommandType.Text, SqlQuery, buy, new string[] { buy.BuyTbl.TableName });

                return buy;
            }
            else
            {
                BuyConData buy = new BuyConData();
                string SqlQuery = "select * from BuyTbl where conCode='" + conOfficeName + "';";
                SqlHelper.FillDataset(Conn, CommandType.Text, SqlQuery, buy, new string[] { buy.BuyTbl.TableName });
                return buy;
            }

        }

        //자동 생성 순번NO 반환
        public int GetBuyNum()
        {
            SqlConnection con = new SqlConnection(ConnString);
            con.Open();

            string query = "select count(*) from BuyTbl;";

            SqlCommand com = new SqlCommand(query, con);

            int ConNum = Convert.ToInt32(com.ExecuteScalar().ToString());
           
            return ConNum;
        }

        //매입내역 조회(거래처 코드,이름)
        public BuyConData GetConOfficeName()
        {
            return new BuyConData();
        }

    }
}