private void CreateCompBtn_Click(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(compNameTxt.Text) || String.IsNullOrEmpty(compNumTxt.Text) || String.IsNullOrEmpty(DecisionTxt.Text) || String.IsNullOrEmpty(decisionNumTxt.Text)) { throw new Exception("برجاء ادخال البيانات المطلوبة في الصفجة المنافسة"); } Competition newComp = new Competition(); newComp.comp_Name = compNameTxt.Text; newComp.comp_Code = compNumTxt.Text; /******************Dates**********************/ //DecisionDate// DecDate = DecDateDayCBox.Text + " / " + DecDateMonthCBox.Text + " / " + DecDateYearCBox.Text; //meetDate// meetDate = MeetDatDayCBox.Text + " / " + MeetDatMonCBox.Text + " / " + MeetDatYearCBox.Text; //OpenDate// OpenDate = OpenDatDayCBox.Text + " / " + OpenDatMonCBox.Text + " / " + OpenDatYearCBox.Text; //SendDate// SendDate = SendDatDayCbox.Text + " / " + SendDatMonCbox.Text + " / " + SendDatYearCBox.Text; /*********************************************/ newComp.Date_Created = OpenDate; newComp.Decision_Date = DecDate; newComp.meetDate = meetDate; newComp.comp_sendDate = SendDate; newComp.items_count = itemsCount; if (fullRdb.Checked) { newComp.comp_Stat = fullRdb.Text; } else if (partRdb.Checked) { newComp.comp_Stat = partRdb.Text; } newComp.Decision_Num = decisionNumTxt.Text; newComp.Decision = DecisionTxt.Text; foreach (item item in itemslist) { newComp.Items.Add(item);; } foreach (Helper helper in helpersList) { newComp.Helpers.Add(helper); } foreach (item offer in offerslist) { newComp.Offers.Add(offer); } newComp.ADD_Competiton(); MessageBox.Show("تمت العملية بنجاح"); Competitions frm = new Competitions(); frm.Show(); this.Hide(); } catch (Exception ex) { if (ex.Message.Contains("duplicate key")) { MessageBox.Show("رقم المنافسة موجود مسبقا، برجاء ادخال رقم اخر"); } else { MessageBox.Show(ex.Message); } } }