日期:2014-05-17  浏览次数:20758 次

求高手 给 这段代码 优化一下

DataTable dtPay = dgvPay.DataSource as DataTable;
            DataTable dtReceive = dgvReceive.DataSource as DataTable;
            if (dtPay != null)
            {
                if (dtReceive.Rows.Count == dtPay.Rows.Count) 
                {
                    for (int i = 0; i < dtPay.Rows.Count; i++) 
                    {
                        dtReceive.Rows[i]["IsOriginal"] = dtPay.Rows[i]["IsOriginal"];
                    }
                }
                else if (dtPay.Rows.Count > dtReceive.Rows.Count) 
                {
                    int j = 0;
                    for (int i = 0; i < dtPay.Rows.Count; i++) 
                    {
                        for (; j < dtReceive.Rows.Count; ) 
                        {
                            dtReceive.Rows[j]["IsOriginal"] = dtPay.Rows[i]["IsOriginal"];
                            j++;
                            break;
                        }
                    }
                }
                else if (dtPay.Rows.Count < dtReceive.Rows.Count) 
                {
 &n