private CKGPartOrderDetail[] queryBySql(string p_sql)
        {
            DataView l_dv = ivContext.資料管理員.getDataViewBySql(p_sql);
            List <CKGPartOrderDetail> l_datas = new List <CKGPartOrderDetail>();

            if (l_dv.Count > 0)
            {
                for (int i = 0; i < l_dv.Count; i++)
                {
                    CKGPartOrderDetail l_code = createCKGPartOrderDetail();
                    l_code.f_ExchangeID請購單號 = l_dv[i]["f_ExchangeID"].ToString();
                    //l_code.f_AssistantSmid助理員編 = l_dv[i]["f_AssistantSmid"].ToString();
                    //l_code.f_SalesSmid業代員編 = l_dv[i]["f_SalesSmid"].ToString();
                    l_code.f_ProductID產品編號   = l_dv[i]["f_ProductID"].ToString();
                    l_code.f_ProductName產品名稱 = l_dv[i]["f_ProductName"].ToString();
                    l_code.f_Amount選購數量      = Convert.ToInt32(l_dv[i]["f_Amount"].ToString());
                    l_code.f_Qty產品單位         = l_dv[i]["f_Qty"].ToString();
                    l_code.f_Cost產品成本價       = Convert.ToInt32(l_dv[i]["f_Cost"].ToString());
                    l_code.f_UnitPrice產品單價   = Convert.ToInt32(l_dv[i]["f_UnitPrice"].ToString());
                    l_code.f_ListPrice建議售價   = Convert.ToInt32(l_dv[i]["f_ListPrice"].ToString());
                    l_code.f_Total總計價格       = Convert.ToInt32(l_dv[i]["f_Total"].ToString());
                    l_code.f_EditDate編輯日期    = l_dv[i]["f_EditDate"].ToString();
                    l_code.f_SalePrice販賣價    = Convert.ToInt32("0" + l_dv[i]["f_SalePrice"].ToString());

                    l_datas.Add(l_code);
                }
                return(l_datas.ToArray());
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// (way 20130520) 取得請購明細By請購單號s
        /// </summary>
        /// <param name="p_strExchangeID">請購單號s</param>
        /// <returns></returns>
        public CKGPartOrderDetail[] get請購明細ByExchangeID(List <string> p_strExchangeIDs)
        {
            //string l_strSql = "SELECT * FROM [KG].[dbo].[tbKGPartOrderDetail] WHERE f_ExchangeID='" + p_strExchangeID + "'";
            if (p_strExchangeIDs.Count <= 0)
            {
                return(null);
            }
            string l_strSql = "SELECT d.*,c.Name";

            l_strSql += " FROM [KG].[dbo].[tbKGPartOrderDetail] d";
            l_strSql += " inner join dbo.tbKGPartOrder p on d.f_ExchangeID = p.f_ExchangeID";
            l_strSql += " left join kddb..orders o on o.EngNo = p.f_engineno";
            l_strSql += " left join kddb..customer c on o.customerid = c.customerid";
            string l_str = "";

            for (int i = 0; i < p_strExchangeIDs.Count; i++)
            {
                l_str += "'" + p_strExchangeIDs[i] + "',";
            }
            l_strSql += " WHERE d.f_ExchangeID in (" + l_str.Substring(0, l_str.Length - 1) + ")";

            l_strSql += " order by d.f_EditDate";
            DataView l_dv = ivContext.資料管理員.getDataViewBySql(l_strSql);
            List <CKGPartOrderDetail> l_datas = new List <CKGPartOrderDetail>();

            if (l_dv.Count > 0)
            {
                for (int i = 0; i < l_dv.Count; i++)
                {
                    CKGPartOrderDetail l_code = createCKGPartOrderDetail();
                    l_code.f_ExchangeID請購單號 = l_dv[i]["f_ExchangeID"].ToString();
                    //l_code.f_AssistantSmid助理員編 = l_dv[i]["f_AssistantSmid"].ToString();
                    //l_code.f_SalesSmid業代員編 = l_dv[i]["f_SalesSmid"].ToString();
                    l_code.f_ProductID產品編號   = l_dv[i]["f_ProductID"].ToString();
                    l_code.f_ProductName產品名稱 = l_dv[i]["f_ProductName"].ToString();
                    l_code.f_Amount選購數量      = Convert.ToInt32(l_dv[i]["f_Amount"].ToString());
                    l_code.f_Qty產品單位         = l_dv[i]["f_Qty"].ToString();
                    l_code.f_Cost產品成本價       = Convert.ToInt32(l_dv[i]["f_Cost"].ToString());
                    l_code.f_UnitPrice產品單價   = Convert.ToInt32(l_dv[i]["f_UnitPrice"].ToString());
                    l_code.f_ListPrice建議售價   = Convert.ToInt32(l_dv[i]["f_ListPrice"].ToString());
                    l_code.f_Total總計價格       = Convert.ToInt32(l_dv[i]["f_Total"].ToString());
                    l_code.f_EditDate編輯日期    = l_dv[i]["f_EditDate"].ToString();
                    l_code.f_SalePrice販賣價    = Convert.ToInt32("0" + l_dv[i]["f_SalePrice"].ToString());

                    l_code.顧客姓名 = l_dv[i]["Name"].ToString();
                    l_datas.Add(l_code);
                }
                return(l_datas.ToArray());
            }
            else
            {
                return(null);
            }
        }
        public void updateCKGPartOrderDetail(CKGPartOrderDetail p_code)
        {
            string l_strSql = "UPDATE [kdnews].[dbo].[tbKGPartOrderDetail] SET ";

            l_strSql += "[f_AssistantSmid] = '" + p_code.f_AssistantSmid助理員編 + "',";
            l_strSql += "[f_SalesSmid] = '" + p_code.f_SalesSmid業代員編 + "',";
            l_strSql += "[f_ProductID] = '" + p_code.f_ProductID產品編號 + "',";
            l_strSql += "[f_ProductName] = '" + p_code.f_ProductName產品名稱.Replace("'", "''") + "',";
            l_strSql += "[f_Amount] = '" + p_code.f_Amount選購數量 + "',";
            l_strSql += "[f_Cost] = '" + p_code.f_Cost產品成本價 + "',";
            l_strSql += "[f_UnitPrice] = '" + p_code.f_UnitPrice產品單價 + "',";
            l_strSql += "[f_Total] = '" + p_code.f_Total總計價格 + "',";
            l_strSql += "[f_EditDate] = '" + p_code.f_EditDate編輯日期 + "'";
            l_strSql += " WHERE f_ExchangeID = '" + p_code.f_ExchangeID請購單號 + "'";
            ivContext.資料管理員.excuteSqlNonquery(l_strSql);
        }