Esempio n. 1
0
 private static string GetFormatedText(ProductPrice_LineOfOperation target, string [] textField, string textFormatString)
 {
     for (int i = 0; i < textField.Length; i++)
     {
         PropertyInfo pi = target.GetType().GetProperty(textField[i]);
         textFormatString = textFormatString.Replace("{" + i.ToString() + "}", pi != null ? pi.GetValue(target, null).ToString() : string.Empty);
     }
     return(textFormatString);
 }
Esempio n. 2
0
        /// <summary>
        /// Loads a collection of ProductPrice_LineOfOperation objects from the database.
        /// </summary>
        /// <returns>A collection containing all of the ProductPrice_LineOfOperation objects in the database.</returns>
        public static ProductPrice_LineOfOperationCollection LoadCollection(string spName, SqlParameter[] parms)
        {
            ProductPrice_LineOfOperationCollection result = new ProductPrice_LineOfOperationCollection();

            using (SqlDataReader reader = SqlHelper.Default.ExecuteReader(spName, parms))
            {
                while (reader.Read())
                {
                    ProductPrice_LineOfOperation tmp = new ProductPrice_LineOfOperation();
                    tmp.LoadFromReader(reader);
                    result.Add(tmp);
                }
            }
            return(result);
        }
Esempio n. 3
0
 /// <summary>
 /// Loads a ProductPrice_LineOfOperation object from the database using the given ItemId
 /// </summary>
 /// <param name="itemId">The primary key value</param>
 /// <returns>A ProductPrice_LineOfOperation object</returns>
 public static ProductPrice_LineOfOperation Load(Guid itemId)
 {
     SqlParameter[] parameterValues = new SqlParameter[] { new SqlParameter("@ItemId", itemId) };
     using (SqlDataReader reader = SqlHelper.Default.ExecuteReader("spProductPrice_LineOfOperation_SelRec", parameterValues))
     {
         if (reader.Read())
         {
             ProductPrice_LineOfOperation result = new ProductPrice_LineOfOperation();
             result.LoadFromReader(reader);
             return(result);
         }
         else
         {
             return(null);
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Loads a ProductPrice_LineOfOperation object from the database using the given where clause
 /// </summary>
 /// <param name="whereClause">The filter expression for the query</param>
 /// <returns>A ProductPrice_LineOfOperation object</returns>
 public static ProductPrice_LineOfOperation LoadWhere(string whereClause)
 {
     SqlParameter[] parameterValues = new SqlParameter[] { new SqlParameter("@WhereClause", whereClause) };
     using (SqlDataReader reader = SqlHelper.Default.ExecuteReader("spProductPrice_LineOfOperation_SelAll", parameterValues))
     {
         if (reader.Read())
         {
             ProductPrice_LineOfOperation result = new ProductPrice_LineOfOperation();
             result.LoadFromReader(reader);
             return(result);
         }
         else
         {
             return(null);
         }
     }
 }
Esempio n. 5
0
        private static bool IgnorThis(ProductPrice_LineOfOperation target, string parentFilter)
        {
            bool result = true;

            parentFilter = parentFilter.Replace(" ", "");                       // remove spaces
            parentFilter = parentFilter.Replace("'", "");                       // remove '
            string [] parsed = parentFilter.Split('=');                         // parse

            if (target.ProductId == Guid.Empty)
            {
                PropertyInfo pi          = target.GetType().GetProperty(parsed[0]);
                string       filterField = (string)pi.GetValue(target, null);
                if (filterField.ToLower() == parsed[1].ToLower())
                {
                    result = false;
                }
            }
            else
            {
                ProductPrice_LineOfOperation parentTemplate = ProductPrice_LineOfOperation.Load(target.ProductId);
                result = IgnorThis(parentTemplate, parentFilter);
            }
            return(result);
        }
Esempio n. 6
0
        /// <summary>
        /// Only support the ComboBox control from WinForm/Visual WebGUI
        /// </summary>
        /// <param name="ddList">the ComboBox control from WinForm/Visual WebGUI</param>
        /// <param name="TextField">e.g. new string[]{"FieldName1", "FieldName2", ...}</param>
        /// <param name="TextFormatString">e.g. "{0} - {1}"</param>
        /// <param name="SwitchLocale">Can be localized, if the FieldName has locale suffix, e.g. '_chs'</param>
        /// <param name="BlankLine">add blank label text to ComboBox or not</param>
        /// <param name="BlankLineText">the blank label text</param>
        /// <param name="ParentFilter">e.g. "ForeignFieldName = 'value'"</param>
        /// <param name="WhereClause">Where Clause for SQL Statement. e.g. "FieldName = 'SomeCondition'"</param>
        /// <param name="OrderBy">Sorting order, string array, e.g. {"FieldName1", "FiledName2"}</param>
        public static void LoadCombo(ref ComboBox ddList, string [] TextField, string TextFormatString, bool SwitchLocale, bool BlankLine, string BlankLineText, string ParentFilter, string WhereClause, string[] OrderBy)
        {
            if (SwitchLocale)
            {
                TextField = GetSwitchLocale(TextField);
            }
            ddList.Items.Clear();

            ProductPrice_LineOfOperationCollection source;

            if (OrderBy == null || OrderBy.Length == 0)
            {
                OrderBy = TextField;
            }
            // Filter the retired records
            if (WhereClause.Length > 0)
            {
                WhereClause += " AND Retired = 0";
            }
            else
            {
                WhereClause = "Retired = 0";
            }

            if (WhereClause.Length > 0)
            {
                source = ProductPrice_LineOfOperation.LoadCollection(WhereClause, OrderBy, true);
            }
            else
            {
                source = ProductPrice_LineOfOperation.LoadCollection(OrderBy, true);
            }

            Common.ComboList sourceList = new Common.ComboList();

            if (BlankLine)
            {
                sourceList.Add(new Common.ComboItem(BlankLineText, Guid.Empty));
            }

            foreach (ProductPrice_LineOfOperation item in source)
            {
                bool filter = false;
                if (ParentFilter.Trim() != String.Empty)
                {
                    filter = true;
                    if (item.ProductId != Guid.Empty)
                    {
                        filter = IgnorThis(item, ParentFilter);
                    }
                }
                if (!(filter))
                {
                    string code = GetFormatedText(item, TextField, TextFormatString);
                    sourceList.Add(new Common.ComboItem(code, item.ItemId));
                }
            }

            ddList.DataSource    = sourceList;
            ddList.DisplayMember = "Code";
            ddList.ValueMember   = "Id";

            if (ddList.Items.Count > 0)
            {
                ddList.SelectedIndex = 0;
            }
        }