C# DataGridView 的UserDeletingRow事件,删除

 DialogResult dr = MessageBox.Show("确认删除记录吗?", "提示", MessageBoxButtons.YesNo);
            if (dr == DialogResult.Yes)
            {
                DataSet deleRcom2 = Collections.FastSocket.get_ds("select o.id,b.dd_size,b.size_long,b.size_wide,b.size_high,o.goodsType,o.cname,o.pay_type,o.order_memo,o.address,o.RecipientCode,o.mobile,o.country_free,o.agencyFund,o.order_code,o.cforhmType,b.goods,b.kd_billcode,b.dd_weight,b.dd_weight2,b.member_id,b.username,b.goodsTyep goodsType2  from pmw_order o left join pmw_billcode b on o.order_code=b.order_code where isnull(o.DoubleCheck,0)=1 and isnull(b.lost_flag,0)=0 and isnull(b.is_outplace,0)=1 and  isnull(is_packed,0)=0 and isnull(packed_billcode,'')='' and o.order_code='" + this.tool_order_code.Text + "' and b.kd_billcode='" + e.Row.Cells["kd_billcode2"].Value + "'");
                if (deleRcom2 != null && deleRcom2.Tables.Count > 0 && deleRcom2.Tables[0].Rows.Count > 0)
                {

                    DataTable dt1 = (DataTable)rcomdgv1.DataSource;
                    DataRow drcalc = dt1.NewRow();
                    drcalc.ItemArray = deleRcom2.Tables[0].Rows[0].ItemArray;
                    dt1.Rows.Add(drcalc);
                    rcomdgv1.DataSource = dt1;
                }
                else
                {
                    MessageBox.Show("无法获取该数据");
                    e.Cancel = true;
                }
            }
            else
            {
                e.Cancel = true;
            }

posted @ 2017-10-18 12:26  LuoCore  阅读(1218)  评论(0编辑  收藏  举报