Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (CustomeRepository.IsExistsDifferentLog(
                        commonFunctions.ToInt(cmb_days.SelectedValue.ToString()),
                        commonFunctions.ToInt(cmb_sessions.SelectedValue.ToString()),
                        commonFunctions.ToInt(cmb_pumper.SelectedValue.ToString())
                        ) > 0)
                {
                    MessageBox.Show("Already Printed for this Day ,Session and pumper ", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (MessageBox.Show("Do you want to Save and Print this record?", Messaging.MessageCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    DifferentLog log = new DifferentLog();
                    log.CardTotal       = commonFunctions.ToDecimal(lbl_card.Text.Trim());
                    log.CashTotal       = commonFunctions.ToDecimal(lbl_cash.Text.Trim());
                    log.VoucherTotal    = commonFunctions.ToDecimal(lbl_Voucher.Text.Trim());
                    log.Expenses        = commonFunctions.ToDecimal(lbl_expense.Text.Trim());
                    log.Testing         = commonFunctions.ToDecimal(lbl_othertotal.Text.Trim());
                    log.DayID           = commonFunctions.ToInt(cmb_days.SelectedValue.ToString());
                    log.PumperId        = commonFunctions.ToInt(cmb_pumper.SelectedValue.ToString());
                    log.SessionId       = commonFunctions.ToInt(cmb_sessions.SelectedValue.ToString());
                    log.SystemTotal     = commonFunctions.ToDecimal(lbl_systemtotal.Text.Trim());
                    log.TotalCollection = commonFunctions.ToDecimal(lbl_totalCollection.Text.Trim());
                    log.Differences     = commonFunctions.ToDecimal(lbl_diff.Text.Trim());
                    log.DiffCaculated   = true;
                    log.IsFinal         = true;
                    log.IgnoreDiff      = chk_ignorediff.Checked;
                    log.ModifiedDate    = DateTime.Now;
                    log.CreatedDate     = DateTime.Now;
                    log.CreatedUser     = commonFunctions.LoginuserID;
                    log.ModifiedUser    = commonFunctions.LoginuserID;
                    log.DataTransfer    = 1;


                    CustomeRepository.InsertSalesPrint(log);
                    string filename = PrintRepository.WriteSimpleReciept(log, cmb_pumper.Text, commonFunctions.GlobalCompany);
                    System.Diagnostics.Process.Start(filename);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Has found in program. Please forword following details to technical" + Environment.NewLine + "[" + ex.Message + Environment.NewLine + ex.Source + "]", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }