/// <summary> /// rest the UI to its default /// </summary> /// <param name="tabPage"></param> /// <param name="type"></param> /// <param name="sender"></param> /// <param name="e"></param> void ClearData(ref MetroTabPage tabPage, DataType type, object sender, EventArgs e) { foreach (var i in tabPage.Controls) { if (i is BunifuMaterialTextbox) { BunifuMaterialTextbox temp = (BunifuMaterialTextbox)i; temp.Text = ""; } else if (i is ComboBox) { ComboBox temp = (ComboBox)i; temp.SelectedIndex = 0; } else if (i is MyTextBox) { MyTextBox temp = (MyTextBox)i; temp.Text = ""; } else if (i is TextBox) { TextBox temp = (TextBox)i; temp.Text = ""; } } if (type == DataType.Agent) { tabControlAgent_SelectedIndexChanged(sender, e); } else if (type == DataType.Branch) { tabControlBranch_SelectedIndexChanged(sender, e); } }
/// <summary> /// auto fill the branch control /// </summary> /// <param name="tabPage"></param> /// <param name="data"></param> void AutoFillBranchData(ref MetroTabPage tabPage, Branch data) { foreach (var i in tabPage.Controls) { if (i is BunifuMaterialTextbox) { BunifuMaterialTextbox temp = (BunifuMaterialTextbox)i; if (temp.Name == "textBoxEditBranchAddress") { temp.Text = data.Address; } else if (temp.Name == "textBoxEditBranchCity") { temp.Text = data.City; } if (temp.Name == "labelDeleteBranchAddress") { temp.Text = data.Address; } else if (temp.Name == "labelDeleteBranchCity") { temp.Text = data.City; } } else if (i is ComboBox) { ComboBox temp = (ComboBox)i; if (temp.Name == "comboBoxEditBranchID" || temp.Name == "comboBoxDeleteBranchID") { temp.SelectedItem = data.ID; } else if (temp.Name == "comboBoxEditBranchName" || temp.Name == "comboBoxDeleteBranchName") { temp.SelectedItem = data.Name; } } else if (i is MyTextBox) { MyTextBox temp = (MyTextBox)i; temp.Text = ""; } else if (i is Label) { Label temp = (Label)i; if (temp.Name == "labelDeleteBranchAddress") { temp.Text = data.Address; } else if (temp.Name == "labelDeleteBranchCity") { temp.Text = data.City; } } } }
/// <summary> /// auto fill principal and vice data /// </summary> /// <param name="tabPage"></param> /// <param name="data"></param> void AutoFillPrincipalOrViceData(ref MetroTabPage tabPage, PrincipalAndVice data) { foreach (var i in tabPage.Controls) { if (i is TextBox) { } else if (i is ComboBox) { ComboBox temp = (ComboBox)i; if (temp.Name == "comboBoxPrincipalName" || temp.Name == "comboBoxVicePrincipalName") { temp.SelectedItem = Connection.Instance.GetAgentName(data.AgentID); } else if (temp.Name == "comboBoxPrincipalBranchName" || temp.Name == "comboBoxVicePrincipalBranchName") { temp.SelectedItem = Connection.Instance.GetBranchNameFromID(data.BranchID); } } else if (i is MyTextBox) { MyTextBox temp = (MyTextBox)i; temp.Text = ""; } else if (i is Label) { Label temp = (Label)i; if (temp.Name == "labelPrincipalDateJoined" || temp.Name == "labelVicePrincipalDateJoined") { temp.Text = data.DateSelected.ToString("dddd, dd - MMM - yyyy"); } } else if (i is BunifuDatepicker) { BunifuDatepicker temp = (BunifuDatepicker)i; if (temp.Name == "dateTimePickerPrincipalDateJoinend" || temp.Name == "dateTimePickerVicePrincipalDateJoined") { temp.Value = data.DateSelected; } } } }
/// <summary> /// auto fill the agents data /// </summary> /// <param name="tabPage"></param> /// <param name="data"></param> void AutoFillAgentData(ref MetroTabPage tabPage, Agent data) { foreach (var i in tabPage.Controls) { if (i is BunifuMaterialTextbox) { BunifuMaterialTextbox temp = (BunifuMaterialTextbox)i; if (temp.Name == "textBoxUpdateAgentEmail") { temp.Text = data.Email; } if (temp.Name == "labelDisableAgentEmail") { temp.Text = data.Email; } else if (temp.Name == "labelDisableAgentPhoneNumber") { temp.Text = data.PhoneNumber; } else if (temp.Name == "labelDisableAgentDateJoined") { temp.Text = data.DateJoined.ToString(); } else if (temp.Name == "labelDisableAgentBranchName") { temp.Text = Connection.Instance.GetBranchNameFromAgentID(data.ID); } else if (temp.Name == "labelDisableAgentUplineName") { temp.Text = Connection.Instance.GetAgentName(data.UplineID); } else if (temp.Name == "labelUpdateAgentDateJoined") { temp.Text = data.DateJoined.ToString("dddd, dd - MMM - yyyy"); } } else if (i is ComboBox) { ComboBox temp = (ComboBox)i; if (temp.Name == "comboBoxUpdateAgentID" || temp.Name == "comboBoxDisableAgentID") { temp.SelectedItem = data.ID; } else if (temp.Name == "comboBoxUpdateAgentName" || temp.Name == "comboBoxDisableAgentName") { temp.SelectedItem = data.Name; } else if (temp.Name == "comboBoxUpdateAgentBranchName") { temp.SelectedItem = Connection.Instance.GetBranchNameFromID(data.BranchID); } else if (temp.Name == "comboBoxUpdateAgentUplineName") { temp.SelectedItem = Connection.Instance.GetAgentName(data.UplineID); } } else if (i is MyTextBox) { MyTextBox temp = (MyTextBox)i; temp.Text = ""; } else if (i is Label) { Label temp = (Label)i; if (temp.Name == "labelDisableAgentEmail") { temp.Text = data.Email; } else if (temp.Name == "labelDisableAgentPhoneNumber") { temp.Text = data.PhoneNumber; } else if (temp.Name == "labelDisableAgentDateJoined") { temp.Text = data.DateJoined.ToString(); } else if (temp.Name == "labelDisableAgentBranchName") { temp.Text = Connection.Instance.GetBranchNameFromAgentID(data.ID); } else if (temp.Name == "labelDisableAgentUplineName") { temp.Text = Connection.Instance.GetAgentName(data.UplineID); } else if (temp.Name == "labelUpdateAgentDateJoined") { temp.Text = data.DateJoined.ToString("dddd, dd - MMM - yyyy"); } } else if (i is BunifuDatepicker) { BunifuDatepicker temp = (BunifuDatepicker)i; if (temp.Name == "dateTimePickerUpdateAgent") { temp.Value = data.DateJoined; } } else if (i is TextBox) { TextBox temp = (TextBox)i; if (temp.Name == "textBoxNumericUpdateAgentPhoneNumber") { temp.Text = data.PhoneNumber; } } } }
/// <summary> /// refresh the UI for agent closing /// </summary> public void RefreshAgentGroupBox() { flowLayoutPanelAgent.Controls.Clear(); for (int i = 0; i < ParticipatedAgents.Count; i++) { Label agentName = new Label(); agentName.AutoSize = true; agentName.Text = (i + 1) + ". " + ParticipatedAgents[i].agent.Name; agentName.Font = new Font("Century Gothic", 15, FontStyle.Bold); agentName.ForeColor = Color.White; Label nominalLabel = new Label(); nominalLabel.AutoSize = true; nominalLabel.Text = "Nominal"; nominalLabel.Font = new Font("Century Gothic", 14f); nominalLabel.ForeColor = Color.White; Label unitLabel = new Label(); unitLabel.AutoSize = true; unitLabel.Text = "Unit"; unitLabel.Font = new Font("Century Gothic", 14f); unitLabel.ForeColor = Color.White; MyButton myButtonRemove = new MyButton(); myButtonRemove.id = i; myButtonRemove.Text = "Remove"; myButtonRemove.Size = new Size(111, 29); myButtonRemove.BackColor = Color.FromArgb(37, 45, 51); myButtonRemove.ForeColor = Color.White; MyTextBox myTextBoxNominal = new MyTextBox(); if (ParticipatedAgents[i].nominal != null) { myTextBoxNominal = ParticipatedAgents[i].nominal; } else { myTextBoxNominal.Multiline = true; myTextBoxNominal.BackColor = Color.FromArgb(37, 45, 51); myTextBoxNominal.Size = new Size(300, 32); myTextBoxNominal.ForeColor = Color.White; myTextBoxNominal.TextAlign = HorizontalAlignment.Right; myTextBoxNominal.Font = new Font("Century Gothic", 14f); } TextBoxNumeric textBoxNumericUnit = new TextBoxNumeric(); if (ParticipatedAgents[i].unit != null) { textBoxNumericUnit = ParticipatedAgents[i].unit; } else { textBoxNumericUnit.Multiline = true; textBoxNumericUnit.BackColor = Color.FromArgb(37, 45, 51); textBoxNumericUnit.Size = new Size(300, 32); textBoxNumericUnit.ForeColor = Color.White; textBoxNumericUnit.TextAlign = HorizontalAlignment.Right; textBoxNumericUnit.Font = new Font("Century Gothic", 14f); } Panel panelControl = new Panel(); panelControl.Width = 300; panelControl.AutoSize = true; panelControl.Controls.Add(agentName); panelControl.Controls.Add(nominalLabel); panelControl.Controls.Add(unitLabel); panelControl.Controls.Add(myTextBoxNominal); ParticipatedAgents[i].nominal = myTextBoxNominal; panelControl.Controls.Add(textBoxNumericUnit); ParticipatedAgents[i].unit = textBoxNumericUnit; panelControl.Controls.Add(myButtonRemove); flowLayoutPanelAgent.Controls.Add(panelControl); panelControl.Left = 3; panelControl.Top = 3 + (panelControl.Height * (i)); agentName.Left = 85; agentName.Top = 14; myButtonRemove.Left = agentName.Left + 263; myButtonRemove.SetMiddle(agentName.Middle()); nominalLabel.Left = agentName.Left; nominalLabel.Top = agentName.Top + 41; myTextBoxNominal.Left = nominalLabel.Right + 19; myTextBoxNominal.SetMiddle(nominalLabel.Middle()); unitLabel.SetRight(nominalLabel.Right); unitLabel.Top = nominalLabel.Bottom + 19; textBoxNumericUnit.Left = myTextBoxNominal.Left; textBoxNumericUnit.SetMiddle(unitLabel.Middle()); myButtonRemove.Click += delegate { ParticipatedAgents.RemoveAt(myButtonRemove.id); RefreshAgentGroupBox(); SetValuesToDefault(); }; } }