예제 #1
0
        private void btnInStoreUpdate_Click(object sender, EventArgs e)
        {
            string strXslt = @"updateInStoreQualityInfor.xslt";
            //组织发送记录集
            DataSet dsM = new DataSet();

            if (dsMain.Tables[0].Rows.Count > 0)
            {
                //组织主表记录集
                DataTable tbM = new DataTable();
                tbM           = dsMain.Tables[0].Clone();
                tbM           = dsMain.Tables[0].Copy();
                tbM.TableName = "M";
                dsM.Tables.Add(tbM);
            }
            else
            {
                MessageBox.Show("请查询出需要上传的数据!");
                return;
            }

            //组织从表记录集1
            if (dsMaterial1.Tables[0].Rows.Count > 0)
            {
                DataTable tbS1 = new DataTable();
                tbS1           = dsMaterial1.Tables[0].Clone();
                tbS1           = dsMaterial1.Tables[0].Copy();
                tbS1.TableName = "s1";
                dsM.Tables.Add(tbS1);
            }
            else
            {
                MessageBox.Show("请查询出需要上传的数据!");
                return;
            }
            //组织从表记录集2
            if (dsMaterial2.Tables[0].Rows.Count > 0)
            {
                DataTable tbS2 = new DataTable();
                tbS2           = dsMaterial2.Tables[0].Clone();
                tbS2           = dsMaterial2.Tables[0].Copy();
                tbS2.TableName = "s2";
                dsM.Tables.Add(tbS2);
            }
            else
            {
                MessageBox.Show("请查询出需要上传的数据!");
                return;
            }

            string strXML = TelComm.TranslateDataSetToNC(strXslt, dsM);
            string strRet = TelComm.TransferXML(strXML);

            if (strRet != "")
            {
                if (strRet == "1")
                {
                    //组建成功记录集
                    dsLog.Clear();
                    DataRow row = dsLog.Tables[0].NewRow();
                    row["HeatID"]   = dsM.Tables[0].Rows[0]["HeatID"].ToString();
                    row["BillType"] = strXslt;
                    row["Other1"]   = dsM.Tables[0].Rows[0]["Flag"].ToString();
                    row["Flag"]     = "0";
                    dsLog.Tables[0].Rows.Add(row);

                    AppSvrIF.Command cmdLog = null;
                    int iRet = Adapter.Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "WriteLogFromNC", ref cmdLog);
                    if (iRet != 0)
                    {
                        return;
                    }
                    cmdLog.set_Parameters(0, dsLog);
                    Adapter.Session.Execute(cmdLog);
                }
                else
                {
                    //组建失败记录集
                    dsLog.Clear();
                    DataRow row = dsLog.Tables[0].NewRow();
                    row["HeatID"]   = dsM.Tables[0].Rows[0]["HeatID"].ToString();
                    row["BillType"] = strXslt;
                    row["Other1"]   = dsM.Tables[0].Rows[0]["Flag"].ToString();
                    row["Flag"]     = "1";
                    row["Remark"]   = strRet;
                    dsLog.Tables[0].Rows.Add(row);

                    AppSvrIF.Command cmdLog = null;
                    int iRet = Adapter.Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "WriteLogFromNC", ref cmdLog);
                    if (iRet != 0)
                    {
                        return;
                    }
                    cmdLog.set_Parameters(0, dsLog);
                    Adapter.Session.Execute(cmdLog);
                }
            }
            else
            {
                MessageBox.Show("发送失败!");
            }
        }
