大佬大佬请教请教

PhotoPilotListController

using System;
using System.Collections.Generic;
using System.Data;
using System.Reflection;
using System.Web.Mvc;
using log4net;
using NewKWeb.Models.Authorize;
using NewKWeb.Models.Common;
using NewKWeb.Models.Photo;
using NewKWeb.Models.Util;
using System.Linq;

namespace NewKWeb.Controllers.Photo
{
      public class PhotoPilotListController : Controller
      {
            private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod( ).DeclaringType);

            private string FabID = "N1";

            private string DEPTID = "PB21";

            private CommonUtil commonUtil = new CommonUtil( );

            public ActionResult Index( )
            {
                  List<List<SelectListItem>> llResult = new List<List<SelectListItem>>( );
                  DataSet ds = new DataSet( );
                  HomeController.userIdentity = new UserIdentity(HttpContext.Request.LogonUserIdentity.Name);
                  ViewBag.UserAD = HomeController.userIdentity.User;
                ViewBag.UserDEPT= HomeController.userIdentity.DeptId;
            if (HomeController.usageStatistic == null)
                  {
                        HomeController.usageStatistic = new UsageRate( );
                  }
                  HomeController.usageStatistic.UsageStatistic(HomeController.userIdentity , Convert.ToDouble(EnumUtil.pageId.PhotoPilotList));
                  AuthorizeModel authorizeModel = new AuthorizeModel( );
                  DataTable dtLoginMenu = authorizeModel.getLoginAuth("N1" , "KWEB" , ViewBag.UserAD);
                  dtLoginMenu.TableName = "LoginAuth";
                  ds.Tables.Add(dtLoginMenu);
                  SetButtonAuth( );
                  llResult.Insert(0 , getProductList(FabID));
                  ViewData["ResultDropDown"] = llResult;
                  return View("~/Views/Photo/PilotList/PilotListDefault.cshtml" , ds);
            }


        [HttpGet]
        public JsonResult GetFilteredProducts(string department, string category, string product = "")
        {
            try
            {
                // 实例化ProductDataAccess
                var productDataAccess = new ProductDataAccess();
                // 调用ProductDataAccess的方法来获取筛选后的数据
                var filteredProducts = productDataAccess.GetProductsByDepartmentAndCategory(department, category);
                var result = filteredProducts.Select(p => new {
                    ChipBody = p.ChipBody,
                    DepartmentId = p.DepartmentId,
                    ProductGroup = p.ProductGroup
                }).ToList();
                return Json(result, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                // 记录日志或处理异常
                log.Error("Error fetching filtered products.", ex);
                return Json(new { error = "An error occurred while fetching the products." }, JsonRequestBehavior.AllowGet);
            }
        }





        [AllowAnonymous]
            public ActionResult PilotListshow(FormCollection form)
            {
                  List<List<SelectListItem>> llResult = new List<List<SelectListItem>>( );
                  DataSet dsMorning = new DataSet( );
                  DataSet dsPilotInit = new DataSet( );
                  llResult.Insert(0 , getProductList(FabID));
                  ViewData["ResultDropDown"] = llResult;
                  getPilotListData(ref dsPilotInit);
                  foreach (DataTable table in dsPilotInit.Tables)
                  {
                        dsMorning.Tables.Add(table.Copy( ));
                  }
                  SetButtonAuth( );
                  return PartialView("~/Views/Photo/PilotList/PilotList.cshtml" , dsMorning);
            }

            [AllowAnonymous]
            public ActionResult PilotListCompleted(FormCollection form)
            {
                  //new List<List<SelectListItem>>();
                  PhotoPilotList model = new PhotoPilotList( );
                  DataTable dt = model.getPilotListCompleted(FabID , DEPTID);
                  dt.TableName = "PilotListCompleted";
                  DataSet ds = new DataSet( );
                  ds.Tables.Add(dt);
                  return PartialView("~/Views/Photo/PilotList/PilotList_Completed.cshtml" , ds);
            }

            [AllowAnonymous]
            public int getPilotListData(ref DataSet dsResult)
            {
                  int num = -1;
                  PhotoPilotList photoPilotList = new PhotoPilotList( );
                  ProductMaskService productMaskService = new ProductMaskService( );
                  try
                  {
                        DataTable dtLayerMask = null;
                        DataTable dtLotsList = null;
                        DataTable dtLotsStatus = null;
                        DataTable dtAllMaskProductData = photoPilotList.getAllProductMaskData(FabID);
                        DataTable dtLayerProduct = photoPilotList.getProductList(FabID);
                        DataTable sProductMask = null;
                        DataTable dtReworkNum = photoPilotList.getReworkNum(FabID);
                        for (int i = 0 ; i < dtLayerProduct.Rows.Count ; i++)
                        {
                              string product = dtLayerProduct.Rows[i]["PRODUCT"].ToString( );
                              DataTable dtMergeAutoMask = dtAllMaskProductData;
                              object[ ] objAutoLayer = new object[dtMergeAutoMask.Columns.Count];
                              DataTable dtMergeLayer = productMaskService.GetLayerbyProduct(product);
                              object[ ] objLayer = new object[dtMergeLayer.Columns.Count];
                              DataTable dtMergeLotStatus = photoPilotList.getLotsStatusbyProduct(FabID , product);
                              object[ ] objLotStatus = new object[dtMergeLotStatus.Columns.Count];
                              if (i == 0)
                              {
                                    sProductMask = dtMergeAutoMask.Clone( );
                                    dtLayerMask = dtMergeLayer.Clone( );
                                    dtLotsStatus = dtMergeLotStatus.Clone( );
                              }
                              foreach (DataRow row in dtMergeAutoMask.Rows)
                              {
                                    row.ItemArray.CopyTo(objAutoLayer , 0);
                                    sProductMask.Rows.Add(objAutoLayer);
                              }
                              foreach (DataRow row in dtMergeLayer.Rows)
                              {
                                    row.ItemArray.CopyTo(objLayer , 0);
                                    dtLayerMask.Rows.Add(objLayer);
                              }
                              foreach (DataRow row in dtMergeLotStatus.Rows)
                              {
                                    row.ItemArray.CopyTo(objLotStatus , 0);
                                    dtLotsStatus.Rows.Add(objLotStatus);
                              }
                        }
                        //photo的站点对应layer默认呈现蓝色
                        DataTable dtLayerStatus_Blue = photoPilotList.getLayerStatus(FabID , false);
                        //近一天的photo的站点 对应layer 呈现绿色
                        DataTable dtLayerStatus_Green = photoPilotList.getLayerStatus(FabID , true);
                        if (sProductMask != null)
                        {
                              sProductMask.TableName = "AutoMask";
                              dsResult.Tables.Add(sProductMask);
                        }
                        if (dtLayerMask != null)
                        {
                              dtLayerMask.TableName = "LayerMask";
                              dsResult.Tables.Add(dtLayerMask);
                        }
                        if (dtLotsList != null)
                        {
                              dtLotsList.TableName = "LotsList";
                              dsResult.Tables.Add(dtLotsList);
                        }
                        if (dtLotsStatus != null)
                        {
                              dtLotsStatus.TableName = "LotsStatus";
                              dsResult.Tables.Add(dtLotsStatus);
                        }
                        if (dtLayerProduct != null)
                        {
                              dtLayerProduct.TableName = "LayerProduct";
                              dsResult.Tables.Add(dtLayerProduct);
                        }
                        if (dtReworkNum != null)
                        {
                              dtReworkNum.TableName = "ReworkNum";
                              dsResult.Tables.Add(dtReworkNum);
                        }
                        if (dtLayerStatus_Blue != null)
                        {
                              dtLayerStatus_Blue.TableName = "LayerStatusBlue";
                              dsResult.Tables.Add(dtLayerStatus_Blue);
                        }
                        if (dtLayerStatus_Green != null)
                        {
                              dtLayerStatus_Green.TableName = "LayerStatusGreen";
                              dsResult.Tables.Add(dtLayerStatus_Green);
                        }
                        num = 0;
                  }
                  catch (Exception ex)
                  {
                        throw new Exception(ex.Message);
                  }
                  SetButtonAuth( );
                  return num;
            }

            [AllowAnonymous]
            public ActionResult CreatePilotProduct(FormCollection form)
            {
                  DataSet dsPilotProduct = new DataSet( );
                  List<List<SelectListItem>> llResult = new List<List<SelectListItem>>( );
                  try
                  {
                        HomeController.userIdentity = new UserIdentity(HttpContext.Request.LogonUserIdentity.Name);
                        ViewBag.UserAD = HomeController.userIdentity.User;
                        PhotoPilotList model = new PhotoPilotList( );
                        string prodId = form["prodId"].ToString( ).Trim( );
                        model.createPilotProduct(FabID , DEPTID , prodId , ViewBag.UserAD);
                        getPilotListData(ref dsPilotProduct);
                        llResult.Insert(0 , getProductList(FabID));
                  }
                  catch (Exception ex)
                  {
                        throw new Exception(ex.Message);
                  }
                  return PartialView("PilotList" , dsPilotProduct);
            }

            [AllowAnonymous]
            public JsonResult CheckCanInsertChipbody(FormCollection form)
            {
                  PhotoPilotList model = new PhotoPilotList( );
                  string prodId = form["prodId"].ToString( ).Trim( );
                  if (string.IsNullOrEmpty(prodId) || !model.CheckChipbodyExists(prodId))
                  {
                        return Json(new string[2] { "error" , "该产品不存在" });
                  }
                  if (model.CheckPirunChipbodyExists(prodId , DEPTID , FabID))
                  {
                        return Json(new string[2] { "error" , "该产品已存在于进行区或完成区" });
                  }
                  return Json(new string[2] { "ok" , "" });
            }

            [AllowAnonymous]
            public ActionResult DelPilotProduct(FormCollection form)
            {
                  DataSet dsPilotProduct = new DataSet( );
                  List<List<SelectListItem>> llResult = new List<List<SelectListItem>>( );
                  try
                  {
                        HomeController.userIdentity = new UserIdentity(HttpContext.Request.LogonUserIdentity.Name);
                        ViewBag.UserAD = HomeController.userIdentity.User;
                        PhotoPilotList model = new PhotoPilotList( );
                        string prodId = form["prodId"].ToString( );
                        model.delPilotProduct(ViewBag.UserAD , FabID , prodId);
                        getPilotListData(ref dsPilotProduct);
                        llResult.Insert(0 , getProductList(FabID));
                  }
                  catch (Exception ex)
                  {
                        throw new Exception(ex.Message);
                  }
                  ViewData["ResultDropDown"] = llResult;
                  return PartialView("PilotList" , dsPilotProduct);
            }

            [AllowAnonymous]
            public ActionResult SetPilotProductStatus(FormCollection form)
            {
                  DataSet dsPilotProduct = new DataSet( );
                  List<List<SelectListItem>> llResult = new List<List<SelectListItem>>( );
                  string prodId = form["prodId"].ToString( );
                  string status = form["status"].ToString( );
                  PhotoPilotList model = new PhotoPilotList( );
                  try
                  {
                        HomeController.userIdentity = new UserIdentity(HttpContext.Request.LogonUserIdentity.Name);
                        ViewBag.UserAD = HomeController.userIdentity.User;
                        model.SetPilotProductStatus(ViewBag.UserAD , FabID , prodId , status);
                        if (status == "2")
                        {
                              getPilotListData(ref dsPilotProduct);
                              llResult.Insert(0 , getProductList(FabID));
                        }
                  }
                  catch (Exception ex)
                  {
                        throw new Exception(ex.Message);
                  }
                  //根据进行区和完成区来区分
                  if (status == "2")
                  {
                        ViewData["ResultDropDown"] = llResult;
                        return PartialView("PilotList" , dsPilotProduct);
                  }
                  DataTable pilotListCompleted = model.getPilotListCompleted(FabID , DEPTID);
                  pilotListCompleted.TableName = "PilotListCompleted";
                  DataSet dataSet = new DataSet( );
                  dataSet.Tables.Add(pilotListCompleted);
                  return PartialView("~/Views/Photo/PilotList/PilotList_Completed.cshtml" , dataSet);
            }

            [AllowAnonymous]
            public ActionResult AddLotStatus(FormCollection form)
            {
                  DataSet dsLotStatus = new DataSet( );
                  List<List<SelectListItem>> llResult = new List<List<SelectListItem>>( );
                  try
                  {
                        HomeController.userIdentity = new UserIdentity(HttpContext.Request.LogonUserIdentity.Name);
                        ViewBag.UserAD = HomeController.userIdentity.User;
                        string prodId = form["prodId"].ToString( );
                        string lotId = form["lotId"].ToString( );
                        PhotoPilotList model = new PhotoPilotList( );
                        model.InsertPiLot(ViewBag.UserAD , FabID , prodId , lotId.Trim( ));
                        getPilotListData(ref dsLotStatus);
                        llResult.Insert(0 , getProductList(FabID));
                  }
                  catch (Exception ex)
                  {
                        throw new Exception(ex.Message);
                  }
                  ViewData["ResultDropDown"] = llResult;
                  return PartialView("PilotList" , dsLotStatus);
            }

            [AllowAnonymous]
            public ActionResult DelLotStatus(FormCollection form)
            {
                  DataSet dsLotStatus = new DataSet( );
                  List<List<SelectListItem>> llResult = new List<List<SelectListItem>>( );
                  try
                  {
                        HomeController.userIdentity = new UserIdentity(HttpContext.Request.LogonUserIdentity.Name);
                        ViewBag.UserAD = HomeController.userIdentity.User;
                        string prodId = form["prodId"].ToString( );
                        string lotId = form["lotId"].ToString( );
                        PhotoPilotList model = new PhotoPilotList( );
                        model.delLotStatus(ViewBag.UserAD , FabID , prodId , lotId);
                        getPilotListData(ref dsLotStatus);
                        llResult.Insert(0 , getProductList(FabID));
                  }
                  catch (Exception ex)
                  {
                        throw new Exception(ex.Message);
                  }
                  ViewData["ResultDropDown"] = llResult;
                  return PartialView("PilotList" , dsLotStatus);
            }

            [AllowAnonymous]
            public ActionResult UpdateLotStatus(FormCollection form)
            {
                  DataSet dsLotStatus = new DataSet( );
                  List<List<SelectListItem>> llResult = new List<List<SelectListItem>>( );
                  try
                  {
                        HomeController.userIdentity = new UserIdentity(HttpContext.Request.LogonUserIdentity.Name);
                        ViewBag.UserAD = HomeController.userIdentity.User;
                        string lotId = form["lotid"].ToString( );
                        string purpose = form["ddlPurpose"].ToString( );
                        string note = form["ddlNote"].ToString( );
                        PhotoPilotList model = new PhotoPilotList( );
                        model.updateLotStatus(lotId , FabID , ViewBag.UserAD , purpose , note);
                        getPilotListData(ref dsLotStatus);
                        llResult.Insert(0 , getProductList(FabID));
                  }
                  catch (Exception ex)
                  {
                        throw new Exception(ex.Message);
                  }
                  ViewData["ResultDropDown"] = llResult;
                  return PartialView("PilotList" , dsLotStatus);
            }

            private List<SelectListItem> getProductList(string fabId)
            {
                  List<SelectListItem> lRet = new List<SelectListItem>( );
                  PhotoPilotList model = new PhotoPilotList( );
                  DataTable dtProductList = model.getProductDDL(fabId , DEPTID);
                  if (dtProductList.Rows.Count > 0)
                  {
                        DataRow[ ] drProductList = dtProductList.Select("1 = 1" , "PRODUCT");
                        //DataRow[ ] array2 = drProductList;
                        foreach (DataRow drRow in drProductList)
                        {
                              lRet.Add(new SelectListItem
                              {
                                    Text = drRow[0].ToString( ) ,
                                    Value = drRow[0].ToString( )
                              });
                        }
                  }
                  return lRet;
            }

            private void SetButtonAuth( )
            {
                  HomeController.userIdentity = new UserIdentity(HttpContext.Request.LogonUserIdentity.Name);
                  string userId = HomeController.userIdentity.User;
                  bool isHaveOperPriv = new AuthorizeModel( ).IsHaveOperPriv(Convert.ToDouble(EnumUtil.pageId.PhotoPilotList).ToString( ) , userId);
                  ViewData["ColVisible"] = false;
                  ViewData["ButtonVisible"] = "Hidden";
                  if (isHaveOperPriv)
                  {
                        ViewData["ColVisible"] = true;
                        ViewData["ButtonVisible"] = "Visible";
                  }
            }
      }
}

