private void DoEditBatch(DataRow drBtn)
        {
            if (this.gridVMain.SelectedRowsCount <= 0)
            {
                MessageBox.Show("请先选择要批量修改的记录.");
                return;
            }
            string         strKeyFiled = drBtn["BatchUpdateKeyId"].ToString();
            List <DataRow> lisRows     = new List <DataRow>();
            string         strKeyIds   = string.Empty;

            foreach (int i in gridVMain.GetSelectedRows())
            {
                DataRow dr = gridVMain.GetDataRow(i);
                strKeyIds += strKeyIds == string.Empty ? dr[strKeyFiled].ToString() : "," + dr[strKeyFiled].ToString();
                lisRows.Add(dr);
            }
            if (strKeyIds == string.Empty)
            {
                return;
            }

            DataTable    dtInfo = (gridCMain.DataSource as DataView).Table;
            frmBatchEdit frm    = new frmBatchEdit(drBtn["BatchFormName"].ToString());

            frm.frmDataTable = dtInfo.Clone();
            frm.DrBtn        = drBtn;
            frm.StrUpdKeyIds = strKeyIds;
            frm.StrUpdSpName = strSpName;
            frm.DrBatchs     = lisRows;
            frm.DtSps        = dtSp;
            if (frm.ShowDialog(this) != DialogResult.Yes)
            {
                return;
            }

            dtInfo.AcceptChanges();
        }
示例#2
0
        private void DoEditBatch()
        {
            if (this.gridVMain.SelectedRowsCount <= 0)
            {
                return;
            }
            DataTable    dtInfo = (gridCMain.DataSource as DataView).Table;
            frmBatchEdit frm    = new frmBatchEdit(strBatchFormName);

            frm.frmDataTable = dtInfo.Clone();
            if (frm.ShowDialog(this) != DialogResult.Yes)
            {
                return;
            }

            DataRow        drEdit  = frm.frmDataTable.Rows[0];
            List <DataRow> lisRows = new List <DataRow>();

            foreach (int i in gridVMain.GetSelectedRows())
            {
                DataRow dr = gridVMain.GetDataRow(i);
                lisRows.Add(dr);
            }
            foreach (DataRow dr in lisRows)
            {
                foreach (string strFiled in frm.strFileds)
                {
                    if (drEdit[strFiled] == DBNull.Value || drEdit[strFiled].ToString() == string.Empty)
                    {
                        continue;
                    }

                    dr[strFiled] = drEdit[strFiled];
                }
            }
        }