Beispiel #1
0
 /// <summary>
 /// 获取指定行最新修改后的数据
 /// </summary>
 /// <param name="row">指定行</param>
 /// <param name="recCodeCompasion">最新修改后的数据</param>
 /// <returns>bool</returns>
 private bool MakeRowData(DataTableViewRow row, ref RecCodeCompasion recCodeCompasion)
 {
     if (row == null || row.Index < 0)
     {
         return(false);
     }
     recCodeCompasion = row.Tag as RecCodeCompasion;
     if (recCodeCompasion == null)
     {
         recCodeCompasion    = new RecCodeCompasion();
         recCodeCompasion.ID = recCodeCompasion.MakeID();
     }
     if (row.Cells[this.col_CODE_ID.Index].Value != null)
     {
         recCodeCompasion.CODE_ID = row.Cells[this.col_CODE_ID.Index].Value.ToString();
     }
     if (row.Cells[this.col_CODE_NAME.Index].Value != null)
     {
         recCodeCompasion.CODE_NAME = (string)row.Cells[this.col_CODE_NAME.Index].Value;
     }
     if (row.Cells[this.col_DM.Index].Value != null)
     {
         recCodeCompasion.DM = (string)row.Cells[this.col_DM.Index].Value;
     }
     else
     {
         recCodeCompasion.DM = string.Empty;
     }
     recCodeCompasion.DMLB = this.m_RecCodeCompasion.DMLB;
     if (row.Cells[this.col_MC.Index].Value != null)
     {
         recCodeCompasion.MC = row.Cells[this.col_MC.Index].Value.ToString();
     }
     else
     {
         recCodeCompasion.MC = string.Empty;
     }
     recCodeCompasion.CODETYPE_NAME = this.m_RecCodeCompasion.CODETYPE_NAME;
     return(true);
 }
        /// <summary>
        /// 增加一行记录
        /// </summary>
        private void AddNewItem()
        {
            RecCodeCompasion rec = this.dataGridView1.SelectedRows[0].Tag as RecCodeCompasion;
            //创建数据
            RecCodeCompasion recCodeCompasion = new RecCodeCompasion();
            //创建行
            int index            = this.dataGridView1.Rows.Add();
            DataTableViewRow row = this.dataGridView1.Rows[index];

            recCodeCompasion.ID = recCodeCompasion.MakeID();
            row.Tag             = recCodeCompasion;
            if (rec != null)
            {
                row.Cells[this.col_FORM_SQL.Index].Value = rec.FORM_SQL;
                row.Cells[this.col_TO_SQL.Index].Value   = rec.TO_SQL;
            }
            this.dataGridView1.SetRowState(row, RowState.New);
            this.UpdateUIState();

            this.dataGridView1.CurrentCell = row.Cells[this.col_CONFIG_NAME.Index];
            this.dataGridView1.BeginEdit(true);
        }