dev gridview循环

来源:互联网 发布:电子版世界名画淘宝店 编辑:程序博客网 时间:2024/06/08 07:52

       








private void btnSave2_Click(object sender, EventArgs e)

        {
            for (int i = 0; i < gridView2.RowCount; i++)
            {
                string ID = this.gridView2.GetRowCellValue(i, gridView2.Columns["ReportTypeMappingID"]).ToString();
                string itemCode = this.gridView2.GetRowCellValue(i, gridView2.Columns["ReportTypeMappingItemCode"]).ToString();
                string ItemName = this.gridView2.GetRowCellValue(i, gridView2.Columns["ReportTypeMappingItemName"]).ToString();
                string Remark = this.gridView2.GetRowCellValue(i, gridView2.Columns["ReportTypeMappingRemark"]).ToString();
                string lbbh = this.gridView2.GetRowCellValue(i, gridView2.Columns["ReportTypeMappingTypeCode"]).ToString();
                string gdfl2 = this.gridView2.GetRowCellValue(i, gridView2.Columns["gdfl2"]).ToString();
                ProcSqlHelper.ExecuteNonQuery(@"update hnzcims.dbo.ReportTypeMapping set ReportTypeMappingItemCode=@ReportTypeMappingItemCode,ReportTypeMappingItemName=@ReportTypeMappingItemName,ReportTypeMappingRemark=@ReportTypeMappingRemark where ReportTypeMappingID=@ReportTypeMappingID", CommandType.Text, new SqlParameter[] { new SqlParameter("ReportTypeMappingID", ID), new SqlParameter("@ReportTypeMappingItemCode", itemCode), new SqlParameter("@ReportTypeMappingItemName", ItemName), new SqlParameter("@ReportTypeMappingRemark", Remark) });
                ProcSqlHelper.ExecuteNonQuery(@"update wllb set gdfl1 =a.ReportTypeMappingRemark from hnzcims..ReportTypeMapping a where lbbh = a.ReportTypeMappingTypeCode and lbbh like '12%'", CommandType.Text);
                ProcSqlHelper.ExecuteNonQuery(@"update wllb set gdfl2 = @gdfl2 where lbbh = @lbbh", CommandType.Text, new SqlParameter[] { new SqlParameter("@gdfl2", gdfl2), new SqlParameter("@lbbh", lbbh) });
            }
            MessageBox.Show("保存成功!");
        }

原创粉丝点击