Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (Convert.ToDouble(RemainingMonytextbox.Text) != (Convert.ToDouble(allMonytextpox.Text) - Convert.ToDouble(Paiedmonytextbox.Text)))
                {
                    MessageBox.Show("القيمة المتبقية من الاموال غير مستحقة", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    allMonytextpox.Text       = "0";
                    RemainingMonytextbox.Text = "0";
                    return;
                }

                SolfaClientDetailsClass newduration = new SolfaClientDetailsClass
                {
                    DateAdded         = dateTimePicker1.Value,
                    allMony           = Convert.ToDouble(allMonytextpox.Text),
                    paidOrderMony     = Convert.ToDouble(Paiedmonytextbox.Text),
                    RemaningOrderMony = Convert.ToDouble(RemainingMonytextbox.Text),
                    solfaclientid     = this.clientId
                };
                context.solfaClientDetails.Add(newduration);
                context.SaveChanges();
                MessageBox.Show("تم الاضافة بنجاح", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch
            {
                MessageBox.Show("من فضلك اكمل البيانات", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #2
0
        private void savesolfa_Click(object sender, EventArgs e)
        {
            try
            {
                if (clientNametextbox.Text == "")
                {
                    MessageBox.Show("من فضلك ادخل اسم العميل", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (Convert.ToDouble(RemainingMonytextbox.Text) != (Convert.ToDouble(AllMonytextBox.Text) - Convert.ToDouble(PaiedMonytextpox.Text)))
                {
                    MessageBox.Show("القيمة المتبقية من الاموال غير مستحقة", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    PaiedMonytextpox.Text     = "0";
                    RemainingMonytextbox.Text = "0";
                    return;
                }
                var clientifexist = context.solfaClientClass.FirstOrDefault(c => c.Name == clientNametextbox.Text);

                if (firstPhonetextbox.Text != "")
                {
                    clientifexistusingphone1 = context.solfaClientClass.FirstOrDefault(c => (c.FirstPhoneNumner == firstPhonetextbox.Text) || (c.SecondPhoneNumner == firstPhonetextbox.Text));
                }
                if (seceondPhoneTextbox.Text != "")
                {
                    clientifexistusingphone2 = context.solfaClientClass.FirstOrDefault(c => (c.FirstPhoneNumner == seceondPhoneTextbox.Text) || (c.SecondPhoneNumner == seceondPhoneTextbox.Text));
                }
                if (clientifexist != null)
                {
                    DialogResult dialog = MessageBox.Show("هذا الاسم موجود بافعل لايمكن اضافةمره اخرى", "المريض موجود", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (dialog == DialogResult.OK)
                    {
                        FormClearName();
                        clientifexist = null;
                        return;
                    }
                }
                if (clientifexistusingphone1 != null || clientifexistusingphone2 != null)
                {
                    DialogResult dialog = MessageBox.Show("رقم الهاتف موجود بافعل لا يمكن اضافةمره اخرى", "المريض موجود", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (dialog == DialogResult.OK)
                    {
                        FormClearphone();
                        clientifexistusingphone1 = null;
                        clientifexistusingphone2 = null;
                        return;
                    }
                }
                SolfaClientClass newclient = new SolfaClientClass()
                {
                    Name              = clientNametextbox.Text,
                    Address           = clientAddresstextbox.Text,
                    FirstPhoneNumner  = firstPhonetextbox.Text,
                    SecondPhoneNumner = seceondPhoneTextbox.Text,
                    Nots              = NotstextBox.Text,
                };

                context.solfaClientClass.Add(newclient);
                context.SaveChanges();
                var curentclientid = context.solfaClientClass.FirstOrDefault(
                    c => c.Name == clientNametextbox.Text &&
                    c.Address == clientAddresstextbox.Text &&
                    c.FirstPhoneNumner == firstPhonetextbox.Text &&
                    c.SecondPhoneNumner == seceondPhoneTextbox.Text &&
                    c.Nots == NotstextBox.Text);

                SolfaClientDetailsClass newduration = new SolfaClientDetailsClass
                {
                    DateAdded         = AddeddateTimePicker.Value,
                    allMony           = Convert.ToDouble(AllMonytextBox.Text),
                    paidOrderMony     = Convert.ToDouble(PaiedMonytextpox.Text),
                    RemaningOrderMony = Convert.ToDouble(RemainingMonytextbox.Text),
                    solfaclientid     = curentclientid.Id
                };
                context.solfaClientDetails.Add(newduration);
                context.SaveChanges();
                MessageBox.Show("تم الاضافة بنجاح", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                FormClear();
            }
            catch {
                MessageBox.Show("من فضلك اكمل البيانات", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }