Пример #1
0
 private void appStartup()
 {
     try
     {
         Jobs.Log("appStartup Called", null);
         Action act = null;
         if (!Jobs.isDatabaseExists())
         {
             act = () => { WaitingDialog.getMessageLabel().Text = "Initiating database..."; };
             Invoke(act);
             Jobs.Log("New Database Initilized", null);
         }
         Jobs.initiateDatabaseConnection();
         act = () =>
         {
             loadLoans();
         };
         Invoke(act);
     }
     catch (Exception ex)
     {
         Jobs.Log("Error[appStartup]", ex);
     }
 }
Пример #2
0
        public static bool printLoan(String loanid, String loanno)
        {
            bool ret = false;

            try
            {
                if (loanid == null && loanno == null)
                {
                    ret = false; return(ret);
                }
                if (loanid == null)
                {
                    loanid = "0";
                }
                if (loanno == null)
                {
                    loanno = "";
                }
                SQLiteParameter[] param = new SQLiteParameter[2];
                param[0] = new SQLiteParameter("@loanid", loanid);
                param[1] = new SQLiteParameter("@loanno", loanno.ToLower().Trim());

                //SQLiteDataReader dr = Jobs.executeReader("select * from loan where " + Jobs.CL_LOANID + "=" + loanid + " or trim(lower(" + Jobs.CL_LOANNO + "))='" + loanno.ToLower().Trim() + "'");
                SQLiteDataReader dr = Jobs.executeReaderWithParam("select * from loan where " + Jobs.CL_LOANID + "=@loanid or trim(lower(" + Jobs.CL_LOANNO + "))=@loanno", param);
                if (dr.Read())
                {
                    loanNumber  = dr[Jobs.CL_LOANNO].ToString();
                    custName    = dr[Jobs.CL_NAME].ToString();
                    custAddress = dr[Jobs.CL_ADDRESS].ToString();
                    custCNo     = dr[Jobs.CL_CONTACTNUMBER].ToString();
                    refName     = dr[Jobs.CL_REFNAME].ToString();
                    refCNo      = dr[Jobs.CL_REFCONTACTNUMBER].ToString();
                    mgItems     = dr[Jobs.CL_MORTGAGE_ITEMS].ToString();
                    mgRemarks   = dr[Jobs.CL_MORTGAGE_REMARKS].ToString();

                    String[] rms = mgRemarks.Split(new String[] { Jobs.DATABASE_FIELD_SEPARATOR }, StringSplitOptions.None);
                    if (rms.Length == 4)
                    {
                        rmCheck    = rms[0].Trim();
                        rmVehicle  = rms[1].Trim();
                        rmGold     = rms[2].Trim();
                        rmDocument = rms[3].Trim();
                    }

                    byte[] imgBytes = null;
                    try
                    {
                        imgBytes = (Byte[])dr[Jobs.CL_PHOTO];
                    }
                    catch (Exception)
                    {
                        imgBytes = null;
                    }
                    finally
                    {
                        if (imgBytes != null)
                        {
                            custPhoto = Jobs.ByteToImage(imgBytes);
                        }
                    }

                    byte[] spBytes = null;
                    try
                    {
                        spBytes = (Byte[])dr[Jobs.CL_CHECK_SCAN];
                    }
                    catch (Exception)
                    {
                        spBytes = null;
                    }
                    finally
                    {
                        if (spBytes != null)
                        {
                            scanPhoto = Jobs.ByteToImage(spBytes);
                        }
                    }

                    PrintDialog printDialog = new PrintDialog();
                    using (PrintDocument pDoc = new PrintDocument())
                    {
                        printDialog.Document = pDoc;
                        printDialog.PrinterSettings.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
                        pDoc.PrinterSettings = printDialog.PrinterSettings;
                        pDoc.PrintPage      += pDoc_PrintPage;
                        if (printDialog.ShowDialog() == DialogResult.OK)
                        {
                            pDoc.Print();
                            ret = true;
                        }
                        if (scanPhoto != null)
                        {
                            pDoc.PrintPage += pDoc_PrintPage1;
                            pDoc.Print();
                        }
                    }
                }
                else
                {
                    MessageBox.Show(frmMain.ActiveForm, "Sorry, selected loan details is removed from database.", "Deleted entry", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                Jobs.Log("Error[printLoan]", ex);
            }

            loanNumber = custName = custCNo = custAddress = refName = refCNo = mgItems = mgRemarks = rmCheck = rmGold = rmVehicle = rmDocument = "";
            custPhoto  = scanPhoto = null;


            return(ret);
        }
Пример #3
0
        private void addLoan(bool close)
        {
            try
            {
                Jobs.Log("NewLoan Add Called", null);
                if (txtCustFullname.Text.Trim().Length == 0)
                {
                    MessageBox.Show(this, "Please enter valid customer's full name.", "Invalid Details", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtCustFullname.Focus();
                    return;
                }
                if (txtCustAddress.Text.Trim().Length == 0)
                {
                    MessageBox.Show(this, "Please enter valid customer's address.", "Invalid Details", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtCustAddress.Focus();
                    return;
                }
                if (txtCustContactNo.Text.Trim().Length == 0)
                {
                    MessageBox.Show(this, "Please enter valid customer's contact number.", "Invalid Details", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtCustContactNo.Focus();
                    return;
                }
                if (txtLoanNumber.Text.Trim().Length == 0)
                {
                    MessageBox.Show(this, "Please enter valid loan number.", "Invalid Details", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtLoanNumber.Focus();
                    return;
                }
                if (bmpCapturedImg == null)
                {
                    if (MessageBox.Show(this, "Are you sure to add loan detail without customer photo ?", "No customer photo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                }
                String separator       = Jobs.DATABASE_FIELD_SEPARATOR;
                String mortgageItems   = "";
                String mortgageRemarks = "";
                if (chkMortCheck.Checked)
                {
                    mortgageItems   = "Check" + separator;
                    mortgageRemarks = txtCheckRemarks.Text + separator;
                }
                else
                {
                    mortgageItems   = separator;
                    mortgageRemarks = separator;
                }

                if (chkMortVehicle.Checked)
                {
                    mortgageItems   += "Vehicle" + separator;
                    mortgageRemarks += txtVehicleRemarks.Text + separator;
                }
                else
                {
                    mortgageItems   += separator;
                    mortgageRemarks += separator;
                }

                if (chkMortGold.Checked)
                {
                    mortgageItems   += "Gold" + separator;
                    mortgageRemarks += txtGoldRemarks.Text + separator;
                }
                else
                {
                    mortgageItems   += separator;
                    mortgageRemarks += separator;
                }

                if (chkMortDocument.Checked)
                {
                    mortgageItems   += "Document";
                    mortgageRemarks += txtDocumentRemarks.Text;
                }
                else
                {
                    mortgageItems   += "";
                    mortgageRemarks += "";
                }

                String loanid = null;
                if (editMode)
                {
                    loanid = editLoanId;
                }

                //compress(pbScanImage.Image, "");
                Bitmap bmpCheckScan = null;
                try
                {
                    bmpCheckScan = (Bitmap)pbScanImage.Image; ///Image.FromFile("check1.jpg");
                }
                catch (Exception) { }

                if (Jobs.sqlAddLoan(loanid, txtCustFullname.Text.Trim(), txtCustAddress.Text.Trim(), txtCustContactNo.Text.Trim(), txtRefFullname.Text.Trim(), txtRefContactNo.Text.Trim(), txtLoanNumber.Text.Trim(), mortgageItems, mortgageRemarks, bmpCapturedImg, bmpCheckScan))
                {
                    if (close)
                    {
                        DialogResult = DialogResult.OK;
                        Close();
                    }
                    else
                    {
                        txtCustFullname.Text = txtCustAddress.Text = txtCustContactNo.Text = txtRefFullname.Text = txtRefContactNo.Text = txtLoanNumber.Text = txtCheckRemarks.Text = txtVehicleRemarks.Text = txtGoldRemarks.Text = txtDocumentRemarks.Text = "";
                        chkMortCheck.Checked = chkMortVehicle.Checked = chkMortGold.Checked = chkMortDocument.Checked = false;
                        bmpCapturedImg       = null;
                        if (camera.IsCapturing)
                        {
                            camera.StopCapture();
                        }
                        camera.Visible        = true;
                        pbCapturedImg.Visible = false;
                        txtCustFullname.Focus();
                    }
                }
                else
                {
                    MessageBox.Show(this, "Unable to add new loan, please try again." + Environment.NewLine + "Please contact technical team.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                Jobs.Log("Error[AddLoan]", ex);
            }
        }