private bool UpdateDatabasebyChange(Common.Model.MouldingViDefectTracking_Model objViDef) { bool result = false; try { string txt = this.Name.Replace("ubct123", "-").Replace("ubct1680", " ");; string[] _partNumber = txt.Split('_'); DateTime dTime = DateTime.Now; List <System.Data.SqlClient.SqlCommand> lSqlCmd = new List <System.Data.SqlClient.SqlCommand>(); //database update Common.BLL.MouldingViDefectTracking_BLL bllViDef = new Common.BLL.MouldingViDefectTracking_BLL(); objViDef.lastUpdatedTime = dTime; objViDef.stopTime = dTime; lSqlCmd.Add(bllViDef.UpdateCommandbypartNubmer(objViDef, _partNumber[2].ToString())); // by trackingID + DefectCodeID objViDef = bllViDef.GetModelList_ByDayShiftPartMachineForDefectTracking(objViDef.day, objViDef.shift, _partNumber[2].ToString(), objViDef.machineID, objViDef.defectCode, objViDef); Common.BLL.MouldingViDefectHistory_BLL bllViDefHis = new Common.BLL.MouldingViDefectHistory_BLL(); lSqlCmd.Add(bllViDefHis.AddCommand(bllViDefHis.CopyObj(objViDef))); int TotalRejQty = bllViDef.getTotalRejQty_By_TrackingID(objViDef.trackingID) + _Count; // must add 1 bucause the defect record is not updated Common.BLL.MouldingViTracking_BLL bllViTrk = new Common.BLL.MouldingViTracking_BLL(); Common.Model.MouldingViTracking_Model objViTck = new Common.Model.MouldingViTracking_Model(); objViTck = bllViTrk.GetModel_ByTrackingID(objViDef.trackingID); if (objViTck == null) { return(false); } objViTck.lastUpdatedTime = dTime; objViTck.rejectQty = TotalRejQty; objViTck.acceptQty = objViTck.acceptQty - _Count; lSqlCmd.Add(bllViTrk.UpdateCommandbyTrackingID(objViTck)); //note: update data base on ID Common.BLL.MouldingViHistory_BLL bllViHis = new Common.BLL.MouldingViHistory_BLL(); lSqlCmd.Add(bllViHis.AddCommand(bllViHis.CopyObj(objViTck))); result = DBHelp.SqlDB.SetData_Rollback(lSqlCmd); _Count = 0; StaticRes.Global._isUsingObjCurVi = false; } catch (Exception ex) { StaticRes.Global._isUsingObjCurVi = false; throw; } return(result); }
internal DataSet GetModel_ByTrackingID(string trackingID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select trackingID,machineID,UsageQTY01,UsageQTY02,UsageQTY03,UsageQTY04,UsageQTY05,UsageQTY06,UsageQTY07,UsageQTY08,UsageQTY09,UsageQTY10,UsageQTY11,UsageQTY12,RejectQTY01,RejectQTY02,RejectQTY03,RejectQTY04,RejectQTY05,RejectQTY06,RejectQTY07,RejectQTY08,RejectQTY09,RejectQTY10,RejectQTY11,RejectQTY12,SerialNo01,SerialNo02,SerialNo03,SerialNo04,SerialNo05,SerialNo06,SerialNo07,SerialNo08,SerialNo09,SerialNo10,SerialNo11,SerialNo12,SerialNoEnd,SerialNo "); strSql.Append(" FROM MouldingLabel "); strSql.Append(" where trackingID =@trackingID"); SqlParameter[] parameters = { new SqlParameter("@trackingID", SqlDbType.VarChar, 50) }; parameters[0].Value = trackingID; DBHelp.Reports.LogFile.DebugLog("AUTOCODE", "NameSpace:Common.SQLServerDAL", "Class:MouldingLabel_DAL", "Function: public Common.Model.MouldingLabel_Model GetModel(string trackingID,string machineID,decimal UsageQTY01,decimal UsageQTY02,decimal UsageQTY03,decimal UsageQTY04,decimal UsageQTY05,decimal UsageQTY06,decimal UsageQTY07,decimal UsageQTY08,decimal UsageQTY09,decimal UsageQTY10,decimal UsageQTY11,decimal UsageQTY12,decimal RejectQTY01,decimal RejectQTY02,decimal RejectQTY03,decimal RejectQTY04,decimal RejectQTY05,decimal RejectQTY06,decimal RejectQTY07,decimal RejectQTY08,decimal RejectQTY09,decimal RejectQTY10,decimal RejectQTY11,decimal RejectQTY12,decimal SerialNo01,decimal SerialNo02,decimal SerialNo03,decimal SerialNo04,decimal SerialNo05,decimal SerialNo06,decimal SerialNo07,decimal SerialNo08,decimal SerialNo09,decimal SerialNo10,decimal SerialNo11,decimal SerialNo12,decimal SerialNoEnd,string SerialNo)"+ "TableName:MouldingLabel", ""); Common.Model.MouldingViTracking_Model model = new Common.Model.MouldingViTracking_Model(); DataSet ds = DBHelp.SqlDB.Query(strSql.ToString(), parameters); return(ds); }