예제 #1
0
        private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cbxGroupList.SelectedIndex > 0)
            {
                //butun faturalar
                InvoiceSelect iS         = new InvoiceSelect(this._dbo);
                int           groupIndex = cbxGroupList.SelectedIndex;
                int           groupId    = this._groupList[groupIndex].GroupId;
                var           dt         = iS.SelectAsTable(groupId);
                gdInvoices.ItemsSource = dt.DefaultView;

                //borclar
                if (dt.Rows.Count > 1)
                {
                    SpLoanList sp = new SpLoanList(this._dbo);
                    dt = sp.SelectByGroupId(groupId);
                    dgLoan.ItemsSource = dt.DefaultView;
                }
                else
                {
                    dgLoan.ItemsSource = null;
                }
            }
            else
            {
                gdInvoices.ItemsSource = null;
                dgLoan.ItemsSource     = null;
            }
        }
예제 #2
0
        private void btnSearchInvoice_Click(object sender, RoutedEventArgs e)
        {
            if (cbxGroupList.SelectedIndex > 0)
            {
                int    userId  = this._userId;
                int    groupId = _groupList[cbxGroupList.SelectedIndex].GroupId;
                string query   = @" SELECT ui.name || ' ' || ui.lastname AS fullname " +
                                 " ,i.invoice_id" +
                                 " ,i.user_id" +
                                 " ,i.group_id" +
                                 " ,i.buy_date" +
                                 " ,i.price " +
                                 " FROM invoice AS i " +
                                 " INNER JOIN userinfo AS ui ON ui.user_id = i.user_id " +
                                 " WHERE i.is_expired = FALSE ";
                if (this.tsDate.IsChecked == true)
                {
                    var dt1 = dpSmall.SelectedDate;
                    var dt2 = dpBig.SelectedDate;
                    if ((dt1 != null && dt2 != null) && (dt1 > dt2))
                    {
                        MessageBox("SEARCH", "LEFT SIDE DATE CANNOT BE BIGGER");
                    }
                    else
                    {
                        query += $" AND i.buy_date BETWEEN " +
                                 $" \'{dt1.Value.Date.ToString(CultureInfo.InvariantCulture)}\' " +
                                 $" AND " +
                                 $" \'{dt2.Value.Date.ToString(CultureInfo.InvariantCulture)}\' ";
                    }
                }
                if (this.tsPrice.IsChecked == true)
                {
                    double price1;
                    double price2;
                    if (double.TryParse(txtPriceSmall.Text, out price1))
                    {
                        if (double.TryParse(this.txtPriceBig.Text, out price2))
                        {
                            if (!(price1 > price2))
                            {
                                query += " AND " +
                                         " i.price BETWEEN " +
                                         $" CAST({price1} AS money) " +
                                         $" AND " +
                                         $" CAST({price2} AS money) ";
                            }
                            else
                            {
                                MessageBox("SEARCH", "ERROR:LEFT SIDE PRICE CANNOT BE BIGGER");
                            }
                        }
                        else
                        {
                            MessageBox("SEARCH", "ERROR:RIGHT SIDE PRICE NOT VALID");
                        }
                    }
                    else
                    {
                        MessageBox("SEARCH", "ERROR:LEFT SIDE PRICE NOT VALID");
                    }
                    //TODO query
                }
                if (this.tsProducts.IsChecked == true)
                {
                    if (this._productList == null)
                    {
                        this._productList = new List <Product>();
                    }
                    else
                    {
                        this._productList.Clear();
                    }
                    var products = txtProducts.Text.Split(','); // txt de ki product lari , e gore ayirip trimledikten sonra diziye atilmasi
                    foreach (var product in products.Select(t => t.Trim()).Where(product => product.Length > 0))
                    {
                        this._productList.Add(
                            new Product {
                            Name = product
                        });
                    }
                    if (this._productList.Count > 0)
                    {
                        //TODO
                        query += "  ";
                    }
                }
                query += " ORDER BY i.invoice_id;";

                InvoiceSelect iS = new InvoiceSelect(new DbOperations());
                Debug.WriteLine(query);
                dg.ItemsSource = iS.SelectAsTable(query).DefaultView;
            }
            else
            {
                MessageBox("SEARCH", "PLEASE SELECT A GROUP");
            }
        }