private void upLoadData() { // downSprueflosInfo("5000452515", "20071481"); if (uGridData.Rows.Count == 0) { lstHint2.Items.Add("错误:没有需要上传的数据!"); return; } //if (!ckQR1.Checked) //{ // MessageBox.Show("只有查询模式为【已确认】,才允许进行上传操作!"); // return; //} //if (uGridData.Rows[0].Cells["FS_ISMATCH"].Value.ToString() == "0") //{ // MessageBox.Show("你可能没有执行数据修改操作!"); // return; //} string strTmpMater, strTmpOrder, strTmpBatch1, strTmpBatch2, strTmpValue, strTmpJzrq, strTmpPrebatch,strPriBatchNo; strTmpMater = ""; string strTmpNo = ""; decimal dTmpZl = 0; System.Data.DataRow[] tmpRow; ArrayList listBatch = new ArrayList(); string[] strTmpHeader = new string[] { "", "", "" }; string[] strTmpUpload = new string[] { "", "", "", "", "", "", "", "", "", "", "", "" }; CoreClientParam ccp = new CoreClientParam(); String strTmpRfc = "BAPI_GOODSMVT_CREATE"; String strTmpCode = "02"; strTmpOrder = ""; tmpRow = dataSet1.Tables[0].Select("FS_ISMATCH='1' AND FS_UPLOADFLAG='0'", "FS_BATCHNO,FN_BANDNO"); for (int i = 0; i < tmpRow.Length; i++) { ArrayList listItem = new ArrayList(); ArrayList listSubItem = new ArrayList(); ArrayList listItem2 = new ArrayList();//上传批次特性时使用 // if (tmpRow[i].Cells["FS_ISMATCH"].Value.ToString() == "0") continue; // if (!chkDataInfo(i)) continue; listBatch.Add(tmpRow[i]["FN_BANDNO"].ToString()); strTmpBatch1 = tmpRow[i]["FS_BATCHNO"].ToString().Substring(0, 8); strTmpBatch2 = (i < (tmpRow.Length - 1)) ? tmpRow[i + 1]["FS_BATCHNO"].ToString().Substring(0, 8) : tmpRow[i]["FS_BATCHNO"].ToString().Substring(0, 8); if (ckTheory.Checked) dTmpZl += Convert.ToDecimal(tmpRow[i]["FN_THEORYWEIGHT"]); else dTmpZl += Convert.ToDecimal(tmpRow[i]["FN_WEIGHT"]); if ((strTmpBatch1 != strTmpBatch2) || (i == (tmpRow.Length - 1))) { strTmpJzrq = Convert.ToDateTime(tmpRow[i]["FS_ACCOUNTDATE"]).ToString("yyyy-MM-dd"); strTmpHeader[0] = Convert.ToDateTime(tmpRow[i]["FS_ACCOUNTDATE"]).ToString("yyyy.MM.dd"); strTmpHeader[1] = Convert.ToDateTime(tmpRow[i]["FS_ACCOUNTDATE"]).ToString("yyyy.MM.dd"); strTmpHeader[2] = tmpRow[i]["FS_HEADER"].ToString(); strTmpOrder = tmpRow[i]["FS_PRODUCTNO"].ToString(); strTmpMater = getMaterial(strTmpOrder); strTmpNo = tmpRow[i]["FS_BATCHNO"].ToString(); strTmpPrebatch = tmpRow[i]["FS_GP_STOVENO"].ToString(); strPriBatchNo=tmpRow[i]["FS_PRIBATCHNO"].ToString(); listSubItem.Clear(); listItem.Clear(); listSubItem.Add(strTmpMater);//物料编号 listSubItem.Add("8500");//工厂 listSubItem.Add(tmpRow[i]["FS_SAPSTORE"].ToString());//库存地点 listSubItem.Add(strTmpNo);//批次 listSubItem.Add("101");//移动类型101 listSubItem.Add("");//库存类型 listSubItem.Add("");//特殊库存标识 listSubItem.Add(dTmpZl.ToString());//发货数量 listSubItem.Add("TON");//收货时的计量单位 listSubItem.Add("0001");//项目文本 listSubItem.Add(strTmpOrder);//生产订单编号 listSubItem.Add("F");//移动标识'F' listSubItem.Add("");//销售订单号 listSubItem.Add("");//销售订单行项目 listItem.Add(listSubItem); strTmpUpload[0] = strTmpMater; strTmpUpload[1] = "101"; strTmpUpload[3] = tmpRow[i]["FS_PRODUCTNO"].ToString(); strTmpUpload[4] = strTmpNo; strTmpUpload[5] = Convert.ToDateTime(this.GetServerTime()).ToString("yyyy-MM-dd HH:mm:ss"); strTmpUpload[7] = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(); strTmpUpload[8] = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID(); strTmpUpload[9] = tmpRow[i]["FS_ITEMNO"].ToString(); strTmpUpload[10] = strTmpUpload[5]; ccp.ServerName = "ygjzjl.sap.UploadSapRfc"; ccp.MethodName = "up_Product"; ccp.ServerParams = new object[] { strTmpRfc, strTmpHeader, strTmpCode, listItem }; this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++杨滔增上传上工序批次号功能 listItem2.Add(strPriBatchNo); ccp.MethodName = "upBatchValue"; ccp.ServerParams = new object[] { strTmpMater, strTmpNo, "8500", listItem2 }; this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ string sTmp; if (ccp.ReturnCode == 0) { sTmp = ccp.ReturnObject.ToString(); strTmpValue = "FS_UPLOADFLAG='1',FS_SPRUEFLOS='" + sapClass.downSprueflosInfo(sTmp) + "'"; // downSprueflosInfo(sTmp, strTmpNo); upTheoryWt(strTmpNo, strTmpHeader[0], strTmpOrder, strTmpMater, Convert.ToDateTime(tmpRow[i]["GBSJ"]).ToString("yyyy.MM.dd"), tmpRow[i]["FS_SPEC"].ToString(), tmpRow[i]["FS_HEADER"].ToString()); //sapClass.insChemCopy(strTmpMater, tmpRow[i]["FS_PLANT"].ToString(), // strTmpNo, tmpRow[i]["FS_GP_STOVENO"].ToString()); strTmpUpload[2] = sTmp + "-" + tmpRow[i]["FS_BATCHNO"].ToString(); strTmpUpload[6] = dTmpZl.ToString(); sTmp = "炉号为" + strTmpNo + "-凭证号" + sTmp + "-上传重量" + dTmpZl.ToString(); sapClass.uptDataFlag("dt_pipeweightmain", "FS_UPLOADFLAG='1',FS_MATERIALNO='" + strTmpMater + "'", "FS_BATCHNO='" + strTmpNo + "' AND FS_ACCOUNTDATE='" + strTmpJzrq + "'"); for (int j = 0; j < listBatch.Count; j++) { sapClass.uptDataFlag("dt_pipeweightdetail", strTmpValue, "FS_BATCHNO='" + strTmpNo + "' AND FN_BANDNO=" + listBatch[j]); } listBatch.Clear(); // sapClass.uptSapLog(strTmpNo, sapClass.strArrayUpload); uptSapLog(strTmpNo, strTmpUpload); // sapClass.insMssqlData(1, "chemCopy", "PSTING_DATE,BATCH,PLANT,preBatch,MATERIAL", // "'" + strTmpJzrq + "','" + strTmpNo + "','1100','" + strTmpPrebatch + "','" + strTmpMater // + "'"); sTmp += ",数据上传成功!"; //垛帐接口 //垛帐接口 DepotManage dm = new DepotManage(); bool flag = dm.UpdateMaterial(strTmpNo, strTmpMater); } else { sTmp = ccp.ReturnInfo; } //upTheoryWt("20080556", "2010.08.08", "000200017617", "BHRB3E0320011", "2010.08.08","HRB335E", "丙早"); dTmpZl = 0;//清0 lstHint2.Items.Add(sTmp); } } showGridInfo(); }
private void upLoadData() { if (uGridData.Rows.Count == 0) { lstHint2.Items.Add("错误:没有需要上传的数据!"); return; } string strTmpMater, strTmpOrder, strTmpBatch1, strTmpBatch2, strTmpValue, strTmpJzrq, strTmpPrebatch; strTmpMater = ""; string strTmpNo = ""; decimal dTmpZl = 0; string[] strTmpHeader = new string[] { "", "", "" }; ArrayList listSubItem = new ArrayList(); ArrayList listBatch = new ArrayList(); strTmpOrder = ""; dTmpZl = 0; System.Data.DataRow[] tmpRow; //edit tmpRow = dataSet1.Tables[0].Select("FS_ISMATCH='1' AND FS_UPLOADFLAG='0'", "FS_BATCHNO,FN_BANDNO"); for (int i = 0; i < tmpRow.Length; i++) { //strTmpOrder = tmpRow[i]["FS_PRODUCTNO"].ToString(); //strTmpMater = sapClass.getMaterial(strTmpOrder); //strTmpNo = (tmpRow[i]["FS_BATCHNO"].ToString()); ////strTmpNo = (tmpRow[i]["FN_BANDNO"].ToString().Length == 1) //// ? tmpRow[i]["FS_BATCHNO"].ToString() + "0" + tmpRow[i]["FN_BANDNO"].ToString() //// : tmpRow[i]["FS_BATCHNO"].ToString() + tmpRow[i]["FN_BANDNO"].ToString(); //sapClass.batchValueUp(strTmpMater, strTmpNo, "8000"); //break; listBatch.Add(tmpRow[i]["FN_BANDNO"].ToString()); strTmpBatch1 = tmpRow[i]["FS_BATCHNO"].ToString().Substring(0, 8); strTmpBatch2 = (i < (tmpRow.Length - 1)) ? tmpRow[i + 1]["FS_BATCHNO"].ToString().Substring(0, 8) : tmpRow[i]["FS_BATCHNO"].ToString().Substring(0, 8); dTmpZl += Convert.ToDecimal(tmpRow[i]["FN_WEIGHT"]); if ((strTmpBatch1 != strTmpBatch2) || (i == (tmpRow.Length - 1))) { strTmpJzrq = Convert.ToDateTime(tmpRow[i]["FS_ACCOUNTDATE"]).ToString("yyyy-MM-dd"); strTmpHeader[0] = Convert.ToDateTime(tmpRow[i]["FS_ACCOUNTDATE"]).ToString("yyyy.MM.dd"); strTmpHeader[1] = Convert.ToDateTime(tmpRow[i]["FS_ACCOUNTDATE"]).ToString("yyyy.MM.dd"); strTmpHeader[2] = tmpRow[i]["FS_HEADER"].ToString(); strTmpOrder = tmpRow[i]["FS_PRODUCTNO"].ToString(); strTmpMater = sapClass.getMaterial(strTmpOrder); strTmpNo = tmpRow[i]["FS_BATCHNO"].ToString(); strTmpPrebatch = tmpRow[i]["FS_GP_STOVENO"].ToString(); listSubItem.Clear(); listSubItem.Add(strTmpMater);//物料编号 listSubItem.Add(tmpRow[i]["FS_PLANT"].ToString());//工厂 listSubItem.Add(tmpRow[i]["FS_SAPSTORE"].ToString());//库存地点 listSubItem.Add(strTmpNo);//批次 listSubItem.Add("101");//移动类型101 listSubItem.Add("");//库存类型 listSubItem.Add("");//特殊库存标识 listSubItem.Add(dTmpZl.ToString());//发货数量 listSubItem.Add("TON");//收货时的计量单位 listSubItem.Add("0001");//项目文本 listSubItem.Add(strTmpOrder);//生产订单编号 listSubItem.Add("F");//移动标识'F' listSubItem.Add("");//销售订单号 listSubItem.Add("");//销售订单行项目 string sTmp = sapClass.BAPI_GOODSMVT_CREATE("02", strTmpHeader, listSubItem); if (sTmp != "") { strTmpValue = "FS_UPLOADFLAG='1',FS_SPRUEFLOS='" + sapClass.downSprueflosInfo(sTmp) + "'"; sapClass.strArrayUpload[2] = sTmp + "-" + tmpRow[i]["FS_BATCHNO"].ToString(); sapClass.strArrayUpload[6] = dTmpZl.ToString(); sTmp = "炉号为" + strTmpBatch1 + "-凭证号" + sTmp + "-上传重量" + dTmpZl.ToString(); // sapClass.insChemCopy(strTmpMater, tmpRow[i]["FS_PLANT"].ToString(), // strTmpNo, tmpRow[i]["FS_GP_STOVENO"].ToString()); sapClass.uptDataFlag("DT_GX_STORAGEWEIGHTMAIN", "FS_UPLOADFLAG='1',FS_MATERIALNO='" + strTmpMater + "'", "FS_BATCHNO='" + strTmpNo + "' AND FS_ACCOUNTDATE='" + strTmpJzrq + "'"); //sapClass.uptDataFlag("DT_GX_STORAGEWEIGHTDETAIL", "FS_UPLOADFLAG='1'", "FS_BATCHNO='" + strTmpNo //+ "' AND FS_ACCOUNTDATE='" + strTmpJzrq + "'"); for (int j = 0; j < listBatch.Count; j++) { sapClass.uptDataFlag("DT_GX_STORAGEWEIGHTDETAIL", strTmpValue, "FS_BATCHNO='" + strTmpNo + "' AND FN_BANDNO=" + listBatch[j]); } listBatch.Clear(); sapClass.uptSapLog(strTmpNo, sapClass.strArrayUpload); // sapClass.insMssqlData(1, "chemCopy", "PSTING_DATE,BATCH,PLANT,preBatch,MATERIAL", // "'" + strTmpJzrq + "','" + strTmpBatch1 + "','" // + "1100','" + strTmpPrebatch + "','" + strTmpMater + "'"); sTmp += ",数据上传成功!"; //垛帐接口 DepotManage dm = new DepotManage(); bool flag = dm.UpdateMaterial(strTmpNo, strTmpMater); //dTmpZl = 0;//清0 lstHint2.Items.Add(sTmp); } else { lstHint2.Items.Add(sapClass.strSapError); } dTmpZl = 0; } } showGridInfo(); }