コード例 #1
0
        /// <summary>
        /// Get all menu items with image fields
        /// </summary>
        /// <param name="pobjObjectVO">Sys_Menu_EntryVO object</param>
        /// <returns>ArrayList object</returns>
        /// <author> Duong NA - Sep 23, 2005</author>
        public void UpdateMenuWithImageFields(int menuId, int?collapsedImage, int?expandedImage)
        {
            const string METHOD_NAME = THIS + ".UpdateMenuWithImageFields()";

            try
            {
                using (var trans = new TransactionScope())
                {
                    var dcPCS = new PCSDataContext(Utils.Instance.ConnectionString);
                    var sql   = string.Format("UPDATE Sys_Menu_Entry SET CollapsedImage={0}, ExpandedImage={1} WHERE Menu_EntryID={2}", collapsedImage, expandedImage, menuId);
                    dcPCS.ExecuteCommand(sql);
                    trans.Complete();
                }
            }
            catch (SqlException ex)
            {
                if (ex.Errors.Count > 1)
                {
                    if (ex.Number == ErrorCode.SQLDUPLICATE_KEYCODE)
                    {
                        throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);
                    }
                    throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
                }
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }
        }
コード例 #2
0
 /// <summary>
 /// Cleans the temp table.
 /// </summary>
 public void CleanTempTable()
 {
     try
     {
         using (var dataContext = new PCSDataContext(Utils.Instance.ConnectionString))
         {
             // get list of table need to be clean up by current user
             var strSql  = new StringBuilder();
             var listCmd = string.Format(
                 "SELECT name FROM dbo.sysobjects WHERE xtype = 'U' AND name LIKE 'PRO_IssueMaterialDetail{0}%' AND crdate >= '2010-01-01'",
                 SystemProperty.UserName);
             var tableNames = dataContext.ExecuteQuery <string>(listCmd);
             foreach (var tableName in tableNames)
             {
                 strSql.AppendLine(string.Format("DROP TABLE {0};", tableName));
             }
             if (strSql.Length > 0)
             {
                 dataContext.ExecuteCommand(strSql.ToString());
             }
         }
     }
     catch (Exception ex)
     {
         _logger.Info(string.Format("Could not delete temp table: {0}", ex.Message), ex);
     }
 }
コード例 #3
0
        public void UpdateBeginStock(List <IV_BeginDCPReport> beginDcp, DateTime effectDate, List <ITM_Product> productList)
        {
            const string methodName = THIS + ".UpdateBeginStock()";

            try
            {
                using (var trans = new TransactionScope())
                {
                    using (var dataContext = new PCSDataContext(Utils.Instance.ConnectionString))
                    {
                        var productids    = productList.Select(p => p.ProductID.ToString()).ToArray();
                        var query         = string.Join(",", productids);
                        var deleteCommand = string.Format("DELETE FROM IV_BeginDCPReport WHERE effectDate = '{0}' AND ProductID IN ({1})", effectDate.ToString("yyyy-MM-dd"), query);

                        dataContext.ExecuteCommand(deleteCommand);
                        dataContext.IV_BeginDCPReports.InsertAllOnSubmit(beginDcp);

                        // submit changes
                        dataContext.SubmitChanges();
                        trans.Complete();
                    }
                }
            }
            catch (SqlException ex)
            {
                if (ex.Errors.Count > 1)
                {
                    if (ex.Number == ErrorCode.SQLDUPLICATE_KEYCODE)
                    {
                        throw new PCSDBException(ErrorCode.DUPLICATE_KEY, methodName, ex);
                    }
                    throw new PCSDBException(ErrorCode.ERROR_DB, methodName, ex);
                }
                throw new PCSDBException(ErrorCode.ERROR_DB, methodName, ex);
            }
        }