Example #1
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            string printerName = "Posiflex PP6900 Partial Cut v3.01"; // Your Printer Name


            System.Drawing.Printing.PrintDocument doctoprint = new System.Drawing.Printing.PrintDocument();
            doctoprint.PrinterSettings.PrinterName = printerName;
            int rawKind = 0;
            for (int i = 0; i <= doctoprint.PrinterSettings.PaperSizes.Count - 1; i++)
            {
                if (doctoprint.PrinterSettings.PaperSizes[i].PaperName == "3.14 x 6 in") // "LXP : Your Page Size"
                {
                    rawKind = Convert.ToInt32(doctoprint.PrinterSettings.PaperSizes[i].GetType().GetField
                     ("kind",
                    System.Reflection.BindingFlags.Instance |
                    System.Reflection.BindingFlags.NonPublic).GetValue(doctoprint.PrinterSettings.PaperSizes[i]));
                    break;
                }
                
            }

            if (txtRecieve.Text != "")
            {
                //MakeOver_Paris.rpt_saleinvoice rpt = new rpt_saleinvoice();
                MakeOver_Paris.rpt_test rpt = new rpt_test();
                rpt.Refresh();
                rpt.SetParameterValue("p_invoiceid", invoiceid);
                rpt.SetParameterValue("p_received", decimal.Parse(txtRecieve.Text));
                try
                {
                    rpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA5;
                    rpt.PrintToPrinter(1, false, 0, 0);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
                DTO.Transaction transaction = new DTO.Transaction();
                transaction.Incomeamount = decimal.Parse(txtTotal.Text);
                transaction.Createdby = UserSession.Session.Staff;
                transaction.Remark = "InvoiceID: " + invoiceid;
                new DAO.TransactionDAO().AddTransaction(transaction);
                this.Dispose();
            }
        }
Example #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (id == 0)
            {
                if (txtExpenseAmount.Text == "" && txtIncomeAmount.Text == "")
                {
                    MessageBox.Show("សូមបំពេញពត៏មានឲ្យបានត្រឹមត្រូវ!!!");
                }
                else
                {
                    DTO.Staff staff = new DTO.Staff();
                    // GET FROM USER SESSION
                    staff.Staffid = UserSession.Session.Staff.Staffid;
                    // CONVERTING VALIDATION
                    decimal incomeAmount = 0;
                    decimal expenseAmount = 0;
                    if (txtIncomeAmount.Text != "")
                        incomeAmount = System.Convert.ToDecimal(txtIncomeAmount.Text);
                    else
                        incomeAmount = 0;
                    if (txtExpenseAmount.Text != "")
                        expenseAmount = System.Convert.ToDecimal(txtExpenseAmount.Text);
                    else
                        expenseAmount = 0;

                    DTO.Transaction tran = new DTO.Transaction(incomeAmount
                                                               , expenseAmount
                                                               , staff
                                                               , txtRemark.Text);
                    if (new TransactionDAO().AddTransaction(tran))
                    {
                        txtIncomeAmount.Clear();
                        txtExpenseAmount.Clear();
                        txtRemark.Clear();
                        txtIncomeAmount.Enabled = true;
                        txtExpenseAmount.Enabled = true;
                        dgvTransaction.DataSource = new DAO.TransactionDAO().GetAllTransactions().Tables[0];
                        id = 0;
                    }
                    else
                    {
                        MessageBox.Show("ប្រតិបត្តិការណ៍បរាជ័យ!!!");
                    }
                }
            }
            else
            {
                DTO.Staff staff = new DTO.Staff();
                // GET FROM USER SESSION
                staff.Staffid = UserSession.Session.Staff.Staffid;
                // CONVERTING VALIDATION
                decimal incomeAmount = 0;
                decimal expenseAmount = 0;
                if (txtIncomeAmount.Text != "")
                    incomeAmount = System.Convert.ToDecimal(txtIncomeAmount.Text);
                else
                    incomeAmount = 0;
                if (txtExpenseAmount.Text != "")
                    expenseAmount = System.Convert.ToDecimal(txtExpenseAmount.Text);
                else
                    expenseAmount = 0;

                DTO.Transaction tran = new DTO.Transaction(incomeAmount
                                                           , expenseAmount
                                                           , staff
                                                           , txtRemark.Text);
                tran.Transactionid = id;
                if (new TransactionDAO().UpdateTransaction(tran))
                {
                    txtIncomeAmount.Clear();
                    txtExpenseAmount.Clear();
                    txtRemark.Clear();
                    txtIncomeAmount.Enabled = true;
                    txtExpenseAmount.Enabled = true;
                    dgvTransaction.DataSource = new DAO.TransactionDAO().GetAllTransactions().Tables[0];
                    id = 0;
                }
                else
                {

                }
            }

            getBalance();

        }