private void LoadData() { MDMachineHeader oMDMCHeader = new MDMachineHeader(); oMDMCHeader = oMachineHeader.GetMachineHeaderBymc_code(ViewState["mc_code"].ToString()); if (oMDMCHeader.ListOfMachineHeader.Count > 0) { txtDatetime.Text = oMDMCHeader.ListOfMachineHeader[0].index_datetime; txtModel.Text = oMDMCHeader.ListOfMachineHeader[0].index_modelcode; txtPartNumber.Text = oMDMCHeader.ListOfMachineHeader[0].index_partnumber; txtResult.Text = oMDMCHeader.ListOfMachineHeader[0].index_result; txtValue.Text = oMDMCHeader.ListOfMachineHeader[0].index_value; } }
public MDMachineHeader GetMachineHeader(string inSearch) { inSearch = "%" + inSearch + "%"; MDMachineHeader oMDMCHeader = new MDMachineHeader(); DataTable dTable = new DataTable(); SqlCommand sql = new SqlCommand(); sql.CommandText = "SELECT mhi_id,mhi.mc_code,mc_name,mhi.index_id,mhi.header_id,mhi_createby,mhi_createdate"; sql.CommandText += ",mhi_updateby,mhi_updatedate,header_detail,index_datetime,index_partnumber,index_modelcode,index_result"; sql.CommandText += ",index_value"; sql.CommandText += " FROM MachineHeaderIndex mhi"; sql.CommandText += " LEFT JOIN headerMaster hm ON mhi.header_id = hm.header_id"; sql.CommandText += " LEFT JOIN IndexColumn ic ON mhi.index_id = ic.index_id"; sql.CommandText += " LEFT JOIN machine mc ON mhi.mc_code=mc.mc_code"; sql.CommandText += " WHERE ISNULL(mhi.mc_code,'') like @inSearch"; sql.Parameters.Add(new SqlParameter("@inSearch", inSearch)); dTable = oConn.Query(sql); if (dTable.Rows.Count > 0) { foreach (DataRow row in dTable.Rows) { MDMachineHeader.CMDMachineHeader oMD = new MDMachineHeader.CMDMachineHeader(); oMD.mhi_id = row["mhi_id"].ToString(); oMD.mc_code = row["mc_code"].ToString(); oMD.index_id = row["index_id"].ToString(); oMD.header_id = row["header_id"].ToString(); oMD.mhi_createby = row["mhi_createby"].ToString(); oMD.mhi_createdate = row["mhi_createdate"].ToString(); oMD.mhi_updateby = row["mhi_updateby"].ToString(); oMD.mhi_updatedate = row["mhi_updatedate"].ToString(); oMD.header_detail = row["header_detail"].ToString(); oMD.index_datetime = row["index_datetime"].ToString(); oMD.index_partnumber = row["index_partnumber"].ToString(); oMD.index_modelcode = row["index_modelcode"].ToString(); oMD.index_value = row["index_value"].ToString(); oMD.index_result = row["index_result"].ToString(); oMD.mc_name = row["mc_name"].ToString(); oMDMCHeader.ListOfMachineHeader.Add(oMD); } } return(oMDMCHeader); }