Example #1
0
    public void LoadGrid()
    {
        DataTable dTable = new DataTable();

        dTable.TableName = "CR";
        SqlCommand sql = new SqlCommand();

        sql.CommandText  = "SELECT MCName,StampDate,Shift,LastAlarmDate,CountAlarm FROM LogAlarmMC lam";
        sql.CommandText += " INNER JOIN AlarmLineSetting als ON lam.MCName=als.MachineName";
        sql.CommandText += " where als.LineName = @LineName";
        sql.CommandText += " and lam.StampDate >= @DateStart";
        sql.CommandText += " and lam.StampDate <= @DateEnd";
        if (ddlShift.SelectedValue != "")
        {
            sql.CommandText += " and lam.Shift = @Shift";
        }
        if (ddlMachine.SelectedValue != "")
        {
            sql.CommandText += " and lam.MCName=@MCName";
        }
        sql.Parameters.Add(new SqlParameter("@DateStart", txtDateStart.Text.Trim()));
        sql.Parameters.Add(new SqlParameter("@DateEnd", txtDateEnd.Text.Trim()));
        sql.Parameters.Add(new SqlParameter("@Shift", ddlShift.SelectedValue));
        sql.Parameters.Add(new SqlParameter("@LineName", ddlLine.SelectedValue));
        sql.Parameters.Add(new SqlParameter("@MCName", ddlMachine.SelectedValue));
        dTable = oConnFac3.Query(sql);

        DataView dView = new DataView();

        dView.Table = dTable;
        gSorting1   = (GVSorting)Session["gSorting1"];

        if (gSorting1 != null)
        {
            if (gSorting1.GetSorting() != "")
            {
                try
                {
                    dView.Sort = gSorting1.GetSorting();
                }
                catch (Exception ex)
                {
                }
            }
        }

        lbSummaryData.Text = dView.Count.ToString();

        GridView1.DataSource = dView;
        GridView1.DataBind();
    }
    public void LoadGrid()
    {
        if (txtSerialNumber.Text.Trim() != "")
        {
            DataTable dTable = new DataTable();
            dTable.TableName = "CR";
            SqlCommand sql = new SqlCommand();
            sql.CommandText = "exec GetDataCRByLabelNo @LabelNo,@Model";
            sql.Parameters.Add(new SqlParameter("@LabelNo", txtSerialNumber.Text.Trim()));
            sql.Parameters.Add(new SqlParameter("@Model", ddlModel.SelectedValue));
            dTable = oConnFac3.Query(sql);

            DataView dView = new DataView();
            dView.Table = dTable;
            gSorting1   = (GVSorting)Session["gSorting1"];

            if (gSorting1 != null)
            {
                if (gSorting1.GetSorting() != "")
                {
                    try
                    {
                        dView.Sort = gSorting1.GetSorting();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

            lbSummaryData.Text = dView.Count.ToString();

            GridView1.DataSource = dView;
            GridView1.DataBind();
        }
        else
        {
            txtSerialNumber.Focus();
        }
    }
Example #3
0
    public void LoadGrid()
    {
        DataTable dTable = new DataTable();

        dTable.TableName = "IndexColumn";
        dTable.Columns.Add("mhi_id");
        dTable.Columns.Add("mc_code");
        dTable.Columns.Add("index_datetime");
        dTable.Columns.Add("index_partnumber");
        dTable.Columns.Add("index_modelcode");
        dTable.Columns.Add("index_value");
        dTable.Columns.Add("index_result");


        StringBuilder sbd = new StringBuilder();

        sbd.AppendLine("SELECT DISTINCT mc.mc_code,index_datetime,index_partnumber,index_modelcode,index_value,index_result");
        sbd.AppendLine(",mhi.mhi_id");
        sbd.AppendLine("FROM Machine mc");
        sbd.AppendLine("LEFT JOIN MachineHeaderIndex mhi ON mc.mc_code=mhi.mc_code");
        sbd.AppendLine("LEFT JOIN IndexColumn ic ON mhi.index_id=ic.index_id");
        sbd.AppendLine("LEFT JOIN LineData ld ON mc.ld_id=ld.ld_id");
        sbd.AppendLine("LEFT JOIN FactoryData fd ON ld.FactoryID=fd.FactoryID");
        if (ddlFactory.SelectedValue != "0")
        {
            sbd.AppendLine("WHERE fd.FactoryID = '" + ddlFactory.SelectedValue + "'");
        }


        if (ddlLine.SelectedValue != "0" && ddlFactory.SelectedValue != "0")
        {
            sbd.AppendLine("AND ld.ld_id='" + ddlLine.SelectedValue + "'");
        }

        dTable = oConn.Query(sbd.ToString());

        dTable.Columns.Add("CanEdit", typeof(bool));
        dTable.Columns.Add("CanDel", typeof(bool));


        if (dTable.Rows.Count > 0)
        {
            for (int i = 0; i < dTable.Rows.Count; i++)
            {
                dTable.Rows[i]["CanEdit"] = true;
                dTable.Rows[i]["CanDel"]  = true;
            }
        }
        else
        {
            DataRow row;
            row            = dTable.NewRow();
            row["CanEdit"] = false;
            row["CanDel"]  = false;
            dTable.Rows.Add(row);
        }


        DataView dView = new DataView();

        dView.Table = dTable;
        gSorting1   = (GVSorting)Session["gSorting1"];

        if (gSorting1 != null)
        {
            if (gSorting1.GetSorting() != "")
            {
                try
                {
                    dView.Sort = gSorting1.GetSorting();
                }
                catch (Exception ex)
                {
                }
            }
        }

        GridView1.DataSource = dView;
        GridView1.DataBind();
    }
Example #4
0
    public void LoadGrid()
    {
        if (txtSerialNumber.Text.Trim() != "")
        {
            SqlCommand sql          = new SqlCommand();
            DataTable  dTablePallet = new DataTable();
            dTablePallet.TableName = "Pallet";
            sql.CommandText        = "SELECT pl_no,pl_date,pck_no,prd_serial,prd_cd,prd_date,wh_recieve FROM vi_Pack_Pallet";
            sql.CommandText       += " WHERE pl_no = @Pallet AND line_cd=6";
            sql.Parameters.Add(new SqlParameter("@Pallet", txtSerialNumber.Text.Trim()));
            dTablePallet = oConnDCI.Query(sql);

            DataTable dTable = new DataTable();
            dTable.TableName = "CR";
            if (dTablePallet.Rows.Count > 0)
            {
                foreach (DataRow _row in dTablePallet.Rows)
                {
                    DataTable _dTable = new DataTable();
                    sql             = new SqlCommand();
                    sql.CommandText = "exec GetDataCRByLabelNo @LabelNo,@Model";
                    sql.Parameters.Add(new SqlParameter("@LabelNo", _row["prd_serial"].ToString().Substring(7, 8)));
                    sql.Parameters.Add(new SqlParameter("@Model", _row["prd_serial"].ToString().Substring(3, 4)));
                    _dTable = oConnFac3.Query(sql);

                    if (dTable.Columns.Count != _dTable.Columns.Count)
                    {
                        dTable = _dTable.Clone();
                    }

                    if (_dTable.Rows.Count > 0)
                    {
                        foreach (DataRow row in _dTable.Rows)
                        {
                            dTable.Rows.Add(row.ItemArray);
                        }
                    }
                }
            }



            DataView dView = new DataView();
            dView.Table = dTable;
            gSorting1   = (GVSorting)Session["gSorting1"];

            if (gSorting1 != null)
            {
                if (gSorting1.GetSorting() != "")
                {
                    try
                    {
                        dView.Sort = gSorting1.GetSorting();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

            lbSummaryData.Text = dView.Count.ToString();

            GridView1.DataSource = dView;
            GridView1.DataBind();
        }
        else
        {
            txtSerialNumber.Focus();
        }
    }
    public void LoadGrid()
    {
        DataTable dTable = new DataTable();

        dTable.TableName = "Quantity";
        StringBuilder sbd = new StringBuilder();

        if (ViewState["ld_id"].ToString() == "4")
        {
            // From MES
            // Main Assembly Line
            if (ViewState["mc_code"].ToString() == "Main01") // Rotor Yakibame
            {
                sbd.AppendLine("SELECT * FROM Rotor_Yakibame");
                sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
                sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
                sbd.AppendLine("ORDER BY InsertDate desc");
            }
            else if (ViewState["mc_code"].ToString() == "Main02") // Magnetize
            {
                sbd.AppendLine("SELECT * FROM Magnetize");
                sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
                sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
                sbd.AppendLine("ORDER BY InsertDate desc");
            }
            else if (ViewState["mc_code"].ToString() == "Main03") // Pipe Yakibame
            {
                sbd.AppendLine("SELECT * FROM Pipe_Yakibame");
                sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
                sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
                sbd.AppendLine("ORDER BY InsertDate desc");
            }
            else if (ViewState["mc_code"].ToString() == "Main04") // Tack Welding
            {
                sbd.AppendLine("SELECT * FROM TackWelding");
                sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
                sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
                sbd.AppendLine("ORDER BY InsertDate desc");
            }
            else if (ViewState["mc_code"].ToString() == "Main05") // Magnet Center
            {
                sbd.AppendLine("SELECT * FROM MagnetCenter");
                sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
                sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
                sbd.AppendLine("ORDER BY InsertDate desc");
            }
            else if (ViewState["mc_code"].ToString() == "Main06") // Air Gap
            {
                sbd.AppendLine("SELECT * FROM AirGap");
                sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
                sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
                sbd.AppendLine("ORDER BY InsertDate desc");
            }
            else if (ViewState["mc_code"].ToString() == "Main07") // Connecting Check
            {
                sbd.AppendLine("SELECT * FROM ElectricalConduction");
                sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
                sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
                sbd.AppendLine("ORDER BY InsertDate desc");
            }
        }
        else
        {
            // From Data Logger
        }



        dTable = oConnFac3.Query(sbd.ToString());

        DataView dView = new DataView();

        dView.Table = dTable;
        gSorting1   = (GVSorting)Session["gSorting1"];

        if (gSorting1 != null)
        {
            if (gSorting1.GetSorting() != "")
            {
                try
                {
                    dView.Sort = gSorting1.GetSorting();
                }
                catch (Exception ex)
                {
                }
            }
        }

        GridView1.DataSource = dView;
        GridView1.DataBind();
    }
    public void LoadGrid()
    {
        DataTable     dTable     = new DataTable();
        StringBuilder sbd        = new StringBuilder();
        DataTable     dTableData = new DataTable();

        sbd.AppendLine("SELECT TOP 3 data_detail,hm.header_detail");
        sbd.AppendLine("FROM Data dt");
        sbd.AppendLine("LEFT JOIN MachineHeaderIndex mhi ON dt.mc_code=mhi.mc_code");
        sbd.AppendLine("LEFT JOIN HeaderMaster hm ON mhi.header_id=hm.header_id");
        sbd.AppendLine("where dt.mc_code = '" + ViewState["mc_code"].ToString() + "'");

        dTableData = oConn.Query(sbd.ToString());

        DataTable dTableDetail = new DataTable();

        dTableDetail.TableName = "Detail";
        if (dTableData.Rows.Count > 0)
        {
            string[] header = dTableData.Rows[0]["header_detail"].ToString().Split(',');
            if (header.Length > 0)
            {
                int       countRow  = 0;
                ArrayList arrHeader = new ArrayList();
                foreach (string head in header)
                {
                    if (!arrHeader.Contains(head))
                    {
                        dTableDetail.Columns.Add(countRow.ToString() + ". " + head.Trim());
                    }
                    else
                    {
                        dTableDetail.Columns.Add(countRow.ToString() + ". " + head.Trim() + "2");
                    }
                    arrHeader.Add(head.Trim());
                    countRow++;
                }
            }


            foreach (DataRow row in dTableData.Rows)
            {
                string[] spl = row[0].ToString().Split(',');
                if (spl.Length > 0)
                {
                    DataRow dRow;
                    dRow = dTableDetail.NewRow();
                    for (int i = 0; i < spl.Length; i++)
                    {
                        dRow[i] = spl[i].ToString();
                    }
                    dTableDetail.Rows.Add(dRow);
                }
            }
        }

        dTable = dTableDetail.Copy();

        DataView dView = new DataView();

        dView.Table = dTable;
        gSorting1   = (GVSorting)Session["gSorting1"];

        if (gSorting1 != null)
        {
            if (gSorting1.GetSorting() != "")
            {
                try
                {
                    dView.Sort = gSorting1.GetSorting();
                }
                catch (Exception ex)
                {
                }
            }
        }

        GridView1.DataSource = dView;
        GridView1.DataBind();
    }
    public void LoadGrid()
    {
        DataTable dTable = new DataTable();

        dTable.TableName = "Quantity";
        StringBuilder sbd = new StringBuilder();

        if (ViewState["ld_id"].ToString() == "4")
        {
            // From MES
            // Main Assembly Line
            if (ViewState["mc_code"].ToString() == "Main01") // Rotor Yakibame
            {
                sbd.AppendLine("SELECT * FROM Rotor_Yakibame");
                sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
                sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
                sbd.AppendLine("ORDER BY InsertDate desc");
            }
            else if (ViewState["mc_code"].ToString() == "Main02") // Magnetize
            {
                sbd.AppendLine("SELECT * FROM Magnetize");
                sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
                sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
                sbd.AppendLine("ORDER BY InsertDate desc");
            }
            else if (ViewState["mc_code"].ToString() == "Main03") // Pipe Yakibame
            {
                sbd.AppendLine("SELECT * FROM Pipe_Yakibame");
                sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
                sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
                sbd.AppendLine("ORDER BY InsertDate desc");
            }
            else if (ViewState["mc_code"].ToString() == "Main04") // Tack Welding
            {
                sbd.AppendLine("SELECT * FROM TackWelding");
                sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
                sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
                sbd.AppendLine("ORDER BY InsertDate desc");
            }
            else if (ViewState["mc_code"].ToString() == "Main05") // Magnet Center
            {
                sbd.AppendLine("SELECT * FROM MagnetCenter");
                sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
                sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
                sbd.AppendLine("ORDER BY InsertDate desc");
            }
            else if (ViewState["mc_code"].ToString() == "Main06") // Air Gap
            {
                sbd.AppendLine("SELECT * FROM AirGap");
                sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
                sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
                sbd.AppendLine("ORDER BY InsertDate desc");
            }
            else if (ViewState["mc_code"].ToString() == "Main07") // Connecting Check
            {
                sbd.AppendLine("SELECT * FROM ElectricalConduction");
                sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
                sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
                sbd.AppendLine("ORDER BY InsertDate desc");
            }
            else if (ViewState["mc_code"].ToString() == "Main08") // Connecting Check
            {
                sbd.AppendLine("SELECT * FROM TopBottomWelding");
                sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
                sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
                sbd.AppendLine("ORDER BY InsertDate desc");
            }

            dTable = oConnFac3.Query(sbd.ToString());
        }
        else if (ViewState["mc_code"].ToString() == "PISTON_LASER")
        {
            sbd.AppendLine("SELECT * FROM MC_LaserMark_Piston");
            sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
            sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
            sbd.AppendLine("ORDER BY InsertDate desc");
            dTable = oConnFac3.Query(sbd.ToString());
        }
        else if (ViewState["mc_code"].ToString() == "FRONTHEAD_LASER")
        {
            sbd.AppendLine("SELECT * FROM MC_LaserMark_FH");
            sbd.AppendLine("WHERE InsertDate >= '" + txtDateStart.Text.Trim() + "'");
            sbd.AppendLine("AND InsertDate <= '" + txtDateEnd.Text.Trim() + "'");
            sbd.AppendLine("ORDER BY InsertDate desc");
            dTable = oConnFac3.Query(sbd.ToString());
        }
        else
        {
            // From Data Logger
            sbd = new StringBuilder();
            DataTable dTableData = new DataTable();
            sbd.AppendLine("SELECT data_detail,hm.header_detail");
            sbd.AppendLine("FROM Data dt");
            sbd.AppendLine("LEFT JOIN MachineHeaderIndex mhi ON dt.mc_code=mhi.mc_code");
            sbd.AppendLine("LEFT JOIN HeaderMaster hm ON mhi.header_id=hm.header_id");
            sbd.AppendLine("where dt.mc_code = '" + ddlMachine.SelectedValue + "'");
            if (ddlModel.SelectedValue != "0")
            {
                sbd.AppendLine("AND model_id='" + ddlModel.SelectedValue + "'");
            }
            sbd.AppendLine("AND data_mfgdate_search >= '" + txtDateStart.Text.Trim() + "'");
            sbd.AppendLine("AND data_mfgdate_search <= '" + txtDateEnd.Text.Trim() + "'");
            sbd.AppendLine("AND data_partnumber like '%" + txtSerialNumber.Text.Trim() + "%'");
            dTableData = oConn.Query(sbd.ToString());

            DataTable dTableDetail = new DataTable();
            dTableDetail.TableName = "Detail";
            if (dTableData.Rows.Count > 0)
            {
                string[] header = dTableData.Rows[0]["header_detail"].ToString().Split(',');
                if (header.Length > 0)
                {
                    ArrayList arrHeader = new ArrayList();
                    foreach (string head in header)
                    {
                        if (!arrHeader.Contains(head))
                        {
                            dTableDetail.Columns.Add(head.Trim());
                        }
                        else
                        {
                            dTableDetail.Columns.Add(head.Trim() + "2");
                        }
                        arrHeader.Add(head.Trim());
                    }
                }


                foreach (DataRow row in dTableData.Rows)
                {
                    string[] spl = row[0].ToString().Split(',');
                    if (spl.Length > 0)
                    {
                        DataRow dRow;
                        dRow = dTableDetail.NewRow();
                        for (int i = 0; i < spl.Length; i++)
                        {
                            dRow[i] = spl[i].ToString();
                        }
                        dTableDetail.Rows.Add(dRow);
                    }
                }
            }

            dTable = dTableDetail.Copy();
        }

        DataView dView = new DataView();

        dView.Table = dTable;
        gSorting1   = (GVSorting)Session["gSorting1"];

        if (gSorting1 != null)
        {
            if (gSorting1.GetSorting() != "")
            {
                try
                {
                    dView.Sort = gSorting1.GetSorting();
                }
                catch (Exception ex)
                {
                }
            }
        }

        lbSummaryData.Text = dView.Count.ToString();

        GridView1.DataSource = dView;
        GridView1.DataBind();
    }
    private void LoadGrid()
    {
        MDUserLoginData oUserLoginData = new MDUserLoginData();
        DataTable       dTable         = new DataTable();

        dTable.TableName = "Part Package";
        dTable.Columns.Add("CanEdit", typeof(bool));
        dTable.Columns.Add("CanDel", typeof(bool));
        dTable.Columns.Add("IsActive", typeof(bool));
        dTable.Columns.Add("EmpCode", typeof(string));
        dTable.Columns.Add("Password", typeof(string));
        dTable.Columns.Add("PwdExpired", typeof(string));
        dTable.Columns.Add("PwdLastUpdate", typeof(string));
        dTable.Columns.Add("SupplierName", typeof(string));
        dTable.Columns.Add("UpdateBy", typeof(string));
        dTable.Columns.Add("UpdateDate", typeof(string));
        dTable.Columns.Add("UserID", typeof(string));
        dTable.Columns.Add("Username", typeof(string));
        dTable.Columns.Add("PwdRemaining", typeof(string));

        int Active = 2; // all

        if (rblActive.SelectedValue == "0")
        {
            Active = 0; // InActive
        }
        else if (rblActive.SelectedValue == "1")
        {
            Active = 1; // Active
        }
        else
        {
            Active = 2; // all
        }
        oUserLoginData = oUser.GetUserListAll(txtSearch.Text.Trim(), Active);

        if (oUserLoginData.ListOfUserLoginData.Length > 0)
        {
            for (int i = 0; i <= oUserLoginData.ListOfUserLoginData.Length - 1; i++)
            {
                DataRow dRow;
                dRow             = dTable.NewRow();
                dRow["CanEdit"]  = true;
                dRow["CanDel"]   = true;
                dRow["IsActive"] = oUserLoginData.ListOfUserLoginData[i].Active;
                dRow["EmpCode"]  = oUserLoginData.ListOfUserLoginData[i].EmpCode;
                //oUserLoginData.ListOfUserLoginData[i].ListOfSystem;
                //oUserLoginData.ListOfUserLoginData[i].ListOfUserInGroup;
                dRow["Password"]   = oUserLoginData.ListOfUserLoginData[i].Password;
                dRow["PwdExpired"] = oUserLoginData.ListOfUserLoginData[i].PwdExpired;
                //dRow[""] = oUserLoginData.ListOfUserLoginData[i].PwdLastUpdate;
                //DateTime date = DateTime.ParseExact(oUserLoginData.ListOfUserLoginData[i].PwdLastUpdate, "dd/MM/yyyy", null);
                //TimeSpan diff = DateTime.Now - date;
                //int days = (int)Math.Abs(Math.Round(diff.TotalDays));
                //dRow["PwdRemaining"] = days.ToString();
                dRow["SupplierName"] = oUserLoginData.ListOfUserLoginData[i].SupplierName;
                //dRow["SupplierNo"] = oUserLoginData.ListOfUserLoginData[i].SupplierNo;
                dRow["UpdateBy"]   = oUserLoginData.ListOfUserLoginData[i].UpdateBy;
                dRow["UpdateDate"] = oUserLoginData.ListOfUserLoginData[i].UpdateDate;
                dRow["UserID"]     = oUserLoginData.ListOfUserLoginData[i].UserID;
                dRow["Username"]   = oUserLoginData.ListOfUserLoginData[i].UserName;
                dTable.Rows.Add(dRow);
            }
        }
        else
        {
            DataRow dRow;
            dRow            = dTable.NewRow();
            dRow["CanEdit"] = false;
            dRow["CanDel"]  = false;
            dTable.Rows.Add(dRow);
        }

        DataView dView = new DataView();

        dView.Table = dTable;
        gSorting1   = (GVSorting)Session["gSorting1"];

        if (gSorting1.GetSorting() != "")
        {
            try
            {
                dView.Sort = gSorting1.GetSorting();
            }
            catch (Exception ex)
            {
            }
        }

        GridView1.DataSource = dView;
        GridView1.DataBind();
    }
    private void LoadData()
    {
        DataTable dTable = new DataTable();

        dTable.TableName = "QC Sampling";
        dTable.Columns.Add("CanEdit", typeof(bool));
        dTable.Columns.Add("CanDel", typeof(bool));
        dTable.Columns.Add("ID", typeof(string));
        dTable.Columns.Add("ModelCode", typeof(string));
        dTable.Columns.Add("MainPoint", typeof(string));
        dTable.Columns.Add("SubPoint", typeof(string));
        dTable.Columns.Add("MQMin", typeof(string));
        dTable.Columns.Add("MQMax", typeof(string));
        dTable.Columns.Add("UCL", typeof(string));
        dTable.Columns.Add("CL", typeof(string));
        dTable.Columns.Add("LCL", typeof(string));
        dTable.Columns.Add("UpdateBy", typeof(string));
        dTable.Columns.Add("UpdateDate", typeof(DateTime));
        DataTable  dDataTable = new DataTable();
        SqlCommand sql        = new SqlCommand();

        if (ddlMainPoint.Text != "" && ddlSubPoint.Text != "")
        {
            sql.CommandText = @"SELECT [ID],[PartType],[Model],[MainPoint],[SubPoint],[MQMin],[MQMax],[UCL],[CL],[LCL],[UpdateBy],[UpdateDate]
                            FROM [dbIoT].[dbo].[QC_StandardMaster] 
                               where PartType = @part and MainPoint = @MainPoint and SubPoint = @SubPoint order by UpdateDate desc";

            sql.Parameters.Add(new SqlParameter("@Part", ViewState["PartType"].ToString()));
            sql.Parameters.Add(new SqlParameter("@MainPoint", ddlMainPoint.SelectedValue));
            sql.Parameters.Add(new SqlParameter("@SubPoint", ddlSubPoint.SelectedValue));
        }
        else if (ddlMainPoint.Text != "" && ddlSubPoint.Text == "")
        {
            sql.CommandText = @"SELECT [ID],[PartType],[Model],[MainPoint],[SubPoint],[MQMin],[MQMax],[UCL],[CL],[LCL],[UpdateBy],[UpdateDate]
                            FROM [dbIoT].[dbo].[QC_StandardMaster] 
                               where PartType = @part and MainPoint = @MainPoint order by UpdateDate desc";

            sql.Parameters.Add(new SqlParameter("@Part", ViewState["PartType"].ToString()));
            sql.Parameters.Add(new SqlParameter("@MainPoint", ddlMainPoint.SelectedValue));
        }
        else
        {
            sql.CommandText = @"SELECT [ID],[PartType],[Model],[MainPoint],[SubPoint],[MQMin],[MQMax],[UCL],[CL],[LCL],[UpdateBy],[UpdateDate]
                            FROM [dbIoT].[dbo].[QC_StandardMaster] 
                               where PartType = @part order by UpdateDate desc";

            sql.Parameters.Add(new SqlParameter("@Part", ViewState["PartType"].ToString()));
        }
        dDataTable = oConn.Query(sql);



        if (dDataTable.Rows.Count > 0)
        {
            foreach (DataRow row in dDataTable.Rows)
            {
                DataRow dRow;
                dRow               = dTable.NewRow();
                dRow["CanEdit"]    = true;
                dRow["CanDel"]     = true;
                dRow["ID"]         = row["ID"].ToString();
                dRow["ModelCode"]  = row["Model"].ToString();
                dRow["MainPoint"]  = row["MainPoint"].ToString();
                dRow["SubPoint"]   = row["SubPoint"].ToString();
                dRow["MQMin"]      = row["MQMin"].ToString();
                dRow["MQMax"]      = row["MQMax"].ToString();
                dRow["UCL"]        = row["UCL"].ToString();
                dRow["CL"]         = row["CL"].ToString();
                dRow["LCL"]        = row["LCL"].ToString();
                dRow["UpdateBy"]   = row["UpdateBy"].ToString();
                dRow["UpdateDate"] = row["UpdateDate"].ToString();
                dTable.Rows.Add(dRow);
            }
        }
        else
        {
            DataRow dRow;
            dRow            = dTable.NewRow();
            dRow["CanEdit"] = false;
            dRow["candel"]  = false;
            dTable.Rows.Add(dRow);
        }
        DataView dView = new DataView();

        dView.Table = dTable;
        gSorting1   = (GVSorting)Session["gSorting1"];

        if (gSorting1.GetSorting() != "")
        {
            try
            {
                dView.Sort = gSorting1.GetSorting();
            }
            catch (Exception ex)
            {
            }
        }

        GridView1.DataSource = dView;
        GridView1.DataBind();
    }