コード例 #1
0
        private void btnGerarProc_Click(object sender, EventArgs e)
        {
            txtInsertUpdate.Text = String.Empty;
            txtUpdate.Text       = String.Empty;
            txtDelete.Text       = String.Empty;
            txtPesquisa.Text     = String.Empty;
            txtDuplicar.Text     = String.Empty;
            txtViews.Text        = String.Empty;

            objbo.setTabela(lbTabelas.ListBox.Text);

            txtInsertUpdate.Text = objbo.GerarInsert_Update_SP();
            txtUpdate.Text       = objbo.GerarUpdate_SP();
            txtDelete.Text       = objbo.GerarDelete_SP();
            txtPesquisa.Text     = objbo.GerarSelect_SP();
            txtDuplicar.Text     = objbo.GerarDuplicar_SP();

            txtViews.Text       = objbo.GetView(lbTabelas.SelectedValue.ToString());
            txtConstraints.Text = "";

            constraintsModel objConstraints = null;

            foreach (var item in clBoxColunas.CheckedItems)
            {
                objConstraints             = new constraintsModel();
                objConstraints.sColumnName = item.ToString();
                objConstraints.sTabela     = lbTabelas.SelectedValue.ToString();
                objConstraints.sConstrName = "constr" + "_" + lbTabelas.SelectedValue.ToString() +
                                             "_" + item.ToString();
                txtConstraints.Text += objConstbo.MontaScript(objConstr: objConstraints) + Environment.NewLine;
            }
        }
コード例 #2
0
ファイル: UISalvaScript.cs プロジェクト: dramosti/Gerador_1.0
        private void btnSalvarSel_Click(object sender, EventArgs e)
        {
            if (edtPreView.Text != "")
            {
                if (_controle == 'p')
                {
                    try
                    {
                        if (_objProcBO.SalvarProcedureView(edtPreView.Text, edtCaminho.Text + @"\procedures\",
                                                           listProcedures.SelectedValue.ToString() + ".sql"))
                        {
                            MessageBox.Show("Procedure salva com sucesso no caminho " +
                                            edtCaminho.Text + @"\procedures", "Ok", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + Environment.NewLine +
                                        ex.InnerException + Environment.NewLine +
                                        ex.StackTrace + Environment.NewLine);
                    }
                }
                else if (_controle == 'v')
                {
                    try
                    {
                        if (_objProcBO.SalvarProcedureView(edtPreView.Text, edtCaminho.Text + @"\views\",
                                                           listView.SelectedValue.ToString() + ".sql"))
                        {
                            MessageBox.Show("View salva com sucesso no caminho " +
                                            edtCaminho.Text + @"\views", "Ok", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + Environment.NewLine +
                                        ex.InnerException + Environment.NewLine +
                                        ex.StackTrace + Environment.NewLine);
                    }
                }
                else if (_controle == 't')
                {
                    if (_objProcBO.SalvarProcedureView(edtPreView.Text, edtCaminho.Text + @"\triggers\",
                                                       listTriggers.SelectedValue.ToString() + ".sql"))
                    {
                        MessageBox.Show("Trigger salva com sucesso no caminho " +
                                        edtCaminho.Text + @"\triggers", "Ok", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else if (_controle == 'c')
                {
                    List <infConstraints> lInfConst   = new List <infConstraints>();
                    infConstraints        objInfConst = new infConstraints
                    {
                        nomeConst   = listConstraints.SelectedItem.ToString(),
                        scriptConst = objConstrBo.MontaScript(
                            lConstraints.Where(c => c.sConstrName ==
                                               listConstraints.SelectedItem.ToString()).FirstOrDefault())
                    };
                    lInfConst.Add(objInfConst);

                    try
                    {
                        SalvarConstraint(lInfConst);
                        MessageBox.Show("Constraint salva com sucesso no caminho " +
                                        edtCaminho.Text + @"\constraints");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + Environment.NewLine +
                                        ex.StackTrace);
                    }
                }
                else
                {
                    MessageBox.Show("Não foi selecionada nenhuma procedure ou view", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }