21-04-23, 07:27 PM
السلام عليكم ورحمة الله وبركاته
لدي كود الحفظ التالي
يتحقق عن طريق اسم مورد ورقم هاتف
لماذا عندما ادخل رقم هاتف موجود مسبق تظهر رساله انه رقم موجود مسبقا لكن في حالة اسم مورد موجود مسبقا لاتظهر رساله تنبيه
هل لغة عربية هيا سبب مشكلة في تحميله في Datatable
ياريت من اخوة افادتي بجواب مقنع وكل عام وانتم بخير
لدي كود الحفظ التالي
يتحقق عن طريق اسم مورد ورقم هاتف
لماذا عندما ادخل رقم هاتف موجود مسبق تظهر رساله انه رقم موجود مسبقا لكن في حالة اسم مورد موجود مسبقا لاتظهر رساله تنبيه
هل لغة عربية هيا سبب مشكلة في تحميله في Datatable
ياريت من اخوة افادتي بجواب مقنع وكل عام وانتم بخير
كود :
if(sup_name.Text=="")
{
MessageBox.Show("الرجاء ادخال اسم المورد", "رسالة تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
sup_name.Select();
return;
}
if (sup_tel.Text == "")
{
MessageBox.Show("الرجاء ادخال رقم الهاتف ", "رسالة تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
sup_tel.Select();
return;
}
DataTable dt = new DataTable();
SqlDataAdapter adp = new SqlDataAdapter("select *from suppliers where sup_name='" + sup_name.Text + "' or sup_tel='" + sup_tel.Text+ "'",Class1.con);
adp.Fill(dt);
if(dt.Rows.Count>0)
{
int i = dt.Rows.Count - 1;
MessageBox.Show(" مورد موجود مسبقا تحت اسم: "+ dt.Rows[i]["sup_name"] +":"+ "ورقم هاتفه:"+ dt.Rows[i]["sup_tel"], "رسالة تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
dt.Rows.Add();
int i = dt.Rows.Count - 1;
dt.Rows[i]["sup_code"] = sup_code.Text;
dt.Rows[i]["sup_name"] = sup_name.Text;
dt.Rows[i]["sup_address"] = sup_address.Text;
dt.Rows[i]["sup_tel"] = sup_tel.Text;
dt.Rows[i]["name_company"] = name_company.Text;
dt.Rows[i]["notes"] = notes.Text;
dt.Rows[i]["status"] = true;
SqlCommandBuilder save = new SqlCommandBuilder(adp);
adp.Update(dt);
dt.AcceptChanges();
MessageBox.Show(" تم حفظ بنجاح ", "رسالة تاكيد", MessageBoxButtons.OK, MessageBoxIcon.Information);
button1_Click(sender, e);