Ejemplo n.º 1
0
        protected bool WfUpdateAda08(string pAda01, string pAda08)
        {
            StringBuilder       sbSql;
            List <SqlParameter> sqlParmsList;

            try
            {
                sbSql = new StringBuilder();
                sbSql.AppendLine("UPDATE ada_tb");
                sbSql.AppendLine("SET ada08=@ada08");
                sbSql.AppendLine("WHERE ada01=@ada01");
                sqlParmsList = new List <SqlParameter>();
                sqlParmsList.Add(new SqlParameter("ada01", pAda01));
                sqlParmsList.Add(new SqlParameter("ada08", pAda08));
                BoSecurity.OfExecuteNonquery(sbSql.ToString(), sqlParmsList.ToArray());
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        //todo:目前是以proc運作,需考量改用程式碼來執行
        private void WfRefreshView()
        {
            StringBuilder sbSql, sbViewSql;
            string        lsSql;
            string        viewName;
            DataTable     dtAta, dtView;
            string        ata01;
            CommonBLL     boRefresh;

            try
            {
                if (BoSecurity == null)
                {
                    WfShowErrorMsg("未設定主要連線!");
                    return;
                }

                //先更新主要連線的view YR
                sbViewSql = new StringBuilder();
                sbViewSql.AppendLine(string.Format("SELECT  name "));
                sbViewSql.AppendLine(string.Format("FROM sys.objects"));
                sbViewSql.AppendLine(string.Format("WHERE type = 'V'"));
                dtView = BoSecurity.OfGetDataTable(sbViewSql.ToString());
                foreach (DataRow ldr in dtView.Rows)
                {
                    viewName = ldr["name"] == DBNull.Value ? "" : ldr["name"].ToString();
                    lsSql    = string.Format("EXEC sp_refreshview '{0}' ", viewName);
                    BoSecurity.OfExecuteNonquery(lsSql.ToString());
                    lsSql = string.Format("EXEC sp_gen_aza '{0}' ", viewName);
                    BoSecurity.OfExecuteNonquery(lsSql.ToString());
                }

                sbSql = new StringBuilder();
                sbSql.AppendLine("SELECT * FROM ata_tb");
                dtAta = BoSecurity.OfGetDataTable(sbSql.ToString(), null);

                if (dtAta != null && dtAta.Rows.Count > 0)
                {
                    foreach (DataRow drTemp in dtAta.Rows)
                    {
                        ata01     = drTemp["ata01"] == DBNull.Value ? "" : drTemp["ata01"].ToString();
                        boRefresh = new CommonBLL(ata01, "", "", "");
                        //boRefresh.TRAN = admBll.TRAN;

                        dtView = boRefresh.OfGetDataTable(sbViewSql.ToString());
                        foreach (DataRow ldr in dtView.Rows)
                        {
                            viewName = ldr["name"] == DBNull.Value ? "" : ldr["name"].ToString();
                            lsSql    = string.Format("EXEC sp_refreshview '{0}' ", viewName);
                            boRefresh.OfExecuteNonquery(lsSql.ToString());
                        }
                    }
                }
                //admBll.TRAN.Commit();
            }
            catch (System.Exception ex)
            {
                BoSecurity.TRAN.Rollback();
                throw ex;
            }
        }