PhotoPilotList

using System;
using System.Configuration;
using System.Data;
using NewKWeb.Models.Common;
using NewKWeb.Models.Util;
using System.Security.Claims;

namespace NewKWeb.Models.Photo
{
	public class PhotoPilotList
	{
		public enum eAccessType
		{
			Insert,
			Update,
			Refresh
		}

		private string _group;

		private DatabaseUtil _oDBUtil;

		private CommonUtil commonUtil = new CommonUtil();

		private string edwDbLink = ConfigurationManager.AppSettings["EDWDBLINK"].ToString();

		public string group
		{
			get
			{
				return _group;
			}
			set
			{
				_group = value;
			}
		}

		public PhotoPilotList()
		{
			_oDBUtil = new DatabaseUtil();
		}

		public DataTable getProductList(string fabId)
		{
			DataTable dataTable = new DataTable();
			dataTable = getProductMaskProvider(fabId);
			DataTable dataTable2 = null;
			commonUtil.getMeetingProductFormat("PilotList");
			string text = "";
			text = "SELECT M.FAB_ID,  PR.CHIPBODY PRODUCT,PR.PRODG1,        '' mask_station,'' PROVIDER,PR.CHIPBODY,'' RANK   FROM product_pirun_info M,  ( SELECT DISTINCT P.PRODG1,P.CHIPBODY FROM PRODUCT P )PR  WHERE 1 = 1    AND M.IS_ACTIVE = 'Y' AND M.STATUS=1    AND M.FAB_ID = '" + fabId + "'   AND M.CHIPBODY=PR.CHIPBODY  ORDER BY PRODUCT ASC";
			try
			{
				dataTable2 = _oDBUtil.getQueryResult(DatabaseUtil.UseDB.KWEB, text);
				foreach (DataRow row in dataTable2.Rows)
				{
					DataRow[] array = dataTable.Select("PRODUCT='" + row["CHIPBODY"].ToString() + "' and PROVIDER is not null");
					if (array.Length > 0)
					{
						row["PROVIDER"] = array[0]["PROVIDER"].ToString();
					}
				}
				return dataTable2;
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public DataTable getProductMaskProvider(string fabid)
		{
			new DataTable();
			new DataTable();
			DataTable dataTable = null;
			DataTable allProductMaskData = getAllProductMaskData(fabid);
			return allProductMaskData.DefaultView.ToTable(true, "PROVIDER", "PRODUCT");
		}

		public DataTable getAllProductMaskData(string fabId)
		{
			DataTable dataTable = new DataTable();
			DataTable dataTable2 = new DataTable();
			DataTable dataTable3 = new DataTable();
			try
			{
				dataTable = getReloadAllLayerFromPWeb(fabId);
				dataTable2 = getPMosCheckIn(fabId);
				dataTable3 = getMisMaskDelivery(fabId);
				foreach (DataRow row in dataTable.Rows)
				{
					DataRow[] array = dataTable2.Select("reticle_id='" + row["RTCL_ID"].ToString() + "'");
					DataRow[] array2 = dataTable3.Select("reticle_id='" + row["RTCL_ID"].ToString() + "'");
					if (array.Length > 0)
					{
						row["CHECK_IN_DATE"] = array[0]["INFAB_TM"].ToString();
						row["CHECK_IN_FLAG"] = "Y";
						continue;
					}
					if (array2.Length > 0)
					{
						row["request_due_date"] = array2[0]["REQUEST_DUE_DATE"].ToString();
						row["re_schedule"] = array2[0]["RE_SCHEDULE"].ToString();
						row["PROVIDER"] = array2[0]["PROVIDER"].ToString();
						row["FORCAST_DAY"] = array2[0]["FORCAST_DAY"].ToString();
						row["FORCAST_DATE"] = array2[0]["FORCAST_DATE"].ToString();
					}
					row["CHECK_IN_FLAG"] = "N";
				}
				return dataTable;
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public int delLotStatus(string user, string fabId, string prodId, string lotId)
		{
			int num = -1;
			string text = "";
			text = "UPDATE product_pilot_list    SET IS_ACTIVE = 'N',        UPDATE_USER = '" + user + "',        UPDATE_TIME = SYSDATE  WHERE IS_ACTIVE = 'Y'    AND FAB_ID = '" + fabId + "'    AND CHIPBODY = '" + prodId + "'    AND LOT_ID = '" + lotId + "'";
			try
			{
				return _oDBUtil.executeNonQuery(DatabaseUtil.UseDB.KWEB, text);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public int updateLotStatus(string lotid, string fabid, string user, string purpose, string note)
		{
			int num = -1;
			string sql = "UPDATE product_pilot_list    SET purpose='" + purpose + "',note='" + note + "',        UPDATE_USER = '" + user + "',        UPDATE_TIME = SYSDATE  WHERE IS_ACTIVE = 'Y'    AND FAB_ID = '" + fabid + "'    AND LOT_ID = '" + lotid + "' ";
			try
			{
				return _oDBUtil.executeNonQuery(DatabaseUtil.UseDB.KWEB, sql);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		private DataTable getReloadAllLayerFromPWeb(string fabId)
		{
			DataTable dataTable = new DataTable();
			string text = "";
			text = text + "with t as (select /*+ materialize */ P.PRODG1, MA.CHIPBODY from product_pirun_info MA, product P WHERE P.CHIPBODY = MA.CHIPBODY and MA.FAB_ID = '" + fabId + "' and MA.STATUS = 1 AND MA.IS_ACTIVE = 'Y') select DISTINCT(RB.RTCL_ID)RTCL_ID,(substr(RB.OPER_NO, 1, instr(RB.OPER_NO, '.') - 1)) LAYER,RB.PROD_ID, RB.PRODG1, t.CHIPBODY PRODUCT,'' CHECK_IN_DATE, '' CHECK_IN_FLAG, '' request_due_date, '' re_schedule, '' PROVIDER, '' FORCAST_DAY, '' FORCAST_DATE FROM kweb_reticle_prod RB, t where RB.PRODG1 = t.prodg1";
			try
			{
				return _oDBUtil.getQueryResult(DatabaseUtil.UseDB.KWEB, text);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		private DataTable getPMosCheckIn(string fabId)
		{
			DataTable dataTable = new DataTable();
			string text = "";
			text += "  select Mi.reticle_id,to_char(Mi.INFAB_TM,'mm/dd') INFAB_TM \n";
			text += "  from  V_MASK_INFO Mi                        \n";
			try
			{
				return _oDBUtil.getQueryResult(DatabaseUtil.UseDB.KWEB, text);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		private DataTable getMisMaskDelivery(string fabId)
		{
			DataTable dataTable = new DataTable();
			string text = "";
			text += " select MW.PROVIDER,MW.MASK_NAME,MW.LAYER_NAME,MW.MFG_SERIAL_NO,                  \n";
			text += " (MW.MASK_NAME||'-'||MW.LAYER_NAME||'-'||MW.MFG_SERIAL_NO) reticle_id,\n";
			text += " to_char(MW.REQUEST_DUE_DATE,'mm/dd') REQUEST_DUE_DATE,to_char(MW.RE_SCHEDULE,'mm/dd') RE_SCHEDULE,ROUND((sysdate-MW.request_due_date),4) FORCAST_DAY,TO_CHAR(MW.request_due_date,'MM/DD') FORCAST_DATE                     \n";
			text += " from MASK_WIP MW                                              \n";
			text += " where 1=1                                                            \n";
			text += " AND MW.Request_Due_Date is not null                                  \n";
			try
			{
				return _oDBUtil.getQueryResult(DatabaseUtil.UseDB.KWEB, text);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public DataTable getLotsStatusbyProduct(string fabId, string prodId)
		{
			DataTable dataTable = null;
			string sql = "SELECT P.LOT_ID,P.CHIPBODY PRODUCT,'' PURPOSE,'' Note,'' ReworkRatio,'' LAYER_HISTORY, \n       B.WAFER_QTY QTY, \n       B.PRIORITY_CLASS PRIORITY, \n       B.OPE_NO, \n       B.STATUS, \n      B.DUE_DATE,\n        B.FORECAST_DATE ,\n        decode((to_date(B.DUE_DATE,'YYYY/MM/DD') - to_date(B.FORECAST_DATE,'YYYY/MM/DD')),null,0,(to_date(B.DUE_DATE,'YYYY/MM/DD') - to_date(B.FORECAST_DATE,'YYYY/MM/DD'))) SCHEDULE_DAY ,\n        '' SCHEDULE,        '' FireNumber,        b.last_claim_time  FROM LOT_TRANS_STATUS_V B,(select L.* from product_pirun_info P,product_pilot_list L where P.CHIPBODY=L.CHIPBODY AND P.IS_ACTIVE='Y' AND P.STATUS=1 AND L.IS_ACTIVE='Y' and P.chipbody='" + prodId + "') P \n WHERE 1 = 1 \n AND P.LOT_ID=B.LOT_ID(+)            \n order by last_claim_time desc";
			dataTable = _oDBUtil.getQueryResult(DatabaseUtil.UseDB.KWEB, sql);
			ProductMaskService productMaskService = new ProductMaskService();
			DataTable dataTable2 = productMaskService.QueryFireNumberAndComment(fabId, "");
			DataTable lotsLayerHistory = getLotsLayerHistory(fabId);
			DataTable purposeAndNote = getPurposeAndNote(fabId, "1");
			DataTable reworkRatio = getReworkRatio(fabId);
			foreach (DataRow row in dataTable.Rows)
			{
				DataRow[] array = lotsLayerHistory.Select("LOT_ID='" + row["lot_id"].ToString() + "'");
				if (array.Length > 0)
				{
					row["LAYER_HISTORY"] = array[0]["layer"].ToString();
				}
				DataRow[] array2 = dataTable2.Select("LOT_ID='" + row["LOT_ID"].ToString() + "'");
				if (array2.Length > 0)
				{
					row["FireNumber"] = array2[0]["FireNumber"].ToString();
				}
				DataRow[] array3 = purposeAndNote.Select("LOT_ID='" + row["LOT_ID"].ToString() + "'");
				if (array3.Length > 0)
				{
					row["PURPOSE"] = array3[0]["PURPOSE"].ToString();
					row["NOTE"] = array3[0]["NOTE"].ToString();
				}
				DataRow[] array4 = reworkRatio.Select("LOT_ID='" + row["LOT_ID"].ToString() + "'");
				if (array4.Length > 0)
				{
					row["REWORKRATIO"] = array4[0]["REWORKRATIO"].ToString();
				}
				if (row["SCHEDULE_DAY"] != null && row["SCHEDULE_DAY"].ToString().Length > 0)
				{
					if (Convert.ToInt32(row["SCHEDULE_DAY"].ToString()) == 0)
					{
						row["SCHEDULE"] = "On Schedule";
					}
					else if (Convert.ToInt32(row["SCHEDULE_DAY"].ToString()) >= 0)
					{
						row["SCHEDULE"] = "Ahead " + row["SCHEDULE_DAY"].ToString() + " D";
					}
					else
					{
						row["SCHEDULE"] = "Delay " + Convert.ToInt32(row["SCHEDULE_DAY"].ToString()) * -1 + " D";
					}
				}
			}
			return dataTable;
		}

		public DataTable getPurposeAndNote(string fabId, string status)
		{
			DataTable dataTable = null;
			string text = "select lot_id,purpose,note from product_pilot_list L,PRODUCT_PIRUN_INFO P where P.CHIPBODY=L.CHIPBODY AND L.IS_ACTIVE='Y' and P.IS_ACTIVE='Y'";
			if (!string.IsNullOrEmpty(status))
			{
				text = text + " and P.STATUS='" + status + "'";
			}
			try
			{
				return _oDBUtil.getQueryResult(DatabaseUtil.UseDB.KWEB, text);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public DataTable getReworkRatio(string fabId)
		{
			DataTable dataTable = null;
			string text = "with t as (select distinct lot_id from product_pilot_list L,product_pirun_info P WHERE L.CHIPBODY = P.CHIPBODY AND L.IS_ACTIVE = 'Y' AND P.IS_ACTIVE = 'Y' AND P.STATUS = '1' and P.FAB_ID='" + fabId + "') \n";
			string text2 = "select t1.lot_id,t1.molecule,t2.denominator,decode(t2.denominator, 0, 0, round(t1.molecule / t2.denominator * 100, 2)) reworkratio from (select lot_id, sum(molecule) molecule from(select lot_id, substr(ope_no, 0, 2) OPE_NO, count(*) molecule from LOT_HISTORY where FAB_ID='" + fabId + "' AND lot_id in (select * from t) and(ope_no like '%PPK%' OR ope_no like '%PPU%' OR ope_no like '%PPH%') AND FLOW_NO LIKE 'YY%' group by lot_id, substr(ope_no, 0, 2)) group by lot_id) t1,(select lot_id, count(DISTINCT OPE_NO) denominator from LOT_HISTORY where FAB_ID='" + fabId + "' AND lot_id in (select * from t) and(ope_no like '%PPK%' OR ope_no like '%PPU%' OR ope_no like '%PPH%') group by lot_id) t2 where t1.lot_id = t2.lot_id";
			try
			{
				return _oDBUtil.getQueryResult(DatabaseUtil.UseDB.KWEB, text + text2);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public DataTable getReworkNum(string fabId)
		{
			DataTable dataTable = null;
			string text = "with t as (select distinct lot_id from product_pilot_list L,product_pirun_info P WHERE L.CHIPBODY = P.CHIPBODY AND L.IS_ACTIVE = 'Y' AND P.IS_ACTIVE = 'Y' AND P.STATUS = '1') \n";
			string text2 = "select LOT_ID,substr(ope_no,0,2) OPE_NO,count(*) ReworkNum from lot_history where lot_id IN(SELECT * FROM t) and (ope_no like '%PPK%' OR ope_no like '%PPU%' OR ope_no like '%PPH%') AND FLOW_NO LIKE 'YY%' group by lot_id,substr(ope_no,0,2)";
			try
			{
				return _oDBUtil.getQueryResult(DatabaseUtil.UseDB.KWEB, text + text2);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public DataTable getLotsLayerHistory(string fabId)
		{
			DataTable dataTable = null;
			DataTable dataTable2 = new DataTable();
			DataTable dataTable3 = new DataTable();
			string text = "";
			text += "select distinct(substr(l.OPE_NO,1,instr(l.OPE_NO,'.')-1)) layer ,  \n";
			text += "l.lot_id                                                          \n";
			text += "from LOT_HISTORY l                                            \n";
			text += "where 1=1                                                          \n";
			text += "and l.lot_id  in(select L.LOT_ID from product_pirun_info P,product_pilot_list L where P.CHIPBODY=L.CHIPBODY AND P.IS_ACTIVE='Y' AND P.STATUS=1 AND L.IS_ACTIVE='Y')       \n";
			text = text + "and l.fab_id='" + fabId + "'                                                 \n";
			text += "order by l.lot_id DESC, substr(l.OPE_NO,1,instr(l.OPE_NO,'.')-1)   \n";
			try
			{
				dataTable = _oDBUtil.getQueryResult(DatabaseUtil.UseDB.KWEB, text);
				DataView defaultView = dataTable.DefaultView;
				dataTable2 = defaultView.ToTable(true, "LOT_ID");
				dataTable3 = dataTable.Clone();
				foreach (DataRow row in dataTable2.Rows)
				{
					string text2 = "";
					DataRow[] array = dataTable.Select("LOT_ID='" + row["lot_id"].ToString() + "'");
					DataRow[] array2 = array;
					foreach (DataRow dataRow2 in array2)
					{
						text2 = text2 + dataRow2["layer"].ToString() + ",";
					}
					text2 = text2.TrimEnd(',');
					DataRow dataRow3 = dataTable3.NewRow();
					dataRow3["layer"] = text2;
					dataRow3["lot_id"] = row["lot_id"].ToString();
					dataTable3.Rows.Add(dataRow3);
				}
				return dataTable3;
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public DataTable getLayerStatus(string fabId, bool recentOneDay)
		{
			string text = "select H.lot_id,substr(H.ope_no,0,2) layer,COUNT(*) passLayer from lot_history H,(select L.LOT_ID from product_pirun_info P, product_pilot_list L where P.CHIPBODY = L.CHIPBODY AND P.IS_ACTIVE = 'Y' AND P.STATUS = 1 AND L.IS_ACTIVE = 'Y' and P.fab_id='" + fabId + "') L WHERE H.LOT_ID = L.LOT_ID and(H.ope_no like('%PPK%') OR H.ope_no like('%PPU%') OR H.ope_no like('%PPH%')) and H.fab_id='" + fabId + "' ";
			if (recentOneDay)
			{
				text += " AND H.MOVE_IN_TIME > SYSDATE-1";
			}
			text += "group by H.lot_id,substr(H.ope_no, 0, 2)";
			DataTable dataTable = null;
			try
			{
				return _oDBUtil.getQueryResult(DatabaseUtil.UseDB.KWEB, text);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public DataTable getProductDDL(string fabId, string dept_id)
		{
			string text = "";
			text += " select distinct p.chipbody product \n";
			text += " from PRODUCT P  \n";
			text += " where p.prodg1 is not null         \n";
			text += " and prodg2='Foundry'               \n";
			text = text + " and p.chipbody not in(select distinct chipbody from PRODUCT_PIRUN_INFO where is_active='Y' and dept_id='" + dept_id + "')              \n";
			text += " ORDER BY p.chipbody ASC            \n";
			DataTable dataTable = null;
			try
			{
				return _oDBUtil.getQueryResult(DatabaseUtil.UseDB.KWEB, text);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public DataTable getPilotListCompleted(string fabId, string dept_id)
		{
			string sql = "select I.CHIPBODY,I.DEPT_ID,I.STATUS,I.CREATE_USER,I.CREATE_TIME,I.UPDATE_USER,I.UPDATE_TIME,L.LOT_ID,L.PURPOSE,L.NOTE,'Update Status' Action from product_pirun_info I JOIN (select CHIPBODY, lot_id, purpose, note from product_pilot_list WHERE IS_ACTIVE ='Y') L ON I.CHIPBODY = L.CHIPBODY(+) WHERE I.IS_ACTIVE = 'Y' AND I.STATUS = 2 AND I.DEPT_ID='" + dept_id + "' AND I.FAB_ID='" + fabId + "'  ORDER BY I.UPDATE_TIME DESC";
			DataTable dataTable = null;
			try
			{
				return _oDBUtil.getQueryResult(DatabaseUtil.UseDB.KWEB, sql);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public int createPilotProduct(string fabId, string deptId, string prodId, string user)
		{
			int num = 0;
			string sql = "insert into PRODUCT_PIRUN_INFO(FAB_ID,CHIPBODY,DEPT_ID,IS_ACTIVE,STATUS,CREATE_USER,CREATE_TIME) values('" + fabId + "','" + prodId + "','" + deptId + "','Y',1,'" + user + "',SYSDATE)";
			try
			{
				return _oDBUtil.executeNonQuery(DatabaseUtil.UseDB.KWEB, sql);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public bool CheckChipbodyExists(string chipbody)
		{
			string sql = "select * from PRODUCT where chipbody='" + chipbody + "'";
			DataTable dataTable = new DataTable();
			bool result = false;
			try
			{
				dataTable = _oDBUtil.getQueryResult(DatabaseUtil.UseDB.KWEB, sql);
				if (dataTable.Rows.Count > 0)
				{
					result = true;
				}
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
			return result;
		}

		public bool CheckPirunChipbodyExists(string chipbody, string dept_id, string fab_id)
		{
			string sql = "select * from product_pirun_info where dept_id='" + dept_id + "' AND FAB_ID='" + fab_id + "' AND IS_ACTIVE='Y' and chipbody='" + chipbody + "'";
			DataTable dataTable = new DataTable();
			bool result = false;
			try
			{
				dataTable = _oDBUtil.getQueryResult(DatabaseUtil.UseDB.KWEB, sql);
				if (dataTable.Rows.Count > 0)
				{
					result = true;
				}
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
			return result;
		}

		public int delPilotProduct(string user, string fabId, string prodId)
		{
			int result = -1;
			string text = "";
			string text2 = "";
			_oDBUtil.beginTrans(DatabaseUtil.UseDB.KWEB);
			try
			{
				text = "UPDATE PRODUCT_PIRUN_INFO    SET IS_ACTIVE = 'N',        UPDATE_USER = '" + user + "',        UPDATE_TIME = SYSDATE  WHERE IS_ACTIVE = 'Y'    AND FAB_ID = '" + fabId + "'    AND CHIPBODY = '" + prodId + "' ";
				_oDBUtil.executeNonQuery(text);
				text2 = "UPDATE product_pilot_list    SET IS_ACTIVE = 'N',        UPDATE_USER = '" + user + "',        UPDATE_TIME = SYSDATE  WHERE IS_ACTIVE = 'Y'    AND FAB_ID = '" + fabId + "'    AND CHIPBODY = '" + prodId + "' ";
				_oDBUtil.executeNonQuery(text2);
			}
			catch (Exception ex)
			{
				throw new Exception("(delPilotProduct) Update:" + ex.Message);
			}
			_oDBUtil.commitTrans();
			return result;
		}

		public int SetPilotProductStatus(string user, string fabId, string prodId, string status)
		{
			int result = -1;
			string text = "";
			string text2 = "";
			_oDBUtil.beginTrans(DatabaseUtil.UseDB.KWEB);
			try
			{
				text = "UPDATE PRODUCT_PIRUN_INFO    SET STATUS = '" + status + "',        UPDATE_USER = '" + user + "',        UPDATE_TIME = SYSDATE  WHERE IS_ACTIVE = 'Y'    AND FAB_ID = '" + fabId + "'    AND CHIPBODY = '" + prodId + "' ";
				_oDBUtil.executeNonQuery(text);
				text2 = "UPDATE product_pilot_list    SET        UPDATE_USER = '" + user + "',        UPDATE_TIME = SYSDATE  WHERE IS_ACTIVE = 'Y'    AND FAB_ID = '" + fabId + "'    AND CHIPBODY = '" + prodId + "' ";
				_oDBUtil.executeNonQuery(text2);
			}
			catch (Exception ex)
			{
				throw new Exception("(delPilotProduct) Update:" + ex.Message);
			}
			_oDBUtil.commitTrans();
			return result;
		}

		public int InsertPiLot(string user, string fabId, string prodId, string lotId)
		{
			int result = -1;
			string text = "";
			try
			{
				string meetingProductFormat = commonUtil.getMeetingProductFormat("PilotList");
				string product = commonUtil.getProduct(lotId, meetingProductFormat);
				if (prodId != product)
				{
					throw new Exception("Lot ID:" + lotId + " Product:" + product + " is not Exist!");
				}
				DataTable queryResult = _oDBUtil.getQueryResult(DatabaseUtil.UseDB.KWEB, "select * from product_pilot_list where lot_id='" + lotId + "' and is_active='Y' and chipbody='" + prodId + "'");
				if (queryResult.Rows.Count > 0)
				{
					throw new Exception("Lot ID:" + lotId + "is Exist!");
				}
				text = "insert into product_pilot_list(FAB_ID,CHIPBODY,LOT_ID,IS_ACTIVE,CREATE_USER,CREATE_TIME) VALUES('" + fabId + "','" + prodId + "','" + lotId + "','Y','" + user + "',sysdate)";
				_oDBUtil.executeNonQuery(DatabaseUtil.UseDB.KWEB, text);
				return result;
			}
			catch (Exception ex)
			{
				throw new Exception("(InsertPiLot) Update:" + ex.Message);
			}
		}
	}
}

 PilotList.cshtml

<style>
    .bs-wizard > .bs-wizard-step .bs-wizard-date,.bs-wizard-date-highlight {
        -ms-writing-mode:lr-tb !important;
    }
    .change {
        cursor: pointer;
        color: blue !important;
    }
</style>
@model System.Data.DataSet
@{
//List<List<SelectListItem>> llResult = ViewData["ResultDropDown"] as List<List<SelectListItem>>;
//List<SelectListItem> lProdgList = llResult[0];
}
<div id="colPilotLists" style="margin: 20px 10px 10px 10px;">
    @Html.Label("PRODUCT:", new { style = "margin-top:8px;float:left" })
    @*@Html.DropDownList("ddlProdg", lProdgList, new { style = "width:180px;margin-left:10px;margin-bottom:5px;float:left", @class = "form-control" })*@

    <input class="form-control" placeholder="例:AFGNE701N" style="width:180px;margin-left:10px;margin-bottom:5px;float:left" size="12" type="text" id="ddlProdg" />

    @{
        if (ViewData["ButtonVisible"].ToString() == "Visible")
        {
            <button class="btn btn-info btn-new" id="btnSecondIntSave" style="float:left">
                <span>Add</span>
            </button>
        }
    }
    
    <hr />
    @{
        if (Model.Tables["LayerProduct"] != null && Model.Tables["LayerProduct"].Rows.Count > 0)
        {
            foreach (System.Data.DataRow xRow in Model.Tables["LayerProduct"].Rows)
            {
                string prodId = xRow["PRODUCT"].ToString();
                <div class="ProductSet">
                    @{
                        if (ViewData["ButtonVisible"].ToString() == "Visible")
                        {
                            <span class="glyphicon glyphicon-trash icon" style="margin-top:8px;float:left" onclick="DelPilotProduct('@xRow["PRODUCT"].ToString()')"></span>
                            <span class="glyphicon glyphicon-off icon" style="margin-top:8px;margin-left:10px;float:left" onclick="SetPilotProductCompleted('@xRow["PRODUCT"].ToString()')"></span>
                        }

                        @Html.Label(xRow["PRODG1"].ToString()+"_"+xRow["PRODUCT"].ToString() + ":", new { style = "margin-left:5px;margin-top:8px;float:left;color:blue;" })

                        System.Data.DataRow[] drLayer = Model.Tables["LayerMask"].Select("PRODUCT = '" + xRow["PRODUCT"].ToString() + "'", "OP_SEQ");

                        string product = xRow["PRODUCT"].ToString();
                        string mask_provider = xRow["PROVIDER"].ToString();
                        @Html.Label(", Mask Status   ", new { style = "margin-left:5px;margin-top:8px" })
                        @Html.Label("Mask Provider: " + @mask_provider, new { style = "margin-left:5px;margin-top:8px;float:left;" })


                        if (ViewData["ButtonVisible"].ToString() == "Visible")
                        {
                            string prod = xRow["PRODUCT"].ToString();
                            <button class="btn btn-info btn-new" style="float:right;padding:6px 6px !important" id="btnAddLot_@prod" onclick="AddLotStatus('@xRow["PRODUCT"].ToString()')">Add Lot</button>
                            <input class="form-control" placeholder="例:NBS999000" style="float:right;width:180px;margin-left:1px;margin-bottom:5px;" size="12" type="text"  id="ddlLot_@prod" />
                        }

                        <br>
                            if (drLayer.Length > 0)
                            {
                            <div class="row bs-wizard" style="clear:both;margin:1px;border:1px solid #ccc;border-radius:5px;padding-top:5px">
                                @{
                                    bool bIsFound = false;
                                    string sWidth = Math.Round((double)99 / (double)drLayer.Length, 2, MidpointRounding.AwayFromZero).ToString();
                                    string sCssStatus = "disabled";
                                    foreach (System.Data.DataRow xLayer in drLayer)
                                    {
                                        sCssStatus = "disabled";
                                        string checkdate = "";
                                        string checkflag = "";
                                        string forcastdate = "";
                                        double forcast_day = -1000;
                                        string reschedule_date = "";
                                        //按照FORCAST_DATE降序,一个layer对应多个suffix,如果有一笔未入库视为未入库,有一笔delay视为delay
                                        System.Data.DataRow[] drSingleMask = Model.Tables["AutoMask"].Select("PRODUCT = '" + xRow["PRODUCT"].ToString() + "' AND LAYER = '" + xLayer["LAYER_NO"].ToString() + "'", "FORCAST_DAY DESC");
                                        if (drSingleMask.Length > 0)
                                        {
                                            checkdate = drSingleMask[0]["CHECK_IN_DATE"].ToString();
                                            checkflag = drSingleMask[0]["CHECK_IN_FLAG"].ToString();
                                            forcastdate = drSingleMask[0]["FORCAST_DATE"].ToString();
                                            reschedule_date = drSingleMask[0]["RE_SCHEDULE"].ToString();
                                            if (drSingleMask[0]["FORCAST_DAY"].ToString() != "")
                                            {
                                                forcast_day = Convert.ToDouble(drSingleMask[0]["FORCAST_DAY"].ToString());
                                            }
                                            if (checkflag == "Y")
                                            {
                                                bIsFound = true;
                                                sCssStatus = "complete";
                                            }
                                        }
                                        <div class="col-rythm bs-wizard-step @sCssStatus" style="width:@sWidth%">
                                            <div class="text-center bs-wizard-stepnum">@xLayer["LAYER_NO"].ToString()</div>
                                            <div class="progress"><div class="progress-bar"></div></div>
                                            <a href="#" class="bs-wizard-dot"></a>
                                            <div style="height:10px;"></div>
                                            @if (checkflag == "Y")
                                            {
                                                <table style="text-align:center;margin:0 auto">
                                                    <tr>
                                                        <td>
                                                            <div class="text-center bs-wizard-date">@checkdate</div>
                                                        </td>

                                                    </tr>
                                                </table>

                                            }
                                            else if (checkflag == "N" && forcast_day > 0)
                                            {
                                                if (reschedule_date != "")
                                                {
                                                    <table style="text-align:center;margin:0 auto">
                                                        <tr>
                                                            <td>
                                                                <div style="text-decoration:line-through;" class="bs-wizard-date-highlight">@forcastdate <br></div>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                <div class="bs-wizard-date-highlight">@reschedule_date</div>

                                                            </td>
                                                        </tr>
                                                    </table>
                                                }
                                                else
                                                {
                                                    <div class="bs-wizard-date-highlight text-center">@forcastdate</div>
                                                }

                                            }
                                            else if (checkflag == "N" && forcast_day < 0)
                                            {
                                                <table style="text-align:center;margin:0 auto">
                                                    <tr>
                                                        <td>
                                                            <div class="bs-wizard-date text-center">@forcastdate</div>
                                                        </td>
                                                    </tr>
                                                </table>

                                            }

                                        </div>

                                    }
                                }
                            </div>
                                    }
                                    
                                    if (Model.Tables["LotsStatus"] != null && Model.Tables["LotsStatus"].Rows.Count > 0)
                                    {
                                        System.Data.DataRow[] drLotsStatus = Model.Tables["LotsStatus"].Select("PRODUCT = '" + xRow["PRODUCT"].ToString() + "'", "LOT_ID DESC");
                                        if (drLotsStatus.Length > 0)
                                        {
                                            <div style="">@{
                                                foreach (System.Data.DataRow xLotStatus in drLotsStatus)
                                                {
                                                string lotID = xLotStatus["LOT_ID"].ToString();
                                                string _layer = "";
                                                <div class="LotSet">
                                                    <table class="zui-table">
                                                        <thead>
                                                            <tr>
                                                                @foreach (System.Data.DataColumn xCol in Model.Tables["LotsStatus"].Columns)
                                                                {
                                                                    if (xCol.ColumnName.ToUpper() == "LAYER_HISTORY" || xCol.ColumnName.ToUpper() == "SCHEDULE_DAY" || xCol.ColumnName.ToUpper() == "FIRENUMBER")
                                                                    {
                                                                        continue;
                                                                    }
                                                                <td>
                                                                    @xCol.ColumnName
                                                                </td>
                                                                }
                                                                @if (ViewData["ButtonVisible"].ToString() == "Visible")
                                                                {
                                                                <td>
                                                                    EDIT
                                                                </td>
                                                                }
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <tr>
                                                                @foreach (System.Data.DataColumn xCol in Model.Tables["LotsStatus"].Columns)
                                                                {
                                                                    if (xCol.ColumnName.ToUpper() == "LAYER_HISTORY" || xCol.ColumnName.ToUpper() == "SCHEDULE_DAY" || xCol.ColumnName.ToUpper() == "FIRENUMBER")
                                                                    {
                                                                        continue;
                                                                    }
                                                                    if (xCol.ColumnName == "OPE_NO")
                                                                    {
                                                                        _layer = xLotStatus[xCol.ColumnName].ToString() ==""?"":xLotStatus[xCol.ColumnName].ToString().Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries)[0];
                                                                    }
                                                                    if (xCol.ColumnName.ToUpper() == "SCHEDULE" && xLotStatus[xCol.ColumnName].ToString().Contains("Ahead"))
                                                                    {
                                                                @*<td style="background-color:lightgreen">
                                                                        @xLotStatus[xCol.ColumnName].ToString()
                                                                    </td>*@
                                                                <td style="background-color:#C6EFCE">
                                                                    @xLotStatus[xCol.ColumnName].ToString()
                                                                </td>
                                                                    }
                                                                    else if (xCol.ColumnName.ToUpper() == "SCHEDULE" && xLotStatus[xCol.ColumnName].ToString().Contains("Delay"))
                                                                    {
                                                                @*<td style="background-color:red">
                                                                        @xLotStatus[xCol.ColumnName].ToString()
                                                                    </td>*@
                                                                <td style="background-color:#FFC7CE">
                                                                    @xLotStatus[xCol.ColumnName].ToString()
                                                                </td>
                                                                    }
                                                                    else if (xCol.ColumnName.ToUpper() == "STATUS" && xLotStatus[xCol.ColumnName].ToString().ToUpper().Contains("HOLD"))
                                                                    {
                                                                @*<td style="background-color:red">
                                                                        @xLotStatus[xCol.ColumnName].ToString()
                                                                    </td>*@
                                                                <td style="background-color:#FFC7CE">
                                                                    @xLotStatus[xCol.ColumnName].ToString()
                                                                </td>
                                                                    }
                                                                    else if (xCol.ColumnName.ToUpper() == "STATUS" && xLotStatus[xCol.ColumnName].ToString().ToUpper().Contains("RUN"))
                                                                    {
                                                                @*<td style="background-color:lightgreen">
                                                                        @xLotStatus[xCol.ColumnName].ToString()
                                                                    </td>*@
                                                                <td style="background-color:#C6EFCE">
                                                                    @xLotStatus[xCol.ColumnName].ToString()
                                                                </td>
                                                                    }
                                                                    else if (xCol.ColumnName.ToUpper() == "REWORKRATIO")
                                                                    {
                                                                        <td>
                                                                            @xLotStatus[xCol.ColumnName].ToString() %
                                                                        </td>
                                                                    }
                                                                    else
                                                                    {
                                                                        if (xCol.ColumnName.ToUpper() == "LOT_ID")
                                                                        {
                                                                            string imgpath = Url.Content(string.Format("~/Content/Images/fire.gif"));

                                                                            if (xLotStatus[xCol.ColumnName].ToString().Contains("NAX") || xLotStatus[xCol.ColumnName].ToString().Contains("NAY") || xLotStatus[xCol.ColumnName].ToString().Contains("NAZ"))
                                                                            {

                                                                <td style="background-color:#c5d99e;font-weight:bold">
                                                                    @if (xLotStatus["FireNumber"].ToString() == "1")
                                                                                    {
                                                                                    <img src=@imgpath style='border: 0; margin: 2px 4px;' />
                                                                                    }
                                                                                    else if (xLotStatus["FireNumber"].ToString() == "2")
                                                                                    {
                                                                                    <img src=@imgpath />
                                                                                    <img src=@imgpath />
                                                                                    }
                                                                                    else if (xLotStatus["FireNumber"].ToString() == "3")
                                                                                    {
                                                                                    <img src=@imgpath style='border: 0; margin: 2px 4px;' />
                                                                                    <img src=@imgpath style='border: 0; margin: 2px 4px;' />
                                                                                    <img src=@imgpath style='border: 0; margin: 2px 4px;' />
                                                                                    }

                                                                    <a style="color:blue !important" href="/NewKWeb/Yield/CommonYield/SingleLotHistory?sPageFrom=MENU&sFabId=N1&sLotNo=@xLotStatus[xCol.ColumnName].ToString()" target="_blank">@xLotStatus[xCol.ColumnName].ToString()</a>
                                                                </td>
                                                                            }
                                                                            else
                                                                            {

                                                                <td style="background-color:#ccbfd9;font-weight:bold">
                                                                    @if (xLotStatus["FireNumber"].ToString() == "1")
                                                                                    {
                                                                                    <img src=@imgpath style='border: 0; margin: 2px 4px;' />
                                                                                    }
                                                                                    else if (xLotStatus["FireNumber"].ToString() == "2")
                                                                                    {
                                                                                    <img src=@imgpath />
                                                                                    <img src=@imgpath />
                                                                                    }
                                                                                    else if (xLotStatus["FireNumber"].ToString() == "3")
                                                                                    {
                                                                                    <img src=@imgpath style='border: 0; margin: 2px 4px;' />
                                                                                    <img src=@imgpath style='border: 0; margin: 2px 4px;' />
                                                                                    <img src=@imgpath style='border: 0; margin: 2px 4px;' />
                                                                                    }
                                                                    <a style="color:blue !important" href="/NewKWeb/Yield/CommonYield/SingleLotHistory?sPageFrom=MENU&sFabId=N1&sLotNo=@xLotStatus[xCol.ColumnName].ToString()" target="_blank">@xLotStatus[xCol.ColumnName].ToString() </a>
</td>
                                                                            }

                                                                        }
                                                                        //新增车规产品底色highlight. add by lixinyue 20231211
                                                                        else if (xCol.ColumnName.ToUpper() == "PRODUCT")
                                                                        {
                                                                            if (xLotStatus[xCol.ColumnName].ToString().Substring(0, 1) == "V")
                                                                            {
                                                                                <td style="background-color: #ED7D31">
                                                                                    @xLotStatus[xCol.ColumnName].ToString()
                                                                                </td>
                                                                            }
                                                                            else
                                                                            {
                                                                                <td>@xLotStatus[xCol.ColumnName].ToString()</td>
                                                                            }
                                                                        }
                                                                        else
                                                                        {

                                                                <td>
                                                                    @xLotStatus[xCol.ColumnName].ToString()
                                                                </td>
                                                                        }

                                                                    }

                                                                }
                                                                @if (ViewData["ButtonVisible"].ToString() == "Visible")
                                                                {
                                                                <td>
                                                                    <span class="glyphicon glyphicon-edit icon" data-toggle="modal" data-target="#secondIntModal"></span>
                                                                    <span class="glyphicon glyphicon-trash icon" onclick="DelLotStatus($(this))"></span>
                                                                </td>
                                                                }

                                                            </tr>
                                                        </tbody>
                                                    </table>


                                                    <div class="row bs-wizard" style="clear:both;margin:1px 0 0 0;border:1px solid #ccc;border-radius:5px">
                                                        @{

                                                            string sWidth = Math.Round((double)99 / (double)drLayer.Length, 2, MidpointRounding.AwayFromZero).ToString();
                                                            string sCssStatus = "disabled";
                                                            //蓝色:过PK  PU  PH站点且已经过了该Layer; 绿色:过PK  PU  PH站点且近24小时
                                                            foreach (System.Data.DataRow xLayer in drLayer)
                                                            {
                                                                System.Data.DataRow[] dr_layerstatus_blue = Model.Tables["LayerStatusBlue"].Select("LOT_ID='" + lotID + "' and layer='"+ xLayer["LAYER_NO"].ToString() + "'");
                                                                System.Data.DataRow[] dr_layerstatus_green = Model.Tables["LayerStatusGreen"].Select("LOT_ID='" + lotID + "' and layer='" + xLayer["LAYER_NO"].ToString() + "'");
                                                                bool passlayer_blue = false;
                                                                bool passlayer_green = false;
                                                                if (dr_layerstatus_blue.Length > 0 && Convert.ToInt32(dr_layerstatus_blue[0]["PassLayer"].ToString())>0) {
                                                                    passlayer_blue = true;
                                                                }
                                                                if (dr_layerstatus_green.Length > 0 && Convert.ToInt32(dr_layerstatus_blue[0]["PassLayer"].ToString()) > 0)
                                                                {
                                                                    passlayer_green = true;
                                                                }
                                                                bool bIsLotFound = false;
                                                                sCssStatus = "disabled";
                                                                if (xLotStatus["layer_history"].ToString() != "")
                                                                {
                                                                    string new_layer = xLotStatus["OPE_NO"].ToString().Split('.')[0];

                                                                    if (("," + xLotStatus["layer_history"].ToString() + ",").IndexOf("," + xLayer["LAYER_NO"].ToString() + ",") >= 0)
                                                                    {
                                                                        if (passlayer_green)
                                                                        {
                                                                            bIsLotFound = true;
                                                                            sCssStatus = "active";
                                                                        }
                                                                        else if (passlayer_blue)
                                                                        {
                                                                            bIsLotFound = true;
                                                                            sCssStatus = "complete";
                                                                        }
                                                                    }
                                                                }
                                                        <div class="col-rythm bs-wizard-step @sCssStatus" style="width:@sWidth%">
                                                            <div class="text-center bs-wizard-stepnum">@xLayer["LAYER_NO"].ToString()</div>
                                                            <div class="progress">
                                                                <div class="progress-bar"></div>
                                                            </div>
                                                            <a href="#" class="bs-wizard-dot"></a>
                                                            @{ 
                                                                System.Data.DataRow[] dr_reworkNum_layer = Model.Tables["ReworkNum"].Select("LOT_ID='" + lotID + "'");
                                                                string reworkNum_layer = "";
                                                                for (int i = 0; i < dr_reworkNum_layer.Length; i++) {
                                                                    if (dr_reworkNum_layer[i]["OPE_NO"].ToString().Contains(xLayer["LAYER_NO"].ToString())) {
                                                                        reworkNum_layer = dr_reworkNum_layer[i]["REWORKNUM"].ToString();
                                                                    }
                                                                }
                                                            }
                                                            <div style="width:20px;height:20px;position:absolute;left:50%;top:23px;color:red;margin-left:-11px;text-align:center;font-weight:bold;">@reworkNum_layer</div>
                                                        </div>
                                                            }
                                                        }

                                                    </div>
                                                    @*lot分个空白*@
                                                    <br>
                                                </div>
                                                            } // End Foreach
                                            }</div>
                                                                } // End If
                                                            } // End If
                    }
                </div>
                        <hr style="background: #337AB7;height: 1px;border: none;height:3px">
                                @*<hr />*@
                                    } // End Foreach
                                } // End If
    }

</div>



@* Modal *@
@{
    Html.RenderPartial("SecondIntModal");
    //Html.RenderPartial("MaskLayerModal");
}

<script>

    $(function () {
        $("#btnSecondIntSave").click(function () {
            $(this).attr("disabled","disabled");
            var prodId = $("#ddlProdg").val();
            var form = new FormData();
            form.append("prodId", prodId);
            $.ajax({
                url: "CheckCanInsertChipbody",
                type: "post",
                dataType: "json",
                async: "true",
                processData: false,
                contentType: false,
                data: form,
                success: function (data) {
                    if (data[0] == "error") {
                        alert(data[1]); $("#btnSecondIntSave").removeAttr("disabled"); return false;
                    } else {
                        $.ajax({
                            url: "CreatePilotProduct",
                            type: "post",
                            dataType: "html",
                            async: "true",
                            processData: false,
                            contentType: false,
                            data: form,
                            success: function (data) {
                                console.log(data);
                                $("#PilotLists_Ongoing").html(data)
                            },
                            error: function (request, status, error) {
                                errorHandle(request, status, error);
                            }
                        })
                    }
                    
                },
                error: function (request, status, error) {
                    errorHandle(request, status, error);
                }
            })
        })
    })

    function PilotListshow() {
        layer.load(2);
        var form = new FormData();
        form.append("mode", "@ViewBag.mode");
        $.ajax({
            url: "PilotListshow",
            type: "post",
            dataType: "html",
            async: "true",
            processData: false,
            contentType: false,
            data: form,
            success: function (data) {
                layer.closeAll();
                $("#PilotLists_Ongoing").html(data);
                
            },
            error: function (request, status, error) {
                layer.closeAll();
                errorHandle(request, status, error);
            }
        });
    }

    function DelPilotProduct(prodId) {
        var ret = confirm("Are You Sure to Delete <" + prodId + ">?");
        if (ret == false) {
            return;
        }
        // ------------------------------------------------------------------------------
        var form = new FormData();
        form.append("prodId", prodId);
        // ------------------------------------------------------------------------------
        //debugger
        $.ajax({
            url: "DelPilotProduct",
            type: "post",
            dataType: "html",
            async: "true",
            processData: false,
            contentType: false,
            data: form,
            success: function (data) {
                $("#PilotLists_Ongoing").html(data);
            },
            error: function (request, status, error) {
                errorHandle(request, status, error);
            }
        });
    }

    function SetPilotProductCompleted(prodId) {
        var ret = confirm("Are You Sure to change <" + prodId + "> to complete status?");
        if (ret == false) {
            return;
        }
        var form = new FormData();
        form.append("prodId", prodId);
        form.append("status", "2");
        $.ajax({
            url: "SetPilotProductStatus",
            type: "post",
            dataType: "html",
            async: "true",
            processData: false,
            contentType: false,
            data: form,
            success: function (data) {
                $("#PilotLists_Ongoing").html(data);
            },
            error: function (request, status, error) {
                errorHandle(request, status, error);
            }
        });
    }

    function AddLotStatus(prodId) {
        var lotId = $("#ddlLot_" + prodId).val();
        var form = new FormData();
        form.append("prodId", prodId);
        form.append("lotId", lotId);
        $.ajax({
            url: "AddLotStatus",
            type: "post",
            dataType: "html",
            async: "true",
            processData: false,
            contentType: false,
            data: form,
            success: function (data) {
                $("#PilotLists_Ongoing").html(data)
            },
            error: function (request, status, error) {
                errorHandle(request, status, error);
            }
        })
    }

    function DelLotStatus(obj) {
        var row = obj.closest("tr").children("td");
        var lotId = row.eq(0).text().trim();
        var prodId = row.eq(1).text().trim();
        var ret = confirm("Are You Sure to Delete <" + lotId + ">?");
        if (ret == false) {
            return
        }
        var form = new FormData();
        form.append("prodId", prodId);
        form.append("lotId", lotId);
        $.ajax({
            url: "DelLotStatus",
            type: "post",
            dataType: "html",
            async: "true",
            processData: false,
            contentType: false,
            data: form,
            success: function (data) {
                $("#PilotLists_Ongoing").html(data)
            },
            error: function (request, status, error) {
                errorHandle(request, status, error);
            }
        });
    }
</script>

PilotList_Completed.cshtml 

@model System.Data.DataSet
@using System.Data;
@{
    var grid = Html.DevExpress().GridView(settings =>
    {
        settings.Name = "GridView_PilotList_";
        settings.CallbackRouteValues = new
        {

            Controller = "PhotoPilotList",
            Action = "PilotListCompleted"
        };
        settings.KeyFieldName = "ID";

        settings.Width = Unit.Percentage(100);


        settings.SettingsExport.EnableClientSideExportAPI = true;
        settings.SettingsExport.ExcelExportMode = DevExpress.Export.ExportType.DataAware;
        settings.Settings.ShowFooter = true;
        settings.Toolbars.Add(tb =>
        {
            tb.EnableAdaptivity = true;
            tb.Items.Add(GridViewToolbarCommand.ExportToXls);
            tb.Enabled = true;
            tb.Position = GridToolbarPosition.Top;
        });


        settings.Styles.Table.CssClass = "gridView-table";
        settings.Styles.Header.CssClass = "gridView-tableHead";
        settings.Styles.Cell.CssClass = "gridView-tableBody";
        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
        settings.SettingsBehavior.ConfirmDelete = true;

        settings.Settings.ShowFilterRow = true;//显示搜索行
        settings.Settings.ShowFilterRowMenu = true;//显示自定义搜索条件的按钮
        settings.CommandColumn.ShowClearFilterButton = true;//显示清除查询条件的链接
        settings.SettingsPager.Visible = true;//显示设置page页
                                              //settings.Settings.ShowGroupPanel = true;
                                              //settings.SettingsBehavior.AllowSelectByRowClick = true;
        settings.SettingsPager.PageSize = 100;//默认每页的条数
        settings.SettingsPager.PageSizeItemSettings.Visible = true;//显示可以自定义选择每页条数
        settings.SettingsPager.PageSizeItemSettings.Items = new string[] { "100", "200", "500" };//自定义每页条数选择项
        settings.CommandColumn.ShowSelectCheckbox = true;
        settings.Columns.Add(column =>
        {
            column.FieldName = "CHIPBODY";
            column.Caption = "PRODUCT";
            column.Settings.AutoFilterCondition = AutoFilterCondition.Like;
            column.Settings.ShowFilterRowMenuLikeItem = DefaultBoolean.True;
        });
        //新增车规产品底色highlight. add by lixinyue 20231128
        settings.HtmlDataCellPrepared = (sender, e) =>
        {
            if (e.DataColumn.FieldName == "CHIPBODY")
            {
                if ((e.GetValue("CHIPBODY").ToString() != "" && e.GetValue("CHIPBODY").ToString().Substring(0, 1) == "V"))
                { e.Cell.BackColor = System.Drawing.Color.FromArgb(237, 125, 49); }
            }
        };
        settings.Columns.Add(column =>
        {
            column.FieldName = "LOT_ID";
            column.Caption = "LOT_ID";
            column.Settings.AutoFilterCondition = AutoFilterCondition.Like;
            column.Settings.ShowFilterRowMenuLikeItem = DefaultBoolean.True;
        });
        settings.Columns.Add(column =>
        {
            column.FieldName = "PURPOSE";
            column.Caption = "PURPOSE";
            column.Settings.AutoFilterCondition = AutoFilterCondition.Like;
            column.Settings.ShowFilterRowMenuLikeItem = DefaultBoolean.True;
        });
        settings.Columns.Add(column =>
        {
            column.FieldName = "NOTE";
            column.Caption = "NOTE";
            column.Settings.AutoFilterCondition = AutoFilterCondition.Like;
            column.Settings.ShowFilterRowMenuLikeItem = DefaultBoolean.True;
        });
        settings.Columns.Add(column =>
        {
            column.FieldName = "CREATE_USER";
            column.Caption = "CREATE_USER";
            column.Settings.AutoFilterCondition = AutoFilterCondition.Like;
            column.Settings.ShowFilterRowMenuLikeItem = DefaultBoolean.True;
        });
        settings.Columns.Add(column =>
        {
            column.FieldName = "CREATE_TIME";
            column.Caption = "CREATE_TIME";
            column.Settings.AutoFilterCondition = AutoFilterCondition.Like;
            column.Settings.ShowFilterRowMenuLikeItem = DefaultBoolean.True;
        });
        settings.Columns.Add(column =>
        {
            column.FieldName = "UPDATE_USER";
            column.Caption = "UPDATE_USER";
            column.Settings.AutoFilterCondition = AutoFilterCondition.Like;
            column.Settings.ShowFilterRowMenuLikeItem = DefaultBoolean.True;
        });
        settings.Columns.Add(column =>
        {
            column.FieldName = "UPDATE_TIME";
            column.Caption = "UPDATE_TIME";
            column.Settings.AutoFilterCondition = AutoFilterCondition.Like;
            column.Settings.ShowFilterRowMenuLikeItem = DefaultBoolean.True;
        });
        settings.Columns.Add(column =>
        {
            column.FieldName = "ACTION";
            column.Caption = "ACTION";
            column.CellStyle.CssClass = "change";
        });
        settings.Settings.ShowGroupPanel = true;
        settings.Settings.ShowGroupPanel = true;
        settings.SettingsBehavior.AutoExpandAllGroups = true;
    });
}
@grid.Bind(Model.Tables["PilotListCompleted"]).GetHtml()


<script>
    $(".change").bind('click', function () {
        var prodId = $(this).parent().find("td").eq(0).text();
        SetPilotProductOngoing(prodId);
    });


    function SetPilotProductOngoing(prodId) {
        var ret = confirm("Are You Sure to change <" + prodId + "> to ongoing status?");
        if (ret == false) {
            return;
        }
        var form = new FormData();
        form.append("prodId", prodId);
        form.append("status", "1");
        $.ajax({
            url: "SetPilotProductStatus",
            type: "post",
            dataType: "html",
            async: "true",
            processData: false,
            contentType: false,
            data: form,
            success: function (data) {
                $("#PilotLists_Completed").html(data);
            },
            error: function (request, status, error) {
                errorHandle(request, status, error);
            }
        });
    }
</script>

PiLotListDefault.cshtml

@{
    ViewBag.Title = "PiLotListsDefault";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@Styles.Render("~/content/css/tables.css")
@Styles.Render("~/content/css/fieldsets.css")

@* Bootstrap Modal *@
@Styles.Render("~/Content/Css/bootstrap.min.css")
@Scripts.Render("~/Scripts/common.js")

@* Bootstrap DateTimePicker *@
@Styles.Render("~/Content/Css/bootstrap-datetimepicker.min.css")
@Scripts.Render("~/Scripts/bootstrap-datetimepicker.js")

@Styles.Render("~/Content/Css/bs-wizard-new.css")
@model System.Data.DataSet
@{
    List<List<SelectListItem>> llResult = ViewData["ResultDropDown"] as List<List<SelectListItem>>;
    List<SelectListItem> lProdgList = llResult[0];
}

<style type="text/css">
    #DatePick {
        margin-top: 5px;
        float: right;
    }
    .zui-table tbody .run_status {
        background-color: #1E90FF;
    }

    .zui-table tbody .wait_status {
        background-color: #00FF00;
    }

    .zui-table tbody .hold_status {
        background-color: #FF0000;
    }

    .fieldset .t {
        top: 0px;
        width: 250px;
    }

    .fieldset .b {
        margin-top: -12px;
        padding: 20px 20px 10px;
        box-sizing: border-box;
        overflow-x: auto;
    }

    hr {
        width: 100%;
        margin: 10px auto;
        border: 0;
        height: 0;
        border-top: 1px solid rgba(0, 0, 0, 0.3);
        border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    }

    .icon {
        font-size: 16px;
    }

        .icon:hover {
            color: #428BCA;
            cursor: pointer;
        }

        .icon[disabled] {
            cursor: not-allowed;
        }

    .btnNew {
        color: #fff;
        background-color: #337ab7;
        border-color: #2e6da4;
        border-radius: 4px;
        border: 1px solid transparent;
    }

        .btnNew:hover {
            background-color: #286090;
            border-color: #204d74;
        }

    .btn-new {
        width: 70px;
        margin-left: 5px;
        /*margin-bottom:5px;*/
    }

    .Partial {
        margin-top: 10px;
        padding: 10px 0;
    }

    .partial-title {
        font-size: 14px;
        font-weight: 500;
        /*font-variant:small-caps;*/
        letter-spacing: 1px;
    }

    .control-label[class^="col-md"] {
        margin-bottom: 0;
        vertical-align: middle;
        height: 30px;
        padding-top: 6px;
    }

    .ProductSet {
        margin-top: 15px;
        /*border:1px solid #000;*/
    }

    .LayerSet {
        margin-left: 10px;
    }

    .LotSet {
        margin-top: 5px;
        /*border:1px solid #000;*/
    }
</style>

<style>
    body {
        font-size:14px !important;
    }
    .deptUl {
        margin-top: 40px;
    }

    .deptUl > li a {
        font-size: 14px;
        font-weight: bold;
        color: black !important;
    }
    .bs-wizard-date-highlight {
        height:20px !important;
    }
    .bs-wizard > .bs-wizard-step .bs-wizard-date {
        height:20px !important;
    }
</style>
<ul class="nav nav-tabs deptUl" role="tablist">
    <li role="presentation" class="active" attr="ongoing"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">进行区</a></li>
    <li role="presentation" attr="completed"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">完成区</a></li>
</ul>
<div style="border:1px solid #ccc;margin-top:-1px;background-color:white;">
    <div id="PilotLists_Ongoing">
        @{
            Html.RenderPartial("PilotList");
        }
    </div>
    <div id="PilotLists_Completed">
        @{
            Html.RenderPartial("PilotList_Completed");
        }
    </div>
</div>

<script type="text/javascript">
    $(function () {
        $("#PilotLists_Ongoing").show();
        $("#PilotLists_Completed").hide();
        PilotListshow();


        $(".deptUl li").bind("click", function () {
            var active = $(this).attr("attr");
            if (active == "ongoing") {
                $("#PilotLists_Ongoing").show();
                $("#PilotLists_Completed").hide();
                PilotListshow();
            } else {
                $("#PilotLists_Ongoing").hide();
                $("#PilotLists_Completed").show();
                getPilotListCompleted();
            }
        });

        
    })


    function getPilotListCompleted()
    {
        layer.load(2);
        var form = new FormData();
        $.ajax({
            url: "PilotListCompleted",
            type: "post",
            dataType: "html",
            async: "true",
            processData: false,
            contentType: false,
            data: form,
            success: function (data) {
                layer.closeAll();
                $("#PilotLists_Completed").html(data);

            },
            error: function (request, status, error) {
                errorHandle(request, status, error);
            }
        });
    }
</script>

以上是源代码,以下是我修改的 ,我加了一个

ProductDataAccess.cs

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Linq;
using System.Security.Claims;

public class ProductDataAccess
{
    private readonly string connectionString = ConfigurationManager.ConnectionStrings["NewKwebConnString"].ConnectionString;
    // 修改了此方法,增加对用户部门的处理以决定默认分类,并处理ALL分类情况
    public List<ProductCategory> GetProductsByDepartmentAndCategory(string department, string category = "INT", string userDepartment = "RK50")
    {
        // 根据用户部门设定默认分类
        if (string.IsNullOrEmpty(category))
        {
            category = userDepartment == "RK50" ? "TD" : "INT";
        }
        // 当分类为ALL时,不应用任何PRDODG1的筛选
        string effectiveCategory = category == "ALL" ? null : category;
        List<ProductCategory> products = new List<ProductCategory>();
        string sql = BuildSqlQuery(effectiveCategory, department);
        try
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    if (effectiveCategory != null)
                    {
                        command.Parameters.AddWithValue("@prdodg1", effectiveCategory);
                    }

                    var deptIds = GetDepartmentIds(department);
                    if (deptIds != null)
                    {
                        command.Parameters.AddWithValue("@deptIds", string.Join(",", deptIds));
                    }

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            products.Add(new ProductCategory
                            {
                                ChipBody = reader.GetString(0),
                                DepartmentId = reader.GetString(1),
                                ProductGroup = reader.GetString(2)
                            });
                        }
                    }
                }
            }
        }
        catch (SqlException ex)
        {
            Console.WriteLine("SQL Error: " + ex.Message);
        }
        catch (Exception ex)
        {
            Console.WriteLine("An error occurred: " + ex.Message);
        }

        return products;
    }

    private string BuildSqlQuery(string category, string department)
    {
        string prdodgClause = category != null ? "PRDODG1 = @prdodg1" : "1 = 1";
        string deptClause = GetDepartmentIds(department) != null ? "DEPT_ID1 IN (@deptIds)" : "1 = 1";

        return $@"
            SELECT CHIPBODY, DEPT_ID1, PRDODG1 
            FROM PRODUCT_OWNER 
            WHERE {prdodgClause} AND {deptClause}";
    }

    private IEnumerable<string> GetDepartmentIds(string department)
    {
        switch (department)
        {
            case "RK50":
                return new[] { "PD10", "PD20", "PD30" };
            case "otherDept":
                return new[] { "RH10", "RH20" };
            case "NEW_DEPT":
                return new[] { "NE10", "NE20", "NE30" };
            default:
                return Enumerable.Empty<string>();
        }
    }
}

public class ProductCategory
{
    public string ChipBody { get; set; }
    public string DepartmentId { get; set; }
    public string ProductGroup { get; set; }
}

 PhotoPilotListController新增一个方法PhotoPilotListController

  public JsonResult GetFilteredProducts(string department, string category, string product = "")
        {
            try
            {
                // 实例化ProductDataAccess
                var productDataAccess = new ProductDataAccess();
                // 调用ProductDataAccess的方法来获取筛选后的数据
                var filteredProducts = productDataAccess.GetProductsByDepartmentAndCategory(department, category);
                var result = filteredProducts.Select(p => new {
                    ChipBody = p.ChipBody,
                    DepartmentId = p.DepartmentId,
                    ProductGroup = p.ProductGroup
                }).ToList();
                return Json(result, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                // 记录日志或处理异常
                log.Error("Error fetching filtered products.", ex);
                return Json(new { error = "An error occurred while fetching the products." }, JsonRequestBehavior.AllowGet);
            }
        }

 PilotList.cshtml修改部分如下:

@model System.Data.DataSet
<div id="colPilotLists" style="display: flex; align-items: center; margin: 20px 10px 10px 10px;">
    @Html.Label("PRODUCT:", new { style = "flex-shrink: 0; margin-right: 10px;" })
    <input class="form-control" placeholder="例:AFGNE701N" style="flex-shrink: 0; width: 180px; margin-right: 10px;" type="text" id="ddlProdg" />

    @if (ViewData["ButtonVisible"].ToString() == "Visible")
    {
        <button class="btn btn-info btn-new" id="btnSecondIntSave" style="flex-shrink: 0; margin-right: 10px;">
            <span>Add</span>
        </button>
    }

    <div style="display: flex; align-items: center; flex-shrink: 0; margin-right: 10px;">
        @Html.Label("CLASSIFICATION:", new { style = "margin-right: 10px;" })
        @Html.DropDownList("ddlClassification", new SelectList(
        new[] {
            new SelectListItem { Text = "INT", Value = "INT" },
            new SelectListItem { Text = "TD", Value = "TD" },
            new SelectListItem { Text = "ALL", Value = "ALL" }
        }, "Value", "Text"), new { @class = "form-control", style = "width: 180px;" })
    </div>

    <button class="btn btn-info btn-new" id="btnQuery" style="flex-shrink: 0;">
        <span>Query</span>
    </button>
@{
    ViewBag.UserDepartment = ViewBag.UserDEPT; 
}

<script>
$(document).ready(function () {
    // 初始化页面时加载默认分类的产品
      var userDepartment = '@ViewBag.UserDepartment'; // 从ViewBag中获取部门代码
    var defaultCategory = userDepartment === 'RK50' ? 'TD' : 'INT';
    var defaultProduct = ""; // 新增默认产品代码变量,默认为空
    loadFilteredProducts(defaultCategory, defaultProduct);

    // 分类下拉框改变时触发
    $('#ddlClassification').on('change', function () {
        var selectedCategory = $(this).val();
        loadFilteredProducts(selectedCategory, defaultProduct); // 仅根据分类加载
    });
    // 查询按钮点击事件
    $('#btnQuery').click(function () {
        var userInput = $('#ddlProdg').val(); // 获取用户输入的产品代码
        var selectedCategory = $('#ddlClassification').val(); // 获取选择的分类
        loadFilteredProducts(selectedCategory, userInput);
    });

    function loadFilteredProducts(category, productCode = "") {
        $.ajax({
            url: '@Url.Action("GetFilteredProducts", "PhotoPilotList")', // 使用Url.Action确保路径正确
            type: 'GET',
            data: { department: '@User.Identity.Name', category: category, productCode: productCode }, // 参数名调整为productCode
            success: function (data) {
                updateProductList(data);
            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.error('Error fetching products: ' + textStatus + ', ' + errorThrown);
            }
        });
    }
	
    function updateProductList(products) {
        var productListDiv = $('#colPilotLists');
        productListDiv.empty();

        products.forEach(function (product) {
            var productItem = $('<div class="product-item">') // 添加样式类以美化显示
                .append($('<span>').text(product.ChipBody))
                .append($('<span>').text(' - '))
                .append($('<span>').text(product.DepartmentId))
                .append($('<span>').text(' - '))
                .append($('<span>').text(product.ProductGroup));
            productListDiv.append(productItem);
        });
    }
});

 这是系统一个页面的前后端代码,我现在需要在页面的进行区的product框右边加一个classification,冒号一个下拉框,三个选项:INTTDALL,右边一个query按钮,大小,颜色,格式和左边的PRODUCT一样,以上已经完成了,根据数据库账号为newkweb密码为newkwebPRODUCT_OWNER这张表下有有CHIPBODYDEPT_ID1PRDODG1三个栏位,数据库的表有栏位PRODG1CHIPBODYDEPT_ID1;PRODG1数据类型为L90RB04ACHIPBODY数据类似AFMN4E01NDEPT_ID1数据类似PM10根据CHIPBODY对应的DEPT_ID1PRDODG1,确定PRDODG1产品输入那个部门,的列名为CHIPBODY的名称对应DEPT_ID1,DEPT_ID1PD10PD20PD60PD70PD80PM10PM20product归类为INT产品,将DEPT_ID1RH10RH20RH40RH50RI10RI20RI30归类为TD产品,页面打开的时候根据index方法,可以获取当前用户信息,部门为RK50默认呈现TD产品,其他部门默认INT产品,下拉框选择INT产品呈现INT产品,选择TD产品呈现TD产品,选择ALL呈现全部产品,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值