public void AddControl(Control ctrl) { this.Visible = false; string XPath, sValue; XmlNode nodeControl; switch (ctrl.GetType().ToString().Replace("ToolsDocument.", "")) { case "ucCheckBox": ucCheckBox ucChb = (ucCheckBox)ctrl; XPath = ucChb._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucChb._Checked = strToBool(sValue); break; case "ucComboBox": ucComboBox ucCbx = (ucComboBox)ctrl; XPath = ucCbx._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucCbx._SelectedValue = sValue; break; case "ucDateTimePicker": ucDateTimePicker ucDtp = (ucDateTimePicker)ctrl; XPath = ucDtp._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); strToDate(sValue, ucDtp); break; case "ucRichTextBox": ucRichTextBox ucRtb = (ucRichTextBox)ctrl; XPath = ucRtb._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucRtb._Value = sValue; break; case "ucTextBox": ucTextBox ucTbx = (ucTextBox)ctrl; XPath = ucTbx._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucTbx._Value = sValue; break; case "ucPopup": ucPopup ucPP = (ucPopup)ctrl; XPath = ucPP._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucPP.Tag = sValue; ucPP._Text = nodeControl.InnerText; ucPopup ucSub = ucPP.GetSubPopup(); if (ucSub != null) { ucSub._RepleaceID = sValue; } break; case "ucDataGridView": ucDataGridView ucDGB = (ucDataGridView)ctrl; XPath = ucDGB._XPath; ucDGB.CreateDataSource(xmlDoc.SelectSingleNode(XPath)); break; case "ucRadioButton": ucRadioButton ucRB = (ucRadioButton)ctrl; XPath = ucRB._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucRB._Value = sValue; break; case "ucPictureImage": ucPictureImage ucPI = (ucPictureImage)ctrl; XPath = ucPI._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = nodeControl.InnerText; ucPI._imgBinary = sValue; break; case "ucNumericUpDown": ucNumericUpDown ucNUD = (ucNumericUpDown)ctrl; XPath = ucNUD._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucNUD._Value = strToDecimal(sValue); break; case "ucDoubleTextBox": ucDoubleTextBox ucDTB = (ucDoubleTextBox)ctrl; XPath = ucDTB._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucDTB._Value = sValue; break; } DocControl.AddControls(ctrl); }
public bool funSaveXml() { for (int i = 0; i < DocControl.CountControl; i++) { Control ctrl = DocControl.GetControls(i); string XPath, sValue; XmlNode nodeControl; switch (ctrl.GetType().ToString().Replace("ToolsDocument.", "")) { case "ucCheckBox": ucCheckBox ucChb = (ucCheckBox)ctrl; XPath = ucChb._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = "" + ucChb._Checked; AddData(nodeControl, sValue); break; case "ucComboBox": ucComboBox ucCbx = (ucComboBox)ctrl; XPath = ucCbx._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = "" + ucCbx._SelectedValue; AddData(nodeControl, sValue); break; case "ucDateTimePicker": ucDateTimePicker ucDtp = (ucDateTimePicker)ctrl; XPath = ucDtp._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = ucDtp._Day + "/" + ucDtp._Month + "/" + ucDtp._Year; AddData(nodeControl, sValue); break; case "ucRichTextBox": ucRichTextBox ucRtb = (ucRichTextBox)ctrl; XPath = ucRtb._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = ucRtb._Value; AddData(nodeControl, sValue); break; case "ucTextBox": ucTextBox ucTbx = (ucTextBox)ctrl; XPath = ucTbx._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = ucTbx._Value; AddData(nodeControl, sValue); break; case "ucPopup": ucPopup ucPP = (ucPopup)ctrl; XPath = ucPP._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = ucPP._Value; AddData(nodeControl, sValue); nodeControl.InnerText = ucPP._Text; break; case "ucDataGridView": ucDataGridView ucDGB = (ucDataGridView)ctrl; XPath = ucDGB._XPath; GetDataFromDataGridView(xmlDoc.SelectSingleNode(XPath), ucDGB); break; case "ucRadioButton": ucRadioButton ucRB = (ucRadioButton)ctrl; XPath = ucRB._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = ucRB._Value; AddData(nodeControl, sValue); break; case "ucPictureImage": ucPictureImage ucPI = (ucPictureImage)ctrl; XPath = ucPI._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = ucPI._imgBinary; int cCount = nodeControl.ChildNodes.Count; for (int j = 0; j < cCount; j++) { nodeControl.RemoveChild(nodeControl.ChildNodes[0]); } nodeControl.AppendChild(CreateCDataSection(sValue)); break; case "ucNumericUpDown": ucNumericUpDown ucNUD = (ucNumericUpDown)ctrl; XPath = ucNUD._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = "" + ucNUD._Value; AddData(nodeControl, sValue); break; case "ucDoubleTextBox": ucDoubleTextBox ucDTB = (ucDoubleTextBox)ctrl; XPath = ucDTB._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = ucDTB._Value; AddData(nodeControl, sValue.Replace(",", "")); break; } } return(true); }