private void check_radio() { Customers_Suppliers CS = new Customers_Suppliers(); if (radioButton1.Checked) { con_ID = "Sup"; } else if (radioButton2.Checked) { con_ID = "Cus"; } }
private void New_cust_Click(object sender, EventArgs e) { Customers_Suppliers CS = new Customers_Suppliers(); check_radio(); Random rnd = new Random(); textBox1.Text = rnd.Next().ToString(); if (con_ID == null) { MessageBox.Show("please select the Radiobutton"); } else { CS.ID = con_ID + "-" + textBox1.Text; CS.name = comboBox1.Text; CS.type = con_ID; CS.BirthDate = dateTimePicker1.Value.ToShortDateString(); CS.phone = int.Parse(textBox4.Text); CS.mobile = int.Parse(textBox5.Text); CS.fax = int.Parse(textBox6.Text); CS.Mail = textBox7.Text; CS.website = textBox2.Text; CS.Location = textBox3.Text; CS.Comments = textBox8.Text; if (CS.name == null) { MessageBox.Show("name is empty"); } else { Company_ProjectEntities company_Project = new Company_ProjectEntities(); company_Project.Customers_Suppliers.Add(CS); company_Project.SaveChanges(); MessageBox.Show($"New {CS.type} Added"); } } EmptyForm(); comboBox1_showList(); }