private void btnAdd_Click(object sender, System.EventArgs e) { if (table == null) { ExMessageBox.Show(this, "请选择一个数据表再进行操作!"); return; } if (data_profile == null) { data_profile = DBInitDataProfile.fromXMLFile(data_file_path); data_profile.table_name = table.table_name; } DBInitData data = new DBInitData(table); data_profile.data_list.Add(data); data_profile.toXmlFile(root_path); int row = dgvData.Rows.Add(); loadDataForRow(row, data); }
private DBInitData readDataFromRow(int row) { DBInitData data = new DBInitData(); for (int i = 0; i < dgvData.Columns.Count; i++) { if (table.columns[i].data_type == DBDataType.Binary) { continue; } string value = ""; if (dgvData.Rows[row].Cells[i].Value != null) { value = dgvData.Rows[row].Cells[i].Value.ToString(); } DBInitDataItem di = new DBInitDataItem(); di.column_name = dgvData.Columns[i].Name; di.data_type = table.columns[i].data_type; di.StringValue = value; data.item_list.Add(di); } return(data); }
private void loadDataForRow(int row, DBInitData data) { loading_detail = true; for (int i = 0; i < dgvData.Columns.Count; i++) { if (table.columns[i].data_type == DBDataType.Bit) { object value = data.valueWithName(dgvData.Columns[i].Name); if (value == null) { dgvData.Rows[row].Cells[i].Value = false; } else { dgvData.Rows[row].Cells[i].Value = value; } } else { dgvData.Rows[row].Cells[i].Value = data.valueWithName(dgvData.Columns[i].Name); } } loading_detail = false; }