コード例 #1
0
        private void btnTaoThuTuc_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn đang muốn sinh lại mã của các thủ tục (_Get, _Add, _Update, _Delete). Việc làm này sẽ thay thế toàn bộ các thủ tục này bạn đã xây dựng trong cơ sở dữ liệu. Bạn chắc chắn muốn thực hiện hành động này?", "TRUONG VIET - GENCODE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }
            cTaoThuTuc   oTaoThuTuc   = new cTaoThuTuc();
            cTruyVanCSDL oTruyVanCSDL = new cTruyVanCSDL();

            File.WriteAllText("a.txt", oTaoThuTuc.TaoThuTucGet());
            File.WriteAllText("b.txt", oTaoThuTuc.TaoThuTucAdd());
            File.WriteAllText("c.txt", oTaoThuTuc.TaoThuTucUpdate());
            File.WriteAllText("d.txt", oTaoThuTuc.TaoThuTucDelete());

            oTruyVanCSDL.RunSQL(oTaoThuTuc.TaoThuTucGet());
            oTruyVanCSDL.RunSQL(oTaoThuTuc.TaoThuTucAdd());
            oTruyVanCSDL.RunSQL(oTaoThuTuc.TaoThuTucUpdate());
            oTruyVanCSDL.RunSQL(oTaoThuTuc.TaoThuTucDelete());
            MessageBox.Show("Đã tạo xong đầy đủ các thủ tục (_Get, _Add, _Update, _Delete) trong cơ sở dữ liệu!", "TRUONG VIET - GENCODE", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
コード例 #2
0
        private void btnTaoThuTuc_Click(object sender, EventArgs e)
        {
            if (grvTable.DataRowCount > 0)
            {
                try
                {
                    DataTable dt = (DataTable)grdTable.DataSource;
                    if (MessageBox.Show("Bạn đang muốn sinh lại mã của các thủ tục (_Get, _Add, _Update, _Delete). Việc này sẽ tạo ra các file script trong thư mục bạn chọn. Bạn chắc chắn muốn thực hiện hành động này?", "TRUONG VIET - GENCODE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    foreach (DataRow dr in dt.Rows)
                    {
                        if ((bool)dr["Select"] == true)
                        {
                            cTaoThuTuc   oTaoThuTuc   = new cTaoThuTuc();
                            cTruyVanCSDL oTruyVanCSDL = new cTruyVanCSDL();
                            File.WriteAllText("a.txt", oTaoThuTuc.TaoThuTucGet(dr["TableName"].ToString(), dr["Id"].ToString()));
                            File.WriteAllText("b.txt", oTaoThuTuc.TaoThuTucAdd(dr["TableName"].ToString(), dr["Id"].ToString()));
                            File.WriteAllText("c.txt", oTaoThuTuc.TaoThuTucUpdate(dr["TableName"].ToString(), dr["Id"].ToString()));
                            File.WriteAllText("d.txt", oTaoThuTuc.TaoThuTucDelete(dr["TableName"].ToString(), dr["Id"].ToString()));

                            oTruyVanCSDL.RunSQL(oTaoThuTuc.TaoThuTucGet(dr["TableName"].ToString(), dr["Id"].ToString()));
                            oTruyVanCSDL.RunSQL(oTaoThuTuc.TaoThuTucAdd(dr["TableName"].ToString(), dr["Id"].ToString()));
                            oTruyVanCSDL.RunSQL(oTaoThuTuc.TaoThuTucUpdate(dr["TableName"].ToString(), dr["Id"].ToString()));
                            oTruyVanCSDL.RunSQL(oTaoThuTuc.TaoThuTucDelete(dr["TableName"].ToString(), dr["Id"].ToString()));
                        }
                    }
                    MessageBox.Show("Đã tạo xong đầy đủ các thủ tục (_Get, _Add, _Update, _Delete) trong cơ sở dữ liệu!", "TRUONG VIET - GENCODE", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch
                {
                    MessageBox.Show("Có lỗi xảy ra khi tạo lại các thủ tục trong Cơ sở dữ liệu!", "TRUONG VIET - GENCODE", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Database của bạn chưa có bảng nào!", "THÔNG BÁO");
            }
        }