// List rental window public void InitializeComponent(Form parent) { // Window parameters this.BackColor = ColorTranslator.FromHtml("#6d6a75"); this.Font = new Font(this.Font, FontStyle.Bold); this.Size = new Size(600, 640); this.parent = parent; // PictureBox this.pb_Lista = new Library.PictureBox(); this.pb_Lista.Location = new Point(50, 0); this.pb_Lista.Size = new Size(470, 80); this.pb_Lista.ClientSize = new Size(470, 80); this.pb_Lista.Load("./Views/assets/lista.jpg"); this.Controls.Add(pb_Lista); // ListView - Rentals this.lv_ListaLocacoes = new Library.ListView(); this.lv_ListaLocacoes.Location = new Point(20, 100); this.lv_ListaLocacoes.Size = new Size(540, 400); ListViewItem locacoes = new ListViewItem(); List <LocacaoModels> locacoesLista = LocacaoController.GetLocacoes(); foreach (var locacao in locacoesLista) { ListViewItem lv_ListaLocacao = new ListViewItem(locacao.IdLocacao.ToString()); ClienteModels cliente = ClienteController.GetCliente(locacao.IdCliente); lv_ListaLocacao.SubItems.Add(cliente.NomeCliente.ToString()); lv_ListaLocacao.SubItems.Add(cliente.CpfCliente.ToString()); lv_ListaLocacao.SubItems.Add(locacao.DataLocacao.ToString("dd/MM/yyyy")); lv_ListaLocacao.SubItems.Add(locacao.CalculoDataDevol().ToString("dd/MM/yyyy")); lv_ListaLocacao.SubItems.Add(locacao.QtdeFilmes().ToString()); lv_ListaLocacao.SubItems.Add(locacao.ValorTotal().ToString("C2")); lv_ListaLocacoes.Items.Add(lv_ListaLocacao); } this.lv_ListaLocacoes.MultiSelect = false; this.lv_ListaLocacoes.Columns.Add("ID", -2, HorizontalAlignment.Center); this.lv_ListaLocacoes.Columns.Add("Locatário", -2, HorizontalAlignment.Left); this.lv_ListaLocacoes.Columns.Add("CPF", -2, HorizontalAlignment.Center); this.lv_ListaLocacoes.Columns.Add("Data Locação", -2, HorizontalAlignment.Center); this.lv_ListaLocacoes.Columns.Add("Data Devolução", -2, HorizontalAlignment.Center); this.lv_ListaLocacoes.Columns.Add("Qtde Filmes", -2, HorizontalAlignment.Center); this.lv_ListaLocacoes.Columns.Add("Total", -2, HorizontalAlignment.Left); this.Controls.Add(lv_ListaLocacoes); // List grouping box this.gb_ListaLocacoes = new Library.GroupBox(); this.gb_ListaLocacoes.Location = new Point(10, 80); this.gb_ListaLocacoes.Size = new Size(560, 430); this.gb_ListaLocacoes.Text = "LISTA DE LOCAÇÕES"; this.Controls.Add(gb_ListaLocacoes); // Buttons this.btn_ListaSair = new Library.Button(); this.btn_ListaSair.Text = "SAIR"; this.btn_ListaSair.Location = new Point(200, 530); this.btn_ListaSair.Click += new EventHandler(this.btn_ListaSairClick); this.Controls.Add(btn_ListaSair); }
// List movie window public void InitializeComponent(Form parent) { // Window parameters this.BackColor = ColorTranslator.FromHtml("#6d6a75"); this.Font = new Font(this.Font, FontStyle.Bold); this.Size = new Size(600, 640); this.parent = parent; // PictureBox this.pb_Lista = new Library.PictureBox(); this.pb_Lista.Location = new Point(50, 0); this.pb_Lista.Size = new Size(470, 80); this.pb_Lista.ClientSize = new Size(470, 80); this.pb_Lista.Load("./Views/assets/lista.jpg"); this.Controls.Add(pb_Lista); // ListView - Movie this.lv_ListaFilmes = new Library.ListView(); this.lv_ListaFilmes.Location = new Point(20, 100); this.lv_ListaFilmes.Size = new Size(540, 400); ListViewItem filmes = new ListViewItem(); foreach (FilmeModels filme in FilmeController.GetFilmes()) { ListViewItem lv_ListaFilme = new ListViewItem(filme.IdFilme.ToString()); lv_ListaFilme.SubItems.Add(filme.Titulo); lv_ListaFilme.SubItems.Add(filme.DataLancamento); lv_ListaFilme.SubItems.Add(filme.ValorLocacaoFilme.ToString()); lv_ListaFilme.SubItems.Add(filme.EstoqueFilme.ToString()); lv_ListaFilme.SubItems.Add(filme.Sinopse); lv_ListaFilmes.Items.Add(lv_ListaFilme); } this.lv_ListaFilmes.MultiSelect = false; this.lv_ListaFilmes.Columns.Add("ID", -2, HorizontalAlignment.Center); this.lv_ListaFilmes.Columns.Add("Título", -2, HorizontalAlignment.Left); this.lv_ListaFilmes.Columns.Add("Data Lançamento", -2, HorizontalAlignment.Center); this.lv_ListaFilmes.Columns.Add("Valor", -2, HorizontalAlignment.Center); this.lv_ListaFilmes.Columns.Add("Estoque", -2, HorizontalAlignment.Center); this.lv_ListaFilmes.Columns.Add("Sinopse", -2, HorizontalAlignment.Left); this.Controls.Add(lv_ListaFilmes); // List grouping box this.gb_ListaFilmes = new Library.GroupBox(); this.gb_ListaFilmes.Location = new Point(10, 80); this.gb_ListaFilmes.Size = new Size(560, 430); this.gb_ListaFilmes.Text = "LISTA DE FILMES"; this.Controls.Add(gb_ListaFilmes); // Buttons this.btn_ListaSair = new Library.Button(); this.btn_ListaSair.Location = new Point(200, 530); this.btn_ListaSair.Text = "SAIR"; this.btn_ListaSair.Click += new EventHandler(btn_ListaSairClick); this.Controls.Add(btn_ListaSair); }
// List customer window public void InitializeComponent(Form parent) { // Window parameters this.BackColor = ColorTranslator.FromHtml("#6d6a75"); this.Font = new Font(this.Font, FontStyle.Bold); this.Size = new Size(500, 640); this.parent = parent; // PictureBox this.pb_Lista = new Library.PictureBox(); this.pb_Lista.Size = new Size(460, 75); this.pb_Lista.Load("./Views/assets/lista.jpg"); this.Controls.Add(pb_Lista); // ListView - Customer this.lv_ListaClientes = new Library.ListView(); this.lv_ListaClientes.Location = new Point(20, 100); this.lv_ListaClientes.Size = new Size(440, 400); ListViewItem clientes = new ListViewItem(); List <ClienteModels> clientesLista = ClienteController.GetClientes(); foreach (var cliente in clientesLista) { ListViewItem lv_ListaCliente = new ListViewItem(cliente.IdCliente.ToString()); lv_ListaCliente.SubItems.Add(cliente.NomeCliente); lv_ListaCliente.SubItems.Add(cliente.DataNascimento); lv_ListaCliente.SubItems.Add(cliente.CpfCliente); lv_ListaCliente.SubItems.Add(cliente.DiasDevolucao.ToString()); lv_ListaClientes.Items.Add(lv_ListaCliente); } this.lv_ListaClientes.MultiSelect = false; this.lv_ListaClientes.Columns.Add("ID", -2, HorizontalAlignment.Center); this.lv_ListaClientes.Columns.Add("Nome", -2, HorizontalAlignment.Left); this.lv_ListaClientes.Columns.Add("Data Nascimento", -2, HorizontalAlignment.Center); this.lv_ListaClientes.Columns.Add("CPF", -2, HorizontalAlignment.Center); this.lv_ListaClientes.Columns.Add("Dias Devolução", -2, HorizontalAlignment.Center); this.Controls.Add(lv_ListaClientes); // List grouping box this.gb_ListaClientes = new Library.GroupBox(); this.gb_ListaClientes.Location = new Point(10, 80); this.gb_ListaClientes.Size = new Size(460, 430); this.gb_ListaClientes.Text = "LISTA DE CLIENTES"; this.Controls.Add(gb_ListaClientes); // Buttons this.btn_ListaSair = new Library.Button(); this.btn_ListaSair.Location = new Point(160, 530); this.btn_ListaSair.Text = "SAIR"; this.btn_ListaSair.Click += new EventHandler(btn_ListaSairClick); this.Controls.Add(btn_ListaSair); }
// Customer data entry public void InitializeComponent(Form parent, bool isUpdate) { this.BackColor = ColorTranslator.FromHtml("#6d6a75"); this.Font = new Font(this.Font, FontStyle.Bold); this.Size = new Size(500, 400); this.parent = parent; if (isUpdate) { this.Load += new EventHandler(this.LoadForm); } // PictureBox - Using Property Bind this.pb_Cadastro = new Library.PictureBox(); this.pb_Cadastro.Location = new Point(0, 10); this.pb_Cadastro.Size = new Size(480, 100); this.pb_Cadastro.ClientSize = new Size(480, 80); this.pb_Cadastro.Load($"./Views/assets/{(isUpdate ? "alteracao" : "cadastra")}.jpg"); this.Controls.Add(pb_Cadastro); // Fill orientation tip this.tt_Help = new Library.ToolTip(); // Label this.lbl_Nome = new Library.Label(); this.lbl_Nome.Text = "Nome :"; this.lbl_Nome.Location = new Point(20, 100); this.Controls.Add(lbl_Nome); this.lbl_DataNasc = new Library.Label(); this.lbl_DataNasc.Text = "Data de Nascimento :"; this.lbl_DataNasc.Location = new Point(20, 140); this.Controls.Add(lbl_DataNasc); this.lbl_CPF = new Library.Label(); this.lbl_CPF.Text = "CPF :"; this.lbl_CPF.Location = new Point(20, 180); this.Controls.Add(lbl_CPF); this.lbl_DiasDevol = new Library.Label(); this.lbl_DiasDevol.Text = "Dias P/ Devolução :"; this.lbl_DiasDevol.Location = new Point(20, 220); this.Controls.Add(lbl_DiasDevol); // RichTextBox (Edited text) this.rtxt_NomeCliente = new Library.RichTextBox(); this.tt_Help.SetToolTip(rtxt_NomeCliente, "Digite o nome completo"); this.Controls.Add(rtxt_NomeCliente); // NumericUpDown this.num_DataNascDia = new NumericUpDown(); this.num_DataNascDia.Location = new Point(150, 140); this.num_DataNascDia.Size = new Size(50, 20); this.num_DataNascDia.Enter += new EventHandler(this.num_DataNascimento_Enter); this.num_DataNascDia.Minimum = 0; this.num_DataNascDia.Maximum = 31; this.Controls.Add(num_DataNascDia); this.num_DataNascMes = new NumericUpDown(); this.num_DataNascMes.Location = new Point(210, 140); this.num_DataNascMes.Size = new Size(50, 20); this.num_DataNascMes.Enter += new EventHandler(this.num_DataNascimento_Enter); this.num_DataNascMes.Minimum = 0; this.num_DataNascMes.Maximum = 12; this.Controls.Add(num_DataNascMes); this.num_DataNascAno = new NumericUpDown(); this.num_DataNascAno.Location = new Point(270, 140); this.num_DataNascAno.Size = new Size(50, 20); this.num_DataNascAno.Enter += new EventHandler(this.num_DataNascimento_Enter); this.num_DataNascAno.Minimum = 1930; this.num_DataNascAno.Maximum = 2020; this.Controls.Add(num_DataNascAno); // MaskedTextBox this.mtxt_CpfCLiente = new Library.MaskedTextBox(); this.mtxt_CpfCLiente.Mask = "000,000,000-00"; this.mtxt_CpfCLiente.ReadOnly = isUpdate; this.Controls.Add(mtxt_CpfCLiente); //mtxt_CpfCLiente.SelectionStart = mtxt_CpfCLiente.Text.Length + 1; // ComboBox this.cb_DiasDevol = new ComboBox(); this.cb_DiasDevol.Items.Add("2 Dias"); this.cb_DiasDevol.Items.Add("3 Dias"); this.cb_DiasDevol.Items.Add("4 Dias"); this.cb_DiasDevol.Items.Add("5 Dias"); this.cb_DiasDevol.Items.Add("PLUS - 10 Dias"); this.cb_DiasDevol.AutoCompleteMode = AutoCompleteMode.Append; this.cb_DiasDevol.Location = new Point(150, 220); this.cb_DiasDevol.Size = new Size(170, 20); this.Controls.Add(cb_DiasDevol); // Buttons this.btn_Confirmar = new Library.Button(); this.btn_Confirmar.Text = "CONFIRMAR"; this.btn_Confirmar.Location = new Point(80, 280); this.btn_Confirmar.Click += new EventHandler(this.btn_ConfirmarClick); this.Controls.Add(btn_Confirmar); this.btn_Cancelar = new Library.Button(); this.btn_Cancelar.Text = "CANCELAR"; this.btn_Cancelar.Location = new Point(260, 280); this.btn_Cancelar.Click += new EventHandler(this.btn_CancelarClick); this.Controls.Add(btn_Cancelar); }
// Rent data entry public void InitializeComponent(Form parent) { // Window parameters this.BackColor = ColorTranslator.FromHtml("#6d6a75"); this.Font = new Font(this.Font, FontStyle.Bold); this.Size = new Size(500, 580); this.parent = parent; // PictureBox this.pb_Cadastro = new Library.PictureBox(); this.pb_Cadastro.Load($"./Views/assets/cadastra.jpg"); this.Controls.Add(pb_Cadastro); this.lbl_BuscaCliente = new Library.Label(); this.lbl_BuscaCliente.Text = "Busca Cliente :"; this.lbl_BuscaCliente.Location = new Point(30, 80); this.Controls.Add(lbl_BuscaCliente); this.lbl_BuscaFilme = new Library.Label(); this.lbl_BuscaFilme.Text = "Busca Filme :"; this.lbl_BuscaFilme.Location = new Point(30, 270); this.Controls.Add(lbl_BuscaFilme); // Fill orientation tip this.tt_BuscaCliente = new Library.ToolTip(); // RichTextBox (Edited text - Keypress mode to filter a customer in ListView) this.rtxt_BuscaCliente = new Library.RichTextBox(); this.rtxt_BuscaCliente.Location = new Point(150, 80); this.Controls.Add(rtxt_BuscaCliente); this.tt_BuscaCliente.SetToolTip(rtxt_BuscaCliente, "Digite o nome ou selecione abaixo"); this.rtxt_BuscaCliente.KeyPress += new KeyPressEventHandler(keypressed1); // Fill orientation tip this.tt_BuscaFilme = new Library.ToolTip(); // RichTextBox (Edited text - Keypress mode to filter a movie in ListView) this.rtxt_BuscaFilme = new Library.RichTextBox(); this.rtxt_BuscaFilme.Location = new Point(150, 270); this.Controls.Add(rtxt_BuscaFilme); this.tt_BuscaFilme.SetToolTip(rtxt_BuscaFilme, "Digite o título ou selecione abaixo"); this.rtxt_BuscaFilme.KeyPress += new KeyPressEventHandler(keypressed2); // ListView - Customer this.lv_ListaClientes = new Library.ListView(); this.lv_ListaClientes.Location = new Point(40, 130); this.lv_ListaClientes.Size = new Size(400, 120); List <ClienteModels> listaCliente = (from cliente in ClienteController.GetClientes() where cliente.NomeCliente.Contains(rtxt_BuscaCliente.Text) select cliente).ToList(); ListViewItem clientes = new ListViewItem(); foreach (ClienteModels cliente in ClienteController.GetClientes()) { ListViewItem lv_ListaCliente = new ListViewItem(cliente.IdCliente.ToString()); lv_ListaCliente.SubItems.Add(cliente.NomeCliente); lv_ListaCliente.SubItems.Add(cliente.DataNascimento); lv_ListaCliente.SubItems.Add(cliente.CpfCliente); lv_ListaCliente.SubItems.Add(cliente.DiasDevolucao.ToString()); lv_ListaClientes.Items.Add(lv_ListaCliente); } this.lv_ListaClientes.MultiSelect = false; this.lv_ListaClientes.Columns.Add("ID", -2, HorizontalAlignment.Center); this.lv_ListaClientes.Columns.Add("Nome", -2, HorizontalAlignment.Left); this.lv_ListaClientes.Columns.Add("Data Nascimento", -2, HorizontalAlignment.Center); this.lv_ListaClientes.Columns.Add("CPF", -2, HorizontalAlignment.Center); this.lv_ListaClientes.Columns.Add("Dias Devolução", -2, HorizontalAlignment.Center); this.Controls.Add(lv_ListaClientes); // ListView grouping box this.gb_ListaCliente = new Library.GroupBox(); this.gb_ListaCliente.Location = new Point(30, 110); this.gb_ListaCliente.Size = new Size(420, 150); this.gb_ListaCliente.Text = "LISTA DE CLIENTES"; this.Controls.Add(gb_ListaCliente); // ListView - Movies this.lv_ListaFilmes = new Library.ListView(); this.lv_ListaFilmes.Location = new Point(40, 320); this.lv_ListaFilmes.Size = new Size(400, 120); this.lv_ListaFilmes.CheckBoxes = true; List <FilmeModels> listaFilme = (from filme in FilmeController.GetFilmes() where filme.Titulo.Contains(rtxt_BuscaFilme.Text) select filme).ToList(); ListViewItem filmes = new ListViewItem(); foreach (FilmeModels filme in FilmeController.GetFilmes()) { ListViewItem lv_ListaFilme = new ListViewItem(filme.IdFilme.ToString()); lv_ListaFilme.SubItems.Add(filme.Titulo); lv_ListaFilme.SubItems.Add(filme.DataLancamento); lv_ListaFilme.SubItems.Add(filme.ValorLocacaoFilme.ToString()); lv_ListaFilme.SubItems.Add(filme.EstoqueFilme.ToString()); lv_ListaFilme.SubItems.Add(filme.Sinopse); lv_ListaFilmes.Items.Add(lv_ListaFilme); } this.lv_ListaFilmes.Columns.Add("ID", -2, HorizontalAlignment.Center); this.lv_ListaFilmes.Columns.Add("Título", -2, HorizontalAlignment.Left); this.lv_ListaFilmes.Columns.Add("Data Lançamento", -2, HorizontalAlignment.Center); this.lv_ListaFilmes.Columns.Add("Preço", -2, HorizontalAlignment.Center); this.lv_ListaFilmes.Columns.Add("Estoque", -2, HorizontalAlignment.Center); this.lv_ListaFilmes.Columns.Add("Sinopse", -2, HorizontalAlignment.Left); this.Controls.Add(lv_ListaFilmes); Task t = new Task(new Action(() => { RefreshForm(); })); t.Start(); // ListView grouping box this.gb_ListaFilme = new Library.GroupBox(); this.gb_ListaFilme.Location = new Point(30, 300); this.gb_ListaFilme.Size = new Size(420, 150); this.gb_ListaFilme.Text = "LISTA DE FILMES"; this.Controls.Add(gb_ListaFilme); // Buttons this.btn_Confirmar = new Library.Button(); this.btn_Confirmar.Text = "CONFIRMAR"; this.btn_Confirmar.Location = new Point(80, 470); this.btn_Confirmar.Click += new EventHandler(this.btn_ConfirmarClick); this.Controls.Add(btn_Confirmar); this.btn_Cancelar = new Library.Button(); this.btn_Cancelar.Text = "CANCELAR"; this.btn_Cancelar.Location = new Point(260, 470); this.btn_Cancelar.Click += new EventHandler(this.btn_CancelarClick); this.Controls.Add(btn_Cancelar); }
//打开一个编辑画面 public void OpenOneForm(String name) { //需新增功能: 所有form只打开一次 for (int i = 0; i < editFormList.Count; i++) { if (editFormList[i].currentName == name) { editFormList[i].Show(); return; } } RunTimeForm m_RTeditWindow = new RunTimeForm(this); try { string fileName = myProjectPath + name + ".xml"; HostControl hc = _hostSurfaceManager.LoadNewHost(fileName); m_RTeditWindow.parentForm = this; m_RTeditWindow.currentName = name; m_RTeditWindow.Text = name; m_RTeditWindow.TabText = name; editFormList.Add(m_RTeditWindow); //填充画面 UserControl f = new UserControl(); UserControl user = (UserControl)_hostSurfaceManager.basicHostLoader.mComponents[0]; f.BackColor = user.BackColor; f.BackgroundImage = user.BackgroundImage; f.BackgroundImageLayout = user.BackgroundImageLayout; f.BorderStyle = user.BorderStyle; f.Font = user.Font; f.ForeColor = user.ForeColor; f.Size = user.Size; f.Location = new Point(0, 0);// user.Location; f.Name = user.Name; #region 填充元件 string nodeString = null; List <string> dllFailList = new List <string>(); //自定义控件出现错误的列表 for (int i = 1; i < _hostSurfaceManager.basicHostLoader.mComponents.Count; i++) { Type t = _hostSurfaceManager.basicHostLoader.mComponents[i].GetType(); //自定义控件的处理--> nodeString = "Components/AddedComponent[@Name=\"" + t.Name + "\"]";//注意这里AddedComponent作为与原先的区别 XmlNode tmpXNode = mXDoc.SelectSingleNode(nodeString); if (tmpXNode != null) { //XmlNode test = tmpXNode.SelectSingleNode("Asm"); string asmStr = tmpXNode.Attributes["Asm"].Value; Assembly assembly = null; if (asmStr.Substring(asmStr.Length - 3) == "dll" || asmStr.Substring(asmStr.Length - 3) == "DLL") { if (File.Exists(@dllmng.DLLPATH + asmStr)) { assembly = Assembly.LoadFile(dllmng.DLLPATH + asmStr); } else { if (!dllFailList.Contains("Can not find DLL: " + asmStr + " in file " + dllmng.DLLPATH)) { dllFailList.Add("Can not find DLL: " + asmStr + " in file " + dllmng.DLLPATH); } continue; } } else { if (File.Exists(@dllmng.DLLPATH + asmStr + ".dll")) { assembly = Assembly.LoadFile(dllmng.DLLPATH + asmStr + ".dll"); } else { if (!dllFailList.Contains("Can not find DLL: " + asmStr + ".dll" + " in file " + dllmng.DLLPATH)) { dllFailList.Add("Can not find DLL: " + asmStr + ".dll" + " in file " + dllmng.DLLPATH); } continue; } } Type type = assembly.GetType(t.FullName.ToString()); //类名称 Object obj = System.Activator.CreateInstance(type); Object objInXml = _hostSurfaceManager.basicHostLoader.mComponents[i]; Type typeInXml = _hostSurfaceManager.basicHostLoader.mComponents[i].GetType(); ArrayList mObjectAttribs = new ArrayList(); if (tmpXNode != null) { try { XmlNodeList tmpXPropLst = tmpXNode.SelectNodes("Propertys/Property"); XmlNode m_tmpXNode; IEnumerator tmpIe = tmpXPropLst.GetEnumerator(); while (tmpIe.MoveNext()) { m_tmpXNode = tmpIe.Current as XmlNode; mObjectAttribs.Add(m_tmpXNode.Attributes["Name"].Value); } } catch { } } foreach (string arr in mObjectAttribs) { try { object arrObj = typeInXml.GetProperty(arr).GetValue(objInXml, null); //get type.GetProperty(arr).SetValue(obj, arrObj, null); //set } catch (Exception ex) { MessageBox.Show(ex.Message); } } f.Controls.Add((Control)obj); //<---- } if (t.Name.Equals("PictureBox")) { Library.PictureBox control = (Library.PictureBox)Activator.CreateInstance(t); Library.PictureBox cs = (Library.PictureBox)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.BackColor = cs.BackColor; control.BorderStyle = cs.BorderStyle; control.Image = cs.Image; control.SizeMode = cs.SizeMode; control.Size = cs.Size; control.Location = cs.Location; control.Name = cs.Name; //增加运行时标志,目的仅为可见性使用!!! control.isVisible = cs.isVisible; //增加退出keydown 事件 control.KeyDown += new KeyEventHandler(control_KeyDown); f.Controls.Add(control); } if (t.Name.Equals("Button")) { Library.Button control = (Library.Button)Activator.CreateInstance(t); Library.Button cs = (Library.Button)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.BackColor = cs.BackColor; control.Image = cs.Image; control.ImageAlign = cs.ImageAlign; control.Font = cs.Font; control.ForeColor = cs.ForeColor; control.FlatStyle = cs.FlatStyle; control.Text = cs.Text; control.TextAlign = cs.TextAlign; control.TextImageRelation = cs.TextImageRelation; control.Size = cs.Size; control.Location = cs.Location; control.Name = cs.Name; control.KeyDown += new KeyEventHandler(control_KeyDown); f.Controls.Add(control); } if (t.Name.Equals("SendButton")) { Library.SendButton control = (Library.SendButton)Activator.CreateInstance(t); Library.SendButton cs = (Library.SendButton)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.BackColor = cs.BackColor; control.BorderStyle = cs.BorderStyle; control.Font = cs.Font; control.ForeColor = cs.ForeColor; control.Text = cs.Text; control.Size = cs.Size; control.Location = cs.Location; control.Name = cs.Name; //增加运行时标志,目的仅为可见性使用!!! // control.isVisible = cs.isVisible; control.ID = cs.ID; control.RelatedDeviceType = cs.RelatedDeviceType; control.BoardNumber = cs.BoardNumber; control.RelatedPort = cs.RelatedPort; control.DeviceName = cs.DeviceName; control.rtdm = rtdm; //control.Enabled = false; //选中无光标闪烁 //增加退出keydown 事件 control.KeyDown += new KeyEventHandler(control_KeyDown); f.Controls.Add(control); } if (t.Name.Equals("TextBox")) { Library.TextBox control = (Library.TextBox)Activator.CreateInstance(t); Library.TextBox cs = (Library.TextBox)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.BackColor = cs.BackColor; control.BorderStyle = cs.BorderStyle; control.Font = cs.Font; control.ForeColor = cs.ForeColor; control.Text = cs.Text; control.TextAlign = cs.TextAlign; control.Size = cs.Size; control.Location = cs.Location; control.Name = cs.Name; //增加运行时标志,目的仅为可见性使用!!! control.isVisible = cs.isVisible; control.ID = cs.ID; control.RelatedDeviceType = cs.RelatedDeviceType; control.BoardNumber = cs.BoardNumber; control.RelatedPort = cs.RelatedPort; control.DeviceName = cs.DeviceName; control.rtdm = rtdm; //control.Enabled = false; //选中无光标闪烁 //增加退出keydown 事件 control.KeyDown += new KeyEventHandler(control_KeyDown); f.Controls.Add(control); } if (t.Name.Equals("Lable")) { Library.Lable control = (Library.Lable)Activator.CreateInstance(t); Library.Lable cs = (Library.Lable)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.BackColor = cs.BackColor; control.BorderStyle = cs.BorderStyle; control.Font = cs.Font; control.ForeColor = cs.ForeColor; control.Text = cs.Text; control.TextAlign = cs.TextAlign; control.Size = cs.Size; control.Location = cs.Location; control.Name = cs.Name; //增加退出keydown 事件 control.KeyDown += new KeyEventHandler(control_KeyDown); f.Controls.Add(control); } if (t.Name.Equals("LDDS")) { Library.LDDS.Module control = (Library.LDDS.Module)Activator.CreateInstance(t); Library.LDDS.Module cs = (Library.LDDS.Module)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.BackColor = cs.BackColor; control.Size = cs.Size; control.Location = cs.Location; control.Name = cs.Name; control.InterfaceName = cs.InterfaceName; control.OnDrawLineClick += new Library.LDDS.Module.OnDrawLineEventHandle(Control_OnDrawLineClick); f.Controls.Add(control); } if (t.Name.Equals("ArrowLink")) { Library.LDDS.ArrowLink control = (Library.LDDS.ArrowLink)Activator.CreateInstance(t); Library.LDDS.ArrowLink cs = (Library.LDDS.ArrowLink)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.BackColor = cs.BackColor; control.Size = cs.Size; control.Location = cs.Location; control.Name = cs.Name; control.InterfaceName = cs.InterfaceName; control.ArrowName = cs.ArrowName; if (control.ArrowName.ToString() == "WaterMixingArrow") { this.BackgroundImage = global::Designer.Properties.Resources.WaterMixingArrow_new; } else if (control.ArrowName.ToString() == "ThermistorArrow") { this.BackgroundImage = global::Designer.Properties.Resources.ThermistorArrow; } else if (control.ArrowName.ToString() == "VibTestingArrow") { this.BackgroundImage = global::Designer.Properties.Resources.VibTestingArrow; } else if (control.ArrowName.ToString() == "FlowtestingArrow") { this.BackgroundImage = global::Designer.Properties.Resources.FlowTestingArrow_new; } else if (control.ArrowName.ToString() == "LengthArrow") { this.BackgroundImage = global::Designer.Properties.Resources.LengthArrow; } else if (control.ArrowName.ToString() == "HumidityArrow") { this.BackgroundImage = global::Designer.Properties.Resources.HumidityArrow; } //control.BackgroundImage = global::Library.Properties.Resources.VibTestingArrow; control.OnDrawLineClick += new Library.LDDS.Module.OnDrawLineEventHandle(Control_OnDrawLineClick); f.Controls.Add(control); } if (t.Name.Equals("Regenerator1")) { Library.LDDS.Regenerator1 control = (Library.LDDS.Regenerator1)Activator.CreateInstance(t); Library.LDDS.Regenerator1 cs = (Library.LDDS.Regenerator1)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.BackColor = cs.BackColor; control.Size = cs.Size; control.Location = cs.Location; control.Name = cs.Name; control.BoardNumber = cs.BoardNumber; control.InterfaceName = cs.InterfaceName; control.rtdm = rtdm; control.OnDrawLineClick += new Library.LDDS.Regenerator1.OnDrawLineEventHandle(Control_OnDrawLineClick); f.Controls.Add(control); } if (t.Name.Equals("Regenerator2")) { Library.LDDS.Regenerator2 control = (Library.LDDS.Regenerator2)Activator.CreateInstance(t); Library.LDDS.Regenerator2 cs = (Library.LDDS.Regenerator2)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.BackColor = cs.BackColor; control.Size = cs.Size; control.Location = cs.Location; control.Name = cs.Name; control.BoardNumber = cs.BoardNumber; control.InterfaceName = cs.InterfaceName; control.rtdm = rtdm; control.OnDrawLineClick += new Library.LDDS.Regenerator2.OnDrawLineEventHandle(Control_OnDrawLineClick); f.Controls.Add(control); } if (t.Name.Equals("Regenerator3")) { Library.LDDS.Regenerator3 control = (Library.LDDS.Regenerator3)Activator.CreateInstance(t); Library.LDDS.Regenerator3 cs = (Library.LDDS.Regenerator3)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.BackColor = cs.BackColor; control.Size = cs.Size; control.Location = cs.Location; control.Name = cs.Name; control.BoardNumber = cs.BoardNumber; control.InterfaceName = cs.InterfaceName; control.rtdm = rtdm; control.OnDrawLineClick += new Library.LDDS.Regenerator2.OnDrawLineEventHandle(Control_OnDrawLineClick); f.Controls.Add(control); } if (t.Name.Equals("Regenerator4")) { Library.LDDS.Regenerator4 control = (Library.LDDS.Regenerator4)Activator.CreateInstance(t); Library.LDDS.Regenerator4 cs = (Library.LDDS.Regenerator4)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.BackColor = cs.BackColor; control.Size = cs.Size; control.Location = cs.Location; control.Name = cs.Name; control.BoardNumber = cs.BoardNumber; control.InterfaceName = cs.InterfaceName; control.rtdm = rtdm; control.OnDrawLineClick += new Library.LDDS.Regenerator2.OnDrawLineEventHandle(Control_OnDrawLineClick); f.Controls.Add(control); } if (t.Name.Equals("Dehumidifier1")) { Library.LDDS.Dehumidifier1 control = (Library.LDDS.Dehumidifier1)Activator.CreateInstance(t); Library.LDDS.Dehumidifier1 cs = (Library.LDDS.Dehumidifier1)_hostSurfaceManager.basicHostLoader.mComponents[i]; DataBus.DataAccess.CData_PointTable dataPT = new DataBus.DataAccess.CData_PointTable(); control.BackColor = cs.BackColor; control.Size = cs.Size; control.Location = cs.Location; control.Name = cs.Name; control.DeviceName = control.DeviceName; control.InterfaceName = cs.InterfaceName; control.BoardNumber = cs.BoardNumber; control.rtdm = rtdm; control.OnDrawLineClick += new Library.LDDS.Dehumidifier1.OnDrawLineEventHandle(Control_OnDrawLineClick); f.Controls.Add(control); } if (t.Name.Equals("Dehumidifier2")) { Library.LDDS.Dehumidifier2 control = (Library.LDDS.Dehumidifier2)Activator.CreateInstance(t); Library.LDDS.Dehumidifier2 cs = (Library.LDDS.Dehumidifier2)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.BackColor = cs.BackColor; control.Size = cs.Size; control.Location = cs.Location; control.Name = cs.Name; control.InterfaceName = cs.InterfaceName; control.BoardNumber = cs.BoardNumber; control.rtdm = rtdm; control.OnDrawLineClick += new Library.LDDS.Dehumidifier2.OnDrawLineEventHandle(Control_OnDrawLineClick); f.Controls.Add(control); } if (t.Name.Equals("Dehumidifier3")) { Library.LDDS.Dehumidifier3 control = (Library.LDDS.Dehumidifier3)Activator.CreateInstance(t); Library.LDDS.Dehumidifier3 cs = (Library.LDDS.Dehumidifier3)_hostSurfaceManager.basicHostLoader.mComponents[i]; DataBus.DataAccess.CData_PointTable dataPT = new DataBus.DataAccess.CData_PointTable(); control.BackColor = cs.BackColor; control.Size = cs.Size; control.Location = cs.Location; control.Name = cs.Name; control.DeviceName = control.DeviceName; control.InterfaceName = cs.InterfaceName; control.BoardNumber = cs.BoardNumber; control.rtdm = rtdm; control.OnDrawLineClick += new Library.LDDS.Dehumidifier1.OnDrawLineEventHandle(Control_OnDrawLineClick); f.Controls.Add(control); } if (t.Name.Equals("Dehumidifier4")) { Library.LDDS.Dehumidifier4 control = (Library.LDDS.Dehumidifier4)Activator.CreateInstance(t); Library.LDDS.Dehumidifier4 cs = (Library.LDDS.Dehumidifier4)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.BackColor = cs.BackColor; control.Size = cs.Size; control.Location = cs.Location; control.Name = cs.Name; control.InterfaceName = cs.InterfaceName; control.BoardNumber = cs.BoardNumber; control.rtdm = rtdm; control.OnDrawLineClick += new Library.LDDS.Dehumidifier2.OnDrawLineEventHandle(Control_OnDrawLineClick); f.Controls.Add(control); } if (t.Name.Equals("AtoMain")) { // AutotunerFinVerOne.AtoMain control = new AutotunerFinVerOne.AtoMain(); // AutotunerFinVerOne.AtoMain cs = (AutotunerFinVerOne.AtoMain)_hostSurfaceManager.basicHostLoader.mComponents[i]; // control.ret_val = "AHU B4_309 Supply Air Temp Control Loop"; // cs.ret_val = "AHU B4_309 Supply Air Temp Control Loop"; // control.BackColor = cs.BackColor; // control.Size = cs.Size; // control.Location = cs.Location; // //control.Name = cs.Name; // f.Controls.Add(control); } //if (t.Name.Equals("ButtonCheck")) //{ // // SBB_ACMV.Controls.ButtonCheck control = (SBB_ACMV.Controls.ButtonCheck)Activator.CreateInstance(t); // // SBB_ACMV.Controls.ButtonCheck cs = (SBB_ACMV.Controls.ButtonCheck)_hostSurfaceManager.basicHostLoader.mComponents[i]; // // control.BoardNo = cs.BoardNo; // // //control.BoardNoText = cs.BoardNoText; // // control.loopNo = cs.loopNo; // // //control.loopNoText = cs.loopNoText; // // control.BackColor = cs.BackColor; // // control.Name = cs.Name; // // control.Size = cs.Size; // // control.Location = cs.Location; // // //control.Name = cs.Name; // // f.Controls.Add(control); //} if (t.Name.Equals("SendButton")) { Library.SendButton control = (Library.SendButton)Activator.CreateInstance(t); Library.SendButton cs = (Library.SendButton)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.PortData = cs.PortData; control.PortBind = cs.PortBind; control.RelatedPort = cs.RelatedPort; control.BoardNumber = cs.BoardNumber; control.DeviceName = cs.DeviceName; control.BackColor = cs.BackColor; control.Name = cs.Name; control.Size = cs.Size; control.Location = cs.Location; //control.Name = cs.Name; f.Controls.Add(control); } if (t.Name.Equals("statusIndicator")) { Library.statusIndicator control = (Library.statusIndicator)Activator.CreateInstance(t); Library.statusIndicator cs = (Library.statusIndicator)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.RelatedPort = cs.RelatedPort; control.BoardNumber = cs.BoardNumber; control.DeviceName = cs.DeviceName; control.BackColor = cs.BackColor; control.Name = cs.Name; control.Size = cs.Size; control.Location = cs.Location; //control.Name = cs.Name; f.Controls.Add(control); control.rtdm = rtdm; } if (t.Name.Equals("levelmeter")) { Library.Common.levelmeter control = (Library.Common.levelmeter)Activator.CreateInstance(t); Library.Common.levelmeter cs = (Library.Common.levelmeter)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.RelatedPort = cs.RelatedPort; control.BoardNumber = cs.BoardNumber; control.DeviceName = cs.DeviceName; control.BackColor = cs.BackColor; control.Value = cs.Value; control.Name = cs.Name; control.Size = cs.Size; control.Location = cs.Location; control.rtdm = rtdm; f.Controls.Add(control); } if (t.Name.Equals("ButtonCheck")) { Library.Common.ButtonCheck control = (Library.Common.ButtonCheck)Activator.CreateInstance(t); Library.Common.ButtonCheck cs = (Library.Common.ButtonCheck)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.PortData = cs.PortData; control.PortBind = cs.PortBind; control.RelatedPort = cs.RelatedPort; control.BoardNumber = cs.BoardNumber; control.DeviceName = cs.DeviceName; control.BackColor = cs.BackColor; control.Name = cs.Name; control.Size = cs.Size; control.Location = cs.Location; control.CheckStyleX = cs.CheckStyleX; control.CheckCurrentState(); //control.Name = cs.Name; f.Controls.Add(control); } if (t.Name.Equals("ButtonCheckFun")) { Library.Common.ButtonCheckFun control = (Library.Common.ButtonCheckFun)Activator.CreateInstance(t); Library.Common.ButtonCheckFun cs = (Library.Common.ButtonCheckFun)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.PortData = cs.PortData; control.PortBind = cs.PortBind; control.RelatedPort = cs.RelatedPort; control.BoardNumber = cs.BoardNumber; control.DeviceName = cs.DeviceName; control.BackColor = cs.BackColor; control.Name = cs.Name; control.Size = cs.Size; control.Location = cs.Location; control.CheckStyleX = cs.CheckStyleX; control.CheckCurrentState(); //control.Name = cs.Name; f.Controls.Add(control); } //if (t.Name.Equals("OnOff")) //{ // Library.Common.CommunicationOnOff control = (Library.Common.CommunicationOnOff)Activator.CreateInstance(t); // Library.Common.CommunicationOnOff cs = (Library.Common.CommunicationOnOff)_hostSurfaceManager.basicHostLoader.mComponents[i]; // control.PortData = cs.PortData; // control.PortBind = cs.PortBind; // control.RelatedPort = cs.RelatedPort; // control.BoardNumber = cs.BoardNumber; // control.DeviceName = cs.DeviceName; // control.BackColor = cs.BackColor; // control.Name = cs.Name; // control.Size = cs.Size; // control.Location = cs.Location; // control.CheckStyleX = cs.CheckStyleX; // control.CheckCurrentState(); // //control.Name = cs.Name; // f.Controls.Add(control); //} if (t.Name.Equals("Alarm")) { Library.Common.Alarm control = (Library.Common.Alarm)Activator.CreateInstance(t); Library.Common.Alarm cs = (Library.Common.Alarm)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.RelatedPort = cs.RelatedPort; control.BoardNumber = cs.BoardNumber; control.UpLimit = cs.UpLimit; control.DownLimit = cs.DownLimit; control.BackColor = cs.BackColor; control.Name = cs.Name; control.Size = cs.Size; control.Location = cs.Location; control.rtdm = rtdm; //control.Name = cs.Name; f.Controls.Add(control); } if (t.Name.Equals("RunState")) { Library.Common.RunState control = (Library.Common.RunState)Activator.CreateInstance(t); Library.Common.RunState cs = (Library.Common.RunState)_hostSurfaceManager.basicHostLoader.mComponents[i]; control.RelatedPort = cs.RelatedPort; control.BoardNumber = cs.BoardNumber; control.BackColor = cs.BackColor; control.Name = cs.Name; control.Size = cs.Size; control.Location = cs.Location; control.rtdm = rtdm; f.Controls.Add(control); } if (t.Name.Equals("NumericUpDownEx")) { // SBB_ACMV.Controls.NumericUpDownEx control = (SBB_ACMV.Controls.NumericUpDownEx)Activator.CreateInstance(t); // SBB_ACMV.Controls.NumericUpDownEx cs = (SBB_ACMV.Controls.NumericUpDownEx)_hostSurfaceManager.basicHostLoader.mComponents[i]; // control.BoardNo = cs.BoardNo; // //control.BoardNoText = cs.BoardNoText; // control.PortNo = cs.PortNo; // //control.PortNoText = cs.PortNoText; // control.BackColor = cs.BackColor; // control.Name = cs.Name; // control.Size = cs.Size; // control.Location = cs.Location; // //control.Name = cs.Name; // f.Controls.Add(control); } } //自定义dll错误信息显示 string infoStr = ""; foreach (string dllFail in dllFailList) { infoStr += dllFail + "\r\n"; } if (infoStr != "") { MessageBox.Show(infoStr + "\r\n" + "Please Check!", "Custom Control(DLL) Error Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } //全屏幕form // FormState formState = new FormState(); // this.SetVisibleCore(false); // formState.Maximize(m_RTeditWindow, false); // this.SetVisibleCore(true); //放置到主窗体 m_RTeditWindow.panel1.Controls.Add(f); m_RTeditWindow.Show(m_RTmainWindow.ControlsDockPanel); #endregion f.KeyDown += new KeyEventHandler(f_KeyDown); } catch (Exception) { MessageBox.Show("Load Error!", "Load Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// Movie data entry public void InitializeComponent(Form parent, bool isUpdate) { // Window parameters this.BackColor = ColorTranslator.FromHtml("#6d6a75"); this.Font = new Font(this.Font, FontStyle.Bold); this.Size = new Size(500, 450); this.parent = parent; if (isUpdate) { this.Load += new EventHandler(this.LoadForm); } // PictureBox this.pb_Cadastro = new Library.PictureBox(); this.pb_Cadastro.Location = new Point(0, 10); this.pb_Cadastro.Size = new Size(480, 100); this.pb_Cadastro.ClientSize = new Size(480, 80); this.pb_Cadastro.Load($"./Views/assets/{(isUpdate ? "alteracao" : "cadastra")}.jpg"); this.Controls.Add(pb_Cadastro); // Label this.lbl_Titulo = new Library.Label(); this.lbl_Titulo.Text = "Título :"; this.lbl_Titulo.Location = new Point(20, 100); this.Controls.Add(lbl_Titulo); this.lbl_DataLancamento = new Library.Label(); this.lbl_DataLancamento.Text = "Ano de Lançamento :"; this.lbl_DataLancamento.Location = new Point(20, 140); this.Controls.Add(lbl_DataLancamento); this.lbl_Sinopse = new Library.Label(); this.lbl_Sinopse.Text = "Sinopse :"; this.lbl_Sinopse.Location = new Point(20, 180); this.Controls.Add(lbl_Sinopse); this.lbl_ValorLocacao = new Library.Label(); this.lbl_ValorLocacao.Text = "Valor da Locação :"; this.lbl_ValorLocacao.Location = new Point(20, 250); this.Controls.Add(lbl_ValorLocacao); this.lbl_QtdeEstoque = new Library.Label(); this.lbl_QtdeEstoque.Text = "Quantidade Estoque :"; this.lbl_QtdeEstoque.Location = new Point(20, 290); this.Controls.Add(lbl_QtdeEstoque); // Fill orientation tip this.tt_Titulo = new Library.ToolTip(); // RichTextBox (Edited text) this.rtxt_Titulo = new Library.RichTextBox(); this.tt_Titulo.SetToolTip(rtxt_Titulo, "Digite o título do filme"); this.Controls.Add(rtxt_Titulo); // NumericUpDown this.num_DataLancDia = new NumericUpDown(); this.num_DataLancDia.Location = new Point(150, 140); this.num_DataLancDia.Size = new Size(50, 20); this.num_DataLancDia.Enter += new EventHandler(this.num_DataLancamento_Enter); this.num_DataLancDia.Minimum = 0; this.num_DataLancDia.Maximum = 31; this.Controls.Add(num_DataLancDia); this.num_DataLancMes = new NumericUpDown(); this.num_DataLancMes.Location = new Point(210, 140); this.num_DataLancMes.Size = new Size(50, 20); this.num_DataLancMes.Enter += new EventHandler(this.num_DataLancamento_Enter); this.num_DataLancMes.Minimum = 0; this.num_DataLancMes.Maximum = 12; this.Controls.Add(num_DataLancMes); this.num_DataLancAno = new NumericUpDown(); this.num_DataLancAno.Location = new Point(270, 140); this.num_DataLancAno.Size = new Size(50, 20); this.num_DataLancAno.Enter += new EventHandler(this.num_DataLancamento_Enter); this.num_DataLancAno.Minimum = 1890; this.num_DataLancAno.Maximum = 2020; this.Controls.Add(num_DataLancAno); // Fill orientation tip this.tt_Sinopse = new Library.ToolTip(); // RichTextBox (Edited text) this.rtxt_Sinopse = new Library.RichTextBox(); this.rtxt_Sinopse.Location = new Point(150, 180); this.rtxt_Sinopse.Size = new Size(300, 50); this.tt_Sinopse.SetToolTip(rtxt_Sinopse, "Digite a sinopse completa"); this.Controls.Add(rtxt_Sinopse); // ComboBox this.cb_ValorLocacao = new ComboBox(); this.cb_ValorLocacao.Items.Add("R$ 0.99"); this.cb_ValorLocacao.Items.Add("R$ 1.99"); this.cb_ValorLocacao.Items.Add("R$ 2.99"); this.cb_ValorLocacao.Items.Add("R$ 3.99"); this.cb_ValorLocacao.Items.Add("R$ 4.99"); this.cb_ValorLocacao.Items.Add("R$ 5.99"); this.cb_ValorLocacao.AutoCompleteMode = AutoCompleteMode.Append; this.cb_ValorLocacao.Location = new Point(150, 250); this.cb_ValorLocacao.Size = new Size(150, 20); this.Controls.Add(cb_ValorLocacao); // NumericUpDown this.num_QtdeEstoque = new NumericUpDown(); this.num_QtdeEstoque.Location = new Point(150, 290); this.num_QtdeEstoque.Size = new Size(50, 20); this.num_QtdeEstoque.Minimum = 1; this.num_QtdeEstoque.Maximum = 100; this.Controls.Add(num_QtdeEstoque); // Buttons this.btn_Confirmar = new Library.Button(); this.btn_Confirmar.Location = new Point(80, 330); this.btn_Confirmar.Text = "CONFIRMAR"; this.btn_Confirmar.Click += new EventHandler(this.btn_ConfirmarClick); this.Controls.Add(btn_Confirmar); this.btn_Cancelar = new Library.Button(); this.btn_Cancelar.Location = new Point(260, 330); this.btn_Cancelar.Text = "CANCELAR"; this.btn_Cancelar.Click += new EventHandler(this.btn_CancelarClick); this.Controls.Add(btn_Cancelar); }
//载入对应的数据库属性 private void Load_Click(object sender, EventArgs e) { object selectedObj = mainForm.drawToolWindow.getCurrentSelectedObj(); if (selectedObj == null) { MessageBox.Show("请选择组件", "提示", MessageBoxButtons.OK); return; } //Type type = selectedObj.GetType().Name.ToString(); if (selectedObj.GetType().Name.ToString() == "PictureBox" || selectedObj.GetType().Name.ToString() == "TextBox") { string type = null; string id = null; switch (selectedObj.GetType().Name.ToString()) { case "PictureBox": Library.PictureBox pb = (Library.PictureBox)selectedObj; if (pb.ID == null || pb.RelatedDeviceType == null) { MessageBox.Show("组件未绑定", "提示", MessageBoxButtons.OK); return; } type = pb.RelatedDeviceType.ToString(); id = pb.ID.ToString(); break; case "TextBox": Library.TextBox tb = (Library.TextBox)selectedObj; if (tb.ID == null || tb.RelatedDeviceType == null) { MessageBox.Show("组件未绑定", "提示", MessageBoxButtons.OK); return; } type = tb.RelatedDeviceType.ToString(); id = tb.ID.ToString(); break; default: break; } string sql = "select * from " + type + " where id = " + id; DataTable dt = new DataTable(); //dt = StaticFunctions.DAStaticFunctions.querySql(sql, DATABASECON); dt = dataForDBTool.MySqlQuery(sql); //获取组件对应的数据库信息 selectedProID = dt.Rows[0]["Projectid"].ToString(); SetProjectComboBox(Int32.Parse(selectedProID) - 1, CHANGEBYFUN); selectedModuleTypeID = dt.Rows[0]["moduletype"].ToString(); selectedModuleTypeName = Enum.GetName(typeof(ModuleType), Int32.Parse(selectedModuleTypeID)); SetModuleTypeComboBox(Int32.Parse(selectedModuleTypeID) - 1, CHANGEBYFUN); selectedModuleID = dt.Rows[0]["Moduleid"].ToString(); SetModuleNameComboBox(Int32.Parse(selectedModuleID), CHANGEBYFUN); selectedFunUnitID = dt.Rows[0]["functionUnitid"].ToString(); SetFunUnitComboBox(Int32.Parse(selectedFunUnitID), CHANGEBYFUN); selectedDeviceID = id; selectedDeviceTypeName = type; SetDeviceTypeComboBox(selectedDeviceTypeName, CHANGEBYFUN); SetDeviceComboBox(Int32.Parse(selectedDeviceID), CHANGEBYFUN); } }
private void Update_Click(object sender, EventArgs e) { object selectedObj = mainForm.drawToolWindow.getCurrentSelectedObj(); if (selectedObj == null) { MessageBox.Show("请选择组件", "提示", MessageBoxButtons.OK); return; } if (selectedDeviceID == null) { MessageBox.Show("请选择数据库", "提示", MessageBoxButtons.OK); return; } Type type = selectedObj.GetType(); if (type.Name == "PictureBox" || type.Name == "TextBox") { //可能会有问题暂时未处理 2015-8-12 22:03:11已处理 //Type examType = typeof(PictureBox); // Change the static property value. PropertyInfo m_id = type.GetProperty("ID"); PropertyInfo m_type = type.GetProperty("Type"); //更新值前去掉原始值 string oldID = m_id.GetValue(selectedObj, null).ToString(); string oldType = m_type.GetValue(selectedObj, null).ToString(); m_id.SetValue(selectedObj, selectedDeviceID, null); m_type.SetValue(selectedObj, selectedDeviceTypeName, null); if (type.Name == "TextBox") { string sql = "update " + oldType + " set TextBoxName = '' where id = " + oldID; //StaticFunctions.DAStaticFunctions.exeSql(sql, StaticFunctions.DAStaticFunctions.DATABASECON); dataForDBTool.MySqlExe(sql); Library.TextBox s = selectedObj as Library.TextBox; sql = "update " + selectedDeviceTypeName + " set TextBoxName = '" + s.Name + "' where id = " + selectedDeviceID; //StaticFunctions.DAStaticFunctions.exeSql(sql,StaticFunctions.DAStaticFunctions.DATABASECON); dataForDBTool.MySqlExe(sql); } if (type.Name == "Dehumidifier1") { string sql = "update " + oldType + " set TextBoxName = '' where id = " + oldID; //StaticFunctions.DAStaticFunctions.exeSql(sql, StaticFunctions.DAStaticFunctions.DATABASECON); dataForDBTool.MySqlExe(sql); Library.LDDS.Dehumidifier1 s = selectedObj as Library.LDDS.Dehumidifier1; sql = "update " + selectedDeviceTypeName + " set TextBoxName = '" + s.Name + "' where id = " + selectedDeviceID; //StaticFunctions.DAStaticFunctions.exeSql(sql,StaticFunctions.DAStaticFunctions.DATABASECON); dataForDBTool.MySqlExe(sql); } else if (type.Name == "PictureBox") { string sql = "update " + oldType + " set PictureName = '' where id = " + oldID; //StaticFunctions.DAStaticFunctions.exeSql(sql, StaticFunctions.DAStaticFunctions.DATABASECON); dataForDBTool.MySqlExe(sql); Library.PictureBox s = selectedObj as Library.PictureBox; sql = "update " + selectedDeviceTypeName + " set PictureName = '" + s.Name + "' where id = " + selectedDeviceID; //StaticFunctions.DAStaticFunctions.exeSql(sql, StaticFunctions.DAStaticFunctions.DATABASECON); dataForDBTool.MySqlExe(sql); } } }
// Consult registered movies public void InitializeComponent(Form parent) { // Window parameters this.BackColor = ColorTranslator.FromHtml("#6d6a75"); this.Font = new Font(this.Font, FontStyle.Bold); this.Size = new Size(500, 620); this.parent = parent; // PictureBox this.pb_Consulta = new Library.PictureBox(); this.pb_Consulta.Load("./Views/assets/consulta.jpg"); this.Controls.Add(pb_Consulta); // Label this.lbl_ConsultaFilme = new Library.Label(); this.lbl_ConsultaFilme.Text = "Buscar Filme :"; this.lbl_ConsultaFilme.Location = new Point(30, 80); this.Controls.Add(lbl_ConsultaFilme); // Fill orientation tip this.tt_ConsultaFilme = new Library.ToolTip(); // RichTextBox (Edited text - Keypress mode to filter a movie in ListView) this.rtxt_ConsultaFilme = new Library.RichTextBox(); this.rtxt_ConsultaFilme.Location = new Point(150, 80); this.Controls.Add(rtxt_ConsultaFilme); this.tt_ConsultaFilme.SetToolTip(rtxt_ConsultaFilme, "Digite o título ou selecione abaixo"); this.rtxt_ConsultaFilme.KeyPress += new KeyPressEventHandler(keypressed); // ListView - Movie this.lv_ListaFilmes = new Library.ListView(); this.lv_ListaFilmes.Location = new Point(20, 130); this.lv_ListaFilmes.Size = new Size(440, 350); List <FilmeModels> listaFilme = (from filme in FilmeController.GetFilmes() where filme.Titulo.Contains(rtxt_ConsultaFilme.Text) select filme).ToList(); ListViewItem filmes = new ListViewItem(); foreach (FilmeModels filme in FilmeController.GetFilmes()) { ListViewItem lv_ListaFilme = new ListViewItem(filme.IdFilme.ToString()); lv_ListaFilme.SubItems.Add(filme.Titulo); lv_ListaFilme.SubItems.Add(filme.DataLancamento); lv_ListaFilme.SubItems.Add(filme.ValorLocacaoFilme.ToString()); lv_ListaFilme.SubItems.Add(filme.EstoqueFilme.ToString()); lv_ListaFilme.SubItems.Add(filme.Sinopse); lv_ListaFilmes.Items.Add(lv_ListaFilme); } this.lv_ListaFilmes.MultiSelect = false; this.lv_ListaFilmes.Columns.Add("ID", -2, HorizontalAlignment.Center); this.lv_ListaFilmes.Columns.Add("Título", -2, HorizontalAlignment.Left); this.lv_ListaFilmes.Columns.Add("Data Lançamento", -2, HorizontalAlignment.Center); this.lv_ListaFilmes.Columns.Add("Preço", -2, HorizontalAlignment.Center); this.lv_ListaFilmes.Columns.Add("Estoque", -2, HorizontalAlignment.Center); this.lv_ListaFilmes.Columns.Add("Sinopse", -2, HorizontalAlignment.Left); this.Controls.Add(lv_ListaFilmes); Task t = new Task(new Action(() => { RefreshForm(); })); t.Start(); // ListView grouping box this.gb_ListaFilme = new Library.GroupBox(); this.gb_ListaFilme.Location = new Point(10, 110); this.gb_ListaFilme.Size = new Size(460, 380); this.gb_ListaFilme.Text = "LISTA DE FILMES"; this.Controls.Add(gb_ListaFilme); // Buttons this.btn_ListaConsulta = new Library.Button(); this.btn_ListaConsulta.Location = new Point(80, 510); this.btn_ListaConsulta.Text = "CONSULTA"; this.btn_ListaConsulta.Click += new EventHandler(this.btn_ListaConsultaClick); this.Controls.Add(btn_ListaConsulta); this.btn_ListaSair = new Library.Button(); this.btn_ListaSair.Location = new Point(260, 510); this.btn_ListaSair.Text = "SAIR"; this.btn_ListaSair.Click += new EventHandler(this.btn_ListaSairClick); this.Controls.Add(btn_ListaSair); }
// Consult registered customers public void InitializeComponent(Form parent) { // Window parameters this.BackColor = ColorTranslator.FromHtml("#6d6a75"); this.Font = new Font(this.Font, FontStyle.Bold); this.Size = new Size(500, 620); this.Dock = DockStyle.Fill; this.parent = parent; // PictureBox this.pb_Consulta = new Library.PictureBox(); this.pb_Consulta.Load("./Views/assets/consulta.jpg"); this.Controls.Add(pb_Consulta); // Label this.lbl_ConsultaCliente = new Library.Label(); this.lbl_ConsultaCliente.Text = "Buscar Cliente :"; this.lbl_ConsultaCliente.Location = new Point(30, 80); this.Controls.Add(lbl_ConsultaCliente); // Fill orientation tip this.tt_BuscaCliente = new Library.ToolTip(); // RichTextBox (Edited text - Keypress mode to filter a customer in ListView) this.rtxt_ConsultaCliente = new Library.RichTextBox(); this.rtxt_ConsultaCliente.Location = new Point(150, 80); this.Controls.Add(rtxt_ConsultaCliente); this.tt_BuscaCliente.SetToolTip(rtxt_ConsultaCliente, "Digite o nome ou selecione abaixo"); this.rtxt_ConsultaCliente.KeyPress += new KeyPressEventHandler(keypressed); // ListView - Customer this.lv_ListaClientes = new Library.ListView(); this.lv_ListaClientes.Location = new Point(20, 130); this.lv_ListaClientes.Size = new Size(440, 350); List <ClienteModels> listaCliente = (from cliente in ClienteController.GetClientes() where cliente.NomeCliente.Contains(rtxt_ConsultaCliente.Text) select cliente).ToList(); ListViewItem clientes = new ListViewItem(); foreach (ClienteModels cliente in ClienteController.GetClientes()) { ListViewItem lv_ListaCliente = new ListViewItem(cliente.IdCliente.ToString()); lv_ListaCliente.SubItems.Add(cliente.NomeCliente); lv_ListaCliente.SubItems.Add(cliente.DataNascimento); lv_ListaCliente.SubItems.Add(cliente.CpfCliente); lv_ListaCliente.SubItems.Add(cliente.DiasDevolucao.ToString()); lv_ListaClientes.Items.Add(lv_ListaCliente); } this.lv_ListaClientes.MultiSelect = false; this.lv_ListaClientes.Columns.Add("ID", -2, HorizontalAlignment.Center); this.lv_ListaClientes.Columns.Add("Nome", -2, HorizontalAlignment.Left); this.lv_ListaClientes.Columns.Add("Data Nascimento", -2, HorizontalAlignment.Center); this.lv_ListaClientes.Columns.Add("CPF", -2, HorizontalAlignment.Center); this.lv_ListaClientes.Columns.Add("Dias Devolução", -2, HorizontalAlignment.Center); this.Controls.Add(lv_ListaClientes); Task t = new Task(new Action(() => { RefreshForm(); })); t.Start(); // ListView grouping box this.gb_ListaClientes = new Library.GroupBox(); this.gb_ListaClientes.Location = new Point(10, 110); this.gb_ListaClientes.Size = new Size(460, 380); this.gb_ListaClientes.Text = "LISTA DE CLIENTES"; this.Controls.Add(gb_ListaClientes); // Buttons this.btn_ListaConsulta = new Library.Button(); this.btn_ListaConsulta.Location = new Point(80, 510); this.btn_ListaConsulta.Text = "CONSULTA"; this.btn_ListaConsulta.Click += new EventHandler(btn_ListaConsultaClick); this.Controls.Add(btn_ListaConsulta); this.btn_ListaSair = new Library.Button(); this.btn_ListaSair.Location = new Point(260, 510); this.btn_ListaSair.Text = "SAIR"; this.btn_ListaSair.Click += new EventHandler(btn_ListaSairClick); this.Controls.Add(btn_ListaSair); }
public TelaInicial() { // Bar and some window details this.Text = "BLOCKBUSTER - SENAC 2020"; this.BackColor = ColorTranslator.FromHtml("#38323e"); this.Font = new Font(this.Font, FontStyle.Bold); this.Size = new Size(600, 560); // Image to Bloclbuster this.pb_Menu = new Library.PictureBox(); this.pb_Menu.Location = new Point(10, 10); this.pb_Menu.Size = new Size(560, 100); this.pb_Menu.ClientSize = new Size(560, 120); this.pb_Menu.Load("./Views/assets/menu.jpg"); this.Controls.Add(pb_Menu); // Selection button for customer data entry this.btn_CadastroCliente = new Library.Button(); this.btn_CadastroCliente.Location = new Point(40, 160); this.btn_CadastroCliente.Size = new Size(200, 30); this.btn_CadastroCliente.Text = "CADASTRO DO CLIENTE"; this.Controls.Add(btn_CadastroCliente); this.btn_CadastroCliente.Click += new EventHandler(btn_CadastroClienteClick); // this.btn_CadastroCliente.MouseEnter += new EventHandler(btn_MouseEnter); // this.btn_CadastroCliente.MouseLeave += new EventHandler(btn_MouseLeave); // Selection button for querying customer data this.btn_ConsultaCliente = new Library.Button(); this.btn_ConsultaCliente.Location = new Point(40, 200); this.btn_ConsultaCliente.Size = new Size(200, 30); this.btn_ConsultaCliente.Text = "CONSULTA CLIENTE"; this.Controls.Add(btn_ConsultaCliente); this.btn_ConsultaCliente.Click += new EventHandler(btn_ConsultaClienteClick); // Selection button for customer data list this.btn_ListaClientes = new Library.Button(); this.btn_ListaClientes.Location = new Point(40, 240); this.btn_ListaClientes.Size = new Size(200, 30); this.btn_ListaClientes.Text = "LISTA DE CLIENTES"; this.Controls.Add(btn_ListaClientes); this.btn_ListaClientes.Click += new EventHandler(btn_ListaClientesClick); // Customer grouping box this.gb_Cliente = new Library.GroupBox(); this.gb_Cliente.Location = new Point(25, 135); this.gb_Cliente.Text = "CLIENTE"; this.Controls.Add(gb_Cliente); // Selection button for movie data entry this.btn_CadastroFilme = new Library.Button(); this.btn_CadastroFilme.Location = new Point(350, 160); this.btn_CadastroFilme.Size = new Size(200, 30); this.btn_CadastroFilme.Text = "CADASTRO DO FILME"; this.Controls.Add(btn_CadastroFilme); this.btn_CadastroFilme.Click += new EventHandler(btn_CadastroFilmeClick); // Selection button for querying movie data this.btn_ConsultaFilme = new Library.Button(); this.btn_ConsultaFilme.Location = new Point(350, 200); this.btn_ConsultaFilme.Size = new Size(200, 30); this.btn_ConsultaFilme.Text = "CONSULTA FILME"; this.Controls.Add(btn_ConsultaFilme); this.btn_ConsultaFilme.Click += new EventHandler(btn_ConsultaFilmeClick); // Selection button for movie data list this.btn_ListaFilmes = new Library.Button(); this.btn_ListaFilmes.Location = new Point(350, 240); this.btn_ListaFilmes.Size = new Size(200, 30); this.btn_ListaFilmes.Text = "LISTA DE FILMES"; this.Controls.Add(btn_ListaFilmes); this.btn_ListaFilmes.Click += new EventHandler(btn_ListaFilmesClick); // Movie grouping box this.gb_Filme = new Library.GroupBox(); this.gb_Filme.Location = new Point(335, 135); this.gb_Filme.Text = "FILME"; this.Controls.Add(gb_Filme); // Selection button for entering rental data this.btn_CadastroLocacao = new Library.Button(); this.btn_CadastroLocacao.Location = new Point(195, 320); this.btn_CadastroLocacao.Size = new Size(200, 30); this.btn_CadastroLocacao.Text = "CADASTRO DA LOCAÇÃO"; this.Controls.Add(btn_CadastroLocacao); this.btn_CadastroLocacao.Click += new EventHandler(btn_CadastroLocacaoClick); // Selection button for querying rental data this.btn_ConsultaLocacao = new Library.Button(); this.btn_ConsultaLocacao.Location = new Point(195, 360); this.btn_ConsultaLocacao.Size = new Size(200, 30); this.btn_ConsultaLocacao.Text = "CONSULTA LOCAÇÃO"; this.Controls.Add(btn_ConsultaLocacao); this.btn_ConsultaLocacao.Click += new EventHandler(btn_ConsultaLocacaoClick); // Selection button to list rentals this.btn_ListaLocacoes = new Library.Button(); this.btn_ListaLocacoes.Location = new Point(195, 400); this.btn_ListaLocacoes.Size = new Size(200, 30); this.btn_ListaLocacoes.Text = "LISTA DE LOCAÇÕES"; this.Controls.Add(btn_ListaLocacoes); this.btn_ListaLocacoes.Click += new EventHandler(btn_ListaLocacoesClick); // Rent grouping box this.gb_Locaçao = new Library.GroupBox(); this.gb_Locaçao.Location = new Point(180, 295); this.gb_Locaçao.Text = "LOCAÇÃO"; this.Controls.Add(gb_Locaçao); this.btn_MenuSair = new Library.Button(); this.btn_MenuSair.Location = new Point(220, 455); this.btn_MenuSair.Text = "SAIR"; this.Controls.Add(btn_MenuSair); this.btn_MenuSair.Click += new EventHandler(btn_MenuSairClick); }
// Consult registered rentals public void InitializeComponent(Form parent) { // Window parameters this.BackColor = ColorTranslator.FromHtml("#6d6a75"); this.Font = new Font(this.Font, FontStyle.Bold); this.Size = new Size(500, 500); this.parent = parent; // PictureBox this.pb_Consulta = new Library.PictureBox(); this.pb_Consulta.ClientSize = new Size(460, 80); this.pb_Consulta.Load("./Views/assets/locacao.jpg"); this.Controls.Add(pb_Consulta); // Label this.lbl_NomeLocacao = new Library.Label(); this.lbl_NomeLocacao.Text = "Busca Por Cliente :"; this.lbl_NomeLocacao.Location = new Point(20, 100); this.Controls.Add(lbl_NomeLocacao); // Fill orientation tip this.tt_BuscaCliente = new Library.ToolTip(); // RichTextBox (Edited text - Keypress mode to filter a rental by customer in ListView) this.rtxt_BuscaCliente = new Library.RichTextBox(); this.rtxt_BuscaCliente.Location = new Point(150, 100); this.Controls.Add(rtxt_BuscaCliente); this.tt_BuscaCliente.SetToolTip(rtxt_BuscaCliente, "Digite o nome ou selecione abaixo"); this.rtxt_BuscaCliente.KeyPress += new KeyPressEventHandler(keypressed); // ListView - Rentals this.lv_ListaLocacoes = new Library.ListView(); this.lv_ListaLocacoes.Location = new Point(20, 170); this.lv_ListaLocacoes.Size = new Size(440, 185); List <ClienteModels> listaCliente = (from cliente in ClienteController.GetClientes() where cliente.NomeCliente.Contains(rtxt_BuscaCliente.Text) select cliente).ToList(); ListViewItem locacoes = new ListViewItem(); foreach (LocacaoModels locacao in LocacaoController.GetLocacoes()) { ListViewItem lv_ListaLocacao = new ListViewItem(locacao.IdLocacao.ToString()); ClienteModels cliente = ClienteController.GetCliente(locacao.IdCliente); lv_ListaLocacao.SubItems.Add(cliente.NomeCliente.ToString()); lv_ListaLocacao.SubItems.Add(cliente.CpfCliente.ToString()); lv_ListaLocacao.SubItems.Add(locacao.DataLocacao.ToString("dd/MM/yyyy")); lv_ListaLocacao.SubItems.Add(locacao.CalculoDataDevol().ToString("dd/MM/yyyy")); lv_ListaLocacao.SubItems.Add(locacao.QtdeFilmes().ToString()); lv_ListaLocacao.SubItems.Add(locacao.ValorTotal().ToString("C2")); lv_ListaLocacoes.Items.Add(lv_ListaLocacao); } this.lv_ListaLocacoes.MultiSelect = false; this.lv_ListaLocacoes.Columns.Add("ID", -2, HorizontalAlignment.Center); this.lv_ListaLocacoes.Columns.Add("Locatário", -2, HorizontalAlignment.Left); this.lv_ListaLocacoes.Columns.Add("CPF", -2, HorizontalAlignment.Center); this.lv_ListaLocacoes.Columns.Add("Data Locação", -2, HorizontalAlignment.Center); this.lv_ListaLocacoes.Columns.Add("Data Devolução", -2, HorizontalAlignment.Center); this.lv_ListaLocacoes.Columns.Add("Qtde Filmes", -2, HorizontalAlignment.Center); this.lv_ListaLocacoes.Columns.Add("Total", -2, HorizontalAlignment.Left); this.Controls.Add(lv_ListaLocacoes); Task t = new Task(new Action(() => { RefreshForm(); })); t.Start(); // ListView grouping box this.gb_ConsultaLocacao = new Library.GroupBox(); this.gb_ConsultaLocacao.Location = new Point(10, 80); this.gb_ConsultaLocacao.Size = new Size(460, 55); this.gb_ConsultaLocacao.Text = "BUSCAR LOCAÇÃO"; this.Controls.Add(gb_ConsultaLocacao); this.gb_ListaLocacoes = new Library.GroupBox(); this.gb_ListaLocacoes.Location = new Point(10, 150); this.gb_ListaLocacoes.Size = new Size(460, 220); this.gb_ListaLocacoes.Text = "LISTA DE LOCAÇÕES"; this.Controls.Add(gb_ListaLocacoes); // Buttons this.btn_ListaConsulta = new Library.Button(); this.btn_ListaConsulta.Location = new Point(80, 390); this.btn_ListaConsulta.Text = "CONSULTA"; this.btn_ListaConsulta.Click += new EventHandler(this.btn_ListaConsultaClick); this.Controls.Add(btn_ListaConsulta); this.btn_ListaSair = new Library.Button(); this.btn_ListaSair.Location = new Point(260, 390); this.btn_ListaSair.Text = "CANCELAR"; this.btn_ListaSair.Click += new EventHandler(this.btn_ListaSairClick); this.Controls.Add(btn_ListaSair); }