Ejemplo n.º 1
0
        private int printAllInfoAndSaveInDatabase()
        {
            long _id =0;

            if(testCount == 0)
            {

                MessageBox.Show("You didn't add any test yet","MDC",MessageBoxButton.OK,MessageBoxImage.Error);
                return 0;
            }

            // PrintPage obj = print_page();
            PrintPage obj = new PrintPage();



            _id = printBillIDGenerator(_id) + 1;






            obj.print_bill_id.Text = _id.ToString();
            obj.print_name.Text = name_textfield.Text;
            obj.print_age.Text = age_textbox.Text;
            obj.print_date.Text = DateTime.Now.ToString("dd/MM/yyyy");
            obj.print_time.Text = DateTime.Now.ToString("hh:mm:ss tt");
            obj.print_refd_by.Text = doctor_textfield.Text;
            obj.print_delivery_date.Text = home_datepicker.Text;
            obj.print_phone_no.Text = phone_textbox.Text;
            obj.print_dayofweek.Text = DateTime.Today.DayOfWeek.ToString();
            //obj.print_test_textblock.Text = name_textfield.Text;
            obj.print_sex_textblock.Text = home_sex_combobox.Text;
            
            //test name and price
            /*obj.print_test_name_1.Text = combo_box.Text;
            obj.print_amount_1.Text = test_cost_textfield.Text;

            obj.print_test_name_2.Text = combo_box.Text;
            obj.print_amount_2.Text = test_cost_textfield.Text;

            obj.print_test_name_3.Text = combo_box.Text;
            obj.print_amount_3.Text = test_cost_textfield.Text;

            obj.print_test_name_4.Text = combo_box.Text;
            obj.print_amount_4.Text = test_cost_textfield.Text;

            obj.print_test_name_5.Text = combo_box.Text;
            obj.print_amount_5.Text = test_cost_textfield.Text;
            */



            SaveTestNameAndPrice(_id, obj);

            // PrinterWithScaling(obj);

            //obj.print_sub_total.Text = sumTestCost.ToString();
            //obj.print_discount.Text = sumDiscount.ToString();


            obj.print_sub_total.Text =  net_cost_textfield.Text;
            obj.print_discount.Text =   discount_textfield.Text;



            //int netPayable = sumTestCost - sumDiscount;


            int netPayable = int.Parse(net_cost_textfield.Text) - int.Parse(discount_textfield.Text);

            obj.print_net_total.Text = netPayable.ToString();

            obj.print_ammount_receive.Text =  paid_textbox.Text;

            //obj.print_due.Text = sumDue.ToString();

            string _due = (netPayable - int.Parse(paid_textbox.Text)).ToString();

            obj.print_due.Text = _due;


            TotalCostSave(_id, _due);




           

            obj.Show();
            obj.Close();
            printPage2(obj);
            SaveInDatabase(_due);
            ClearFormData();

             index = 0;
             sumTestCost = 0;
             sumDiscount = 0;
             sumDue = 0;
             sumPaid = 0;

            return 1;
        }
        private void printAllInfoAndSaveInDatabase()
        {

            // PrintPage obj = print_page();
            PrintPage obj = new PrintPage();

            obj.print_name.Text = name_textfield.Text;
            obj.print_age.Text = age_textbox.Text;
            obj.print_date.Text = DateTime.Now.ToString("dd/MM/yyyy");
            obj.print_time.Text = DateTime.Now.ToString("hh:mm:ss tt");
            obj.print_refd_by.Text = doctor_textfield.Text;
            obj.print_delivery_date.Text = home_datepicker.Text;
            obj.print_phone_no.Text = phone_textbox.Text;
            obj.print_dayofweek.Text = DateTime.Today.DayOfWeek.ToString();
            //obj.print_test_textblock.Text = name_textfield.Text;
            obj.print_sex_textblock.Text = home_sex_combobox.Text;
            //test name and price
            obj.print_test_name_1.Text = combo_box.Text;
            obj.print_amount_1.Text = test_cost_textfield.Text;

            obj.print_test_name_2.Text = combo_box.Text;
            obj.print_amount_2.Text = test_cost_textfield.Text;

            obj.print_test_name_3.Text = combo_box.Text;
            obj.print_amount_3.Text = test_cost_textfield.Text;

            obj.print_test_name_4.Text = combo_box.Text;
            obj.print_amount_4.Text = test_cost_textfield.Text;

            obj.print_test_name_5.Text = combo_box.Text;
            obj.print_amount_5.Text = test_cost_textfield.Text;

            // PrinterWithScaling(obj);
            obj.Show();
            obj.Close();
            printPage2(obj);
            SaveInDatabase();
        }