Esempio n. 1
0
        private async void buttonX1_Click(object sender, EventArgs e)
        {
            DateTime?DateTimenull = ClassConvert.ConvDateTimeNull(dateTimeInput1.Value);

            if (CV_i == null)
            {
                if (comboBoxEx1.SelectedIndex == -1)
                {
                    MegBox.Show("لا يمكن ترك حقل دراسه فارغ");
                    return;
                }
                else if (textBoxX1.Text.Trim() == "")
                {
                    MegBox.Show("لا يمكن ترك حقل الأسم فارغ");
                    return;
                }
                else if (integerInput1.Value == 0)
                {
                    MegBox.Show("لا يمكن ترك حقل رقم الهاتف فارغ");
                    return;
                }
                else if (!ClassConvert.IsNumberPhoneMobileOrGrund(integerInput1.Value))
                {
                    MegBox.Show("لا يمكن ترك حقل رقم الهاتف فارغ");
                    return;
                }



                int Idc = CV_Study.CV_StudyList[comboBoxEx1.SelectedIndex].id;

                int Idc1 = -1;
                int Idc2 = -1;
                if (comboBoxEx3.SelectedIndex != -1)
                {
                    Idc1 = CvTeamNeed.CvTeamNeedList[comboBoxEx3.SelectedIndex].id;
                }

                if (comboBoxEx4.SelectedIndex != -1)
                {
                    Idc2 = CvTeamNeed.CvTeamNeedList[comboBoxEx4.SelectedIndex].id;
                }

                CV_i = new CV_Info(0, textBoxX1.Text, textBoxX2.Text, await CV.GetTheNumberArchev(Idc), Idc, comboBoxEx2.SelectedIndex, integerInput1.Value, dateTimeInput1.Value, Idc1, checkBoxX1.Checked, comboBoxEx4.SelectedIndex, ClassConvert.ConvDateTimeNull(dateTimeInput2.Value), textBoxX3.Text);
                int idc = await Sqldatabasethrding.SqlSaveAdderAndBack(CV_i.adder());

                if (idc > 0)
                {
                    MegBox.Show("تم التسجيل", this);
                    labelX4.Text = CV_i.GetCodeArch();
                    CV_i         = new CV_Info(idc, textBoxX1.Text, textBoxX2.Text, await CV.GetTheNumberArchev(Idc), Idc, comboBoxEx2.SelectedIndex, integerInput1.Value, dateTimeInput1.Value, Idc1, checkBoxX1.Checked, Idc2, ClassConvert.ConvDateTimeNull(dateTimeInput2.Value), textBoxX3.Text);
                    foreach (HaveScil item in listHavescil)
                    {
                        item.EditCV_Info_ID(CV_i.id);
                    }
                    Sqldatabasethrding.SqlAddOrUpdateOrDelet(ClassConvert.ConvertListInterfaseToDataBase(this.listHavescil), IntAddeHavescilr, InteditHavescil, IntDelHavescil);
                }
                else
                {
                    MegBox.Show("هناك خطأ في الاتصال", this);
                }
            }
            else
            {
                CV_i = new CV_Info(CV_i.id, textBoxX1.Text, textBoxX2.Text, (CV_i.Id_Study == CV_Study.CV_StudyList[comboBoxEx1.SelectedIndex].id ? CV_i.NmuberOfArchev: await CV.GetTheNumberArchev(CV_Study.CV_StudyList[comboBoxEx1.SelectedIndex].id)),
                                   CV_Study.CV_StudyList[comboBoxEx1.SelectedIndex].id,
                                   comboBoxEx2.SelectedIndex,
                                   integerInput1.Value,
                                   DateTimenull,
                                   comboBoxEx3.SelectedIndex != -1 ?    CvTeamNeed.CvTeamNeedList[comboBoxEx3.SelectedIndex].id : -1,
                                   checkBoxX1.Checked,
                                   comboBoxEx4.SelectedIndex != -1 ? CvTeamNeed.CvTeamNeedList[comboBoxEx4.SelectedIndex].id : -1, ClassConvert.ConvDateTimeNull(dateTimeInput2.Value), textBoxX3.Text
                                   );
                if (await Sqldatabasethrding.SqlSaveVitl(CV_i.updata()))
                {
                    labelX4.Text = CV_i.GetCodeArch();
                    MegBox.Show("تم التعديل", this);
                    Sqldatabasethrding.SqlAddOrUpdateOrDelet(ClassConvert.ConvertListInterfaseToDataBase(this.listHavescil), IntAddeHavescilr, InteditHavescil, IntDelHavescil);
                }
                else
                {
                    MegBox.Show("هناك خطأ في الاتصال", this);
                }
            }
        }