public CarDesignArr GetDesigns() { CarColor carColor = null; ColorType colorTypes = null; BodyDesign bodyDesign = null; CarDesignArr carDesignArr = new CarDesignArr(); carDesignArr.Fill(); if (cmb_Color.SelectedIndex != -1) { carColor = cmb_Color.SelectedItem as CarColor; } if (cmb_ColorType.SelectedIndex != -1) { colorTypes = cmb_ColorType.SelectedItem as ColorType; } if (cmb_Body.SelectedIndex != -1) { bodyDesign = cmb_Body.SelectedItem as BodyDesign; } return(carDesignArr.Filter(carColor, colorTypes, bodyDesign)); }
private void btn_Delete_Click(object sender, EventArgs e) { BodyDesign bodyDesign = FormToBodyDesign(); CarDesignArr carDesignArr = new CarDesignArr(); carDesignArr.Fill(); if (bodyDesign.Id == 0) { } else { if (carDesignArr.DoesExist(bodyDesign)) { MessageBox.Show("You can not delete this Body Design, it is connected" + " to 1 or more Orders", "Can not delete Car color", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (MessageBox.Show("Are you sure you want to delete this" + " Body Design? ", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { bodyDesign.Delete(); ClearForm(); BodyDesignArrToForm(null); } } } }
private void btn_Delete_Click(object sender, EventArgs e) { ColorType colorType = FormToColorTypes(); CarDesignArr carDesignArr = new CarDesignArr(); carDesignArr.Fill(); if (colorType.Id == 0) { } else { if (carDesignArr.DoesExist(colorType)) { MessageBox.Show("You can not delete this Car color, it is connected" + " to 1 or more Orders", "Can not delete Color Type", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (MessageBox.Show("Are you sure you want to delete this" + " Color Type? ", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { colorType.Delete(); ClearForm(); ColorTypesArrToForm(null); } } } }
private void CarDesignArrToForm(CarDesign curCarDesign) { CarDesignArr carDesignArr = new CarDesignArr(); carDesignArr.Fill(); listbox_Designs.ValueMember = "ID"; listbox_Designs.DisplayMember = "FullDesign"; listbox_Designs.DataSource = carDesignArr; if (curCarDesign != null) { listbox_Designs.SelectedValue = curCarDesign.Id; } }
private void btn_Save_Click(object sender, EventArgs e) { if (CheckForm()) { CarDesign carDesign = new CarDesign(); carDesign = FormToCarDesign(); CarDesignArr oldCarDesignArr = new CarDesignArr(); oldCarDesignArr.Fill(); if (!oldCarDesignArr.IsContain(carDesign.ToString())) { if (carDesign.Id == 0) { if (carDesign.Insert()) { MessageBox.Show("Data saved successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearForm(); CarDesignArr carDesignArr = new CarDesignArr(); carDesignArr.Fill(); carDesign = carDesignArr.GetCarDesignWithMaxId(); CarDesignArrToForm(carDesign); } } else { if (carDesign.Update()) { MessageBox.Show("Data updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearForm(); CarDesignArr carDesignArr = new CarDesignArr(); carDesignArr.Fill(); carDesign = carDesignArr.GetCarDesignWithMaxId(); CarDesignArrToForm(null); } } } else { MessageBox.Show("Car Design already exsits", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); ClearForm(); } } }