예제 #2
0
        private void btnAddSend_Click(object sender, EventArgs e)
        {
            //if (TelComm.deleteXml() == false)
            //{
            //    MessageBox.Show("请手动删除DataSent文件中的MES_Data.xml文件!");
            //    return;
            //}
            string strXslt = @"BOFAddMaterialsInforToNC.xslt";
            //组织发送记录集
            DataSet dsM = new DataSet();

            if (dsMain.Tables[0].Rows.Count > 0)
            {
                //组织主表记录集
                DataTable tbM = new DataTable();
                tbM           = dsMain.Tables[0].Clone();
                tbM           = dsMain.Tables[0].Copy();
                tbM.TableName = "M";
                dsM.Tables.Add(tbM);
            }
            else
            {
                MessageBox.Show("请查询出需要上传的数据!");
                return;
            }

            //组织从表记录集
            if (dsMaterial.Tables[0].Rows.Count > 0)
            {
                DataTable tbS = new DataTable();
                tbS           = dsMaterial.Tables[0].Clone();
                tbS           = dsMaterial.Tables[0].Copy();
                tbS.TableName = "s1";
                dsM.Tables.Add(tbS);
            }
            else
            {
                MessageBox.Show("请查询出需要上传的数据!");
                return;
            }

            string strXML = TelComm.TranslateDataSetToNC(strXslt, dsM);
            string strRet = TelComm.TransferXML(strXML);

            if (strRet != "")
            {
                if (strRet == "1")
                {
                    //组建成功记录集
                    dsLog.Clear();
                    DataRow row = dsLog.Tables[0].NewRow();
                    row["HeatID"]   = dsM.Tables[0].Rows[0]["HeatID"].ToString();
                    row["BillType"] = strXslt;
                    row["Other1"]   = dsM.Tables[0].Rows[0]["Flag"].ToString();
                    row["Flag"]     = "0";
                    dsLog.Tables[0].Rows.Add(row);

                    AppSvrIF.Command cmdLog = null;
                    int iRet = Adapter.Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "WriteLogFromNC", ref cmdLog);
                    if (iRet != 0)
                    {
                        return;
                    }
                    cmdLog.set_Parameters(0, dsLog);
                    Adapter.Session.Execute(cmdLog);
                }
                else
                {
                    //组建失败记录集
                    dsLog.Clear();
                    DataRow row = dsLog.Tables[0].NewRow();
                    row["HeatID"]   = dsM.Tables[0].Rows[0]["HeatID"].ToString();
                    row["BillType"] = strXslt;
                    row["Other1"]   = dsM.Tables[0].Rows[0]["Flag"].ToString();
                    row["Flag"]     = "1";
                    row["Remark"]   = strRet;
                    dsLog.Tables[0].Rows.Add(row);

                    AppSvrIF.Command cmdLog = null;
                    int iRet = Adapter.Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "WriteLogFromNC", ref cmdLog);
                    if (iRet != 0)
                    {
                        return;
                    }
                    cmdLog.set_Parameters(0, dsLog);
                    Adapter.Session.Execute(cmdLog);
                }
            }
            else
            {
                MessageBox.Show("发送失败!");
            }
        }
예제 #3
0
        private void btnAddSend_Click(object sender, EventArgs e)
        {
            //if (TelComm.deleteXml() == false)
            //{
            //    MessageBox.Show("请手动删除DataSent文件中的MES_Data.xml文件!");
            //    return;
            //}
            string strXslt = @"MillPlanToNC.xslt";

            if (dsPlanOrder.Tables[0].Rows.Count > 0)
            {
                //将数据写入到xml中
                string strXML = TelComm.TranslateDataSetToNC(strXslt, dsPlanOrder);
                //将xml文件发送至NC
                string strRet = TelComm.TransferXML(strXML);
                if (strRet != "")
                {
                    if (strRet == "1")
                    {
                        //组建成功记录集
                        dsLog.Clear();
                        DataRow row = dsLog.Tables[0].NewRow();
                        row["HeatID"]   = dsPlanOrder.Tables[0].Rows[0]["HeatID"].ToString();
                        row["BillType"] = strXslt;
                        row["Other1"]   = dsPlanOrder.Tables[0].Rows[0]["Flag"].ToString();
                        row["Flag"]     = "0";
                        dsLog.Tables[0].Rows.Add(row);

                        AppSvrIF.Command cmdLog = null;
                        int iRet = Adapter.Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "WriteLogFromNC", ref cmdLog);
                        if (iRet != 0)
                        {
                            return;
                        }
                        cmdLog.set_Parameters(0, dsLog);
                        Adapter.Session.Execute(cmdLog);
                    }
                    else
                    {
                        //组建失败记录集
                        dsLog.Clear();
                        DataRow row = dsLog.Tables[0].NewRow();
                        row["HeatID"]   = dsPlanOrder.Tables[0].Rows[0]["HeatID"].ToString();
                        row["BillType"] = strXslt;
                        row["Other1"]   = dsPlanOrder.Tables[0].Rows[0]["Flag"].ToString();
                        row["Flag"]     = "1";
                        row["Remark"]   = strRet;
                        dsLog.Tables[0].Rows.Add(row);

                        AppSvrIF.Command cmdLog = null;
                        int iRet = Adapter.Session.CreateCommand((int)AppSvrIF.CommandType.Call, @"XGMESLogic\BaseDataMag\CBaseData_Mag\BaseData_Mag", "WriteLogFromNC", ref cmdLog);
                        if (iRet != 0)
                        {
                            return;
                        }
                        cmdLog.set_Parameters(0, dsLog);
                        Adapter.Session.Execute(cmdLog);
                    }
                }
                else
                {
                    MessageBox.Show("发送失败!");
                }
            }
            else
            {
                MessageBox.Show("请先查询出需要上传的数据!");
            }
        }