1427 lines
61 KiB
C#
1427 lines
61 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web;
|
|
using Fab2ApprovalSystem.Models;
|
|
using Dapper;
|
|
using System.Transactions;
|
|
using Fab2ApprovalSystem.ViewModels;
|
|
using System.Reflection;
|
|
using Fab2ApprovalSystem.Misc;
|
|
|
|
namespace Fab2ApprovalSystem.DMO
|
|
{
|
|
public class LotDispositionDMO
|
|
{
|
|
private IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
|
|
|
|
//LotDispositionDMO ldDMO = new LotDispositionDMO();
|
|
WorkflowDMO wfDMO = new WorkflowDMO();
|
|
|
|
public IEnumerable<IssuesViewModel> GetTaskList(int userID)
|
|
{
|
|
// eventually, the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
//var lotDispostions = this.db.Query<IssuesViewModel>("GetLotDispositionsByUser", new { UserID = userID }, commandType: CommandType.StoredProcedure).ToList();
|
|
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@UserID", userID);
|
|
|
|
var lotDispostions = this.db.Query<IssuesViewModel>("GetTaskListByUser", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
return lotDispostions;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="userID"></param>
|
|
/// <returns></returns>
|
|
public IEnumerable<OpenActionItemViewModel> GetMyOpenActionItems(int userID)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@UserID", userID);
|
|
|
|
var lotDispostions = this.db.Query<OpenActionItemViewModel>("GetOpenActionItemsByUser", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
return lotDispostions;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public IEnumerable<IssuesViewModel> GetLotDispositions()
|
|
{
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
var lotDispostions = this.db.Query<IssuesViewModel>("GetLotDispositions", null, commandType: CommandType.StoredProcedure).ToList();
|
|
return lotDispostions;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public IEnumerable<IssuesViewModel> GetDocuments()
|
|
{
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
var lotDispostions = this.db.Query<IssuesViewModel>("GetDocuments", null, commandType: CommandType.StoredProcedure).ToList();
|
|
return lotDispostions;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public IEnumerable<IssuesViewModel> GetWorkRequests()
|
|
{
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
var workReqs = this.db.Query<IssuesViewModel>("LTGetWorkRequests", null, commandType: CommandType.StoredProcedure).ToList();
|
|
return workReqs;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public IEnumerable<AuditList> GetAuditList(int userID)
|
|
{
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@UserID", userID);
|
|
var al = this.db.Query<AuditList>("_8DGetAuditList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
return al;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="userID"></param>
|
|
/// <returns></returns>
|
|
public IEnumerable<CorrectiveAction> GetCorrectiveActionList(int userID)
|
|
{
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@UserID", userID);
|
|
var cal = this.db.Query<CorrectiveAction>("_8DGetCorrectiveActionList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
return cal;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="userID"></param>
|
|
/// <returns></returns>
|
|
public IEnumerable<ChangeControlList> GetChangeControls(int userID)
|
|
{
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@UserID", userID);
|
|
var cc = this.db.Query<ChangeControlList>("CCGetChangeControlList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
return cc;
|
|
}
|
|
|
|
public IEnumerable<IssuesViewModel> GetMRBList(int userID)
|
|
{
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@UserID", userID);
|
|
var cc = this.db.Query<IssuesViewModel>("MRBGetMRBList", null, commandType: CommandType.StoredProcedure).ToList();
|
|
return cc;
|
|
}
|
|
|
|
public IEnumerable<IssuesViewModel> GetECNList(int userID)
|
|
{
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@UserID", userID);
|
|
var cc = this.db.Query<IssuesViewModel>("ECNGetECNList", null, commandType: CommandType.StoredProcedure).ToList();
|
|
return cc;
|
|
}
|
|
|
|
|
|
|
|
public IEnumerable<IssuesViewModel> GetLotDispositionList(int userID)
|
|
{
|
|
// later on the View Model will refer to a generic task list instead of the just Lot Disposition Items
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@UserID", userID);
|
|
var cc = this.db.Query<IssuesViewModel>("GetLotDispositionList", null, commandType: CommandType.StoredProcedure).ToList();
|
|
return cc;
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="issueID"></param>
|
|
/// <param name="isITAR"></param>
|
|
/// <param name="userID"></param>
|
|
/// <returns></returns>
|
|
public LotDisposition GetLotDispositionItem(int issueID, out int isITAR, int userID)
|
|
{
|
|
/* IsITAR
|
|
0 = false
|
|
1 = true
|
|
2 = not required
|
|
*/
|
|
isITAR = 2;
|
|
var issueItem = new LotDisposition();
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", value: issueID);
|
|
parameters.Add("@UserID", userID);
|
|
//parameters.Add("@UserID", GlobalVars.USER_ID);
|
|
parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
|
|
|
using (var multipleResultItems = this.db.QueryMultiple("GetLotDispositionItem", parameters, commandType: CommandType.StoredProcedure))
|
|
{
|
|
issueItem = multipleResultItems.Read<LotDisposition>().SingleOrDefault();
|
|
|
|
|
|
var departments = multipleResultItems.Read<int>().ToList();
|
|
if (issueItem != null && departments != null)
|
|
{
|
|
issueItem.DepartmentIDs.AddRange(departments);
|
|
}
|
|
|
|
|
|
isITAR = parameters.Get<int>("@IsITAR");
|
|
|
|
|
|
}
|
|
return issueItem;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="issueID"></param>
|
|
/// <param name="isITAR"></param>
|
|
/// <param name="userID"></param>
|
|
/// <returns></returns>
|
|
public LotDisposition GetLotDispositionItemForRead(int issueID, out int isITAR, int userID)
|
|
{
|
|
/* IsITAR
|
|
0 = false
|
|
1 = true
|
|
2 = not required
|
|
*/
|
|
isITAR = 2;
|
|
var issueItem = new LotDisposition();
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", value: issueID);
|
|
parameters.Add("@UserID", userID);
|
|
//parameters.Add("@UserID", GlobalVars.USER_ID);
|
|
parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
|
|
|
using (var multipleResultItems = this.db.QueryMultiple("GetLotDispositionItemForRead", parameters, commandType: CommandType.StoredProcedure))
|
|
{
|
|
issueItem = multipleResultItems.Read<LotDisposition>().SingleOrDefault();
|
|
|
|
|
|
var departments = multipleResultItems.Read<int>().ToList();
|
|
if (issueItem != null && departments != null)
|
|
{
|
|
issueItem.DepartmentIDs.AddRange(departments);
|
|
}
|
|
|
|
|
|
isITAR = parameters.Get<int>("@IsITAR");
|
|
|
|
|
|
}
|
|
return issueItem;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="issueID"></param>
|
|
/// <returns></returns>
|
|
public int GetRHLotCount(int issueID)
|
|
{
|
|
StringBuilder query = new StringBuilder("SELECT COUNT(*) FROM dbo.fnGetLot_RH(@IssueID) ");
|
|
//query.Append("WHERE UserID = @UserID AND AND EmployeeStatus = 'Active'");
|
|
return this.db.Query<int>(query.ToString(), new { IssueID = issueID }).SingleOrDefault();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<LotDispoDepartment> GetDepartments()
|
|
{
|
|
|
|
var departments = this.db.Query<LotDispoDepartment>("GetLotDispositionDepartments", null, commandType: CommandType.StoredProcedure).ToList();
|
|
return departments;
|
|
|
|
}
|
|
|
|
#region LotDisposition
|
|
public LotDisposition InsertLotDisposition(LotDisposition lotDispo)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
using (var transanction = new TransactionScope())
|
|
{
|
|
// Lot Disposition
|
|
parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", value: lotDispo.IssueID, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
|
parameters.Add("@Title", lotDispo.Title);
|
|
parameters.Add("@IssueDescription", lotDispo.IssueDescription);
|
|
parameters.Add("@PERequired", lotDispo.PERequired);
|
|
parameters.Add("@ResponsibilityID", lotDispo.ResponsibilityID);
|
|
parameters.Add("@IssueDate", lotDispo.IssueDate);
|
|
parameters.Add("@OriginatorID", lotDispo.OriginatorID);
|
|
parameters.Add("@ReasonForDisposition", lotDispo.ReasonForDisposition);
|
|
parameters.Add("@ResponsibilityIssueID", lotDispo.ResponsibilityIssueID);
|
|
parameters.Add("@SPNScrapCode", lotDispo.SPNScrapCode);
|
|
parameters.Add("@CurrentStep", lotDispo.CurrentStep);
|
|
|
|
this.db.Execute("InsertLotDisposition", parameters, commandType: CommandType.StoredProcedure);
|
|
lotDispo.IssueID = parameters.Get<int>("@IssueID");
|
|
|
|
|
|
// Lot Update
|
|
|
|
//parameters = new DynamicParameters();
|
|
//IEnumerable<Lot> lots = lotDispo.Lots;
|
|
//foreach (Lot lot in lots)
|
|
//{
|
|
// parameters = new DynamicParameters();
|
|
// parameters.Add("@LotNumber", lot.LotNumber);
|
|
// parameters.Add("@IssueID", lotDispo.IssueID);
|
|
// parameters.Add("@Description", lot.Description);
|
|
// parameters.Add("@NewPartNo", lot.NewPartNo);
|
|
// parameters.Add("@WipPartNo", lot.WipPartNo);
|
|
// parameters.Add("@DiePartNo", lot.DiePartNo);
|
|
// parameters.Add("@ProductFamily", lot.ProductFamily);
|
|
// parameters.Add("@Gen", lot.Gen);
|
|
|
|
// parameters.Add("@Channel", lot.Channel);
|
|
// parameters.Add("@Hexsize", lot.Hexsize);
|
|
|
|
// parameters.Add("@Voltage", lot.Voltage);
|
|
// parameters.Add("@WaferCount", lot.WaferCount);
|
|
// parameters.Add("@DieCount", lot.DieCount);
|
|
|
|
// parameters.Add("@Location", lot.Location);
|
|
// parameters.Add("@TotalCost", lot.TotalCost);
|
|
// parameters.Add("@LotStatusOptionID", lot.LotStatusOption.LotStatusOptionID);
|
|
|
|
// this.db.Execute("InsertLot", parameters, commandType: CommandType.StoredProcedure);
|
|
|
|
|
|
//}
|
|
|
|
|
|
// LotDispoDepartment
|
|
List<int> lotDispDepIDs = lotDispo.DepartmentIDs;
|
|
|
|
if (lotDispDepIDs != null)
|
|
{
|
|
foreach (int depIds in lotDispDepIDs)
|
|
{
|
|
parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", depIds);
|
|
parameters.Add("@DepartMentID", lotDispo.IssueID);
|
|
this.db.Execute("InsertLotDispoDepartment", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
}
|
|
|
|
transanction.Complete();
|
|
|
|
return lotDispo;
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="issueID"></param>
|
|
/// <param name="lotNumber"></param>
|
|
/// <returns></returns>
|
|
public ScrapLot GetLotStausDetail(int issueID, string lotNumber)
|
|
{
|
|
return this.db.Query<ScrapLot>("SELECT L.WaferCount, S.* FROM ScrapLot S INNER JOIN Lot L ON S.IssueID = L.IssueID AND S.LotNo = L.LotNumber WHERE S.IssueID = @IssueID AND LotNo = @lotNumber", new { IssueID = issueID, lotNumber = lotNumber }).SingleOrDefault();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="lotDispo"></param>
|
|
public void UpdateLotDisposition(LotDisposition lotDispo)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
using (var transanction = new TransactionScope())
|
|
{
|
|
// Lot Disposition
|
|
parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", lotDispo.IssueID);
|
|
parameters.Add("@Title", lotDispo.Title);
|
|
parameters.Add("@IssueDescription", lotDispo.IssueDescription);
|
|
parameters.Add("@PERequired", lotDispo.PERequired);
|
|
parameters.Add("@MRBRequired", lotDispo.MRBRequired);
|
|
parameters.Add("@DispositionByOCAP", lotDispo.DispositionByOCAP);
|
|
parameters.Add("@CANo", lotDispo.CANo);
|
|
parameters.Add("@ResponsibilityID", lotDispo.ResponsibilityID);
|
|
parameters.Add("@IssueDate", lotDispo.IssueDate);
|
|
parameters.Add("@ReasonForDisposition", lotDispo.ReasonForDisposition);
|
|
parameters.Add("@ResponsibilityIssueID", lotDispo.ResponsibilityIssueID);
|
|
parameters.Add("@SPNScrapCode", lotDispo.SPNScrapCode);
|
|
|
|
this.db.Execute("UpdateLotDisposition", parameters, commandType: CommandType.StoredProcedure);
|
|
|
|
List<int> lotDispDepIDs = lotDispo.DepartmentIDs;
|
|
|
|
if (lotDispDepIDs != null)
|
|
{
|
|
parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", lotDispo.IssueID);
|
|
this.db.Execute("DeleteLotDispositionDepartment", parameters, commandType: CommandType.StoredProcedure);
|
|
|
|
foreach (int depIds in lotDispDepIDs)
|
|
{
|
|
parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID",lotDispo.IssueID );
|
|
parameters.Add("@DepartmentID", depIds);
|
|
this.db.Execute("InsertLotDispositionDepartment", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
}
|
|
transanction.Complete();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region LotDispoitio Lot
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="lot"></param>
|
|
/// <returns></returns>
|
|
public int InsertLot(Lot lot, bool getLotInfo)
|
|
{
|
|
if (getLotInfo)
|
|
{
|
|
MiscDMO.GetLotInformation(lot);
|
|
}
|
|
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@LotID", value: lot.LotID, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
|
parameters.Add("@LotNumber", lot.LotNumber);
|
|
parameters.Add("@DieLotNumber", lot.DieLotNumber);
|
|
parameters.Add("@IssueID", lot.IssueID);
|
|
parameters.Add("@Description", lot.Description);
|
|
parameters.Add("@NewPartNo", lot.NewPartNo);
|
|
parameters.Add("@WipPartNo", lot.WipPartNo);
|
|
parameters.Add("@DiePartNo", lot.DiePartNo);
|
|
parameters.Add("@ProductFamily", lot.ProductFamily);
|
|
parameters.Add("@Gen", lot.Gen);
|
|
|
|
parameters.Add("@Channel", lot.Channel);
|
|
parameters.Add("@Hexsize", lot.Hexsize);
|
|
|
|
parameters.Add("@Voltage", lot.Voltage);
|
|
parameters.Add("@WaferCount", lot.WaferCount);
|
|
parameters.Add("@DieCount", lot.DieCount);
|
|
|
|
parameters.Add("@Location", lot.Location);
|
|
parameters.Add("@TotalCost", lot.TotalCost);
|
|
parameters.Add("@LotStatusOptionID", lot.LotStatusOption.LotStatusOptionID);
|
|
parameters.Add("@QualityCode", lot.QualityCode);
|
|
parameters.Add("@OpenIssueWithExistingLot", dbType: DbType.Int32, direction: ParameterDirection.Output);
|
|
|
|
|
|
this.db.Execute("InsertLotDispositionLot", parameters, commandType: CommandType.StoredProcedure);
|
|
|
|
|
|
int lotID = parameters.Get<int>("@LotID");
|
|
if (parameters.Get<int>("@OpenIssueWithExistingLot") != 0)
|
|
{
|
|
|
|
lot.OpenIssueWithExistingLots = parameters.Get<int>("@OpenIssueWithExistingLot");
|
|
}
|
|
|
|
return lotID;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="lotNumber"></param>
|
|
/// <returns></returns>
|
|
public IEnumerable<SPN_MRB> GetMRBsFromSPN(string lotNumber)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@LotNo", lotNumber);
|
|
var mrbList = this.db.Query<SPN_MRB>("GetMRBsFromSPN", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
|
|
|
|
return mrbList;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="lotNumber"></param>
|
|
public void InsertChildLot_NotInTheMRB(string lotNumber)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@LotNo", lotNumber);
|
|
this.db.Execute("InsertChildLot_NotInTheMRB_LD", parameters, commandType: CommandType.StoredProcedure);
|
|
|
|
}
|
|
|
|
public void DeleteCADocument(int CANo, int userID, string caTypeString)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@UserID", userID);
|
|
parameters.Add("@CANo", CANo);
|
|
parameters.Add("@CAType", caTypeString);
|
|
|
|
this.db.Execute("_8DDeleteCADocument", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="lotID"></param>
|
|
|
|
public void DeleteLotDispoLot(int lotID)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@LotID", lotID);
|
|
this.db.Execute("DeleteLotDispositionLot", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="lotID"></param>
|
|
public void DeleteAllLotDispoLot(int issueID)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", issueID);
|
|
this.db.Execute("DeleteLotDispositionAllLots", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="lot"></param>
|
|
public void UpdateLotDispoLot(Lot lot)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@LotID", lot.LotID);
|
|
parameters.Add("@LotNumber", lot.LotNumber);
|
|
parameters.Add("@DieLotNumber", lot.DieLotNumber);
|
|
parameters.Add("@IssueID", lot.IssueID);
|
|
parameters.Add("@Description", lot.Description);
|
|
parameters.Add("@NewPartNo", lot.NewPartNo);
|
|
parameters.Add("@WipPartNo", lot.WipPartNo);
|
|
parameters.Add("@DiePartNo", lot.DiePartNo);
|
|
parameters.Add("@ProductFamily", lot.ProductFamily);
|
|
parameters.Add("@Gen", lot.Gen);
|
|
|
|
parameters.Add("@Channel", lot.Channel);
|
|
parameters.Add("@Hexsize", lot.Hexsize);
|
|
|
|
parameters.Add("@Voltage", lot.Voltage);
|
|
parameters.Add("@WaferCount", lot.WaferCount);
|
|
parameters.Add("@DieCount", lot.DieCount);
|
|
|
|
parameters.Add("@Location", lot.Location);
|
|
parameters.Add("@TotalCost", lot.TotalCost);
|
|
parameters.Add("@LotStatusOptionID", lot.LotStatusOption.LotStatusOptionID);
|
|
|
|
this.db.Execute("UpdateLotDispositionLot", parameters, commandType: CommandType.StoredProcedure);
|
|
|
|
|
|
// Update the Scrap Lot table =====================================================================
|
|
ScrapLot sl = new ScrapLot();
|
|
sl.IssueID = lot.IssueID;
|
|
sl.LotNo = lot.LotNumber;
|
|
sl.WaferCount = lot.WaferCount;
|
|
|
|
foreach (PropertyInfo pi in sl.GetType().GetProperties())
|
|
{
|
|
if (pi.Name.ToLower().StartsWith("lot") && pi.Name.ToLower().EndsWith("state"))
|
|
{
|
|
if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.Release)
|
|
pi.SetValue(sl, (byte)1, null);
|
|
else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.Scrap)
|
|
pi.SetValue(sl, (byte)2, null);
|
|
else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.NotAvailable)
|
|
pi.SetValue(sl, (byte)3, null);
|
|
else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.M_Suffix)
|
|
pi.SetValue(sl, (byte)4, null);
|
|
else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.Select_Wafers)
|
|
pi.SetValue(sl, (byte)5, null);
|
|
else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.CloseToQDB)
|
|
pi.SetValue(sl, (byte)6, null);
|
|
else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.SplitOffHold)
|
|
pi.SetValue(sl, (byte)7, null);
|
|
}
|
|
}
|
|
|
|
// if the Lot Status is M_Suffix, the whole lot is automatically in a Release state per Hans
|
|
if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.Release
|
|
|| lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.M_Suffix
|
|
|| lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.CloseToQDB)
|
|
{
|
|
sl.ScrapCount = 0;
|
|
sl.ReleaseCount = lot.WaferCount > 0 ? lot.WaferCount : lot.DieCount;
|
|
lot.ScrapCount = 0;
|
|
lot.ReleaseCount = sl.ReleaseCount;
|
|
|
|
|
|
}
|
|
else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.Scrap)
|
|
{
|
|
sl.ScrapCount = lot.WaferCount > 0 ? lot.WaferCount : lot.DieCount;
|
|
sl.ReleaseCount = 0;
|
|
|
|
lot.ScrapCount = lot.WaferCount > 0 ? lot.WaferCount : lot.DieCount;
|
|
lot.ReleaseCount = 0;
|
|
}
|
|
else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.SplitOffHold
|
|
|| lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.NotAvailable)
|
|
{
|
|
sl.ScrapCount = 0;
|
|
sl.ReleaseCount = 0;
|
|
|
|
lot.ScrapCount = 0;
|
|
lot.ReleaseCount = 0;
|
|
}
|
|
//else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.NotAvailable)
|
|
//{
|
|
// sl.ScrapCount = 0;
|
|
// sl.ReleaseCount = 0;
|
|
|
|
// lot.ScrapCount = 0;
|
|
// lot.ReleaseCount = 0;
|
|
//}
|
|
|
|
UpdateLotScrapReleaseStatus(sl);
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates the Lot object with additional info based on Lot data downlaoded from SPN
|
|
/// </summary>
|
|
/// <param name="lot"></param>
|
|
//void GetLotInformation(Lot lot)
|
|
//{
|
|
// string qryLotInfo = "SELECT WP_LOT_NO, WP_PART_NUMBER, MP_PRODUCT_FAMILY, MP_DESCRIPTION, WP_CURRENT_QTY, WP_CURRENT_LOCATION, DieLotNumber, DiePartNo, DieCount FROM SPNLot WHERE WP_Lot_No = @LotNumber ";
|
|
// var lotInfoRow = this.db.Query<dynamic>(qryLotInfo, new { lot.LotNumber }).ToList();
|
|
|
|
// //lot.LotNumber = lotInfoRow.Get<string>("@WP_LOT_NO");
|
|
// //lot.WipPartNo = lotInfoRow.Get<int>("@WP_Part_Number");
|
|
// ////lotInfoRow.WP_LOT_NO;
|
|
// //lot.WipPartNo = lotInfoRow.WP_Part_Number;
|
|
|
|
|
|
// foreach (dynamic lotInfoColumn in lotInfoRow)
|
|
// {
|
|
|
|
|
|
// lot.LotNumber = lotInfoColumn.WP_LOT_NO;
|
|
// lot.DieLotNumber = lotInfoColumn.DieLotNumber;
|
|
|
|
// if (lotInfoColumn.WP_PART_NUMBER != null)
|
|
// lot.WipPartNo = lotInfoColumn.WP_PART_NUMBER.Trim();
|
|
|
|
// if (lotInfoColumn.WP_CURRENT_LOCATION != null)
|
|
// {
|
|
// lot.Location = lotInfoColumn.WP_CURRENT_LOCATION;
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (lotInfoColumn.MP_DESCRIPTION != null)
|
|
// {
|
|
// lot.Description = lotInfoColumn.MP_DESCRIPTION;
|
|
// if (lot.Description.Length > 0)
|
|
// {
|
|
// string[] temp = lot.Description.Split(new char[] { ',' });
|
|
// if (temp.Length > 0)
|
|
// {
|
|
// try
|
|
// {
|
|
// lot.ProductFamily = temp[0];
|
|
// }
|
|
// catch { } // ignore the error
|
|
|
|
// try
|
|
// {
|
|
// lot.Gen = double.Parse(temp[2].Substring(1,temp[2].Length - 1));
|
|
// }
|
|
// catch { }// ignore the error
|
|
// try
|
|
// {
|
|
// lot.Hexsize = double.Parse(temp[6]);
|
|
// }
|
|
// catch { }// ignore the error
|
|
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// if (lotInfoColumn.DieCount != null)
|
|
// lot.DieCount = int.Parse(lotInfoColumn.DieCount.ToString());
|
|
|
|
// if (lotInfoColumn.DiePartNo != null)
|
|
// lot.DiePartNo = lotInfoColumn.DiePartNo.Trim();
|
|
|
|
// if (lotInfoColumn.WP_CURRENT_QTY != null)
|
|
// lot.WaferCount = lotInfoColumn.WP_CURRENT_QTY;
|
|
|
|
// if (lot.WipPartNo.Length > 0 || lot.DiePartNo.Length > 0)
|
|
// {
|
|
// qryLotInfo = "SELECT DiePartNo, SourceFAB, Diameter, Silicon, Gen, Layers,HexSize,Voltage,Channel, Type AS ProductFamily, WaferCost, DieCost FROM FabApprovalSystem.dbo.StdCost WHERE WIPWaferNo = @WIPPartNo OR DiePartNo = @DiePartNo ";
|
|
// var moreLotInfoRow = this.db.Query<dynamic>(qryLotInfo, new { lot.WipPartNo, lot.DiePartNo }).ToList();
|
|
|
|
// foreach (var moreLotInfoColumn in moreLotInfoRow)
|
|
// {
|
|
// lot.DieCost = double.Parse(moreLotInfoColumn.DieCost.ToString());
|
|
// lot.WaferCost = double.Parse(moreLotInfoColumn.WaferCost.ToString());
|
|
|
|
// if (moreLotInfoColumn.Channel != null)
|
|
// lot.Channel = moreLotInfoColumn.Channel;
|
|
|
|
// //if (moreLotInfoColumn.ProductFamily != null)
|
|
// // lot.ProductFamily = moreLotInfoColumn.ProductFamily;
|
|
|
|
// if (moreLotInfoColumn.Hexsize != null)
|
|
// lot.Hexsize = moreLotInfoColumn.Hexsize;
|
|
|
|
// if (moreLotInfoColumn.Voltage != null)
|
|
// lot.Voltage = moreLotInfoColumn.Voltage;
|
|
|
|
// //if (moreLotInfoColumn.Gen != null)
|
|
// // lot.Gen = moreLotInfoColumn.Gen;
|
|
|
|
// if (lot.DieCount == 0)
|
|
// lot.TotalCost = Math.Round(lot.WaferCount * lot.WaferCost,2);
|
|
// else
|
|
// lot.TotalCost = Math.Round(lot.DieCount * lot.DieCost,2);
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// //return lotStatusOption;
|
|
|
|
//}
|
|
|
|
#endregion
|
|
|
|
public IEnumerable<LotStatusOptionViewModel> GetLotStatusOptions()
|
|
{
|
|
|
|
var lotStatusOption = this.db.Query<LotStatusOptionViewModel>("SELECT * FROM LotStatusOption").ToList();
|
|
return lotStatusOption;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="issueID"></param>
|
|
/// <returns></returns>
|
|
public IEnumerable<Lot> GetLotDispositionLots(int issueID)
|
|
{
|
|
|
|
// NOTE: Any new fields that needs to be added to select list , needs to be referenced prior to the "LS.LotStatusOptionID , LS.LotStatusOption" fields
|
|
|
|
db.Open();
|
|
#region Commented Code
|
|
/*
|
|
StringBuilder sql = new StringBuilder();
|
|
sql.Append("SELECT DISTINCT SQ.IssueIDs AS MRBsLinkedToLot , DispoType.MRBDispoType, SQP.IssueIDs AS IssueIDWithoutMRB, ");
|
|
sql.Append("CASE WHEN L.LotStatusOptionID = 2 THEN 1 ");
|
|
sql.Append("WHEN PATINDEX('%B%', DispoType.MRBDispoType) > 0 AND L.LotStatusOptionID <> 2 THEN 0 ");
|
|
sql.Append("WHEN PATINDEX('%X%', DispoType.MRBDispoType) > 0 AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 THEN 0 ");
|
|
|
|
sql.Append("WHEN (PATINDEX('%D%', DispoType.MRBDispoType) > 0 ");
|
|
sql.Append(" AND PATINDEX('%X%', DispoType.MRBDispoType) = 0 ");
|
|
sql.Append(" AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 ");
|
|
sql.Append(" AND LS.LotStatusOptionID <> 6 ) ");
|
|
sql.Append(" AND (LTRIM(RTRIM(Location)) <> 'QDB' AND LTRIM(RTRIM(Location)) <> 'EDB') THEN 0 ");
|
|
|
|
sql.Append("ELSE 1 ");
|
|
sql.Append("END AS GoodToSubmit, ");
|
|
|
|
sql.Append("CASE WHEN L.LotStatusOptionID = 2 THEN 'NA' ");
|
|
sql.Append("WHEN (PATINDEX('%B%', DispoType.MRBDispoType) > 0 AND L.LotStatusOptionID <> 2) ");
|
|
sql.Append("OR ( ");
|
|
sql.Append(" (PATINDEX('%D%', DispoType.MRBDispoType) > 0 ");
|
|
sql.Append(" AND PATINDEX('%X%', DispoType.MRBDispoType) = 0 ");
|
|
sql.Append(" AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 ");
|
|
sql.Append(" AND LS.LotStatusOptionID <> 6 AND (LTRIM(RTRIM(Location)) <> 'QDB' AND LTRIM(RTRIM(Location)) <> 'EDB')) ");
|
|
sql.Append(" )");
|
|
sql.Append(" THEN 'MRB Disposition different from Lot Dispostion' ");
|
|
|
|
sql.Append("WHEN PATINDEX('%X%', DispoType.MRBDispoType) > 0 AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 THEN 'MRB Dispo missing' ");
|
|
sql.Append("ELSE 'NA' ");
|
|
sql.Append("END AS SubmitErrorMessage, ");
|
|
|
|
sql.Append(" ");
|
|
sql.Append("L.LotID, L.LotNumber, L.IssueID ,L.DieLotNumber ,L.Description ,L.NewPartNo ,L.WipPartNo ,L.DiePartNo ,L.ProductFamily, ");
|
|
sql.Append("L.Gen ,L.Channel, L.HexSize, L.Voltage, L.WaferCount, L.DieCount, L.Location, L.TotalCost, L.LotStatusOptionID,");
|
|
sql.Append("S.ReleaseCount, S.ScrapCount, L.QualityCode, LS.LotStatusOptionID , LS.LotStatusOption FROM Lot L ");
|
|
sql.Append("INNER JOIN LotStatusOption LS ON L.LotStatusOptionID = LS.LotStatusOptionID ");
|
|
sql.Append("LEFT JOIN ScrapLot S ON L.LotNumber = S.LotNo AND L.IssueID = S.IssueID ");
|
|
|
|
sql.Append("LEFT JOIN ");
|
|
sql.Append("(SELECT DISTINCT L.LotID, STUFF ");
|
|
// Code changed 12/11/2019 RJK
|
|
//sql.Append("((SELECT DISTINCT ',' + CAST(ML.MRBNumber AS varchar(512)) ");
|
|
sql.Append("((SELECT DISTINCT ',' + CAST(ML.MRBNumber AS varchar(512)) + '_' + CAST(ISNULL(ML.DispoType,'') AS varchar(512)) ");
|
|
sql.Append("FROM vMRBLot ML ");
|
|
//sql.Append("WHERE SUBSTRING(LTRIM(RTRIM(L.LotNumber)),1,7) = SUBSTRING(LTRIM(RTRIM(ML.LotNumber)),1,7) ");
|
|
sql.Append("WHERE LTRIM(RTRIM(L.LotNumber)) = LTRIM(RTRIM(ML.LotNumber)) ");
|
|
sql.Append("FOR XML PATH('')), 1, 1, '') AS IssueIDs ");
|
|
sql.Append("FROM Lot L) AS SQ ");
|
|
sql.Append("ON L.LotID = SQ.LotID ");
|
|
|
|
|
|
sql.Append("LEFT JOIN ");
|
|
sql.Append("(SELECT DISTINCT L.LotID, STUFF ");
|
|
sql.Append("((SELECT DISTINCT ',' + CAST(ML.MRBNumber AS varchar(512)) ");
|
|
sql.Append("FROM vMRBLot ML ");
|
|
sql.Append("WHERE LTRIM(RTRIM(L.LotNumber)) = LTRIM(RTRIM(ML.LotNumber)) ");
|
|
sql.Append("FOR XML PATH('')), 1, 1, '') AS IssueIDs ");
|
|
sql.Append("FROM Lot L) AS SQP ");
|
|
sql.Append("ON L.LotID = SQP.LotID ");
|
|
|
|
|
|
sql.Append("LEFT JOIN ");
|
|
sql.Append("(SELECT DISTINCT L.LotID, STUFF ");
|
|
sql.Append("((SELECT DISTINCT ',' + CAST(ISNULL(ML.DispoType, 'X') AS varchar(512)) ");
|
|
sql.Append("FROM vMRBLot ML ");
|
|
sql.Append("WHERE LTRIM(RTRIM(L.LotNumber)) = LTRIM(RTRIM(ML.LotNumber)) ");
|
|
sql.Append("FOR XML PATH('')), 1, 1, '') AS MRBDispoType ");
|
|
sql.Append("FROM Lot L) AS DispoType ");
|
|
sql.Append("ON L.LotID = DispoType.LotID ");
|
|
|
|
sql.Append("WHERE L.IssueID = " + issueID);
|
|
|
|
var data = this.db.Query<Lot, LotStatusOptionViewModel, Lot>
|
|
(sql.ToString(), (lot, lotstatusoption) =>
|
|
{
|
|
lot.LotStatusOption = lotstatusoption;
|
|
return lot;
|
|
},
|
|
splitOn: "LotStatusOptionID").ToList();
|
|
|
|
*/
|
|
#endregion
|
|
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", issueID, DbType.Int32);
|
|
var data = this.db.Query<Lot, LotStatusOptionViewModel, Lot>
|
|
("GetLotDispositionLots", (lot, lotstatusoption) =>
|
|
{
|
|
lot.LotStatusOption = lotstatusoption;
|
|
return lot;
|
|
},
|
|
param:parameters,
|
|
commandType: CommandType.StoredProcedure,
|
|
splitOn: "LotStatusOptionID").ToList();
|
|
|
|
return data;
|
|
|
|
|
|
}
|
|
|
|
|
|
public IEnumerable<Attachment> GetLotDispoAttachments(int issueID)
|
|
{
|
|
var attachments = this.db.Query<Attachment>("SELECT A.AttachmentID, A.IssueID, A.FileName, A.UserID, CONVERT(VARCHAR(10), A.UploadDate, 101) AS UploadDate, U.FirstName + ' ' + U.LastName AS FullName FROM Attachment A INNER JOIN Users U ON A.UserID = U.UserID WHERE IssueID = @IssueID ", new { IssueID = issueID }).ToList();
|
|
return attachments;
|
|
}
|
|
|
|
public void DeleteLotDispoAttachment(int attachmentID)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@AttachmentID", attachmentID);
|
|
this.db.Execute("DeleteLotDispositionAttachment", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
public void InsertLotDispositionAttachment(Attachment attach)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", attach.IssueID);
|
|
parameters.Add("@UserID", attach.UserID);
|
|
parameters.Add("@FileName", attach.FileName);
|
|
|
|
this.db.Execute("InsertLotDispositionAttachment", parameters, commandType: CommandType.StoredProcedure);
|
|
|
|
|
|
}
|
|
|
|
public IEnumerable<Lot> SearchLots(string searchText)
|
|
{
|
|
|
|
// string sql = "SELECT WP_LOT_NO AS LotNumber FROM SPNLot WHERE WP_LOT_NO LIKE '%" + searchText + "%' OR DieLotNumber LIKE '%" + searchText + "%'";
|
|
string sql = "SELECT WP_LOT_NO AS LotNumber FROM SPNLot WHERE WP_LOT_NO LIKE '%" + searchText + "%' ";
|
|
var lotList = this.db.Query<Lot>(sql).ToList();
|
|
return lotList;
|
|
|
|
|
|
}
|
|
|
|
|
|
public IEnumerable<Users> GetUserList()
|
|
{
|
|
StringBuilder sql = new StringBuilder();
|
|
sql.Append("SELECT FirstName + ' ' + LastName AS OriginatorName, U.UserID AS OriginatorID, FirstName ");
|
|
sql.Append("FROM Users U ");
|
|
sql.Append("ORDER BY FirstName");
|
|
|
|
return this.db.Query<Users>(sql.ToString()).ToList();
|
|
}
|
|
|
|
|
|
|
|
//public IEnumerable<ScrapResponsibilty> GetScrapIssueList()
|
|
//{
|
|
// StringBuilder sql = new StringBuilder();
|
|
// sql.Append("SELECT ScrapID, ScrapDescription ");
|
|
// sql.Append("FROM ScrapIssue ");
|
|
// sql.Append("ORDER BY ScrapDescription ");
|
|
|
|
// return this.db.Query<ScrapResponsibilty>(sql.ToString()).ToList();
|
|
//}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
//public List<ResponsibilityArea> GetResponsibilityAreaList()
|
|
//{
|
|
|
|
// var departments = this.db.Query<ResponsibilityArea>("GetLotDispositionResponsibilityAreas", null, commandType: CommandType.StoredProcedure).ToList();
|
|
// return departments;
|
|
|
|
|
|
//}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<Responsibility> GetResponsibilityList()
|
|
{
|
|
var departments = this.db.Query<Responsibility>("SELECT ResponsibilityID, ResponsibilityName FROM Responsibility ORDER BY ResponsibilityName ", null, commandType: CommandType.Text).ToList();
|
|
return departments;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="responsibilityID"></param>
|
|
/// <returns></returns>
|
|
public List<ResponsibilityIssue> GetResponsibilityIssueList(int responsibilityID)
|
|
{
|
|
var respIssue = this.db.Query<ResponsibilityIssue>("SELECT ResponsibilityIssueID, Issue FROM ResponsibilityIssue WHERE ResponsibilityID = @ResponsibilityID ORDER BY Issue ", new { @ResponsibilityID = responsibilityID }, commandType: CommandType.Text).ToList();
|
|
return respIssue;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="scrap"></param>
|
|
public void UpdateLotScrapReleaseStatus(ScrapLot scrap)
|
|
{
|
|
|
|
StringBuilder qryInsert = new StringBuilder();
|
|
qryInsert.Append("DELETE FROM ScrapLot WHERE LotNo = @LotNo AND IssueID = @IssueID");
|
|
qryInsert.Append(" INSERT INTO ScrapLot(LotNo,IssueID,ScrapCount,ReleaseCount, Lot1State,Lot2State,Lot3State,Lot4State,Lot5State,Lot6State,Lot7State,Lot8State,Lot9State,Lot10State, ");
|
|
qryInsert.Append(" Lot11State,Lot12State,Lot13State,Lot14State,Lot15State,Lot16State,Lot17State,Lot18State,Lot19State,Lot20State, ");
|
|
qryInsert.Append(" Lot21State,Lot22State,Lot23State,Lot24State,Lot25State,Lot26State,Lot27State,Lot28State,Lot29State,Lot30State, ");
|
|
qryInsert.Append(" Lot31State,Lot32State,Lot33State,Lot34State,Lot35State,Lot36State,Lot37State,Lot38State,Lot39State,Lot40State, ");
|
|
qryInsert.Append(" Lot41State,Lot42State,Lot43State,Lot44State,Lot45State,Lot46State,Lot47State,Lot48State,Lot49State,Lot50State) ");
|
|
qryInsert.Append(" VALUES(@LotNo,@IssueID,@ScrapCount,@ReleaseCount,@Lot1State,@Lot2State,@Lot3State,@Lot4State,@Lot5State,@Lot6State,@Lot7State,@Lot8State,@Lot9State,@Lot10State,");
|
|
qryInsert.Append(" @Lot11State,@Lot12State,@Lot13State,@Lot14State,@Lot15State,@Lot16State,@Lot17State,@Lot18State,@Lot19State,@Lot20State,");
|
|
qryInsert.Append(" @Lot21State,@Lot22State,@Lot23State,@Lot24State,@Lot25State,@Lot26State,@Lot27State,@Lot28State,@Lot29State,@Lot30State,");
|
|
qryInsert.Append(" @Lot31State,@Lot32State,@Lot33State,@Lot34State,@Lot35State,@Lot36State,@Lot37State,@Lot38State,@Lot39State,@Lot40State,");
|
|
qryInsert.Append(" @Lot41State,@Lot42State,@Lot43State,@Lot44State,@Lot45State,@Lot46State,@Lot47State,@Lot48State,@Lot49State,@Lot50State)");
|
|
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@LotNo", scrap.LotNo);
|
|
parameters.Add("@IssueID", scrap.IssueID);
|
|
parameters.Add("@ScrapCount", scrap.ScrapCount);
|
|
parameters.Add("@ReleaseCount", scrap.ReleaseCount);
|
|
parameters.Add("@Lot1State", scrap.Lot1State);
|
|
parameters.Add("@Lot2State", scrap.Lot2State);
|
|
parameters.Add("@Lot3State", scrap.Lot3State);
|
|
parameters.Add("@Lot4State", scrap.Lot4State);
|
|
parameters.Add("@Lot5State", scrap.Lot5State);
|
|
parameters.Add("@Lot6State", scrap.Lot6State);
|
|
parameters.Add("@Lot7State", scrap.Lot7State);
|
|
parameters.Add("@Lot8State", scrap.Lot8State);
|
|
parameters.Add("@Lot9State", scrap.Lot9State);
|
|
parameters.Add("@Lot10State", scrap.Lot10State);
|
|
parameters.Add("@Lot11State", scrap.Lot11State);
|
|
parameters.Add("@Lot12State", scrap.Lot12State);
|
|
parameters.Add("@Lot13State", scrap.Lot13State);
|
|
parameters.Add("@Lot14State", scrap.Lot14State);
|
|
parameters.Add("@Lot15State", scrap.Lot15State);
|
|
parameters.Add("@Lot16State", scrap.Lot16State);
|
|
parameters.Add("@Lot17State", scrap.Lot17State);
|
|
parameters.Add("@Lot18State", scrap.Lot18State);
|
|
parameters.Add("@Lot19State", scrap.Lot19State);
|
|
parameters.Add("@Lot20State", scrap.Lot20State);
|
|
parameters.Add("@Lot21State", scrap.Lot21State);
|
|
parameters.Add("@Lot22State", scrap.Lot22State);
|
|
parameters.Add("@Lot23State", scrap.Lot23State);
|
|
parameters.Add("@Lot24State", scrap.Lot24State);
|
|
parameters.Add("@Lot25State", scrap.Lot25State);
|
|
parameters.Add("@Lot26State", scrap.Lot26State);
|
|
parameters.Add("@Lot27State", scrap.Lot27State);
|
|
parameters.Add("@Lot28State", scrap.Lot28State);
|
|
parameters.Add("@Lot29State", scrap.Lot29State);
|
|
parameters.Add("@Lot30State", scrap.Lot30State);
|
|
parameters.Add("@Lot31State", scrap.Lot31State);
|
|
parameters.Add("@Lot32State", scrap.Lot32State);
|
|
parameters.Add("@Lot33State", scrap.Lot33State);
|
|
parameters.Add("@Lot34State", scrap.Lot34State);
|
|
parameters.Add("@Lot35State", scrap.Lot35State);
|
|
parameters.Add("@Lot36State", scrap.Lot36State);
|
|
parameters.Add("@Lot37State", scrap.Lot37State);
|
|
parameters.Add("@Lot38State", scrap.Lot38State);
|
|
parameters.Add("@Lot39State", scrap.Lot39State);
|
|
parameters.Add("@Lot40State", scrap.Lot40State);
|
|
parameters.Add("@Lot41State", scrap.Lot41State);
|
|
parameters.Add("@Lot42State", scrap.Lot42State);
|
|
parameters.Add("@Lot43State", scrap.Lot43State);
|
|
parameters.Add("@Lot44State", scrap.Lot44State);
|
|
parameters.Add("@Lot45State", scrap.Lot45State);
|
|
parameters.Add("@Lot46State", scrap.Lot46State);
|
|
parameters.Add("@Lot47State", scrap.Lot47State);
|
|
parameters.Add("@Lot48State", scrap.Lot48State);
|
|
parameters.Add("@Lot49State", scrap.Lot49State);
|
|
parameters.Add("@Lot50State", scrap.Lot50State);
|
|
|
|
|
|
this.db.Execute(qryInsert.ToString(), parameters, commandType: CommandType.Text);
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="scrap"></param>
|
|
public void UpdateLotStatus(ScrapLot lotStatus)
|
|
{
|
|
//if all the wafers in a lot is either "RELEASE" or "SCRAP" from the "SELECT WAFERS SCREEN" set the Lot Status Option accodingly for the particula lot
|
|
int tempLotStatus;
|
|
if ((lotStatus.ReleaseCount == lotStatus.WaferCount || lotStatus.ScrapCount == lotStatus.WaferCount) && (lotStatus.ReleaseCount > 0 || lotStatus.WaferCount > 0))
|
|
{
|
|
// set the LotStatus appropriately because the entire lot either is set to "RELEASE" or "SCRAP"'
|
|
tempLotStatus = lotStatus.ReleaseCount == lotStatus.WaferCount ? (int)GlobalVars.LotStatusOption.Release : (int)GlobalVars.LotStatusOption.Scrap;
|
|
|
|
// Close to QDB is count as "Release"
|
|
if ((lotStatus.CloseToQDBCount == lotStatus.WaferCount) && (lotStatus.CloseToQDBCount > 0 || lotStatus.WaferCount > 0))
|
|
{
|
|
tempLotStatus = (int)GlobalVars.LotStatusOption.CloseToQDB;
|
|
}
|
|
}
|
|
else if ((lotStatus.SplitOfHoldCount == lotStatus.WaferCount) && (lotStatus.SplitOfHoldCount > 0 || lotStatus.WaferCount > 0))
|
|
{
|
|
tempLotStatus = (int)GlobalVars.LotStatusOption.SplitOffHold;
|
|
}
|
|
|
|
|
|
else
|
|
{
|
|
tempLotStatus = (int)GlobalVars.LotStatusOption.Select_Wafers;
|
|
}
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@LotNo", lotStatus.LotNo);
|
|
parameters.Add("@IssueID", lotStatus.IssueID);
|
|
parameters.Add("@LotStatus", tempLotStatus);
|
|
this.db.Execute("UpdateLotStatus", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update the Status of all the lots for a given Lot disposition document
|
|
/// </summary>
|
|
/// <param name="scrap"></param>
|
|
public void UpdateLotStatusAll(ScrapLot scrap, int lotStatus)
|
|
{
|
|
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", scrap.IssueID);
|
|
parameters.Add("@LotStatus", lotStatus);
|
|
parameters.Add("@ScrapCount", 0);
|
|
parameters.Add("@Lot1State", scrap.Lot1State);
|
|
parameters.Add("@Lot2State", scrap.Lot2State);
|
|
parameters.Add("@Lot3State", scrap.Lot3State);
|
|
parameters.Add("@Lot4State", scrap.Lot4State);
|
|
parameters.Add("@Lot5State", scrap.Lot5State);
|
|
parameters.Add("@Lot6State", scrap.Lot6State);
|
|
parameters.Add("@Lot7State", scrap.Lot7State);
|
|
parameters.Add("@Lot8State", scrap.Lot8State);
|
|
parameters.Add("@Lot9State", scrap.Lot9State);
|
|
parameters.Add("@Lot10State", scrap.Lot10State);
|
|
parameters.Add("@Lot11State", scrap.Lot11State);
|
|
parameters.Add("@Lot12State", scrap.Lot12State);
|
|
parameters.Add("@Lot13State", scrap.Lot13State);
|
|
parameters.Add("@Lot14State", scrap.Lot14State);
|
|
parameters.Add("@Lot15State", scrap.Lot15State);
|
|
parameters.Add("@Lot16State", scrap.Lot16State);
|
|
parameters.Add("@Lot17State", scrap.Lot17State);
|
|
parameters.Add("@Lot18State", scrap.Lot18State);
|
|
parameters.Add("@Lot19State", scrap.Lot19State);
|
|
parameters.Add("@Lot20State", scrap.Lot20State);
|
|
parameters.Add("@Lot21State", scrap.Lot21State);
|
|
parameters.Add("@Lot22State", scrap.Lot22State);
|
|
parameters.Add("@Lot23State", scrap.Lot23State);
|
|
parameters.Add("@Lot24State", scrap.Lot24State);
|
|
parameters.Add("@Lot25State", scrap.Lot25State);
|
|
parameters.Add("@Lot26State", scrap.Lot26State);
|
|
parameters.Add("@Lot27State", scrap.Lot27State);
|
|
parameters.Add("@Lot28State", scrap.Lot28State);
|
|
parameters.Add("@Lot29State", scrap.Lot29State);
|
|
parameters.Add("@Lot30State", scrap.Lot30State);
|
|
parameters.Add("@Lot31State", scrap.Lot31State);
|
|
parameters.Add("@Lot32State", scrap.Lot32State);
|
|
parameters.Add("@Lot33State", scrap.Lot33State);
|
|
parameters.Add("@Lot34State", scrap.Lot34State);
|
|
parameters.Add("@Lot35State", scrap.Lot35State);
|
|
parameters.Add("@Lot36State", scrap.Lot36State);
|
|
parameters.Add("@Lot37State", scrap.Lot37State);
|
|
parameters.Add("@Lot38State", scrap.Lot38State);
|
|
parameters.Add("@Lot39State", scrap.Lot39State);
|
|
parameters.Add("@Lot40State", scrap.Lot40State);
|
|
parameters.Add("@Lot41State", scrap.Lot41State);
|
|
parameters.Add("@Lot42State", scrap.Lot42State);
|
|
parameters.Add("@Lot43State", scrap.Lot43State);
|
|
parameters.Add("@Lot44State", scrap.Lot44State);
|
|
parameters.Add("@Lot45State", scrap.Lot45State);
|
|
parameters.Add("@Lot46State", scrap.Lot46State);
|
|
parameters.Add("@Lot47State", scrap.Lot47State);
|
|
parameters.Add("@Lot48State", scrap.Lot48State);
|
|
parameters.Add("@Lot49State", scrap.Lot49State);
|
|
parameters.Add("@Lot50State", scrap.Lot50State);
|
|
|
|
|
|
this.db.Execute("UpdateScrapLotAll", parameters, commandType: CommandType.StoredProcedure);
|
|
|
|
}
|
|
|
|
|
|
public LotDispositionLotSummaryViewModel GetLotDispositionLotSummary(int issueID)
|
|
{
|
|
StringBuilder sql = new StringBuilder();
|
|
sql.Append("SELECT L.WaferCount AS 'TotalWaferCount', L.DieCount AS 'TotalDieCount', L.TotalCost AS 'TotalCost', S.ScrapCount AS 'ScrapWaferCount', S.ReleaseCount AS 'ReleaseWaferCount', L.LotStatusOptionID AS 'LotStatusOption' ");
|
|
sql.Append("FROM ScrapLot S INNER JOIN Lot L ON S.IssueID = L.IssueID AND S.LotNo = L.LotNumber ");
|
|
sql.Append("WHERE S.IssueID = @issueID" );
|
|
|
|
var LotDispositionLotList = this.db.Query<LotDispositionLotSummaryViewModel>(sql.ToString(), new { issueID = issueID }).ToList();
|
|
int lotCount = 0;
|
|
|
|
int totalWaferScrapCount = 0;
|
|
int totalDieScrapCount = 0;
|
|
double totalScrapCost = 0;
|
|
|
|
int totalWaferReleaseCount = 0;
|
|
int totalDieReleaseCount = 0;
|
|
double totalReleaseCost = 0;
|
|
|
|
int releaseWaferCount = 0;
|
|
double releaseCost = 0;
|
|
int releaseDieCount = 0;
|
|
|
|
int scrapWaferCount = 0;
|
|
double scrapCost = 0;
|
|
int scrapDieCount = 0;
|
|
|
|
foreach (LotDispositionLotSummaryViewModel ld in LotDispositionLotList)
|
|
{
|
|
releaseWaferCount = 0;
|
|
releaseCost = 0;
|
|
releaseDieCount = 0;
|
|
|
|
scrapWaferCount = 0;
|
|
scrapCost = 0;
|
|
scrapDieCount = 0;
|
|
|
|
|
|
// Wafer===================================================================
|
|
if (ld.ScrapWaferCount > 0 && ld.TotalWaferCount > 0 && ld.TotalCost > 0)
|
|
{
|
|
scrapWaferCount = ld.ScrapWaferCount;
|
|
double perWaferCost = ld.TotalCost / ld.TotalWaferCount;
|
|
scrapCost = scrapWaferCount * perWaferCost;
|
|
}
|
|
else if (ld.ScrapWaferCount == 0)
|
|
{
|
|
scrapWaferCount = ld.ScrapWaferCount;
|
|
scrapCost = 0;
|
|
}
|
|
|
|
|
|
if (ld.ReleaseWaferCount > 0 && ld.TotalWaferCount > 0 && ld.TotalCost > 0)
|
|
{
|
|
releaseWaferCount = ld.ReleaseWaferCount;
|
|
double perWaferCost = ld.TotalCost / ld.TotalWaferCount;
|
|
releaseCost = releaseWaferCount * perWaferCost;
|
|
}
|
|
else if (ld.ReleaseWaferCount == 0)
|
|
{
|
|
releaseWaferCount = ld.ReleaseWaferCount;
|
|
releaseCost = 0;
|
|
}
|
|
|
|
// Die ===================================================================
|
|
if (
|
|
(ld.LotStatusOption == (int)GlobalVars.LotStatusOption.Release
|
|
|| ld.LotStatusOption == (int)GlobalVars.LotStatusOption.M_Suffix
|
|
|| ld.LotStatusOption == (int)GlobalVars.LotStatusOption.CloseToQDB )
|
|
&& ld.TotalDieCount > 0)
|
|
{
|
|
releaseDieCount = ld.TotalDieCount;//
|
|
releaseCost = ld.TotalCost;
|
|
}
|
|
|
|
|
|
if (ld.LotStatusOption == (int)GlobalVars.LotStatusOption.Scrap && ld.TotalDieCount > 0)
|
|
{
|
|
scrapDieCount = ld.TotalDieCount ;//
|
|
scrapCost = ld.TotalCost;
|
|
}
|
|
|
|
|
|
// Summarize
|
|
lotCount++;
|
|
totalWaferScrapCount = totalWaferScrapCount + scrapWaferCount;
|
|
totalWaferReleaseCount = totalWaferReleaseCount + releaseWaferCount;
|
|
|
|
totalDieScrapCount = totalDieScrapCount + scrapDieCount;
|
|
totalDieReleaseCount = totalDieReleaseCount + releaseDieCount;
|
|
|
|
totalScrapCost = totalScrapCost + scrapCost;
|
|
totalReleaseCost = totalReleaseCost + releaseCost;
|
|
}
|
|
|
|
|
|
//}
|
|
|
|
|
|
return new LotDispositionLotSummaryViewModel()
|
|
{
|
|
LotCount = lotCount,
|
|
ReleaseCost = String.Format("{0:C}", totalReleaseCost),
|
|
//Math.Round(totalReleaseCost, 2).ToString(,
|
|
ReleaseWaferCount = totalWaferReleaseCount,
|
|
ReleaseDieCount = totalDieReleaseCount,
|
|
ScrapCost = String.Format("{0:C}", totalScrapCost),
|
|
//Math.Round(totalScrapCost, 2),
|
|
ScrapWaferCount = totalWaferScrapCount,
|
|
ScrapDieCount = totalDieScrapCount
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
public int SubmitDocument(int issueID, bool peRequired, bool mrbRequired, int userID)
|
|
{
|
|
string subRoles = wfDMO.GetSubRoleItems(issueID, (int)GlobalVars.DocumentType.LotDisposition);
|
|
|
|
// bubble the error
|
|
int appoverCount = 0;
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", issueID);
|
|
parameters.Add("@UserID", userID );
|
|
parameters.Add("@PERequired", peRequired);
|
|
parameters.Add("@MRBRequired", mrbRequired);
|
|
parameters.Add("@DocumentTypeID", 1); // Lot Dispostion
|
|
parameters.Add("@SubRoleCategoriesClause", subRoles);
|
|
parameters.Add("@AppoverCount", appoverCount, dbType: DbType.Int32, direction: ParameterDirection.Output);
|
|
|
|
this.db.Execute("SubmitForApproval_LotDisposition", parameters, commandType: CommandType.StoredProcedure);
|
|
|
|
appoverCount = parameters.Get<int>("@AppoverCount");
|
|
return appoverCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// NOT IN USE
|
|
/// </summary>
|
|
/// <param name="issueID"></param>
|
|
/// <param name="step"></param>
|
|
/// <returns></returns>
|
|
//public List<string> GetApproverEmailList(int issueID, byte step)
|
|
//{
|
|
// var parameters = new DynamicParameters();
|
|
// parameters.Add("@IssueID", issueID);
|
|
// parameters.Add("@Step", step);
|
|
// var emailList = this.db.Query<string>("GetApproverEmailList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
// return emailList;
|
|
|
|
//}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="issueID"></param>
|
|
/// <returns></returns>
|
|
public List<string> GetRejectionOrginatorEmailList(int issueID)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", issueID);
|
|
var emailList = this.db.Query<string>("GetRejectionOrginatorEmailList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
return emailList;
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="issueID"></param>
|
|
/// <param name="reasonForDisposition"></param>
|
|
public void UpdateReasonForDisposition(int issueID, string reasonForDisposition)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
|
|
parameters.Add("@IssueID", issueID);
|
|
parameters.Add("@ReasonForDisposition", reasonForDisposition);
|
|
this.db.Execute("UpdateReasonForDisposition", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
|
|
|
|
public void InsertComments(int issueID, string comments, int commentedBy)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
|
|
parameters.Add("@IssueID", issueID);
|
|
parameters.Add("@Comments", comments);
|
|
parameters.Add("@CommentedBy", commentedBy);
|
|
this.db.Execute("InsertComments", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="issueID"></param>
|
|
internal void DeleteLotDisposition(int issueID)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", issueID);
|
|
this.db.Execute("DeleteLotDisposition", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
|
|
internal IEnumerable<Comments> GetComments(int issueID)
|
|
{
|
|
IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
|
|
return db.Query<Comments>("GetComments", new { @IssueID = issueID}, commandType: CommandType.StoredProcedure).ToList();
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOT IN USE
|
|
//public List<ApproversListViewModel> GetApproversList(int issueID, byte step)
|
|
//{
|
|
// var parameters = new DynamicParameters();
|
|
// parameters.Add("@IssueID", issueID);
|
|
// parameters.Add("@Step", step);
|
|
// var approverList = this.db.Query<ApproversListViewModel>("GetApproversList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
// return approverList;
|
|
//}
|
|
|
|
//public List<ApproversListViewModel> GetPendingApproversList(int issueID, byte step)
|
|
//{
|
|
// var parameters = new DynamicParameters();
|
|
// parameters.Add("@IssueID", issueID);
|
|
// parameters.Add("@Step", step);
|
|
// var approverList = this.db.Query<ApproversListViewModel>("GetPendingApproversList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
|
// return approverList;
|
|
//}
|
|
|
|
|
|
/// <summary>
|
|
/// Not In USE
|
|
/// </summary>
|
|
/// <param name="issueID"></param>
|
|
/// <param name="currentStep"></param>
|
|
/// <returns></returns>
|
|
//public IEnumerable<LoginModel> GetApprovedApproversList(int issueID, int currentStep)
|
|
//{
|
|
|
|
// return this.db.Query<LoginModel>("GetApprovedApproversList", new { @IssueID = issueID, @Step = currentStep }, commandType: CommandType.StoredProcedure).ToList();
|
|
|
|
//}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="userID"></param>
|
|
/// <param name="workRequestID"></param>
|
|
public void ReleaseLockOnDocument(int userID, int issueID)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@IssueID", issueID);
|
|
parameters.Add("@UserID", userID);
|
|
this.db.Execute("ReleaseLockOnLotDispoDoc", parameters, commandType: CommandType.StoredProcedure);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="attachmentID"></param>
|
|
/// <returns></returns>
|
|
public string GetFileName(string attachmentID)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@AttachmentID", attachmentID);
|
|
var fileName = this.db.Query<string>("GetFileName", parameters, commandType: CommandType.StoredProcedure).Single();
|
|
return fileName;
|
|
}
|
|
}
|
|
}
|