Exemplo n.º 1
0
    //�õ�ͨ�ù���ֵ��
    /// <summary>
    /// �õ�ͨ�ù���ֵ��
    /// </summary>
    /// <param name="a">�ڼ������� ��1��</param>
    /// <param name="xmlfile">����xml</param>
    /// <returns>ͨ�ù���ֵ��</returns>
    public static S_Gongxu_Tongyong_Value GetGongxu_Tongyong_Value(int a,string xmlfile)
    {
        S_Gongxu_Tongyong_Value s_value = new S_Gongxu_Tongyong_Value();
        s_value.gongbus = new List<S_Gongbu>(0);
        s_value.JSTJs = new List<S_JSTJ>(0);
        s_value.GYCSs = new List<string>(0);
        s_value.JGZBs = new List<string>(0);
        s_value.FZs = new List<string>(0);
        try
        {

            XmlDocument mydoc = new XmlDocument();
            mydoc.Load(xmlfile);
            string path = "/SYS_3DPPM/Gongyi/Gongxu[" + a.ToString() + "]";
            XmlElement xe = (XmlElement)mydoc.SelectSingleNode(path);
            if (xe.GetAttribute("Type") != E_GongyiNodeType.Gongxu_Tongyong.ToString())
            {
                NXFun.MessageBox("��ѯ������������ʵ���Ͳ�ƥ�䣡");
                return s_value;
            }
            XmlElement infor = xe.SelectSingleNode("Information") as XmlElement;
            //��������
            s_value.gongxuhao = infor.GetAttribute("gongxuhao");
            s_value.gongxumingcheng = infor.GetAttribute("gongxumingcheng");
            s_value.shebei = infor.GetAttribute("shebei");
            s_value.jiamoju = infor.GetAttribute("jiamoju");
            s_value.jizhun = infor.GetAttribute("jizhun");
            s_value.yingdu = infor.GetAttribute("yingdu");
            s_value.guanjiangongxu = NXFun.string2bool(infor.GetAttribute("guanjiangongxu"));
            //�ӹ�׼��
            XmlNodeList jgzb_nodes = infor.SelectNodes("JGZB/jgzb");
            foreach (XmlElement jgzb_node in jgzb_nodes)
            {
                s_value.JGZBs.Add(jgzb_node.GetAttribute("neirong"));
            }
            //��������
            XmlNodeList gbnr_nodes = infor.SelectNodes("GBNR/gbnr");
            foreach (XmlElement gbnr_node in gbnr_nodes)
            {
                S_Gongbu s_gongbu = new S_Gongbu();
                s_gongbu.neirong = gbnr_node.GetAttribute("neirong");
                s_gongbu.renju = gbnr_node.GetAttribute("renju");
                s_gongbu.liangju = gbnr_node.GetAttribute("liangju");
                s_gongbu.beizhu = gbnr_node.GetAttribute("beizhu");
                s_gongbu.zigongbus = new List<S_Zigongbu>();
                //�ӹ���
                XmlNodeList zgb_nodes = gbnr_node.SelectNodes("zgb");
                foreach (XmlElement zgb_node in zgb_nodes)
                {
                    S_Zigongbu s_zigongbu = new S_Zigongbu();
                    s_zigongbu.neirong = zgb_node.GetAttribute("neirong");
                    s_zigongbu.renju = zgb_node.GetAttribute("renju");
                    s_zigongbu.liangju = zgb_node.GetAttribute("liangju");
                    s_zigongbu.beizhu = zgb_node.GetAttribute("beizhu");
                    s_gongbu.zigongbus.Add(s_zigongbu);
                }
                s_value.gongbus.Add(s_gongbu);
            }
            //��������
            XmlNodeList jstj_nodes = infor.SelectNodes("JSTJ/jstj");
            foreach (XmlElement jstj_node in jstj_nodes)
            {
                S_JSTJ s_jstj = new S_JSTJ();
                s_jstj.neirong = jstj_node.GetAttribute("neirong");
                s_jstj.liangju = jstj_node.GetAttribute("liangju");
                s_jstj.beizhu = jstj_node.GetAttribute("beizhu");
                s_value.JSTJs.Add(s_jstj);
            }
            //��ע
            XmlNodeList fz_nodes = infor.SelectNodes("FZ/fz");
            foreach (XmlElement fz_node in fz_nodes)
            {
                s_value.FZs.Add(fz_node.GetAttribute("neirong"));
            }
            //���ղ���
            XmlNodeList gycs_nodes = infor.SelectNodes("GYCS/gycs");
            foreach (XmlElement gycs_node in gycs_nodes)
            {
                s_value.GYCSs.Add(gycs_node.GetAttribute("neirong"));
            }
            return s_value;
        }
        catch (System.Exception ex)
        {
            NXFun.MessageBox(ex.Message);
            return s_value;
        }
    }
