private void initHeader(List <ServiceItemAttribute> attrs) { // 初始化列头 _dataList.Columns.Clear(); int widthTotal = 0; for (int index = 0; index < attrs.Count; index++) { ServiceItemAttribute attr = attrs[index]; if (attr == null || attr.IsShow == 0) { continue; } ColumnHeader newHeader = new ColumnHeader(); newHeader.Text = attr.KAlias; newHeader.Tag = attr; newHeader.Width = 100; widthTotal = widthTotal + 100; _dataList.Columns.Add(newHeader); } // 增加空列 ColumnHeader nullHeader = new ColumnHeader(); nullHeader.Text = ""; nullHeader.Width = _dataList.Width - widthTotal - 50; _dataList.Columns.Add(nullHeader); }
private void loadMenuData() { _dataList.Items.Clear(); for (int index = 0; index < GlobalConfig.SystemMenus.Count; index++) { ServiceItem menu = GlobalConfig.SystemMenus[index]; ListViewItem item = new ListViewItem(); item.Tag = menu; for (int inx = 0; inx < _item.ServiceItemAttrs.Count; inx++) { ServiceItemAttribute attr = _item.ServiceItemAttrs[inx]; if (inx == 0) { item.Text = ToolsUtils.GetObjectPropertyValue <ServiceItem>(menu, attr.KName); continue; } item.SubItems.Add(ToolsUtils.GetObjectPropertyValue <ServiceItem>(menu, attr.KName)); } //item.SubItems.Add(menu.Url); //item.SubItems.Add(menu.PUrlId); //item.SubItems.Add(menu.UrlId); //item.SubItems.Add(menu.ImageName); //item.SubItems.Add(menu.Inx.ToString()); //item.SubItems.Add((menu.IsVirtual == 0? "否":"是")); //item.SubItems.Add(menu.CmdString); _dataList.Items.Add(item); } }
private bool excuteDelete(ServiceItem deleProtocol, ServiceItem srvItem) { HsApply applyLogin = new HsApply(GlobalConfig.getUrlHead(), deleProtocol.CmdString); applyLogin.InvokeType = deleProtocol.getHttpType(OpertorType.Delete); for (int index = 0; index < deleProtocol.ServiceItemAttrs.Count; index++) { ServiceItemAttribute attr = deleProtocol.ServiceItemAttrs[index]; if (attr.KName == "PreApi") { continue; } HsParam param1 = attr.buildParam(applyLogin.InvokeType); param1.ParamValue = ToolsUtils.GetObjectPropertyValue <ServiceItem>(srvItem, attr.KName); applyLogin.addParam(param1); } HsResultData resultDat = applyLogin.excuteCommand(); //GlobalConfig.SystemProtocols.Clear(); if (resultDat.ErrorId == 200) { return(true); } //MessageBox.Show(resultDat.ErrorInfo); return(false); }
private void pbImage_Click(object sender, EventArgs e) { HsApply applyLogin = new HsApply(GlobalConfig.getUrlHead(), SrvItem.CmdString); applyLogin.InvokeType = SrvItem.getHttpType(_operType); //HsParam param1 = new HsParam("Account", userName.Text.ToString(), DataType.String, InvType.POST); //HsParam param2 = new HsParam("Password", ToolsUtils.Md5(userPassword.Text), DataType.String, InvType.POST); //applyLogin.addParam(param1); //applyLogin.addParam(param2); //for (int index = 0 ; index < SrvItem) for (int index = 0; index < SrvItem.ServiceItemAttrs.Count; index++) { ServiceItemAttribute attr = SrvItem.ServiceItemAttrs[index]; HsParam param1 = attr.buildParam(applyLogin.InvokeType); param1.ParamValue = ManageCtrl.getInputValue(attr.KName); applyLogin.addParam(param1); } HsResultData resultDat = applyLogin.excuteCommand(); //GlobalConfig.SystemProtocols.Clear(); if (resultDat.ErrorId == 200) { this.DialogResult = System.Windows.Forms.DialogResult.OK; return; } MessageBox.Show(resultDat.ErrorInfo); return; }
public object getInputValue(string kname) { for (int index = 0; index < this.Controls.Count; index++) { Control ctrl = this.Controls[index]; if (ctrl.Tag == null) { continue; } ServiceItemAttribute attr = ctrl.Tag as ServiceItemAttribute; if (attr.KName == kname) { if (ctrl is TextBox) { return(((TextBox)ctrl).Text); } else if (ctrl is RadioButton) { RadioButton rbt = (RadioButton)ctrl; if (rbt.Checked) { return(rbt.Text == "是" ? 1 : 0); } continue; } else if (ctrl is ComboBox) { ComboBox rbt = (ComboBox)ctrl; object selObj = rbt.SelectedItem; if (selObj == null) { return(null); } return(ToolsUtils.getObjectId(selObj)); } } } return(null); }
private void initCtrl() { int labWidth = 100; int ctrlHeight = 20; int xSep = 40; int rowSep = 25; for (int index = 0; index < SrvItem.ServiceItemAttrs.Count; index++) { ServiceItemAttribute attr = SrvItem.ServiceItemAttrs[index]; Label lab = new Label(); lab.Text = attr.KAlias; lab.Font = new System.Drawing.Font("宋体", 12); lab.Location = new Point(xSep, index * (rowSep + 20)); lab.Size = new Size(labWidth, ctrlHeight); this.Controls.Add(lab); if (attr.SelObjects == null || attr.SelObjects == "") { TextBox box = new TextBox(); box.Name = attr.KName; box.Font = new Font("宋体", 10); box.Location = new Point(xSep + labWidth + xSep, index * (rowSep + 20)); box.Size = new Size(150, ctrlHeight); if (OperType == OpertorType.Modi) { box.Text = ToolsUtils.GetObjectPropertyValue <ServiceItem>(SrvItem, attr.KName); } this.Controls.Add(box); box.Tag = attr; } else { string selString = attr.SelObjects.ToString(); if (selString.Contains("{") && selString.Contains("}")) { selString = selString.Replace("{", ""); selString = selString.Replace("}", ""); RadioButton rbtn1 = new RadioButton(); rbtn1.Text = selString.Split(':')[0].ToString(); rbtn1.Font = new Font("宋体", 10); rbtn1.Location = new Point(lab.Location.X + lab.Width + xSep, index * (rowSep + 20)); rbtn1.Size = new Size(50, ctrlHeight); rbtn1.Tag = attr; this.Controls.Add(rbtn1); RadioButton rbtn2 = new RadioButton(); rbtn2.Text = selString.Split(':')[1].ToString(); rbtn2.Font = new Font("宋体", 10); rbtn2.Location = new Point(rbtn1.Location.X + rbtn1.Width + 5, index * (rowSep + 20)); rbtn2.Size = new Size(50, ctrlHeight); this.Controls.Add(rbtn2); } else if (selString.Contains("$")) { ComboBox cbBox = new ComboBox(); cbBox.Name = attr.KName; cbBox.Font = new Font("宋体", 10); cbBox.Location = new Point(xSep + labWidth + xSep, index * (rowSep + 20)); cbBox.Size = new Size(150, ctrlHeight); cbBox.Tag = attr; string AttrName = selString.Replace("$", ""); cbBox.DataSource = ToolsUtils.GetStaticAttribute(AttrName); this.Controls.Add(cbBox); if (OperType == OpertorType.Modi) { string code = ToolsUtils.GetObjectPropertyValue <ServiceItem>(SrvItem, attr.KName); for (int inx = 0; inx < ((List <object>)cbBox.DataSource).Count; inx++) { object itemObj = ((List <object>)cbBox.DataSource)[inx]; string itemCode = ToolsUtils.getObjectId(itemObj); if (code == itemCode) { cbBox.SelectedIndex = inx; } } } } } } }