private void simpleButton2_Click(object sender, EventArgs e) //新建标签 { if (mtItem.Text != string.Empty) { LabelControl lctemp = new LabelControl(); lc.Add(lctemp); int index = lc.Count - 1; lc[index].Text = mtItem.Text; lc[index].BringToFront(); lc[index].Visible = true; this.pictureBox2.Controls.Add(lctemp); lc[index].MouseDown += new MouseEventHandler(control_MouseDown); lc[index].MouseMove += new MouseEventHandler(control_MouseMove); lc[index].Location = new Point(this.pictureBox2.Width / 2, this.pictureBox2.Height / 2); LogisticCompanyTemplateItem temp = new LogisticCompanyTemplateItem(); temp.LogisticCompanyItemCode = System.Guid.NewGuid().ToString(); temp.LogisticCompanyTemplateCode = templateCode; temp.ItemName = mtItem.Text; temp.ItemValue = mtItem.Text; temp.ItemX = pictureBox2.Width / 2; temp.ItemY = pictureBox2.Height / 2; LogisticCompanyTemplateItemService.AddLogisticCompanyTemplateItem(temp); lcti.Clear(); lcti = LogisticCompanyTemplateItemService.GetLogisticTemplateItems(templateCode); mtItem.Text = string.Empty; } }
private void NewTemplateItems(string TemplateCode) { foreach (LabelControl x in lc) { LogisticCompanyTemplateItem lctItem = new LogisticCompanyTemplateItem(); lctItem.ItemName = x.Text; lctItem.ItemValue = x.Text; lctItem.LogisticCompanyItemCode = System.Guid.NewGuid().ToString(); lctItem.LogisticCompanyTemplateCode = TemplateCode; lctItem.ItemX = x.Location.X; lctItem.ItemY = x.Location.Y; LogisticCompanyTemplateItemService.AddLogisticCompanyTemplateItem(lctItem); } }