private void SummaryButtonSearchClick(object sender, System.Windows.RoutedEventArgs e)
 {
     this.SummaryButtonSearch.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     DataTable tempdateTable = new DataTable();
     MySqlNaceassaryElement mysqElement = new MySqlNaceassaryElement();
     try
     {
         if (this.SummaryDate.SelectedDate.ToString() != string.Empty)
         {
             string tempDate = new PetuniaNecessaryFunction().DateFromRadDatePicker(this.SummaryDate);
             tempdateTable = mysqElement.DataReader(string.Format("SELECT {0} FROM {1} WHERE {2} BETWEEN '{3}' AND '{4}'", Variables.COLUMN_NAME[1], Variables.TABLE_NAME[2], Variables.COLUMN_NAME[0], new NecessaryFunction().MysqlDateFormate(((DateTime)this.SummaryDate.SelectedDate).AddDays(-1).ToString()), tempDate));
             if (tempdateTable.Rows.Count > 0)
             {
                 DataRow tempDataRow = tempdateTable.Rows[0];
                 this.TotalSummary.EndingCash = tempDataRow[0].ToString();
                 try
                 {
                     tempDataRow = tempdateTable.Rows[1];
                     this.TotalSummary.StartingCash = tempDataRow[0].ToString();
                 }
                 catch
                 {
                     this.TotalSummary.StartingCash = Variables.ERROR_MESSAGES[2, 1];
                 }
             }
             tempdateTable = mysqElement.DataReader(string.Format("SELECT SUM({0}),SUM({1}) FROM {2} WHERE {3}='{4}'", Variables.COLUMN_NAME[6], Variables.COLUMN_NAME[1], Variables.TABLE_NAME[12], Variables.COLUMN_NAME[0], tempDate));
             if (tempdateTable.Rows.Count > 0)
             {
                 DataRow tempDataRow = tempdateTable.Rows[0];
                 this.TotalSummary.PurchasQuantity = tempDataRow[0].ToString();
                 this.TotalSummary.PurchaseAmount = tempDataRow[1].ToString();
             }
             tempdateTable = mysqElement.DataReader(string.Format("SELECT SUM({0}),SUM({1}) FROM {2} WHERE {3}='{4}'", Variables.COLUMN_NAME[6], Variables.COLUMN_NAME[1], Variables.TABLE_NAME[14], Variables.COLUMN_NAME[0], tempDate));
             if (tempdateTable.Rows.Count > 0)
             {
                 DataRow tempDataRow = tempdateTable.Rows[0];
                 this.TotalSummary.SalesQuantity = tempDataRow[0].ToString();
                 this.TotalSummary.SalesAmount = tempDataRow[1].ToString();
             }
             tempdateTable = mysqElement.DataReader(string.Format("SELECT SUM({0}) FROM {1} WHERE {2}='{3}'", Variables.COLUMN_NAME[1], Variables.TABLE_NAME[6], Variables.COLUMN_NAME[0], tempDate));
             if (tempdateTable.Rows.Count > 0)
             {
                 DataRow tempDataRow = tempdateTable.Rows[0];
                 this.TotalSummary.Expanses = tempDataRow[0].ToString();
             }
             tempdateTable = mysqElement.DataReader(string.Format("SELECT SUM({0}),SUM({1}) FROM {2} WHERE {3}='{4}' AND {5}='Return'", Variables.COLUMN_NAME[6], Variables.COLUMN_NAME[1], Variables.TABLE_NAME[12], Variables.COLUMN_NAME[0], tempDate, Variables.COLUMN_NAME[14]));
             if (tempdateTable.Rows.Count > 0)
             {
                 DataRow tempDataRow = tempdateTable.Rows[0];
                 this.TotalSummary.PuchaseReturnQuantity = tempDataRow[0].ToString();
                 this.TotalSummary.PuchaseReturnAmount = tempDataRow[1].ToString();
             }
             tempdateTable = mysqElement.DataReader(string.Format("SELECT SUM({0}),SUM({1}) FROM {2} WHERE {3}='{4}' AND {5}='Return'", Variables.COLUMN_NAME[6], Variables.COLUMN_NAME[1], Variables.TABLE_NAME[14], Variables.COLUMN_NAME[0], tempDate, Variables.COLUMN_NAME[14]));
             if (tempdateTable.Rows.Count > 0)
             {
                 DataRow tempDataRow = tempdateTable.Rows[0];
                 this.TotalSummary.SalesReturnQuantity = tempDataRow[0].ToString();
                 this.TotalSummary.SalesReurnAmount = tempDataRow[1].ToString();
             }
         }
         else
         {
             throw new PetuniaException(Variables.ERROR_MESSAGES[0, 5]);
         }
     }
     catch (Exception error)
     {
         Mouse.OverrideCursor = null;
         Microsoft.Windows.Controls.MessageBox.Show(error.Message, Variables.ERROR_MESSAGES[0, 0], MessageBoxButton.OK, MessageBoxImage.Hand);
     }
     finally
     {
         tempdateTable.Dispose();
         mysqElement.Dispose();
         Mouse.OverrideCursor = null;
         this.SummaryButtonSearch.IsEnabled = true;
     }
 }
 //Invoice item Clear
 private void InvoiceItemClear()
 {
     this.InvoiceTextBoxCustomerName.Text = string.Empty;
        this.InvoiceTextBoxBillTo.Text = string.Empty;
        this.InvoiceProductInfo.ClearAllText();
        this.InvoiceLabelProductIDInfo.Text = string.Empty;
        this.InvoiceLabelQuantityInfo.Text = string.Empty;
        this.InvoiceRadioButtonCash.IsChecked = true;
        this.InvoiceComboBoxDebtorName.Text = string.Empty;
        this.GridViewInvoice.Clear();
        invoiceNumber = new PetuniaNecessaryFunction().InvoiceNumbers();
        this.InvoiceTextBoxIssueName.Text = string.Empty;
        this.InvoiceNumberBoxRate.Text = "0";
        this.InvoieLabelCreditAmount.Text = string.Empty;
        this.InvoiceNumberBoxPaidAmount.Text = "0";
        this.InvoiceLabelRateinfo.Text = string.Empty;
 }