コード例 #1
0
ファイル: BaseRepository.cs プロジェクト: 21express/sisco
        /// <summary>
        /// {0} Table Name
        /// {1} Column Name
        /// {2} Operator
        /// </summary>
        /// <param name="param"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        private static string GetValueParameterLinq(IListParameter param, int index)
        {
            switch (param.ParamDataType)
            {
            case EnumParameterDataTypes.Number:
                return(GetNumericLinq(param, index));

            case EnumParameterDataTypes.NumberRange:
                return(GetNumericLinq(param, index));

            case EnumParameterDataTypes.DateTime:
                return(GetDateTimeLinq(param, index));

            case EnumParameterDataTypes.DateTimeRange:
                return(GetDateTimeRangeLinq(param as IListRangeParameter, index));

            case EnumParameterDataTypes.Bool:
                return(GetBooleanLinq(param, index));

            case EnumParameterDataTypes.Guid:
                return(GetGuidLinq(param, index));

            default:
                return(GetCharacterLinq(param, index));
            }
        }
コード例 #2
0
 private static string GetDateTimeLinq(IListParameter param, int index)
 {
     //return string.Format(" ({0}{1}{2}) ", (string.IsNullOrEmpty(param.TableName) ? string.Empty : param.TableName + DefaultValue.DOT),
     //    param.ColumnName, GetOperatorDateTimeLinq(param.Operator, index));
     return(string.Format(" ({0}{1}{2}) ", string.Empty,
                          param.ColumnName, GetOperatorDateTimeLinq(param.Operator, index)));
 }
コード例 #3
0
        public void OpenLookupPopup()
        {
            if (LookupPopup != null && Enabled)
            {
                ((BaseForm)LookupPopup).ShowDialog();

                if (LookupPopup.SelectedValue > 0)
                {
                    DefaultValue = new IListParameter[] { WhereTerm.Default(LookupPopup.SelectedValue, "id") };
                }
            }
        }
コード例 #4
0
ファイル: BaseRepository.cs プロジェクト: 21express/sisco
        private void GetValueClause(IListParameter param)
        {
            switch (param.ParamDataType)
            {
            case EnumParameterDataTypes.Number:
            case EnumParameterDataTypes.NumberRange:
                ListClause.Add(string.Format("{0} {1} {2}", param.ColumnName, GetOperatorClause(param.Operator), param.Value));
                break;

            case EnumParameterDataTypes.DateTime:
                ListClause.Add(string.Format("{0} {1} '{2}'", param.ColumnName, GetOperatorClause(param.Operator), Convert.ToDateTime(param.Value).ToString("yyyy-MM-dd HH:mm:ss")));
                break;

            case EnumParameterDataTypes.Character:
                ListClause.Add(string.Format("{0} {1} '{2}'", param.ColumnName, GetOperatorClause(param.Operator), param.Value));
                break;

            case EnumParameterDataTypes.Bool:
                ListClause.Add(string.Format("{0} {1} {2}", param.ColumnName, GetOperatorClause(param.Operator), Convert.ToByte(param.Value)));
                break;
            }
        }
コード例 #5
0
 private static string GetBooleanLinq(IListParameter control, int index)
 {
     return(string.Format(" ({0}{1} {2}) ",
                          string.Empty,
                          control.ColumnName, GetOperatorBooleanLinq(control.Operator, index)));
 }
コード例 #6
0
ファイル: BaseRepository.cs プロジェクト: 21express/sisco
 /// <summary>
 /// {0} Table Name
 /// {1} Column Name
 /// {2} Operator
 /// </summary>
 /// <param name="param"></param>
 /// <param name="index"></param>
 /// <returns></returns>
 private static string GetCharacterLinq(IListParameter param, int index)
 {
     return(string.Format(" ({0}{1}{2}) ", string.IsNullOrEmpty(param.TableName) ? string.Empty : param.TableName + ".", param.ColumnName, GetOperatorCharacterLinq(param.Operator, index)));
 }
コード例 #7
0
ファイル: BaseRepository.cs プロジェクト: 21express/sisco
 private static string GetGuidLinq(IListParameter param, int index)
 {
     return(string.Format(" ({0}{1}{2}) ",
                          string.Empty,
                          param.ColumnName, GetOperatorGuidLinq(index)));
 }
