private void button5_Click_1(object sender, EventArgs e) { switch (menuOption) { case 4: TabMain.SelectTab(0); break; } }
private void LoadProfileData() { lblUsername.Text = LoggedUser.UserName.ToUpper(); lblCity.Text = LoggedUser.Location; lblDate.Text = LoggedUser.RegisterDate.ToShortDateString(); TabMain.TabPages.Remove(TabPageRestManagement); if (LoggedUser.IsUserRestaurantOwner()) { TabMain.TabPages.Add(TabPageRestManagement); TabMain.SelectTab(TabPageRestManagement); } }
// +---------------------------------------------------+ // | ЗАГРУЗКА ФОРМЫ | // +---------------------------------------------------+ private void FormLoad(object sender, EventArgs e) { TabMain.ItemSize = new Size(0, 1); if (selectedIndex.Split('_')[1].Equals("OrganizationEstimate")) { TabMain.SelectTab("FPage_Estimate"); } else { TabMain.SelectTab(selectedIndex); } object[] Values; // Для редактирования #region Косметические изменения формы int constW1 = 305; switch (TabMain.SelectedTab.Name) { case "FPage_CarBrand": Width = constW1; Height = 110; break; case "FPage_CarModel": Width = 337; Height = 150; break; case "FPage_Cars": Width = constW1; Height = 230; break; case "FPage_CarType": Width = constW1; Height = 230; break; case "FPage_Drivers": Width = constW1; Height = 275; break; case "FPage_Estimate": Width = 560; Height = 340; break; case "FPage_Organizations": Width = constW1; Height = 160; break; case "FPage_Staff": Width = constW1; Height = 235; break; case "FPage_StaffPosition": Width = constW1; Height = 110; break; case "FPage_Trackinglists": Width = constW1; Height = 500; break; } Controls.Add(new Panel { BackColor = Color.White, Location = new Point(0, 0), Width = Width, Height = 6 }); TabMain.SendToBack(); #endregion // Заполнение полей в зависимости от типа открываемой формы switch (TYPE) { case DataCommon.FormType.Add: switch (TabMain.SelectedTab.Name) { case "FPage_CarModel": Image img = new Bitmap(Properties.Resources.add, 16, 16); Button_AddNew_CarBrand.BackgroundImage = img; comboBox1.exFill(DB_ID, "Carbrand_name", "CarBrand"); break; case "FPage_Cars": Width = constW1; Height = 230; comboBox2.exFillExtra(DB_ID, "CarModel.ID, [CarBrand]![Carbrand_name] & \" - \" & [CarModel]![Carmodel_name] AS Result", "CarBrand INNER JOIN CarModel ON CarBrand.ID = CarModel.Carmodel_brand"); comboBox3.exFillExtra(DB_ID, "CarType.ID, \"[\" & [CarType]![Cartype_code] & \"] - \" & [CarType]![Cartype_name] & \" - \" & [CarType]![Cartype_capacity] AS Result", "CarType"); break; case "FPage_Estimate": comboBox4.exFill(DB_ID, "Trackinglist_number", "Trackinglists", "Trackinglists.ID NOT IN(SELECT Estimate.Estimate_tracklist FROM Estimate)"); break; case "FPage_Organizations": comboBox5.SelectedIndex = 0; break; case "FPage_Staff": comboBox6.exFill(DB_ID, "Staffposition_name", "StaffPosition"); break; case "FPage_Trackinglists": int lastnum = Trackinglists.GetLastTrackingNumber(); if (lastnum == 0) { textBox23.Text = "0"; } else { textBox23.Text = (lastnum + 1).ToString(); } comboBox7.exFill(DB_ID, "Organization_name", "Organizations", "Organization_ratio=0"); comboBox8.exFillExtra(DB_ID, "Cars.ID, [CarBrand]![Carbrand_name] & \" \" & [CarModel]![Carmodel_name] & \", Гос. номер: \" & [Cars]![Car_number] AS Result", "(CarBrand INNER JOIN CarModel ON CarBrand.ID = CarModel.Carmodel_brand) INNER JOIN Cars ON CarModel.ID = Cars.Car_model"); comboBox9.exFillExtra(DB_ID, "Drivers.ID, [Drivers]![Driver_lastname] & \" \" & [Drivers]![Driver_firstname] & \" \" & [Drivers]![Driver_thirdname] AS Result", "Drivers"); comboBox10.exFillExtra(DB_ID, "Staff.ID, [Staff]![Staff_lastname] & \" \" & [Staff]![Staff_firstname] & \" \" & [Staff]![Staff_thirdname] AS Result", "Staff"); comboBox11.exFillExtra(DB_ID, "Staff.ID, [Staff]![Staff_lastname] & \" \" & [Staff]![Staff_firstname] & \" \" & [Staff]![Staff_thirdname] AS Result", "Staff"); comboBox12.exFillExtra(DB_ID, "Staff.ID, [Staff]![Staff_lastname] & \" \" & [Staff]![Staff_firstname] & \" \" & [Staff]![Staff_thirdname] AS Result", "Staff"); comboBox13.exFill(DB_ID, "Organization_name", "Organizations", "Organization_ratio=1"); comboBox14.exFill(DB_ID, "Organization_name", "Organizations", "Organization_ratio=2"); if (comboBox11.Items.Count > 0) { comboBox11.SelectedIndex = 1; } if (comboBox12.Items.Count > 0) { comboBox12.SelectedIndex = 1; } break; } break; case DataCommon.FormType.Edit: switch (TabMain.SelectedTab.Name) { case "FPage_CarBrand": Values = Base.GetRowFields(ID, "CarBrand"); textBox1.Text = Values[0].ToString(); break; case "FPage_CarModel": Values = Base.GetRowFields(ID, "CarModel"); comboBox1.exFill(DB_ID, "Carbrand_name", "CarBrand"); comboBox1.SelectedValue = (int)Values[0]; textBox2.Text = Values[1].ToString(); break; case "FPage_Cars": Values = Base.GetRowFields(ID, "Cars"); comboBox2.exFillExtra(DB_ID, "CarModel.ID, [CarBrand]![Carbrand_name] & \" - \" & [CarModel]![Carmodel_name] AS Result", "CarBrand INNER JOIN CarModel ON CarBrand.ID = CarModel.Carmodel_brand"); comboBox3.exFillExtra(DB_ID, "CarType.ID, \"[\" & [CarType]![Cartype_code] & \"] - \" & [CarType]![Cartype_name] & \" - \" & [CarType]![Cartype_capacity] AS Result", "CarType"); comboBox2.SelectedValue = (int)Values[0]; textBox3.Text = Values[1].ToString(); textBox4.Text = Values[2].ToString(); comboBox3.SelectedValue = (int)Values[3]; break; case "FPage_CarType": Values = Base.GetRowFields(ID, "CarType"); textBox5.Text = Values[0].ToString(); textBox6.Text = Values[1].ToString(); textBox7.Text = Values[2].ToString(); textBox33.Text = Values[3].ToString(); textBox32.Text = Values[4].ToString(); break; case "FPage_Drivers": Values = Base.GetRowFields(ID, "Drivers"); textBox9.Text = Values[0].ToString(); textBox8.Text = Values[1].ToString(); textBox10.Text = Values[2].ToString(); textBox11.Text = Values[3].ToString(); textBox16.Text = Values[4].ToString(); break; case "FPage_Estimate": int ThisTrackingList = DataCommon.GetFieldValue(ID, "Estimate_tracklist", "Estimate").exToInt(); Values = Base.GetRowFields(ID, "Estimate"); comboBox4.exFill(DB_ID, "Trackinglist_number", "Trackinglists", $"Trackinglists.ID NOT IN(SELECT Estimate.Estimate_tracklist FROM Estimate WHERE Trackinglists.ID NOT IN({ThisTrackingList}))"); textBox13.Text = Values[0].ToString(); textBox14.Text = Values[1].ToString(); comboBox4.SelectedValue = (int)Values[2]; //comboBox4.Enabled = false; dateTimePicker1.Value = Convert.ToDateTime(Values[3]); textBox15.Text = Values[4].ToString(); textBox12.Text = Values[5].ToString(); //Пробег textBox24.Text = Values[6].ToString(); textBox25.Text = Values[7].ToString(); textBox26.Text = Values[8].ToString(); textBox31.Text = Values[9].ToString(); textBox29.Text = Values[10].ToString(); textBox30.Text = Values[11].ToString(); textBox27.Text = Values[12].ToString(); textBox28.Text = Values[13].ToString(); textBox35.Text = Values[14].ToString(); break; case "FPage_Organizations": Values = Base.GetRowFields(ID, "Organizations"); textBox17.Text = Values[0].ToString(); comboBox5.SelectedIndex = (int)Values[1]; break; case "FPage_Staff": Values = Base.GetRowFields(ID, "Staff"); comboBox6.exFill(DB_ID, "Staffposition_name", "StaffPosition"); textBox20.Text = Values[0].ToString(); textBox21.Text = Values[1].ToString(); textBox19.Text = Values[2].ToString(); comboBox6.SelectedValue = (int)Values[3]; break; case "FPage_StaffPosition": Values = Base.GetRowFields(ID, "StaffPosition"); textBox18.Text = Values[0].ToString(); break; case "FPage_Trackinglists": Values = Base.GetRowFields(ID, "Trackinglists"); comboBox7.exFill(DB_ID, "Organization_name", "Organizations", "Organization_ratio=0"); comboBox8.exFillExtra(DB_ID, "Cars.ID, [CarBrand]![Carbrand_name] & \" \" & [CarModel]![Carmodel_name] & \", Гос. номер: \" & [Cars]![Car_number] AS Result", "(CarBrand INNER JOIN CarModel ON CarBrand.ID = CarModel.Carmodel_brand) INNER JOIN Cars ON CarModel.ID = Cars.Car_model"); comboBox9.exFillExtra(DB_ID, "Drivers.ID, [Drivers]![Driver_lastname] & \" \" & [Drivers]![Driver_firstname] & \" \" & [Drivers]![Driver_thirdname] AS Result", "Drivers"); comboBox10.exFillExtra(DB_ID, "Staff.ID, [Staff]![Staff_lastname] & \" \" & [Staff]![Staff_firstname] & \" \" & [Staff]![Staff_thirdname] AS Result", "Staff"); comboBox11.exFillExtra(DB_ID, "Staff.ID, [Staff]![Staff_lastname] & \" \" & [Staff]![Staff_firstname] & \" \" & [Staff]![Staff_thirdname] AS Result", "Staff"); comboBox12.exFillExtra(DB_ID, "Staff.ID, [Staff]![Staff_lastname] & \" \" & [Staff]![Staff_firstname] & \" \" & [Staff]![Staff_thirdname] AS Result", "Staff"); comboBox13.exFill(DB_ID, "Organization_name", "Organizations", "Organization_ratio=1"); comboBox14.exFill(DB_ID, "Organization_name", "Organizations", "Organization_ratio=2"); textBox22.Text = Values[0].ToString(); textBox23.Text = Values[1].ToString(); dateTimePicker2.Value = Convert.ToDateTime(Values[2]); comboBox7.SelectedValue = (int)Values[3]; comboBox8.SelectedValue = (int)Values[4]; comboBox9.SelectedValue = (int)Values[5]; comboBox10.SelectedValue = (int)Values[6]; comboBox11.SelectedValue = (int)Values[7]; comboBox12.SelectedValue = (int)Values[8]; comboBox13.SelectedValue = (int)Values[9]; comboBox14.SelectedValue = (int)Values[10]; break; } break; } if (TYPE == DataCommon.FormType.Edit) { // Замена событий Button_Add.Click -= Button_Add_Click; Button_Add.Click += Button_Save_Click; // Прочие изменения Text = "Редактировать запись"; Button_Add.Text = "Сохранить"; } }
public MenuPrincipal() { InitializeComponent(); TabMain.SelectTab(2); }