السلام عليكم
انا اعمل على سي شارب 2005
عندى مشكلة كبيرة فى داتا جريد فيو
اريد انا عمل اضافة و حذف و تعديل من داخل الجرد فيو من الخيا تاعيت جريد الفيو
طبعا مع عمل validation على الخلايا ارجو الاجابة بسرعة و شكرا
السلام عليكم
انا اعمل على سي شارب 2005
عندى مشكلة كبيرة فى داتا جريد فيو
اريد انا عمل اضافة و حذف و تعديل من داخل الجرد فيو من الخيا تاعيت جريد الفيو
طبعا مع عمل validation على الخلايا ارجو الاجابة بسرعة و شكرا
هذا الكود يستخدم لتحميل البيانات في الجريد من جدول الاصناف
private void d1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
try
{
if (d1.Rows.Count > 1)
{
switch (e.ColumnIndex)
{
case 1:
if (d1.CurrentRow.Cells[1].Value == null)
{
d1.Rows.RemoveAt(d1.CurrentRow.Index);
// d1.CurrentRow.Cells[4].Value = null;
d1.CurrentCell = d1.Rows[d1.CurrentRow.Index + 1].Cells[1];
return;
}
string s;
s = Convert.ToString(d1.CurrentRow.Cells[1].Value).Trim();
string sqw = "select *from kinds where kind_id=" + s;
SqlConnection con = new SqlConnection(db.connection);
con.Open();
SqlCommand cmd = new SqlCommand(sqw, con);
SqlDataReader rdr = cmd.ExecuteReader();
if (rdr.HasRows == true)
{
while (rdr.Read())
{
if (Convert.ToChar(rdr["manfuctuer"]) == 'y')
{
MessageBox.Show("هذا الصنف تجميعي");
d1.Rows.RemoveAt(d1.CurrentRow.Index);
// d1.CurrentRow.Cells[4].Value = null;
d1.CurrentCell = d1.Rows[d1.CurrentRow.Index + 1].Cells[1];
return;
}
d1.CurrentRow.Cells[2].Value = rdr["kind_" + db.lang + "name"];
d1.CurrentRow.Cells[9].Value = rdr["kind_pr_price"];
conversion = Convert.ToDouble(rdr["conversion"]);
if (Convert.ToChar(rdr["kind_type"]) == '3')
{
d1.CurrentRow.Cells[5].ReadOnly = false;
}
if (Convert.ToChar(rdr["kind_type"]) == '4')
{
d1.CurrentRow.Cells[6].ReadOnly = false;
}
if (Convert.ToChar(rdr["kind_color"]) != 'n')
{
d1.CurrentRow.Cells[7].ReadOnly = false ;
}
if (Convert.ToChar(rdr["size"]) != 'n')
{
d1.CurrentRow.Cells[8].ReadOnly = false;
}
d1.CurrentRow.Cells[10].Value = (Convert.ToDouble(d1.CurrentRow.Cells[3].Value) * Convert.ToDouble(d1.CurrentRow.Cells[9].Value)) + ((Convert.ToDouble(d1.CurrentRow.Cells[4].Value) * Convert.ToDouble(d1.CurrentRow.Cells[9].Value)) / conversion);
d1.CurrentRow.Cells[4].Value = 0;
d1.CurrentRow.Cells[11].Value = 0;
}
}
else
{
MessageBox.Show("هذا الصنف غير موجود");
d1.Rows.RemoveAt(d1.CurrentRow.Index);
// d1.CurrentRow.Cells[4].Value = null;
d1.CurrentCell = d1.Rows[d1.CurrentRow.Index + 1].Cells[1];
}
break;
case 3:
d1.CurrentRow.Cells[10].Value = (Convert.ToDouble(d1.CurrentRow.Cells[3].Value) * Convert.ToDouble(d1.CurrentRow.Cells[9].Value)) + ((Convert.ToDouble(d1.CurrentRow.Cells[4].Value) * Convert.ToDouble(d1.CurrentRow.Cells[9].Value)) / conversion);
break;
case 4:
d1.CurrentRow.Cells[10].Value = (Convert.ToDouble(d1.CurrentRow.Cells[3].Value) * Convert.ToDouble(d1.CurrentRow.Cells[9].Value)) + ((Convert.ToDouble(d1.CurrentRow.Cells[4].Value) * Convert.ToDouble(d1.CurrentRow.Cells[9].Value)) / conversion);
تم تعديل هذه المشاركة بواسطة Ben_Laiid في 7 نوفمبر 2007 في 21:11
هذا الموضوع مغلق.