سلام عليكم
الكود بيظهر ليه ماسج ويقولى ان الداتا ريدر مفتوح ولازم اقفله عشان اسنخدمه
وبعد مااقفل اكيد بيحصل ارور لانى مش هعرف استخدمه وهو مقفول
بجد الكود دا حيرنى
ممكن اعرف الكود ايه المفروض يكون فيه
private void CmdRemove_Click(object sender, EventArgs e)
{
cmd.CommandText = "select * from vpayout";
dr = cmd.ExecuteReader();
dr.Read();
if (dr.HasRows == false)
{
MessageBox.Show("الجدول لايحتوى على سجلات", MsgTxtt.MsgTtl, MessageBoxButtons.OK, MessageBoxIcon.Warning);
dr.Close();
}
else if (dr.HasRows == true)
{
while (dr.Read() == true)
{
int index = dr.FieldCount;
//MessageBox.Show(index.ToString());
string V_Id, V_Component, V_Model, V_Quantity;
V_Id = dr["poid"].ToString();
V_Component = dr["pocomponent"].ToString();
V_Model = dr["pomodel"].ToString();
V_Quantity = dr["poquantity"].ToString();
//if (dr.IsClosed == false)
//{
// dr.Close();
//}
for (int i = 0; i < index; i++)
{
cmd.CommandText = "select * from storer where sid=' " + V_Id.Trim() + " ' and scomponent=' " + V_Component.Trim() + " ' and smodel=' " + V_Model.Trim() + " ' ";
dr = cmd.ExecuteReader();
if (dr.Read() == true)
{
if (dr.IsClosed == false)
{
dr.Close();
}
cmd.CommandText = " update storer set squantity= squantity - (' " + double.Parse(V_Quantity.Trim()) + " ') where sid=' " + V_Id.Trim() + " ' and scomponent=' " + V_Component.Trim() + " ' and smodel=' " + V_Model + " ' ";
cmd.ExecuteNonQuery();
cmd.CommandText = " insert into payout (pono,podate,poid,pocomponent,pomodel,poquantity,posell,pototalsell,podisc,pototalaftdisc,poaftdisc) select * from vpayout where sid=' " + V_Id.Trim() + " ' and scomponent=' " + V_Component.Trim() + " ' and smodel=' " + V_Model + " ' ";
cmd.ExecuteNonQuery();
}
}
}
if (dr.IsClosed == false)
{
dr.Close();
}
cmd.CommandText = "delete from vpayout ";
cmd.ExecuteNonQuery();
MessageBox.Show("تم الحذف", MsgTxtt.MsgTtl, MessageBoxButtons.OK, MessageBoxIcon.Information);
ClearTxt();
MessageBox.Show("تم ترحيل المبيعات بنجاح ", MsgTxtt.MsgTtl, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}


