///// <summary> ///// 根据钢网编号,修改仓库和库位 ///// </summary> ///// <param name="trsn"></param> ///// <param name="storehouseid"></param> ///// <param name="locid"></param> ///// <returns></returns> //public void UpdateByTrsn(string trsn, string storehouseid, string locid) //{ // //MySqlCommand cmd = new MySqlCommand(); // //cmd.CommandText = "update SFCR.T_PART_STOREHOUSE_HAD set storehouseId=@storehouseid,locId=@locid where trsn=@trsn "; // //cmd.Parameters.Add("trsn", MySqlDbType.VarChar, 20).Value = trsn; // //cmd.Parameters.Add("storehouseid", MySqlDbType.VarChar, 20).Value = storehouseid; // //cmd.Parameters.Add("locid", MySqlDbType.VarChar, 20).Value = locid; // //return BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd); // IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); // IDictionary<string, object> mst = new Dictionary<string, object>(); // mst.Add("STOREHOUSEID", storehouseid); // mst.Add("LOCID", locid); // mst.Add("TRSN", trsn); // dp.UpdateData("SFCR.T_PART_STOREHOUSE_HAD", new string[] { "TRSN" }, mst); //} ///// <summary> ///// 记录钢网使用次数 ///// </summary> ///// <param name="trsn"></param> ///// <param name="total"></param> //public void UpdateGangWangUseCount(string trsn, int total) //{ // MySqlCommand cmd = new MySqlCommand(); // cmd.CommandText = "UPDATE SFCR.T_GANGWANG Set usernum=@total+usernum where trsn=@trsn"; // cmd.Parameters.Add("total", MySqlDbType.Int32).Value = total; // cmd.Parameters.Add("trsn", MySqlDbType.VarChar, 20).Value = trsn; // BLL.BllMsSqllib.Instance.ExecteNonQuery(cmd); //} ///// <summary> ///// 获取钢网要刷的板子总数 ///// </summary> ///// <param name="kpnumber"></param> ///// <returns></returns> //public System.Data.DataSet GetGangwangTotal(string kpnumber) //{ // MySqlCommand cmd = new MySqlCommand(); // if (!string.IsNullOrEmpty(kpnumber)) // { // cmd.CommandText = "SELECT D.TRSN,C.KPNUMBER,D.STOREHOUSEID,D.LOCID,D.REMARK,SUM(C.QTY) AS TOTAL " + // "FROM (SELECT A.WOID, A.KPNUMBER, B.QTY FROM SFCR.T_SMT_KP_NORMAL_LOG A, SFCR.T_WO_INFO B " + // "WHERE A.WOID = B.WOID AND A.KPNUMBER = @sPN GROUP BY A.WOID, A.KPNUMBER, B.QTY) C " + // "INNER JOIN SFCR.T_PART_STOREHOUSE_HAD D ON C.KPNUMBER = D.KPNUMBER " + // "GROUP BY C.KPNUMBER, D.TRSN, D.STOREHOUSEID, D.LOCID, D.REMARK "; // cmd.Parameters.Add("sPN", MySqlDbType.VarChar, 30).Value = kpnumber; // } // else // { // cmd.CommandText = "SELECT D.TRSN,C.KPNUMBER,D.STOREHOUSEID,D.LOCID,D.REMARK,SUM(C.QTY) AS TOTAL FROM (SELECT A.WOID, A.KPNUMBER, B.QTY " + // "FROM SFCR.T_SMT_KP_NORMAL_LOG A, SFCR.T_WO_INFO B WHERE A.WOID = B.WOID AND A.KPNUMBER IN (SELECT KPNUMBER " + // "FROM SFCR.T_PART_STOREHOUSE_HAD WHERE TRSN LIKE '999999%') GROUP BY A.WOID, A.KPNUMBER, B.QTY) C " + // "INNER JOIN SFCR.T_PART_STOREHOUSE_HAD D ON C.KPNUMBER = D.KPNUMBER " + // "GROUP BY C.KPNUMBER, D.TRSN, D.STOREHOUSEID, D.LOCID, D.REMARK "; // } // return BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd); //} ///// <summary> ///// 获取在仓库的钢网 ///// </summary> ///// <returns></returns> //public System.Data.DataSet GetGangInfoInWare() //{ // MySqlCommand cmd = new MySqlCommand(); // cmd.CommandText = "select trsn,vendercode,kpnumber,storehouseId,locId,case sstatus when 0 then '仓库' when 1 then '线边仓' when 2 then '生产线' when 3 then '已使用' when 6 then '退回仓库'when 7 then '维修' when 8 then '外借' when 9 then '报废'else '未定义' end as sstatus,recdate,datecode,lotId,remark,userId from SFCR.T_PART_STOREHOUSE_HAD where trsn like '999999%' and sstatus in(0,6,9)"; // return BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd); //} //public string GetSeqTrSnInfo() // { // string C_SEQ = string.Empty; // string PRGNAME = "SEQ_PARTID"; // MySqlCommand cmd = new MySqlCommand(); // cmd.CommandText = "select current_value from sfcb.sequence where name=@PRGNAME"; // cmd.Parameters.Add("PRGNAME", MySqlDbType.VarChar).Value = PRGNAME; // DataTable dtSEQ = BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd).Tables[0]; // C_SEQ = dtSEQ.Rows[0][0].ToString().PadLeft(7, '0'); // cmd = new MySqlCommand(); // cmd.CommandText = "update sfcb.sequence set current_value=current_value+increment where name=@PRGNAME"; // cmd.Parameters.Add("PRGNAME", MySqlDbType.VarChar).Value = PRGNAME; // BLL.BllMsSqllib.Instance.ExecteNonQuery(cmd); // return System.DateTime.Now.ToString("yyyyMMdd")+C_SEQ; // //MySqlCommand cmd = new MySqlCommand(); // //cmd.CommandText = "SELECT TO_CHAR(SYSDATE(),'YYMMDD')||LPAD(TO_CHAR(SEQ_PARTID.NEXTVAL),7,'0') FROM DUAL"; // //return BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd).Tables[0].Rows[0][0].ToString(); // } //public void InsertTrSn(Entity.tPartStorehousehad TrSnInfo, out string err) //{ // err = ""; // BLL.BllMsSqllib.Instance.SP_InsertStorehousehadRecount(TrSnInfo, out err); //} //#region 发料表 ///// <summary> ///// 查询库存最早一天的物料 ///// </summary> ///// <returns></returns> //public System.Data.DataSet QueryKpnumberMoreThanDays(string KpNumber) //{ // MySqlCommand cmd = new MySqlCommand(); // cmd.CommandText = "select * from SFCR.T_PART_STOREHOUSE_HAD where kpnumber=@kpnumber and sstatus='0' " + // " and recdate<(select min(recdate) from SFCR.T_PART_STOREHOUSE_HAD where kpnumber=@kpnumber and sstatus='0')+1 and LIMIT 1001"; // cmd.Parameters.Add("kpnumber", MySqlDbType.VarChar, 30).Value = KpNumber; // return BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd); //} ///// <summary> ///// 由料号查询属于哪个工单 ///// </summary> ///// <param name="kpnumber"></param> ///// <returns></returns> //public System.Data.DataSet QueryWoid(string woid) //{ // MySqlCommand cmd = new MySqlCommand(); // cmd.CommandText = "select woId from SFCR.T_WO_BOM_INFO where woId=@woid"; // cmd.Parameters.Add("woid", MySqlDbType.VarChar, 30).Value = woid; // return BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd); //} //public System.Data.DataSet QueryWoidByKpnumber(string kpnumber) //{ // MySqlCommand cmd = new MySqlCommand(); // cmd.CommandText = "select WoId,qty from SFCR.T_WO_BOM_INFO where kpnumber=@kpnumber"; // cmd.Parameters.Add("kpnumber", MySqlDbType.VarChar, 30).Value = kpnumber; // return BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd); //} ///// <summary> ///// 由工单号获取所有料号 ///// </summary> ///// <param name="woid"></param> ///// <returns></returns> //public System.Data.DataSet GetKpnumberByWoid(string woid,string process) //{ // MySqlCommand cmd = new MySqlCommand(); // if(process=="SMD") // cmd.CommandText = " select kpnumber,qty,process from SFCR.T_WO_BOM_INFO where woId=@woid and (process=@process or kpdesc like 'PCB%')"; // else // cmd.CommandText = " select kpnumber,qty,process from SFCR.T_WO_BOM_INFO where woId=@woid and process=@process"; // cmd.Parameters.Add("woid", MySqlDbType.VarChar, 30).Value = woid; // cmd.Parameters.Add("process", MySqlDbType.VarChar, 30).Value = process; // return BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd); //} //#endregion ///// <summary> ///// 原料出入库查询 ///// </summary> ///// <param name="Flag"></param> ///// <param name="QryInOut"></param> ///// <returns></returns> //public System.Data.DataSet QueryMaterialInputOutQTY(string Flag, Entity.tPartStorehousehadRecount QryInOut) //{ // string sSQL = ""; // string sSQL2 = ""; // string sSQL3 = ""; // sSQL = "select "; // MySqlCommand cmd = new MySqlCommand(); // Dictionary<string, string> nameAndVal = new Dictionary<string, string>(); // if (QryInOut.showworkdate) // { // sSQL = sSQL + " WorkDate as 工作日期, "; // sSQL3 = sSQL3 + " WorkDate,"; // } // if (QryInOut.showpn) // { // sSQL = sSQL + " kpnumber as 料号, "; // sSQL3 = sSQL3 + " kpnumber,"; // } // if (QryInOut.showvc) // { // sSQL = sSQL + " VenderCode as 厂商代码, "; // sSQL3 = sSQL3 + " VenderCode,"; // } // if (QryInOut.showdc) // { // sSQL = sSQL + " DateCode as 生产周期, "; // sSQL3 = sSQL3 + " DateCode,"; // } // if (QryInOut.showlc) // { // sSQL = sSQL + " LotId as 生产批次, "; // sSQL3 = sSQL3 + " LotId,"; // } // if (Flag == "0") // { // sSQL = sSQL + string.Format(" sum(INQTY) as 入库数量,sum(OUTQTY) as 出库数量 from SFCR.T_PART_STOREHOUSE_HAD_RECOUNT where kpnumber=@kpnumber "); // nameAndVal.Add("kpnumber", QryInOut.kpnumber);//2012-11-18号加入 // if (!string.IsNullOrEmpty(QryInOut.vendercode)) // { // sSQL = sSQL + string.Format(" and VenderCode=@VenderCode "); // nameAndVal.Add("VenderCode", QryInOut.vendercode);//2012-11-18号加入 // } // if (!string.IsNullOrEmpty(QryInOut.datecode)) // { // sSQL = sSQL + string.Format(" and DateCode=@DateCode "); // nameAndVal.Add("DateCode", QryInOut.datecode);//2012-11-18号加入 // } // if (!string.IsNullOrEmpty(QryInOut.lotid)) // { // sSQL = sSQL + string.Format(" and LotId=@LotId "); // nameAndVal.Add("LotId", QryInOut.lotid);//2012-11-18号加入 // } // sSQL = sSQL + " group by " + sSQL3.Substring(0, sSQL3.Length - 1); // cmd.CommandText = sSQL; // cmd.Parameters.Clear(); // foreach (string str in nameAndVal.Keys) // { // cmd.Parameters.Add("@" + str, MySqlDbType.VarChar, 50).Value = nameAndVal[str]; // } // } // if (Flag == "1") // { // sSQL2 = ""; // sSQL = sSQL + " sum(INQTY) as 入库数量,sum(OUTQTY) as 出库数量 from SFCR.T_PART_STOREHOUSE_HAD_RECOUNT where "; // if (!string.IsNullOrEmpty(QryInOut.kpnumber)) // { // sSQL2 = sSQL2 + string.Format(" and kpnumber=@kpnumber "); // nameAndVal.Add("kpnumber", QryInOut.kpnumber);//2012-11-18号加入 // } // if (!string.IsNullOrEmpty(QryInOut.vendercode)) // { // sSQL2 = sSQL2 + string.Format(" and VenderCode=@VenderCode "); // nameAndVal.Add("VenderCode", QryInOut.vendercode);//2012-11-18号加入 // } // if (!string.IsNullOrEmpty(QryInOut.datecode)) // { // sSQL2 = sSQL2 + string.Format(" and DateCode=@DateCode "); // nameAndVal.Add("DateCode", QryInOut.datecode);//2012-11-18号加入 // } // if (!string.IsNullOrEmpty(QryInOut.lotid)) // { // sSQL2 = sSQL2 + string.Format(" and LotId=@LotId "); // nameAndVal.Add("LotId", QryInOut.lotid);//2012-11-18号加入 // } // if (QryInOut.StartTime != "ALL" && QryInOut.EndTime != "ALL") // { // sSQL2 = sSQL2 + string.Format(" and workdate+right('00' + convert(varchar,worksection),2)>=@workdateA and workdate+right('00' + convert(varchar,worksection),2)<@workdateB ", // QryInOut.StartDate + QryInOut.StartTime.Substring(0, 2), // QryInOut.EndDate + QryInOut.EndTime.Substring(0, 2)); // nameAndVal.Add("workdateA", QryInOut.StartDate + QryInOut.StartTime.Substring(0, 2));//2012-11-18号加入 // nameAndVal.Add("workdateB", QryInOut.EndDate + QryInOut.EndTime.Substring(0, 2));//2012-11-18号加入 // } // else // { // sSQL2 = sSQL2 + string.Format(" and WorkDate>=@workdateA and WorkDate<=@workdateB ", QryInOut.StartDate, QryInOut.EndDate); // nameAndVal.Add("workdateA", QryInOut.StartDate);//2012-11-18号加入 // nameAndVal.Add("workdateB", QryInOut.EndDate);//2012-11-18号加入 // } // if (QryInOut.sclass != "ALL") // { // sSQL2 = sSQL2 + string.Format(" and class=@class ", QryInOut.sclass); // nameAndVal.Add("class", QryInOut.sclass);//2012-11-18号加入 // } // sSQL = sSQL + sSQL2.Substring(5, sSQL2.Length - 5) + " group by " + sSQL3.Substring(0, sSQL3.Length - 1); // cmd.CommandText = sSQL; // cmd.Parameters.Clear(); // foreach (string str in nameAndVal.Keys) // { // cmd.Parameters.Add("@" + str, MySqlDbType.VarChar, 50).Value = nameAndVal[str]; // } // } // return BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd); //} ///// <summary> ///// 查询库存 ///// </summary> ///// <param name="QMS"></param> ///// <returns></returns> //public System.Data.DataSet QueryMaterialStocks(Entity.tPartStorehousehad QMS) //{ // string sSQL = ""; // string sSQL2 = ""; // sSQL = "select "; // sSQL2 = " group by "; // MySqlCommand cmd = new MySqlCommand(); // Dictionary<string, string> nameAndVal = new Dictionary<string, string>(); // if (QMS.ShowPN) // { // sSQL = sSQL + " kpnumber as 料号,"; // sSQL2 = sSQL2 + " kpnumber,"; // } // if (QMS.ShowVC) // { // sSQL = sSQL + " vendercode as 厂商代码,"; // sSQL2 = sSQL2 + " vendercode,"; // } // if (QMS.ShowDC) // { // sSQL = sSQL + " datecode as 生产周期,"; // sSQL2 = sSQL2 + " datecode,"; // } // if (QMS.ShowLC) // { // sSQL = sSQL + " lotid as 生产批次,"; // sSQL2 = sSQL2 + " lotid,"; // } // if (QMS.ShowLoc) // { // sSQL = sSQL + " locid as 库位,"; // sSQL2 = sSQL2 + " locid,"; // } // sSQL = sSQL.Substring(0, sSQL.Length - 1); // sSQL2 = sSQL2.Substring(0, sSQL2.Length - 1); // sSQL = sSQL + string.Format(",sum(qty) as 库存数量 from SFCR.T_PART_STOREHOUSE_HAD where kpnumber=@kpnumber ", QMS.KpNumber); // nameAndVal.Add("kpnumber", QMS.KpNumber);//2012-11-18号加入 // if (!string.IsNullOrEmpty(QMS.VenderCode)) // { // sSQL = sSQL + string.Format(" and vendercode=@vendercode ", QMS.VenderCode); // nameAndVal.Add("vendercode", QMS.VenderCode);//2012-11-18号加入 // } // if (!string.IsNullOrEmpty(QMS.DateCode)) // { // sSQL = sSQL + string.Format(" and datecode=@datecode ", QMS.DateCode); // nameAndVal.Add("datecode", QMS.DateCode);//2012-11-18号加入 // } // if (!string.IsNullOrEmpty(QMS.LotId)) // { // sSQL = sSQL + string.Format(" and lotid=@lotid ", QMS.LotId); // nameAndVal.Add("lotid", QMS.LotId);//2012-11-18号加入 // } // sSQL = sSQL + " and (sstatus='0' or sstatus='6' ) " + sSQL2; // cmd.CommandText = sSQL; // cmd.Parameters.Clear(); // foreach (string str in nameAndVal.Keys) // { // cmd.Parameters.Add( str, MySqlDbType.VarChar, 30).Value = nameAndVal[str]; // } // return BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd); //} //public System.Data.DataSet QueryTrsnDetail(string trsn) //查询唯一条码状态 //{ // MySqlCommand cmd = new MySqlCommand(); // cmd.CommandText = "select trsn ,userid , case when sstatus=0 then '仓库' " + // " when sstatus=1 then '线边仓' when sstatus=2 then '生产线' " + // " when sstatus=3 then '已使用' when sstatus=4 then '分盘' " + // " when sstatus=5 then '生产线待退料' when sstatus=6 then '线边仓退回仓库' else '未定义' end " + // " as Location,recdate from SFCR.T_PART_STOREHOUSE_DTA where trsn=@trsn "; // cmd.Parameters.Add("trsn", MySqlDbType.VarChar, 30).Value = trsn; // return BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd); //} //#region 仓储原料报表 ///// <summary> ///// 获取料号的库存 ///// </summary> ///// <returns></returns> //public System.Data.DataSet GetAllMaterialStocks() //{ // MySqlCommand cmd = new MySqlCommand(); // cmd.CommandText = "select KpNumber,sum(INQTY) as INQTY,sum(OUTQTY) as OUTQTY,sum(INQTY)-sum(OUTQTY) as 库存 from SFCR.T_PART_STOREHOUSE_HAD_RECOUNT GROUP By KpNumber"; // return BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd); //} ///// <summary> ///// 获取料号的所有出入库记录 ///// </summary> ///// <param name="kpnumber"></param> ///// <returns></returns> //public System.Data.DataSet GetMaterialInfoByKpnumber(string kpnumber) //{ // MySqlCommand cmd = new MySqlCommand(); // cmd.CommandText = "select b.kpnumber,case a.sstatus when 0 then '仓库' when 1 then '线边仓'when 2 then '生产线' when 3 then '已使用' when 4 then '分盘' when 5 then '生产线待退料' when 6 then '线边仓退回仓库' else '未定义'end as sstatus,b.qty,a.recdate from SFCR.T_PART_STOREHOUSE_DTA a,SFCR.T_PART_STOREHOUSE_HAD b where a.trsn = b.trsn and b.kpnumber=@kpnumber"; // cmd.Parameters.Add("kpnumber", MySqlDbType.VarChar, 20).Value = kpnumber; // return BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd); //} //#endregion*/ //public System.Data.DataSet GetGangInfoByVC(string vendercode) //{ // MySqlCommand cmd = new MySqlCommand(); // cmd.CommandText = "select trsn,vendercode,kpnumber,storehouseId,locId,case sstatus when 0 then '仓库' when 1 then '线边仓' when 2 then '生产线' when 3 then '已使用' when 6 then '退回仓库'when 7 then '维修' when 8 then '外借' when 9 then '报废' end as sstatus,recdate,datecode,lotId,remark,userId from SFCR.T_PART_STOREHOUSE_HAD where vendercode=@vendercode"; // cmd.Parameters.Add("vendercode", MySqlDbType.VarChar, 20).Value = vendercode; // return BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd); //} //public System.Data.DataSet GetGangInfoByKpnumber(string kpnumber) //{ // MySqlCommand cmd = new MySqlCommand(); // cmd.CommandText = "select trsn,vendercode,kpnumber,storehouseId,locId,case sstatus when 0 then '仓库' when 1 then '线边仓' when 2 then '生产线' when 3 then '已使用' when 6 then '退回仓库'when 7 then '维修' when 8 then '外借' when 9 then '报废' end as sstatus,recdate,datecode,lotId,remark,userId from SFCR.T_PART_STOREHOUSE_HAD where kpnumber=@kpnumber"; // cmd.Parameters.Add("kpnumber", MySqlDbType.VarChar, 20).Value = kpnumber; // return BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd); //} /// <summary> /// 删除一条钢网信息 /// </summary> /// <param name="trsn"></param> /// <returns></returns> public string DeleteGangInfoByTrsn(string trsn) { //MySqlCommand cmd = new MySqlCommand(); //cmd.CommandText = "delete from SFCR.T_PART_STOREHOUSE_DTA where trsn=@trsn ;" + // "delete from SFCR.T_PART_STOREHOUSE_HAD where trsn=@trsn"; //cmd.Parameters.Add("trsn", MySqlDbType.VarChar, 30).Value = trsn; //BLL.BllMsSqllib.Instance.ExecuteDataSet(cmd); DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); try { IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); IDictionary <string, object> mst = new Dictionary <string, object>(); mst.Add("TRSN", trsn); dp.DeleteData(tx, "SFCR.T_PART_STOREHOUSE_DTA", mst); mst = new Dictionary <string, object>(); mst.Add("TRSN", trsn); dp.DeleteData(tx, "SFCR.T_PART_STOREHOUSE_HAD", mst); tx.Commit(); return("OK"); } catch (Exception ex) { tx.Rollback(); return(ex.Message); } }
public string Rework_SN(IDictionary <string, object> mst, List <string> LsKeyParts) { DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); string Colnum = "ESN,WOID,PARTNUMBER,PRODUCTNAME,VERSIONCODE,TYPE,LOCSTATION,STATIONNAME,WIPSTATION,NEXTSTATION,USERID,RECDATE," + "ERRFLAG,SCRAPFLAG,SN,MAC,IMEI,CARTONNUMBER,TRAYNO,PALLETNUMBER,MCARTONNUMBER,MPALLETNUMBER,LINE,SECTIONNAME,ROUTGROUPID," + "STORENUMBER,WEIGHTQTY,QA_NO,QA_RESULT,TRACK_NO,ATE_STATION_NO,IN_LINE_TIME,BOMNUMBER,REWORKNO"; int count = 0; try { IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("ESN", mst["ESN"]); DataTable dt_wip_tracking = dp.GetData("SFCR.T_WIP_TRACKING_ONLINE", Colnum, dic, out count).Tables[0]; if (count > 0) { dp.AddListData(tx, "SFCR.T_WIP_UNDO", DataTableToDictionary(dt_wip_tracking)); } if (LsKeyParts.Count > 0) { string colnumKeyPart = "esn,woId,sntype,snval,station,kpno,recdate".ToUpper(); DataTable dt_KeyParts = dp.GetData("SFCR.T_WIP_KEYPART_ONLINE", colnumKeyPart, dic, out count).Tables[0]; DataTable dt_Backup_KeyParts = new DataTable(); foreach (string str in colnumKeyPart.Split(',')) { dt_Backup_KeyParts.Columns.Add(str, typeof(string)); } if (dt_KeyParts.Rows.Count > 0) { foreach (DataRow dr in dt_KeyParts.Rows) { if (LsKeyParts.Contains(dr["SNTYPE"].ToString())) { dt_Backup_KeyParts.Rows.Add(dr["ESN"].ToString(), dr["WOID"].ToString(), dr["SNTYPE"].ToString(), dr["SNVAL"].ToString(), dr["STATION"].ToString(), dr["KPNO"].ToString(), dr["RECDATE"].ToString()); } } } if (dt_Backup_KeyParts.Rows.Count > 0) { dp.AddListData(tx, "SFCR.T_WIP_KEYPART_UNDO", DataTableToDictionary(dt_Backup_KeyParts)); dp.DeleteListData(tx, "SFCR.T_WIP_KEYPART_ONLINE", DataTableToDictionary(dt_Backup_KeyParts)); } } dp.UpdateData(tx, "SFCR.T_WIP_TRACKING_ONLINE", new string[] { "ESN" }, mst); tx.Commit(); return("OK"); } catch (Exception ex) { tx.Rollback(); return(ex.Message); } finally { conn.Close(); conn.Dispose(); } }
public string Delete_Route_Info(string routgroupId) { DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); try { IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); IDictionary <string, object> mst = new Dictionary <string, object>(); mst.Add("ROUTGROUPID", routgroupId); dp.DeleteData(tx, "SFCB.B_ROUTE_INFO", mst); dp.DeleteData(tx, "SFCB.B_ROUTE_ATT", mst); tx.Commit(); return("OK"); } catch (Exception ex) { tx.Rollback(); return(ex.Message); } finally { conn.Close(); conn.Dispose(); } }
/// <summary> /// 增加用户权限 /// </summary> /// <param name="ArrUserPopList"></param> public string AddUserJurisdiction(string LsDicstring) { //StringBuilder sql = new StringBuilder(); DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); try { IList <IDictionary <string, object> > LsDic = MapListConverter.JsonToListDictionary(LsDicstring); string table = "SFCB.B_USER_POPLIST"; IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); IDictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("USERID", LsDic[0]["USERID"]); dp.DeleteData(tx, table, dic); dp.AddListData(tx, table, LsDic); tx.Commit(); return(null); } catch (Exception ex) { tx.Rollback(); return(ex.Message); } finally { conn.Close(); conn.Dispose(); } }
/// <summary> /// 添加用户ATE权限 /// </summary> /// <param name="lsAteEmp"></param> /// <returns></returns> public string AddUserAteEmp(string lsAteEmp) { DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); try { IList <IDictionary <string, object> > LsDic = MapListConverter.JsonToListDictionary(lsAteEmp); string table = "sfcb.b_Ate_Emp".ToUpper(); IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); IDictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("USERID", LsDic[0]["USERID"]); dp.DeleteData(tx, table, dic); dp.AddListData(tx, table, LsDic); tx.Commit(); return("OK"); } catch (Exception ex) { tx.Rollback(); return(ex.Message); } finally { conn.Close(); conn.Dispose(); } }
public string Clear_User_Info(string UserId) { DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); try { IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); IDictionary <string, object> mst = new Dictionary <string, object>(); mst.Add("USERID", UserId); mst.Add("PWD", ""); mst.Add("USERSTATUS", "0"); dp.UpdateData(tx, "SFCB.B_USER_INFO", new string[] { "USERID" }, mst); mst = new Dictionary <string, object>(); mst.Add("USERID", UserId); dp.DeleteData(tx, "sfcb.b_user_poplist".ToUpper(), mst); tx.Commit(); return("OK"); } catch (Exception ex) { tx.Rollback(); return(ex.Message); } finally { conn.Close(); conn.Dispose(); } }
// /// <summary> // /// 未入库重工使用 // /// </summary> // /// <param name="ClearWip"></param> // /// <param name="ESN"></param> // /// <param name="LocGroup"></param> // /// <param name="WipGroup"></param> // /// <param name="ReworkNo"></param> // /// <returns></returns> // public string UpdateDataForRework(List<string> ClearWip, List<string> Listsn, string LocGroup, string WipGroup, string ReworkNo, int Total) // { // string Msg = ""; // string ESN = ""; // if (Listsn.Count != Total) // { // return string.Format("传入资料异常,传入ESN数量{0}个,实际应该是{1}", Listsn.Count.ToString(), Total.ToString()); // } // else // { // for (int xi = 0; xi < Listsn.Count; xi++) // { // try // { // ESN = Listsn[xi].ToString(); // List<string> WipKeyparts = new List<string>(); // MySqlCommand[] cmd = new MySqlCommand[100]; // List<MySqlCommand> lsCmd = new List<MySqlCommand>(); // string ColnumWip = ""; // int y = 0; // for (int i = 0; i < ClearWip.Count; i++) // { // string str = ClearWip[i].ToString(); // int x = str.IndexOf('-'); // string Flag = str.Substring(0, x); // string Colnum = str.Substring(x + 1, str.Length - x - 1); // if (Flag == "0") // { // ColnumWip += string.Format("{0}='NA',", Colnum); // } // if (Flag == "1") // { // WipKeyparts.Add(string.Format("sntype='{0}'", Colnum)); // } // } // ColnumWip = ColnumWip + "Locstation=@loc,wipstation=@wip,"; // ColnumWip = ColnumWip.Substring(0, ColnumWip.Length - 1); // string colnum = @"esn,woid,partnumber,productname,versioncode,type,locstation,stationname,wipstation,nextstation,userid,recdate,errflag, // scrapflag,sn,mac,imei,cartonnumber,trayno,palletnumber,mcartonnumber,mpalletnumber,line,sectionname,routgroupid,storenumber, // weightqty,qa_no,qa_result,track_no,ate_station_no,in_line_time,bomnumber"; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = string.Format("insert into SFCR.T_WIP_UNDO ({0},reworkno) select {0},@rewno from sfcr.T_WIP_TRACKING_ONLINE where esn=@esn", colnum); // cmd[y].Parameters.Add("rewno", MySqlDbType.VarChar, ReworkNo.Length).Value = ReworkNo; // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = "Update sfcr.T_WIP_TRACKING_ONLINE set reworkno=@rewno,nextstation=@next," + ColnumWip + " where esn=@esn"; // cmd[y].Parameters.Add("rewno", MySqlDbType.VarChar, ReworkNo.Length).Value = ReworkNo; // cmd[y].Parameters.Add("next", MySqlDbType.VarChar, WipGroup.Length).Value = WipGroup; // cmd[y].Parameters.Add("loc", MySqlDbType.VarChar, LocGroup.Length).Value = LocGroup; // cmd[y].Parameters.Add("wip", MySqlDbType.VarChar, WipGroup.Length).Value = WipGroup; // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // if (WipKeyparts.Count != 0) // { // for (int x = 0; x < WipKeyparts.Count; x++) // { // string colnumKeyPart = "esn,woId,sntype,snval,station,kpno,recdate"; // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = string.Format("insert into SFCR.T_WIP_KEYPART_UNDO ({1}) select {1} from SFCR.T_WIP_KEYPART_ONLINE where esn=@esn and {0}", WipKeyparts[x].ToString(), colnumKeyPart); // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = string.Format("Delete FROM SFCR.T_WIP_KEYPART_ONLINE where esn=@esn and {0}", WipKeyparts[x].ToString()); // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = string.Format("update SFCR.T_WO_SNLIST set snval='0' where snval=(select snval from SFCR.T_WIP_KEYPART_ONLINE where esn=@esn and {0} and rownum=1)", WipKeyparts[x].ToString()); // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // } // } // if (ColnumWip.ToUpper().IndexOf("CARTONNUMBER") > -1) // { // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = "update SFCR.T_CARTON_INFO_HAD set num=num-1,flag='0' where cartonId=(select cartonid from SFCR.T_CARTON_INFO_DTA where esn=@esn and rownum=1)"; // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = "Delete FROM SFCR.T_CARTON_INFO_DTA where esn=@esn"; // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // } // //try // //{ // BLL.BllMsSqllib.Instance.ExecteNonQueryArr(lsCmd); // Msg = "OK"; // } // catch (Exception ex) // { // Msg = ex.Message + "ESN:" + ESN; // } // } // return Msg; // } // } // /// <summary> // /// 未入库重工使用------单个产品一过 // /// </summary> // /// <param name="ClearWip"></param> // /// <param name="Listsn"></param> // /// <param name="LocGroup"></param> // /// <param name="WipGroup"></param> // /// <param name="ReworkNo"></param> // /// <returns></returns> // public string UpdateDataForReworkSigle(List<string> ClearWip, string Listsn, string LocGroup, string WipGroup, string ReworkNo) // { // string Msg = ""; // string ESN = ""; // try // { // ESN = Listsn; // List<string> WipKeyparts = new List<string>(); // MySqlCommand[] cmd = new MySqlCommand[100]; // List<MySqlCommand> lsCmd = new List<MySqlCommand>(); // string ColnumWip = ""; // int y = 0; // for (int i = 0; i < ClearWip.Count; i++) // { // string str = ClearWip[i].ToString(); // int x = str.IndexOf('-'); // string Flag = str.Substring(0, x); // string Colnum = str.Substring(x + 1, str.Length - x - 1); // if (Flag == "0") // { // ColnumWip += string.Format("{0}='NA',", Colnum); // } // if (Flag == "1") // { // WipKeyparts.Add(string.Format("sntype='{0}'", Colnum)); // } // } // ColnumWip = ColnumWip + "Locstation=@loc,wipstation=@wip,"; // ColnumWip = ColnumWip.Substring(0, ColnumWip.Length - 1); // string colnum = @"esn,woid,partnumber,productname,versioncode,type,locstation,stationname,wipstation,nextstation,userid,recdate,errflag, // scrapflag,sn,mac,imei,cartonnumber,trayno,palletnumber,mcartonnumber,mpalletnumber,line,sectionname,routgroupid,storenumber, // weightqty,qa_no,qa_result,track_no,ate_station_no,in_line_time,bomnumber"; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = string.Format("insert into SFCR.T_WIP_UNDO ({0},reworkno) select {0},@rewno from sfcr.T_WIP_TRACKING_ONLINE where esn=@esn", colnum); // cmd[y].Parameters.Add("rewno", MySqlDbType.VarChar, ReworkNo.Length).Value = ReworkNo; // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = "Update sfcr.T_WIP_TRACKING_ONLINE set reworkno=@rewno,nextstation=@next," + ColnumWip + " where esn=@esn"; // cmd[y].Parameters.Add("rewno", MySqlDbType.VarChar, ReworkNo.Length).Value = ReworkNo; // cmd[y].Parameters.Add("next", MySqlDbType.VarChar, WipGroup.Length).Value = WipGroup; // cmd[y].Parameters.Add("loc", MySqlDbType.VarChar, LocGroup.Length).Value = LocGroup; // cmd[y].Parameters.Add("wip", MySqlDbType.VarChar, WipGroup.Length).Value = WipGroup; // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // if (WipKeyparts.Count != 0) // { // for (int x = 0; x < WipKeyparts.Count; x++) // { // string colnumKeyPart = "esn,woId,sntype,snval,station,kpno,recdate"; // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = string.Format("insert into SFCR.T_WIP_KEYPART_UNDO ({1}) select {1} from SFCR.T_WIP_KEYPART_ONLINE where esn=@esn and {0}", WipKeyparts[x].ToString(), colnumKeyPart); // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = string.Format("DELETE FROM SFCR.T_WIP_KEYPART_ONLINE where esn=@esn and {0}", WipKeyparts[x].ToString()); // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = string.Format("update SFCR.T_WO_SNLIST set snval='0' where snval=(select snval from SFCR.T_WIP_KEYPART_ONLINE where esn=@esn and {0} and rownum=1)", WipKeyparts[x].ToString()); // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // } // } // if (ColnumWip.ToUpper().IndexOf("CARTONNUMBER") > -1) // { // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = "update SFCR.T_CARTON_INFO_HAD set num=num-1,flag='0' where cartonId=(select cartonid from SFCR.T_CARTON_INFO_DTA where esn=@esn and rownum=1)"; // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = "DELETE FROM SFCR.T_CARTON_INFO_DTA where esn=@esn"; // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // } // //try // //{ // ExecteNonQueryArr(lsCmd); // Msg = "OK"; // } // catch (Exception ex) // { // Msg = ex.Message + "ESN:" + ESN; // } // // } // return Msg; // //} // } //public void ExecteNonQueryArr(List<MySqlCommand> cmd) //{ // using (MySqlConnection cn = new MySqlConnection(ProConfiguration.GetConfig().DatabaseConnect)) // { // cn.Open(); // MySqlTransaction sTran = cn.BeginTransaction(); // try // { // foreach (MySqlCommand _cmd in cmd) // { // _cmd.Connection = cn; // _cmd.Transaction = sTran; // _cmd.CommandTimeout = 84100; // _cmd.ExecuteNonQuery(); // _cmd.Dispose(); // } // sTran.Commit(); // } // catch (Exception ex) // { // sTran.Rollback(); // throw ex; // } // finally // { // cn.Close(); // cn.Dispose(); // } // } //} // /// <summary> // /// 已经入库使用 // /// </summary> // /// <param name="ClearWip"></param> // /// <param name="ESN"></param> // /// <param name="LocGroup"></param> // /// <param name="WipGroup"></param> // /// <param name="ReworkNo"></param> // /// <returns></returns> // public string UpdateDataForReworkWareHouse(List<string> ClearWip, List<string> Listsn, string LocGroup, string WipGroup, string ReworkNo, int Total) // { // string Msg = ""; // if (Listsn.Count != Total) // { // return string.Format("传入资料异常,传入ESN数量{0}个,实际应该是{1}", Listsn.Count.ToString(), Total.ToString()); // } // else // { // for (int xi = 0; xi < Listsn.Count; xi++) // { // string ESN = Listsn[xi].ToString(); // List<string> WipKeyparts = new List<string>(); // MySqlCommand[] cmd = new MySqlCommand[100]; // List<MySqlCommand> lsCmd = new List<MySqlCommand>(); // string ColnumWip = ""; // int y = 0; // for (int i = 0; i < ClearWip.Count; i++) // { // string str = ClearWip[i].ToString(); // int x = str.IndexOf('-'); // string Flag = str.Substring(0, x); // string Colnum = str.Substring(x + 1, str.Length - x - 1); // if (Flag == "0") // { // ColnumWip += string.Format("{0}='NA',", Colnum); // } // if (Flag == "1") // { // WipKeyparts.Add(string.Format("sntype='{0}'", Colnum)); // } // } // ColnumWip = ColnumWip + "Locstation=@loc,wipstation=@wip,"; // ColnumWip = ColnumWip.Substring(0, ColnumWip.Length - 1); // string colnum = @"esn,woid,partnumber,productname,versioncode,type,locstation,stationname,wipstation,nextstation,userid,recdate,errflag, // scrapflag,sn,mac,imei,cartonnumber,trayno,palletnumber,mcartonnumber,mpalletnumber,line,sectionname,routgroupid,storenumber, // weightqty,qa_no,qa_result,track_no,ate_station_no,in_line_time,bomnumber"; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = string.Format("insert into SFCR.T_WIP_UNDO ({0},@rewno) select {0},@rewno from sfcr.T_WIP_TRACKING_ONLINE where esn=@esn", colnum); // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // cmd[y].Parameters.Add("rewno", MySqlDbType.VarChar, ReworkNo.Length).Value = ReworkNo; // lsCmd.Add(cmd[y]); // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = "Update sfcr.T_WIP_TRACKING_ONLINE set nextstation=@nextwip,reworkno=@rewno," + ColnumWip + " where esn=@esn"; // cmd[y].Parameters.Add("rewno", MySqlDbType.VarChar, ReworkNo.Length).Value = ReworkNo; // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // cmd[y].Parameters.Add("loc", MySqlDbType.VarChar, LocGroup.Length).Value = LocGroup; // cmd[y].Parameters.Add("wip", MySqlDbType.VarChar, WipGroup.Length).Value = WipGroup; // cmd[y].Parameters.Add("nextwip", MySqlDbType.VarChar, WipGroup.Length).Value = WipGroup; // lsCmd.Add(cmd[y]); // y++; // string whcolnum = @"esn,woid,partnumber,productname,versioncode,type,locstation,stationname,wipstation,nextstation,userid,recdate,errflag, // scrapflag,sn,mac,imei,cartonnumber,trayno,palletnumber,mcartonnumber,mpalletnumber,line,sectionname,routgroupid,storenumber, // weightqty,qa_no,qa_result,track_no,ate_station_no,in_line_time,bomnumber,lotin,storehouseid,locid,lotout,recdate1,status"; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = string.Format(" insert into sfcr.z_whs_tracking_undo ({0},reworkno) select {0},@rewno sfcr.Z_WHS_TRACKING where esn=@esn", whcolnum); // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // cmd[y].Parameters.Add("rewno", MySqlDbType.VarChar, ReworkNo.Length).Value = ReworkNo; // lsCmd.Add(cmd[y]); // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = "DELETE FROM sfcr.Z_WHS_TRACKING where esn=@esn"; // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // if (WipKeyparts.Count != 0) // { // for (int x = 0; x < WipKeyparts.Count; x++) // { // y++; // string colnumKeyPart = "esn,woId,sntype,snval,station,kpno,recdate"; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = string.Format("insert into SFCR.T_WIP_KEYPART_UNDO ({1}) select {1} from SFCR.T_WIP_KEYPART_ONLINE where esn=@SN and {0}", WipKeyparts[x].ToString(), colnumKeyPart); // cmd[y].Parameters.Add("SN", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = string.Format("DELETE FROM SFCR.T_WIP_KEYPART_ONLINE where esn=@esn and {0}", WipKeyparts[x].ToString()); // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // } // } // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = string.Format("insert into SFCR.z_whs_keypart_undo (esn,woId,sntype,snval,station,kpno,recdate) select esn,woId,sntype,snval,station,kpno,recdate from SFCR.Z_WHS_KEYPART where esn=@esn "); // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // // cmd[y].Parameters.Add("rewno", MySqlDbType.VarChar, ReworkNo.Length).Value = ReworkNo; // lsCmd.Add(cmd[y]); // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = string.Format("DELETE FROM SFCR.Z_WHS_KEYPART where esn=@esn "); // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // if (ColnumWip.ToUpper().IndexOf("CARTONNUMBER") > -1) // { // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = "update SFCR.T_CARTON_INFO_HAD set num=num-1 where cartonId=(select cartonid from tCartonInfodta where esn=@esn)"; // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // y++; // cmd[y] = new MySqlCommand(); // cmd[y].CommandText = "DELETE FROM SFCR.T_CARTON_INFO_DTA where esn=@esn"; // cmd[y].Parameters.Add("esn", MySqlDbType.VarChar, ESN.Length).Value = ESN; // lsCmd.Add(cmd[y]); // } // try // { // BLL.BllMsSqllib.Instance.ExecteNonQueryArr(lsCmd); // Msg = "OK"; // } // catch (Exception ex) // { // Msg = ex.Message + "ESN:" + ESN; // } // } // return Msg; // } // } public string Release_Bound(string ESN, string INPUTGROUP, string ReworkNo) { DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); try { IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); IDictionary <string, object> mst = new Dictionary <string, object>(); int count = 0; mst.Add("LOCSTATION", INPUTGROUP); mst.Add("STATIONNAME", INPUTGROUP); mst.Add("WIPSTATION", INPUTGROUP); mst.Add("NEXTSTATION", INPUTGROUP); mst.Add("REWORKNO", ReworkNo); mst.Add("ESN", ESN); dp.UpdateData(tx, "SFCR.T_WIP_TRACKING_ONLINE", new string[] { "ESN" }, mst); mst = new Dictionary <string, object>(); mst.Add("ESN", ESN); DataSet ds = dp.GetData("SFCR.T_WIP_KEYPART_ONLINE", "ESN,WOID,SNTYPE,SNVAL,STATION,KPNO,RECDATE", mst, out count); foreach (DataRow dr in ds.Tables[0].Rows) { if (dr["SNTYPE"].ToString() == "KPESN") { mst = new Dictionary <string, object>(); mst.Add("ESN", dr["SNVAL"].ToString()); mst.Add("WIPSTATION", "MB_Repair"); dp.UpdateData(tx, "SFCR.T_WIP_TRACKING_ONLINE", new string[] { "ESN" }, mst); } mst = new Dictionary <string, object>(); mst.Add("ESN", dr["ESN"].ToString()); mst.Add("WOID", dr["WOID"].ToString()); mst.Add("SNTYPE", dr["SNTYPE"].ToString()); mst.Add("SNVAL", dr["SNVAL"].ToString()); mst.Add("STATION", dr["STATION"].ToString()); mst.Add("KPNO", dr["KPNO"].ToString()); mst.Add("RECDATE", Convert.ToDateTime(dr["RECDATE"].ToString())); dp.AddData(tx, "SFCR.T_WIP_KEYPART_UNDO", mst); } mst = new Dictionary <string, object>(); mst.Add("ESN", ESN); dp.DeleteData(tx, "SFCR.T_WIP_KEYPART_ONLINE", mst); tx.Commit(); return("OK"); } catch (Exception ex) { tx.Rollback(); return(ex.Message); } finally { conn.Close(); conn.Dispose(); } }
public string InsertVersionInfo(string WO, string lsVersionMark, string sId) { //OracleCommand cmd = new OracleCommand(); //cmd.CommandText = " DELETE FROM SFCB.B_VERSION_INFO WHERE WOID=:woid "; //cmd.Parameters.Add("woid", OracleDbType.Varchar2, 25).Value = WO; //BLL.BllMsSqllib.Instance.ExecteNonQuery(cmd); //foreach (Entity.tVersionMark item in lsVersionMark) //{ // cmd = new OracleCommand(); // cmd.CommandText = "insert into sfcb.b_version_info(woid,version_name,version_values,user_id,recdate)values(:woid,:version_name,:version_values,:sId,sysdate)"; // cmd.Parameters.Add("woid", OracleDbType.Varchar2, 20).Value = WO; // cmd.Parameters.Add("version_name", OracleDbType.Varchar2, 50).Value = item.VERSION_NAME; // cmd.Parameters.Add("version_values", OracleDbType.Varchar2, 100).Value = item.VERSION_VALUES; // cmd.Parameters.Add("sId", OracleDbType.Varchar2, 100).Value = sId; // BLL.BllMsSqllib.Instance.ExecteNonQuery(cmd); //} //return "OK"; IList <IDictionary <string, object> > VersionMark = MapListConverter.JsonToListDictionary(lsVersionMark); string table = "SFCB.B_VERSION_INFO"; IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); IDictionary <string, object> parms = new Dictionary <string, object>(); parms.Add("WOID", WO); dp.DeleteData(table, parms); DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); try { IDictionary <string, object> mst = new Dictionary <string, object>(); foreach (Dictionary <string, object> dic in VersionMark) { mst = new Dictionary <string, object>(); mst.Add("WOID", dic["WOID"]); mst.Add("VERSION_NAME", dic["VERSION_NAME"]); mst.Add("VERSION_VALUES", dic["VERSION_VALUES"]); mst.Add("user_id", sId); mst.Add("recdate", System.DateTime.Now); dp.AddData(tx, "sfcb.b_version_info", mst); } return("OK"); } catch (Exception ex) { tx.Rollback(); return(ex.Message); } finally { conn.Close(); conn.Dispose(); } }
public string InserSnRule(string Lisdicsnrule, string ESN_TYPE) { IList <IDictionary <string, object> > Lsdicrule = MapListConverter.JsonToListDictionary(Lisdicsnrule); IDictionary <string, object> mst = null; IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); try { mst = new Dictionary <string, object>(); mst.Add("WOID", Lsdicrule[0]["WOID"]); mst.Add("REVE", "1"); dp.DeleteData(tx, "SFCR.T_SN_RULE", mst); mst = new Dictionary <string, object>(); mst.Add("WOID", Lsdicrule[0]["WOID"]); dp.DeleteData(tx, "SFCR.T_WO_SN_RULE", mst); foreach (Dictionary <string, object> dicrule in Lsdicrule) { if (dicrule["SNTYPE"].ToString() != "NA") ////如果前台没有添加区间信息,判定SNTYPE=NA,则不增加区间 { dp.AddData(tx, "SFCR.T_WO_SN_RULE", dicrule); if (dicrule["SNTYPE"].ToString() == ESN_TYPE) { mst = new Dictionary <string, object>(); mst.Add("WOID", dicrule["WOID"]); mst.Add("SNPREFIX", dicrule["SNPREFIX"]); mst.Add("SNPOSTFIX", dicrule["SNPOSTFIX"]); mst.Add("SNSTART", dicrule["SNSTART"]); mst.Add("SNEND", dicrule["SNEND"]); mst.Add("REVE", "1"); mst.Add("VER", dicrule["VER"]); mst.Add("CURRSN", "NA"); dp.AddData(tx, "SFCR.T_SN_RULE", mst); } } } tx.Commit(); return("OK"); } catch (Exception ex) { tx.Rollback(); return(ex.Message); } finally { conn.Close(); conn.Dispose(); } }
/// <summary> /// 导入料表到MaterialPreparation_1 /// </summary> /// <param name="masterid"></param> /// <param name="woid"></param> /// <param name="userid"></param> public string InsertMaterialPreparation_1(string masterid, string woid, string userid) { DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); try { IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); IDictionary <string, object> mst = new Dictionary <string, object>(); mst.Add("WOID", woid); mst.Add("MASTERID", masterid); dp.DeleteData(tx, "sfcr.t_material_preparation_1", mst); string fieldlist = "woId,partnumber,stationno,masterId,kpnumber,bomver".ToUpper(); int count = 0; mst = new Dictionary <string, object>(); mst.Add("WOID", woid); mst.Add("MASTERID", masterid); DataTable dt = dp.GetData(table, fieldlist, mst, out count).Tables[0]; IList <IDictionary <string, object> > list = new List <IDictionary <string, object> >(); foreach (DataRow dr in dt.Rows) { mst = new Dictionary <string, object>(); mst.Add("WOID", dr["WOID"].ToString()); mst.Add("PARTNUMBER", dr["PARTNUMBER"].ToString()); mst.Add("USERID", userid); mst.Add("STATIONNO", dr["STATIONNO"].ToString()); mst.Add("STATIONNUM", (dt.Select(string.Format("STATIONNO='{0}'", dr["STATIONNO"].ToString())).Length).ToString()); mst.Add("MASTERID", dr["MASTERID"].ToString()); mst.Add("KPNUMBER", dr["KPNUMBER"].ToString()); mst.Add("BOMVER", dr["BOMVER"].ToString()); mst.Add("RECDATE", System.DateTime.Now); list.Add(mst); } dp.AddListData(tx, "sfcr.t_material_preparation_1", list); tx.Commit(); return("OK"); } catch (Exception ex) { tx.Rollback(); return(ex.Message); } finally { conn.Close(); conn.Dispose(); } }
public string Scrap_SN(IDictionary <string, object> mst, IDictionary <string, object> mst_scrap) { DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); string Colnum = "ESN,WOID,PARTNUMBER,PRODUCTNAME,VERSIONCODE,TYPE,LOCSTATION,STATIONNAME,WIPSTATION,NEXTSTATION,USERID,RECDATE," + "ERRFLAG,SCRAPFLAG,SN,MAC,IMEI,CARTONNUMBER,TRAYNO,PALLETNUMBER,MCARTONNUMBER,MPALLETNUMBER,LINE,SECTIONNAME,ROUTGROUPID," + "STORENUMBER,WEIGHTQTY,QA_NO,QA_RESULT,TRACK_NO,ATE_STATION_NO,IN_LINE_TIME,BOMNUMBER,REWORKNO"; int count = 0; try { IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("ESN", mst["ESN"]); DataTable dt_wip_tracking = dp.GetData("SFCR.T_WIP_TRACKING_ONLINE", Colnum, dic, out count).Tables[0]; if (count > 0) { dp.AddListData(tx, "SFCR.T_WIP_UNDO", DataTableToDictionary(dt_wip_tracking)); } dp.UpdateData(tx, "SFCR.T_WIP_TRACKING_ONLINE", new string[] { "ESN" }, mst); dp.AddData(tx, "SFCR.T_SN_SCRAP", mst_scrap); string table = "SFCR.T_WO_INFO"; string fieldlist = "SCRAPQTY = SCRAPQTY + {0}"; string filter = "WOID ={0}"; IDictionary <string, object> modFields = new Dictionary <string, object>(); modFields.Add("SCRAPQTY", 1); IDictionary <string, object> keyVals = new Dictionary <string, object>(); keyVals.Add("WOID", mst_scrap["WOID"]); TransactionManager.UpdateBatchData(table, fieldlist, modFields, filter, keyVals); tx.Commit(); return("OK"); } catch (Exception ex) { tx.Rollback(); return(ex.Message); } finally { conn.Close(); conn.Dispose(); } }
public string Update_SmtKpMonitor(string woId, string OldMaterId, string NewMasterId, string Machine) { DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); try { IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); StringBuilder ofilter = new StringBuilder(); ofilter.Append("MASTERID={0},MACHINEID={1}"); IDictionary <string, object> modFields = new Dictionary <string, object>(); modFields.Add("MASTERID", NewMasterId); modFields.Add("MACHINEID", Machine); string filter = "MASTERID={0} AND WOID={1}"; IDictionary <string, object> keyVals = new Dictionary <string, object>(); keyVals.Add("MASTERID1", OldMaterId); keyVals.Add("WOID", woId); dp.UpdateBatchData(tx, "SFCR.T_SMT_KP_MONNITOR", ofilter.ToString(), modFields, filter, keyVals); ofilter = new StringBuilder(); ofilter.Append("MASTERID={0},MACHINEID={1}"); modFields = new Dictionary <string, object>(); modFields.Add("MASTERID", NewMasterId); modFields.Add("MACHINEID", Machine); filter = "MASTERID={0} AND WOID={1}"; keyVals = new Dictionary <string, object>(); keyVals.Add("MASTERID1", OldMaterId); keyVals.Add("WOID", woId); dp.UpdateBatchData(tx, "SFCR.T_SMT_IO", ofilter.ToString(), modFields, filter, keyVals); tx.Commit(); return("OK");// +woId + "--" + OldMaterId + "--" + NewMasterId + "--" + Machine; } catch (Exception ex) { tx.Rollback(); return(ex.Message); } finally { conn.Close(); conn.Dispose(); } }
public List <string> GetSnMacImeiForAte(string Esn, string sntype, string woId, int snqty) { List <string> BarcodeList = new List <string>(); string table = "SFCR.T_WO_SNLIST"; string fieldlist = "SNVAL"; int count = 0; DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); IDictionary <string, object> mst = new Dictionary <string, object>(); mst.Add("WOID", woId); mst.Add("SNTYPE", sntype); mst.Add("ESN", Esn); DataSet ds = dp.GetData(table, fieldlist, mst, out count); if (ds.Tables[0].Rows.Count == 0) { mst = new Dictionary <string, object>(); mst.Add("WOID", woId); mst.Add("SNTYPE", sntype); string field = "woId={0} and sntype={1} and status=0 limit " + snqty; DataTable dt = TransactionManager.GetData(table, "ID AS ROWID,SNVAL", field, mst, null, null, out count).Tables[0]; if (dt != null && dt.Rows.Count != 0) { if (dt.Rows.Count == snqty) { IList <IDictionary <string, object> > lsdic = new List <IDictionary <string, object> >(); BarcodeList.Add("OK"); foreach (DataRow dr in dt.Rows) { StringBuilder ofilter = new StringBuilder(); ofilter.Append(" ESN = {0},STATUS = {1}"); IDictionary <string, object> modFields = new Dictionary <string, object>(); modFields.Add("ESN", Esn); modFields.Add("STATUS", 1); string filter = " ID={0} AND STATUS = {1}"; IDictionary <string, object> keyVals = new Dictionary <string, object>(); keyVals.Add("ID", dr["rowid"].ToString()); keyVals.Add("STATUS1", 0); dp.UpdateBatchData(tx, table, ofilter.ToString(), modFields, filter, keyVals); Insert_System_Log(Esn + "-->" + dr["snval"].ToString()); } string msg = "OK"; try { tx.Commit(); // dp.UpdateListData(table, new string[] { "ID", "STATUS" }, lsdic); } catch (Exception ex) { tx.Rollback(); msg = ex.Message; } finally { conn.Close(); conn.Dispose(); } if (msg != "OK") { BarcodeList[0] = "Update DataBase Fall"; return(BarcodeList); } #region 处理并发时避免重复给号,更新完毕后等待300毫秒再读取一次 System.Threading.Thread.Sleep(300); mst = new Dictionary <string, object>(); mst.Add("WOID", woId); mst.Add("SNTYPE", sntype); mst.Add("ESN", Esn); DataSet dss = dp.GetData(table, fieldlist, mst, out count); if (dss.Tables[0].Rows.Count == 0) { BarcodeList[0] = "Get Sn Exception"; return(BarcodeList); } if (dss.Tables[0].Rows.Count != snqty) { BarcodeList[0] = "Get Sn Insufficient Quantity"; return(BarcodeList); } foreach (DataRow dr in dss.Tables[0].Rows) { BarcodeList.Add(dr["snval"].ToString()); Insert_System_Log(Esn + "-->" + dr["snval"].ToString()); } #endregion } else { BarcodeList.Add("Bar code is not enough"); } } else { BarcodeList.Add("FAIL"); } return(BarcodeList); } else { BarcodeList.Add("OK"); foreach (DataRow dr in ds.Tables[0].Rows) { BarcodeList.Add(dr[0].ToString()); } return(BarcodeList); } }
/// <summary> /// 新增工单信息 /// </summary> /// <param name="TWI"></param> /// <param name="Err"></param> public string InsertWoInfo(string dicwoinfo, string AteScript, string esn, string diclssnrule) { string err = ""; IDictionary <string, object> dicWO = MapListConverter.JsonToDictionary(dicwoinfo); IList <IDictionary <string, object> > lsdicsnrule = null; if (!string.IsNullOrEmpty(diclssnrule)) { lsdicsnrule = MapListConverter.JsonToListDictionary(diclssnrule); } DbConnection conn = ProviderHelper.GetConnection(ProConfiguration.GetConfig().DatabaseType, ProConfiguration.GetConfig().DatabaseConnect); DbTransaction tx = ProviderHelper.BeginTransaction(conn); try { #region 添加工单 string fieldlist = "COUNT(1)"; int count = 0; IAdminProvider dp = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN); IDictionary <string, object> mst = new Dictionary <string, object>(); mst.Add("WOID", dicWO["WOID"]); DataTable dt = dp.GetData(table, fieldlist, mst, out count).Tables[0]; err = "[woinfo]"; if (dt.Rows[0][0].ToString() == "0") { dicWO.Add("RECDATE", System.DateTime.Now); dp.AddData(tx, table, dicWO); #region #endregion } else { dicWO.Add("RECDATE", System.DateTime.Now); dp.UpdateData(tx, table, new string[] { "WOID" }, dicWO); } err = "[AteScript]"; #region 脚本信息 if (!string.IsNullOrEmpty(AteScript)) { mst = new Dictionary <string, object>(); mst.Add("WOID", dicWO["WOID"]); DataTable dtate = dp.GetData("SFCB.B_ATE_SCRIPT", "COUNT(1)", mst, out count).Tables[0]; if (dtate.Rows[0][0].ToString() == "0") { mst = new Dictionary <string, object>(); mst.Add("WOID", dicWO["WOID"]); mst.Add("SCRIPT", AteScript); dp.AddData(tx, "SFCB.B_ATE_SCRIPT", mst); } else { mst = new Dictionary <string, object>(); mst.Add("WOID", dicWO["WOID"]); mst.Add("SCRIPT", AteScript); dp.UpdateData(tx, "SFCB.B_ATE_SCRIPT", new string[] { "WOID" }, mst); } } #endregion #endregion err = "[lsdicsnrule]"; #region 添加工单序列号区间 if (lsdicsnrule != null && lsdicsnrule.Count > 0) { err = "[lsdicsnrule_1]"; mst = new Dictionary <string, object>(); mst.Add("WOID", dicWO["WOID"]); mst.Add("REVE", "1"); dp.DeleteData(tx, "SFCR.T_SN_RULE", mst); mst = new Dictionary <string, object>(); mst.Add("WOID", lsdicsnrule[0]["WOID"]); dp.DeleteData("SFCR.T_WO_SN_RULE", mst); foreach (IDictionary <string, object> dic in lsdicsnrule) { dic.Add("RECDATE", System.DateTime.Now); } dp.AddListData(tx, "SFCR.T_WO_SN_RULE", lsdicsnrule); foreach (IDictionary <string, object> dic in lsdicsnrule) { if (dic["SNTYPE"].ToString() == esn.ToUpper()) { mst = new Dictionary <string, object>(); mst.Add("WOID", dic["WOID"]); mst.Add("SNPREFIX", dic["SNPREFIX"]); mst.Add("SNPOSTFIX", dic["SNPOSTFIX"]); mst.Add("SNSTART", dic["SNSTART"]); mst.Add("SNEND", dic["SNEND"]); mst.Add("REVE", "1"); mst.Add("VER", dic["VER"]); mst.Add("CURRSN", "NA"); mst.Add("RECDATE", System.DateTime.Now); dp.AddData(tx, "SFCR.T_SN_RULE", mst); } } } #endregion tx.Commit(); return("OK"); } catch (Exception ex) { tx.Rollback(); return(err + ex.Message); } finally { conn.Close(); conn.Dispose(); } }