public static PdmKeyColumn GetKeyColumn(int dbid, string tablecode) { PdmKeyColumn rtn = null; try { ArrayList paras = new ArrayList(); paras.Add(DBUtils.MakeInParam("DBID", SqlDbType.Int, dbid)); paras.Add(DBUtils.MakeInParam("TableCode", SqlDbType.NVarChar, 40, tablecode)); SqlDataReader reader = DBUtils.ExecuteReader(CommandType.StoredProcedure, "dbo.P_Get_KeyColumn", paras); if (reader.Read()) { rtn = new PdmKeyColumn(); rtn.OnPopulate(reader); } reader.Close(); } catch { throw; } return(rtn); }
private void ddlTable_SelectedIndexChanged(object sender, EventArgs e) { try { DataTable columns = SqlBaseProvider.GetColumnByTable(Convert.ToInt32(ddlDB.SelectedValue), ddlTable.SelectedValue.ToString()); SqlBaseProvider.GetTableByCode(pTable, Convert.ToInt32(ddlDB.SelectedValue), ddlTable.SelectedValue.ToString()); PdmKeyColumn pkc = SqlBaseProvider.GetKeyColumn(Convert.ToInt32(ddlDB.SelectedValue), ddlTable.SelectedValue.ToString()); txtPackage.Text = Program.ProjectCode; txtSet.Text = String.Empty; txtResult.Text = String.Empty; txtPrefix.Text = String.Empty; txtCatalog.Text = String.Empty; txtClassName.Text = String.Empty; txtValue.Text = String.Empty; string tablename = String.Empty; if (columns.Rows.Count > 0) { string table = ddlTable.SelectedValue.ToString(); if (table.IndexOf("T_") >= 0) { string[] tables = table.Split('_'); for (int i = 1; i < tables.Length; i++) { tablename += tables[i]; } txtPrefix.Text = tables[1]; txtCatalog.Text = tables[1].ToLower(); txtClassName.Text = tablename; txtValue.Text = tablename.ToLower(); } else { string[] tables = table.Split('_'); for (int i = 0; i < tables.Length; i++) { tablename += tables[i].Substring(0, 1).ToUpper() + tables[i].Substring(1).ToLower(); } txtPrefix.Text = tables[0].Substring(0, 1).ToUpper() + tables[0].Substring(1).ToLower(); txtCatalog.Text = tables[0].ToLower(); txtClassName.Text = tablename; txtValue.Text = tablename.ToLower(); } if (pkc != null) { keycolumn = pkc.ColumnCode; OnGetSave(keycolumn); } else { keyCol = pTable.Columns[0]; keycolumn = pTable.Columns[0].ColumnCode; } if (String.IsNullOrEmpty(pTable.TableSet)) { if (pkc != null) { String txtSetText = "G|" + tablename + "|" + pkc.ColumnCode + PublicTools.WriteEnter(1); txtSetText += "S|" + tablename + "|" + pkc.ColumnCode; txtSet.Text = txtSetText; saveConfig(); } else { String txtSetText = "G|" + tablename + "|" + keycolumn + PublicTools.WriteEnter(1); txtSetText += "S|" + tablename + "|" + keycolumn; txtSet.Text = txtSetText; saveConfig(); } } else { txtSet.Text = pTable.TableSet; } } } catch (Exception ex) { Global.ShowSysInfo(ex.Message); } }