コード例 #8
0
ファイル: BaseRepository.cs プロジェクト: 21express/sisco
        public string GetQueryParameterLinqNoRowStatus(IListParameter defaultParameter, params IListParameter[] parameters)
        {
            if (defaultParameter != null)
            {
                var hasRowParams = WhereTerm.ResizeParameter(ref parameters, 1);
                if (!hasRowParams)
                {
                    parameters[parameters.Length - 1] = defaultParameter;
                }
            }


            var query = new StringBuilder();

            ListValue = new Collection <object>();
            var indexpass = 0;

            foreach (var param in parameters)
            {
                var index = parameters.ToList().IndexOf(param) + indexpass;
                switch (param.ParamDataType)
                {
                case EnumParameterDataTypes.DateTime:
                {
                    var date1 = Convert.ToDateTime(param.Value);
                    var fdate = new DateTime(date1.Year, date1.Month, date1.Day, 0, 0, 0);
                    var ldate = new DateTime(date1.Year, date1.Month, date1.Day, 23, 59, 59);
                    if (param.Operator == EnumSqlOperator.Equals)
                    {
                        var fparma = WhereTerm.Default(fdate, param.ColumnName, EnumSqlOperator.GreatThanEqual);
                        var lparma = WhereTerm.Default(ldate, param.ColumnName, EnumSqlOperator.LesThanEqual);
                        query.Append(GetValueParameterLinq(fparma, index) + DefaultValue.LOGICAL_SQL);
                        ListValue.Add(fparma.GetValue());
                        index++;
                        indexpass++;
                        query.Append(GetValueParameterLinq(lparma, index) + DefaultValue.LOGICAL_SQL);
                        ListValue.Add(lparma.GetValue());
                    }
                    else
                    {
                        query.Append(GetValueParameterLinq(param, index) + DefaultValue.LOGICAL_SQL);
                    }
                }
                break;

                case EnumParameterDataTypes.DateTimeRange:
                {
                    query.Append(GetValueParameterLinq(param, index) + DefaultValue.LOGICAL_SQL);
                    ListValue.Add(param.Value);
                    var date1 = Convert.ToDateTime(((IListRangeParameter)param).GetValue2());
                    //var ldate = new DateTime(date1.Year, date1.Month, date1.Day, 23, 59, 59);
                    ListValue.Add(date1);
                    indexpass++;
                }
                break;

                case EnumParameterDataTypes.Guid:
                    query.Append(GetValueParameterLinq(param, index) + DefaultValue.LOGICAL_SQL);
                    ListValue.Add(new Guid(param.Value.ToString()));
                    break;

                default:
                    query.Append(GetValueParameterLinq(param, index) + DefaultValue.LOGICAL_SQL);
                    ListValue.Add(param.Value);
                    break;
                }
            }
            if (query.Length != 0)
            {
                var qresult = query.ToString().Trim();
                if (qresult.Substring(qresult.Length - 3, 3) == DefaultValue.LOGICAL_SQL.Trim())
                {
                    qresult = qresult.Remove(qresult.Length - 3, 3);
                }
                return(qresult);
            }
            return(query.ToString());
        }
コード例 #9
0
        public void Replace(IListParameter listParameter)
        {
            var parameter = (ListParameter <T>)listParameter;

            _values = parameter._values;
        }
コード例 #10
0
 public static bool ResizeParameter(ref IListParameter[] parameters, int size)
 {
     var hasRowParams = false;
     if (parameters == null)
     {
         Array.Resize(ref parameters, size);
     }
     else
     {
         if (parameters.Any(param => param.ColumnName.Equals(DefaultValue.COLUMN_ROW_STATUS)))
             hasRowParams = true;
         if (!hasRowParams)
             Array.Resize(ref parameters, parameters.Length + size);
     }
     return hasRowParams;
 }
コード例 #11
0
ファイル: BaseSearchCode.cs プロジェクト: 21express/sisco
        protected virtual void Filter(object sender, EventArgs e)
        {
            AutoCompleteWheretermFormater = null;

            BeforeFilter();
            if (AutoCompleteWheretermFormater != null)
            {
                if (tbxCode.Text != "")
                {
                    var param = AutoCompleteWheretermFormater;
                    Array.Resize(ref param, param.Length + 1);
                    param[param.Length - 1] = WhereTerm.Default(tbxCode.Text, CodeColumn, EnumSqlOperator.Like);

                    AutoCompleteWheretermFormater = param;
                }
            }
            else
            {
                if (tbxCode.Text != "")
                {
                    AutoCompleteWheretermFormater = new IListParameter[] { WhereTerm.Default(tbxCode.Text, CodeColumn, EnumSqlOperator.Like) };
                }
            }

            var paramEmpty = true;

            foreach (Control o in MainContainer.Panel1.Controls)
            {
                if (o is TextBox)
                {
                    if (o.Text != "")
                    {
                        paramEmpty = false;
                        break;
                    }
                }

                if (o is dTextBox)
                {
                    if (o.Text != "")
                    {
                        paramEmpty = false;
                        break;
                    }
                }

                if (o is dTextBoxNumber)
                {
                    if (o.Text != "")
                    {
                        paramEmpty = false;
                        break;
                    }
                }

                if (o is dCalendar)
                {
                    if (((dCalendar)o).EditValue != null)
                    {
                        paramEmpty = false;
                        o.Focus();
                        break;
                    }
                }

                if (o is dLookupC)
                {
                    if (((dLookupC)o).Value != null)
                    {
                        paramEmpty = false;
                        break;
                    }
                }

                if (o is ComboBox)
                {
                    if (((ComboBox)o).SelectedValue != null)
                    {
                        paramEmpty = false;
                        break;
                    }
                }
            }

            if (paramEmpty)
            {
                MessageBox.Show(@"Masukkan parameter pencarian", Resources.title_information, MessageBoxButtons.OK);
                return;
            }

            if (ByPaging)
            {
                PageLimit  = 10;
                PagingForm = new Paging
                {
                    Direction  = SortDirection,
                    SortColumn = SortColumn
                };

                CurrentFilter = GotoFirstPage <TModel>(sender, e);
            }
            else
            {
                CurrentFilter = DataManager.Get <TModel>(AutoCompleteWheretermFormater);
            }

            GridSearch.DataSource = CurrentFilter;
            SearchView.RefreshData();

            NavigatorPagingState = PagingState;
            GridSearch.Focus();
        }