Exemplo n.º 1
0
        private async void btn_map_Click(object sender, EventArgs e)
        {
            writeclass_progressBar.Enabled = writeclass_progressBar.Visible = true;
            this.Height              = 574;
            btn_map.Enabled          = false;
            choosefolder_btn.Enabled = false;
            await Task.Run(() => {
                foreach (DataGridViewRow row in dataGridView_table.Rows)
                {
                    if (row.Cells[0].Value != null)
                    {
                        if ((bool)row.Cells[0].Value == true)
                        {
                            (row.DataBoundItem as Table).WriteClass();
                            TableList.GetTableList((row.DataBoundItem as Table)).WriteClass();
                        }
                    }
                }


                foreach (DataGridViewRow row in dataGridView_view.Rows)
                {
                    if (row.Cells[0].Value != null)
                    {
                        if ((bool)row.Cells[0].Value == true)
                        {
                            (row.DataBoundItem as View).WriteClass();
                        }
                    }
                }

                foreach (DataGridViewRow row in dataGridView_storedprocedures.Rows)
                {
                    if (row.Cells[0].Value != null)
                    {
                        if ((bool)row.Cells[0].Value == true)
                        {
                            (row.DataBoundItem as StoredProcedure).WriteClass();
                        }
                    }
                }
            });

            btn_map.Enabled          = true;
            choosefolder_btn.Enabled = true;
            this.Height = 542;
            writeclass_progressBar.Enabled = writeclass_progressBar.Visible = false;

            MessageBox.Show("Your Selected Database Objects Mapped Successfully !", "Mapped Successfully", MessageBoxButtons.OK);
        }
Exemplo n.º 2
0
        public static TableList GetTableList(Table table)
        {
            SqlConnection con = new SqlConnection(MiscClass.ConnectionString);

            con.Open();
            SqlCommand cmd = new SqlCommand("SELECT Column_Name , Data_Type , CHARACTER_MAXIMUM_LENGTH as Lenght FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = @tablename", con);

            cmd.Parameters.AddWithValue("@tablename", table.TableName + "_TB");
            SqlDataReader dtreader      = cmd.ExecuteReader();
            TableList     TempTableList = new TableList();

            TempTableList.ListName  = "List" + table.TableName;
            TempTableList.TableName = table.TableName;
            while (dtreader.Read())
            {
                TempTableList.Fields.Add(new Tuple <string, string, string, string>(dtreader.GetValue(0).ToString(), MiscClass.sqltypetonettype(dtreader.GetValue(1).ToString()).Replace("[]", "s"), dtreader.GetValue(2) == DBNull.Value ? "" : dtreader.GetValue(2).ToString(), MiscClass.dbtypetoenumeration(dtreader.GetValue(1).ToString())));
            }
            dtreader.Close();
            con.Close();

            return(TempTableList);
        }