<%@ WebHandler Language="C#" Class="QualityData_SubLineDataQuery" %>

using System;
using System.Web;


public class QualityData_SubLineDataQuery : IHttpHandler {
    
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        string type = HttpContext.Current.Request["type"];
        string responseText = "";
        switch (type)
        {

            //工位号查询查询
            case "OpnameSelect":
                responseText = OpnameSelect();
                break;
            //物料数据查询
            case "dataMateralSelect":
                responseText = dataMateralSelect();
                break;
            //查询物料条码批次
            case "BarcodeBatchMaterialsSelect":
                responseText = MaterialBatchSelect();
                break;
        }
        context.Response.Write(responseText);
    }
    /// <summary>
    ///物料条码批次查询 2014-11-25
    /// </summary>
    /// <returns></returns>
    private string MaterialBatchSelect()
    {
        System.Data.DataTable dt = null;
        string dtStartTime = HttpContext.Current.Request["startdate"];
        string dtEndTime = HttpContext.Current.Request["enddate"];
        MES_SPC.QualityData_MaterialSelect.GetMaterial_SublineBarcodeBatchMaterials(dtStartTime, dtEndTime, out dt);
        string text = JsonHelper.DataTableToJson(dt);
        return text;
    }
    /// <summary>
    ///工位查询
    /// </summary>
    /// <returns></returns>
    private string OpnameSelect()
    {
        System.Data.DataTable dt = null;
        MES_SPC.CraftMana_step.OpnameSelect(out dt);
        string text = JsonHelper.DataTableToJson(dt);
        return text;
    }
    /// <summary>
    /// 分线物料数据查询
    /// </summary>
    /// <returns></returns>
    private string dataMateralSelect()
    {
        System.Data.DataTable dt = null;
        string startdate = HttpContext.Current.Request["startdate"];
        string enddate = HttpContext.Current.Request["enddate"];
        bool checkbox_opname = Convert.ToBoolean(HttpContext.Current.Request["checkbox_opname"]);
        string opName = HttpContext.Current.Request["opName"];
        bool checkbox_MaterialsBatchBarcode = Convert.ToBoolean(HttpContext.Current.Request["checkbox_BarcodeBatchMaterials"]);
        string comboBox_MaterialsBatchBarcode = HttpContext.Current.Request["comboBox_BarcodeBatchMaterials"];
        MES_SPC.QualityData_MaterialSelect.SubLineSelect_material(startdate, enddate,checkbox_opname,
            opName, checkbox_MaterialsBatchBarcode, comboBox_MaterialsBatchBarcode,out  dt);

        string text = JsonHelper.CreateJsonParameters(dt, true, 0);//这句话是将json数据对象化，并且返回数据总条数
        return text;
    }
    public bool IsReusable {
        get {
            return false;
        }
    }

}







