المشاركات : 186
المواضيع 33
الإنتساب : Dec 2018
السمعة :
1
الشكر: 187
تم شكره 150 مرات في 105 مشاركات
السلام عليكم اخوانى
بيظهر لي هذا الخطأ
Operator '>' cannot be applied to operands of type 'void' and 'int'
وهذا هو الكود المستخدم
كود :
public void VerifyEntredQuantity(string Product_S_N,int QuantityEntred)
{
DataTable dt6 = new DataTable();
dt6.Clear();
cmd = new SqlCommand("select * from Products where Product_S_N='" + Product_S_N + "' and Quantity > '" + QuantityEntred + "'", con);
da = new SqlDataAdapter(cmd);
da.Fill(dt6);
}
والخطأ بيظهر فى هذا الكود فى السطر رقم ( 5 )
if (VerifyEntredQuantity(ProductS_N, Convert.ToInt32(txtQuantity.Text)) > 1)
كود :
private void txtDiscount_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
{
if(txtDiscount.Text != string.Empty)
{
foreach(DataGridViewRow Loop in dataGridView1.Rows)
{
if (VerifyEntredQuantity(ProductS_N, Convert.ToInt32(txtQuantity.Text)) > 1)
if(Loop.Cells[1].Value.ToString() == cmbProductName.Text)
{
MessageBox.Show("هذا المنتج موجود بالفعل", "تنبية", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
}
DataRow Row = dt.NewRow();
Row[0] = ProductS_N;
Row[1] = cmbProductName.Text;
Row[2] = txtPrice.Text;
Row[3] = txtQuantity.Text;
Row[4] = txtDiscount.Text;
Row[5] = txtTotalRequired.Text;
dt.Rows.Add(Row);
dataGridView1.DataSource = dt;
CalculateSumBill();
CalculateBill();
ClearBillDetails();
txtPrice.Focus();
}
else
{
MessageBox.Show("يجب ملئ خانة الخصم", "تنبية", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
بتمني حد يساعني في حل هذه المشكلة
شكراً مقدماً
المشاركات : 4
المواضيع 0
الإنتساب : Dec 2020
السمعة :
2
الشكر: 0
تم شكره 6 مرات في 4 مشاركات
الفنكشن VerifyEntredQuantity من نوع void لا يرجع باي قيمه
للتصحيح
غير void الى int
كود :
public int VerifyEntredQuantity(string Product_S_N, int QuantityEntred)
واضف return قبل ;(da.Fill(dt6
كود :
return da.Fill(dt6);
المشاركات : 2,329
المواضيع 81
الإنتساب : May 2018
السمعة :
522
الشكر: 14039
تم شكره 5671 مرات في 2269 مشاركات
PHP كود :
public Int32 VerifyEntredQuantity(string Product_S_N, int QuantityEntred) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(); System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection("Server =(local);database=TestDB;integrated security=True"); DataTable dt6 = new DataTable(); dt6.Clear(); cmd = new System.Data.SqlClient.SqlCommand("select Count(*) from Products where Product_S_N='" + Product_S_N + "' and Quantity > '" + QuantityEntred + "'", con); da = new System.Data.SqlClient.SqlDataAdapter(cmd); da.Fill(dt6); if (dt6.Rows.Count<=0) { return 0; } return Convert.ToInt32(dt6.Rows[0][0]); }
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
المشاركات : 186
المواضيع 33
الإنتساب : Dec 2018
السمعة :
1
الشكر: 187
تم شكره 150 مرات في 105 مشاركات
24-12-20, 09:32 AM
(آخر تعديل لهذه المشاركة : 24-12-20, 09:34 AM {2} بواسطة maxruined.)
(23-12-20, 12:12 PM)Ngm كتب : الفنكشن VerifyEntredQuantity من نوع void لا يرجع باي قيمه
للتصحيح
غير void الى int
كود :
public int VerifyEntredQuantity(string Product_S_N, int QuantityEntred)
واضف return قبل ;(da.Fill(dt6
كود :
return da.Fill(dt6);
شكراً جداً اخوي .. تم حل المشكلة بمساعدتكم
(23-12-20, 01:00 PM)asemshahen5 كتب : PHP كود :
public Int32 VerifyEntredQuantity(string Product_S_N, int QuantityEntred) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(); System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection("Server =(local);database=TestDB;integrated security=True"); DataTable dt6 = new DataTable(); dt6.Clear(); cmd = new System.Data.SqlClient.SqlCommand("select Count(*) from Products where Product_S_N='" + Product_S_N + "' and Quantity > '" + QuantityEntred + "'", con); da = new System.Data.SqlClient.SqlDataAdapter(cmd); da.Fill(dt6); if (dt6.Rows.Count<=0) { return 0; } return Convert.ToInt32(dt6.Rows[0][0]); }
اخوي عاصم .. الاكثر من رائع .. فعلا تم حل المشكلة بمساعدتكم .. حقيقي شكراً جدا لكم
دمت متألق اخوي عاصم الله يجزيك كل خير يارب
المشاركات : 186
المواضيع 33
الإنتساب : Dec 2018
السمعة :
1
الشكر: 187
تم شكره 150 مرات في 105 مشاركات
24-12-20, 02:34 PM
(آخر تعديل لهذه المشاركة : 24-12-20, 02:35 PM {2} بواسطة maxruined.)
واجهتني مشكلة تاني
وهذا هو الخطأ اللى بيظهر
Unclosed quotation mark after the character string ''.'
وهذا هو الكود اللي مستخدم في عمليه الحفظ
كود :
if(txtNewClient.Text != string.Empty)
{
con.Open();
cmd = new SqlCommand("insert into Unknown_Clients (S_N,Client_Name)values(@S_N,@Client_Name)", con);
cmd.Parameters.AddWithValue("S_N", txtClientID.Text);
cmd.Parameters.AddWithValue("Client_Name", txtNewClient.Text);
cmd.ExecuteNonQuery();
con.Close();
//----------------------------------------------------------
con.Open();
cmd = new SqlCommand("insert into Orders_Unknown_Clients (ID_Order,Order_Date,Client_S_N,Description_Order)values(@ID_Order,@Order_Date,@Client_S_N,@Description_Order)", con);
cmd.Parameters.AddWithValue("ID_Order", Convert.ToInt32(txtOrderID.Text));
cmd.Parameters.AddWithValue("Order_Date", Convert.ToDateTime(dateTimePicker1.Text));
cmd.Parameters.AddWithValue("Client_S_N", Convert.ToInt32(txtClientID.Text));
cmd.Parameters.AddWithValue("Description_Order", txtDescription.Text);
cmd.ExecuteNonQuery();
con.Close();
foreach(DataGridViewRow loop in dataGridView1.Rows)
{
con.Open();
cmd = new SqlCommand("insert into Order_Details_Unknown_Clients (Product_S_N,ID_Order,Price,Quantity,Discount,Total_Required)values(@Product_S_N,@ID_Order,@Price,@Quantity,@Discount,@Total_Required)", con);
cmd.Parameters.AddWithValue("Product_S_N", Convert.ToInt32(loop.Cells[0].Value.ToString()));
cmd.Parameters.AddWithValue("ID_Order", Convert.ToInt32(txtOrderID.Text));
cmd.Parameters.AddWithValue("Price", loop.Cells[2].Value.ToString());
cmd.Parameters.AddWithValue("Quantity", loop.Cells[3].Value.ToString());
cmd.Parameters.AddWithValue("Discount", loop.Cells[4].Value.ToString());
cmd.Parameters.AddWithValue("Total_Required", loop.Cells[5].Value.ToString());
cmd = new SqlCommand("update Products set Quantity=@Quantity - '" + loop.Cells[3].Value.ToString() + " where Product_S_N='" + ProductS_N + "'", con);
cmd.Parameters.AddWithValue("Quantity", loop.Cells[3].Value.ToString());
cmd.ExecuteNonQuery();
con.Close();
}
MessageBox.Show("تم حفظ الفاتورة بنجاح", "إضافه", MessageBoxButtons.OK, MessageBoxIcon.Information);
ClearDataInDataGridView();
btnPrintInvoice.Enabled = true;
btnDeleteCurrentRow.Enabled = false;
cmbClientName.Enabled = false;
txtNewClient.Enabled = false;
txtDescription.Enabled = false;
dateTimePicker1.Enabled = false;
cmbProductName.Enabled = false;
txtPrice.Enabled = false;
txtQuantity.Enabled = false;
txtDiscount.Enabled = false;
txtTotalRequired.Enabled = false;
}
المفروض ان الخطأ هنا بش مش عارف ليه الحقيقه ليا اكثر من ساعه مش عارف الاقي فين المشكلة
كود :
cmd = new SqlCommand("update Products set Quantity=@Quantity - '" + loop.Cells[3].Value.ToString() + " where Product_S_N='" + ProductS_N + "'", con);
cmd.Parameters.AddWithValue("Quantity", loop.Cells[3].Value.ToString());
المشاركات : 2,329
المواضيع 81
الإنتساب : May 2018
السمعة :
522
الشكر: 14039
تم شكره 5671 مرات في 2269 مشاركات
Quantity=@Quantity - ' عدله ليكون Quantity=@Quantity -
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
المشاركات : 186
المواضيع 33
الإنتساب : Dec 2018
السمعة :
1
الشكر: 187
تم شكره 150 مرات في 105 مشاركات
(24-12-20, 08:17 PM)asemshahen5 كتب : Quantity=@Quantity - ' عدله ليكون Quantity=@Quantity -
جلا من لا يسهو .. مع اني نظرت الي الكود اكثر من مرة ولم الاحظ اني ما اغلقتش ال Quotation Mark
شكراً جداً اخوي عاصم
ولكن ما تزال المشكلة موجود وهي ان الكود بيتم تحديثه بصفر مش بالقيمه الحقيقه المدخله ؟!
وهي المخزن فعلا - المباع = الكمية الموجوده الفعليه في المخزن
المشاركات : 2,329
المواضيع 81
الإنتساب : May 2018
السمعة :
522
الشكر: 14039
تم شكره 5671 مرات في 2269 مشاركات
حول القيمة من الداتا غريد الى انتجر و الغ ' لانها للقيمة النصية او اعمل استورد بروسيجر يرسل القيمة من الداتاغريد و رقم السيريال للبحث الى الاستعلام في الستورد بروسيجر و هو يقوم بالعملية الحسابية .
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
المشاركات : 186
المواضيع 33
الإنتساب : Dec 2018
السمعة :
1
الشكر: 187
تم شكره 150 مرات في 105 مشاركات
(26-12-20, 01:31 PM)asemshahen5 كتب : حول القيمة من الداتا غريد الى انتجر و الغ ' لانها للقيمة النصية او اعمل استورد بروسيجر يرسل القيمة من الداتاغريد و رقم السيريال للبحث الى الاستعلام في الستورد بروسيجر و هو يقوم بالعملية الحسابية .
حولتها ولكن نفس المشكلة بيحدث القيمه بصفر للاسف !!
ودا الكود المستخدم جايز يكون فيه مشكله !!
كود :
con.Open();
cmd = new SqlCommand("insert into Order_Details_Unknown_Clients (Product_S_N,ID_Order,Price,Quantity,Discount,Total_Required)values(@Product_S_N,@ID_Order,@Price,@Quantity,@Discount,@Total_Required)", con);
cmd.Parameters.AddWithValue("Product_S_N", Convert.ToInt32(loop.Cells[0].Value.ToString()));
cmd.Parameters.AddWithValue("ID_Order", Convert.ToInt32(txtOrderID.Text));
cmd.Parameters.AddWithValue("Price", loop.Cells[2].Value.ToString());
cmd.Parameters.AddWithValue("Quantity",loop.Cells[3].Value);
cmd.Parameters.AddWithValue("Discount", loop.Cells[4].Value.ToString());
cmd.Parameters.AddWithValue("Total_Required", loop.Cells[5].Value.ToString());
cmd = new SqlCommand("update Products set Quantity=@Quantity - " +loop.Cells[3].Value + " where Product_S_N='" + ProductS_N + "'", con);
cmd.Parameters.AddWithValue("Quantity",loop.Cells[3].Value);
cmd.ExecuteNonQuery();
con.Close();
المشاركات : 2,329
المواضيع 81
الإنتساب : May 2018
السمعة :
522
الشكر: 14039
تم شكره 5671 مرات في 2269 مشاركات
26-12-20, 02:26 PM
(آخر تعديل لهذه المشاركة : 26-12-20, 02:27 PM {2} بواسطة asemshahen5.)
PHP كود :
cmd = new SqlCommand("update Products set Quantity=Quantity - " +loop.Cells[3].Value + " where Product_S_N='" + ProductS_N + "'", con);
يعني :
PHP كود :
Quantity=Quantity - " +loop.Cells[3].Value + "
من دون @ .
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
|