Exemplo n.º 2
0
        //更新数据
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="isRead">是从xml读还是写入xml</param>
        /// <param name="index_a">第几个工序,从1起</param>
        public void UpdateData(bool isRead,int index_a)
        {
            if (isRead)
            {
                //读xml到控件
                s_value = XML3DPPM.GetGongxu_Tongyong_Value(index_a,XmlFile);
                //工序属性
                dgvGXSX[1, 0].Value = s_value.gongxuhao;
                dgvGXSX[1, 1].Value = s_value.gongxumingcheng;
                dgvGXSX[1, 2].Value = s_value.shebei;
                dgvGXSX[1, 3].Value = s_value.jiamoju;
                dgvGXSX[1, 4].Value = s_value.jizhun;
                dgvGXSX[1, 5].Value = s_value.yingdu;
                chkGJGX.CheckState = s_value.guanjiangongxu?CheckState.Checked : CheckState.Unchecked;
                //加工准备
                dgvJGZB.Rows.Clear();
                for (int i = 0; i < s_value.JGZBs.Count; i ++ )
                {
                    dgvJGZB.Rows.Add();
                    dgvJGZB[1, i].Value = s_value.JGZBs[i];
                }
                //工步内容
                dgvGBNR.Rows.Clear();
                for (int i = 0; i < s_value.gongbus.Count; i++ )
                {
                    int row = dgvGBNR.Rows.Add();
                    dgvGBNR.Rows[row].Tag = "Gongbu";
                    dgvGBNR[1, row].Value = s_value.gongbus[i].neirong;
                    dgvGBNR[2, row].Value = s_value.gongbus[i].renju;
                    dgvGBNR[3, row].Value = s_value.gongbus[i].liangju;
                    dgvGBNR[4, row].Value = s_value.gongbus[i].beizhu;
                    //子工步
                    {
                        for (int j = 0; j < s_value.gongbus[i].zigongbus.Count; j++ )
                        {
                            row = dgvGBNR.Rows.Add();
                            dgvGBNR.Rows[row].Tag = "Zigongbu";
                            dgvGBNR[1, row].Value = s_value.gongbus[i].zigongbus[j].neirong;
                            dgvGBNR[2, row].Value = s_value.gongbus[i].zigongbus[j].renju;
                            dgvGBNR[3, row].Value = s_value.gongbus[i].zigongbus[j].liangju;
                            dgvGBNR[4, row].Value = s_value.gongbus[i].zigongbus[j].beizhu;
                        }
                    }
                }
                FormatGBNR();
                //技术条件
                dgvJSTJ.Rows.Clear();
                for (int i = 0; i < s_value.JSTJs.Count; i++)
                {
                    dgvJSTJ.Rows.Add();
                    dgvJSTJ[1, i].Value = s_value.JSTJs[i].neirong;
                    dgvJSTJ[2, i].Value = s_value.JSTJs[i].liangju;
                    dgvJSTJ[3, i].Value = s_value.JSTJs[i].beizhu;
                }
                //附注
                dgvFZ.Rows.Clear();
                for (int i = 0; i < s_value.FZs.Count; i++)
                {
                    dgvFZ.Rows.Add();
                    dgvFZ[1, i].Value = s_value.FZs[i];
                }
                //工艺参数
                dgvGYCS.Rows.Clear();
                for (int i = 0; i < s_value.GYCSs.Count; i++)
                {
                    dgvGYCS.Rows.Add();
                    dgvGYCS[1, i].Value = s_value.GYCSs[i];
                }
            }
            else
            {
                //写入xml
                s_value = new S_Gongxu_Tongyong_Value();
                s_value.gongbus = new List<S_Gongbu>(0);
                s_value.JSTJs = new List<S_JSTJ>(0);
                s_value.GYCSs = new List<string>(0);
                s_value.JGZBs = new List<string>(0);
                s_value.FZs = new List<string>(0);
                //工序属性
                dgvGXSX.EndEdit();
                s_value.gongxuhao = (string)dgvGXSX[1, 0].Value;
                s_value.gongxumingcheng = (string)dgvGXSX[1, 1].Value;
                s_value.shebei = (string)dgvGXSX[1, 2].Value;
                s_value.jiamoju = (string)dgvGXSX[1, 3].Value;
                s_value.jizhun = (string)dgvGXSX[1, 4].Value;
                s_value.yingdu = (string)dgvGXSX[1, 5].Value;
                s_value.guanjiangongxu = chkGJGX.CheckState == CheckState.Checked;
                //加工准备
                dgvJGZB.EndEdit();
                foreach (DataGridViewRow row in dgvJGZB.Rows)
                {
                    if (!row.IsNewRow)
                    {
                        s_value.JGZBs.Add((string)row.Cells[1].Value);
                    }
                }
                //工步内容
                dgvGBNR.EndEdit();
                int flag = 0;   //0 起始  1 工步 2  子工步
                S_Gongbu s_gongbu = new S_Gongbu();
                s_gongbu.zigongbus = new List<S_Zigongbu>();
                foreach (DataGridViewRow row in dgvGBNR.Rows)
                {
                    if (!row.IsNewRow)
                    {
                        if (row.Tag == null || row.Tag.ToString() != "Zigongbu")
                        {
                            if (flag != 0)
                            {
                                s_value.gongbus.Add(s_gongbu);
                                s_gongbu = new S_Gongbu();
                                s_gongbu.zigongbus = new List<S_Zigongbu>();
                            }
                            flag = 1;
                            s_gongbu.neirong = (string)row.Cells[1].Value;
                            s_gongbu.renju = (string)row.Cells[2].Value;
                            s_gongbu.liangju = (string)row.Cells[3].Value;
                            s_gongbu.beizhu = (string)row.Cells[4].Value;
                        }
                        else
                        {
                            flag = 2;
                            S_Zigongbu s_zigongbu = new S_Zigongbu();
                            s_zigongbu.neirong = (string)row.Cells[1].Value;
                            s_zigongbu.renju = (string)row.Cells[2].Value;
                            s_zigongbu.liangju = (string)row.Cells[3].Value;
                            s_zigongbu.beizhu = (string)row.Cells[4].Value;
                            s_gongbu.zigongbus.Add(s_zigongbu);
                        }
                    }
                    else
                    {
                        if (flag!=0)
                        {
                            s_value.gongbus.Add(s_gongbu);
                        }
                    }
                }

                //技术条件
                dgvJSTJ.EndEdit();
                S_JSTJ s_jstj = new S_JSTJ();
                foreach (DataGridViewRow row in dgvJSTJ.Rows)
                {
                    if (!row.IsNewRow)
                    {
                        s_jstj.neirong = (string)row.Cells[1].Value;
                        s_jstj.liangju = (string)row.Cells[2].Value;
                        s_jstj.beizhu = (string)row.Cells[3].Value;
                        s_value.JSTJs.Add(s_jstj);
                    }
                }
                //附注
                dgvFZ.EndEdit();
                foreach (DataGridViewRow row in dgvFZ.Rows)
                {
                    if (!row.IsNewRow)
                    {
                        s_value.FZs.Add((string)row.Cells[1].Value);
                    }
                }
                //工艺参数
                dgvGYCS.EndEdit();
                foreach (DataGridViewRow row in dgvGYCS.Rows)
                {
                    if (!row.IsNewRow)
                    {
                        s_value.GYCSs.Add((string)row.Cells[1].Value);
                    }
                }
                XML3DPPM.SetGongxu_Tongyong_Value(index_a,s_value,XmlFile);
            }
        }