示例#1
0
 private void print_Click_1(object sender, EventArgs e)
 {
     if (tab_container.SelectedTab == payments_tab)
     {
         PaymentDataSet data          = new PaymentDataSet();
         String         payment_query = "SELECT pay_id as 'id', pay_price as 'price' " +
                                        ", (SELECT COALESCE(SUM(ch_price), 0)" +
                                        " FROM checks WHERE bill_id=payments.pay_id) as 'checks'" +
                                        ", pay_date as 'date' , pay_note as 'note' " +
                                        " FROM payments WHERE cust_id='" + Id + "'" +
                                        " AND pay_date BETWEEN '" + FormatDate(datefrom_pic.Value) + "'" +
                                        " AND '" + FormatDate(dateto_pic.Value) + "' ORDER BY pay_id DESC";
         db.selectPaymentprint(ref data, payment_query);
         PaymentPrintForm report = new PaymentPrintForm(data, cust_label.Text, total_paid_label.Text);
         report.Show();
     }
     else
     {
         if (MessageBox.Show("هل تريد الطباعه؟", "تاكيد الطباعه", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             Finish();
             CustBillDataSet data         = new CustBillDataSet();
             string          teethe_query = "SELECT " +
                                            "COALESCE(GROUP_CONCAT(t.number SEPARATOR ','),'مثبت') " +
                                            "FROM teeth t WHERE t.bill_id=b.id";
             string query = "SELECT b.id,bill_id,b.bill_teethes,b.bill_price" +
                            ", b.bill_delv_state" +
                            ",DATE_FORMAT(b.bill_delv_date,'%d %m  %Y') as 'bill_delv_date'" +
                            ", (" + teethe_query + ") as 'teeth'  " +
                            "FROM bill b WHERE b.cust_id='" + Id + "'" +
                            " AND b.bill_rec_date BETWEEN '" + FormatDate(datefrom_pic.Value) + "'" +
                            " AND '" + FormatDate(dateto_pic.Value) + "'";
             db.selectDBprint(ref data, query);
             CustPrintForm report = new CustPrintForm(data, total.Text, cust_label.Text
                                                      , total_paid_label.Text, sale_label.Text
                                                      , final_total_label.Text, debt_label.Text);
             report.Show();
         }
     }
 }