Exemplo n.º 1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         Jobs.Log("DeleteLoan Click", null);
         if (lvLoans.CheckedItems.Count == 0)
         {
             btnDelete.Enabled = false;
             return;
         }
         String list = "";
         foreach (ListViewItem li in lvLoans.CheckedItems)
         {
             list += li.Text + " (" + li.ToolTipText + ")" + Environment.NewLine;
         }
         if (MessageBox.Show(this, "Are you sure to delete following loan entries ?" + Environment.NewLine + list, "Delete Loans", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             Jobs.Log("Deleting Selected Loans", null);
             foreach (ListViewItem li in lvLoans.CheckedItems)
             {
                 Jobs.deleteLoan(li.Tag.ToString());
                 Jobs.Log('\t' + "Loan Deleted : " + li.ToolTipText, null);
             }
             loadLoans();
         }
         btnDelete.Enabled = false;
     }
     catch (Exception ex)
     {
         Jobs.Log("Error[DeleteClick]", ex);
     }
 }
Exemplo n.º 2
0
 private void addLoanToLV(ListViewItem li, Image img, String tooltip)
 {
     try
     {
         Action act = () =>
         {
             //Jobs.Log("AppStartupThread(Waiting) Started", null);
             if (img != null)
             {
                 //Jobs.Log("Validating Image Key", null);
                 if (imgsLoans.Images.ContainsKey(li.Tag.ToString()))
                 {
                     //Jobs.Log("Removing Duplicate Image by Key", null);
                     imgsLoans.Images.RemoveByKey(li.Tag.ToString());
                 }
                 imgsLoans.Images.Add(li.Tag.ToString(), img);
                 //Jobs.Log("Image Added in ImageList", null);
             }
             else
             {
                 li.ImageKey = "blank.png";
                 //Jobs.Log("Selecting Blank Image", null);
             }
             ListViewItem nli = li.Clone() as ListViewItem;
             nli.ToolTipText = tooltip;
             lvLoans.Items.Add(nli);
             //Jobs.Log("Loan added to LoanList", null);
         };
         Invoke(act);
     }
     catch (Exception ex)
     {
         Jobs.Log("Error[addLoanToLV]", ex);
     }
 }
Exemplo n.º 3
0
        public void setValues(String custName, String custAddress, String custCNo, String refname, String refCNo, String loannumber, bool mortCheck, bool mortVehicle, bool mortGold, bool mortDocument, String remarkCheck, String remarkVehicle, String remarkGold, String remarkDocument, Bitmap photo, Bitmap scanPhoto)
        {
            try
            {
                Jobs.Log("NewLoan Setting Values", null);
                txtCustFullname.Text    = custName;
                txtCustAddress.Text     = custAddress;
                txtCustContactNo.Text   = custCNo;
                txtRefFullname.Text     = refname;
                txtRefContactNo.Text    = refCNo;
                txtLoanNumber.Text      = loannumber;
                chkMortCheck.Checked    = mortCheck;
                chkMortVehicle.Checked  = mortVehicle;
                chkMortGold.Checked     = mortGold;
                chkMortDocument.Checked = mortDocument;
                txtCheckRemarks.Text    = remarkCheck;
                txtVehicleRemarks.Text  = remarkVehicle;
                txtGoldRemarks.Text     = remarkGold;
                txtDocumentRemarks.Text = remarkDocument;
                bmpCapturedImg          = photo;
                if (bmpCapturedImg != null)
                {
                    camera.Visible        = false;
                    pbCapturedImg.Image   = Image.FromHbitmap(bmpCapturedImg.GetHbitmap());
                    pbCapturedImg.Visible = true;
                }

                pbScanImage.Image = scanPhoto;
            }
            catch (Exception ex)
            {
                Jobs.Log("Error[SetValues]", ex);
            }
        }
Exemplo n.º 4
0
        private void frmNewLoan_Shown(object sender, EventArgs e)
        {
            try
            {
                Jobs.Log("Loading Camera", null);
                cmbCameras.Items.Clear();
                List <WebCameraId> cameras = new List <WebCameraId>(camera.GetVideoCaptureDevices());
                foreach (WebCameraId cam in cameras)
                {
                    cmbCameras.Items.Add(new ComboItem(cam.Name, cam));
                }
                if (cameras.Count > 0)
                {
                    cmbCameras.SelectedIndex = 0;
                }

                if (editMode)
                {
                    Jobs.Log("[EditMode] Filling Loan Details", null);
                    Jobs.fillLoanDetail(this, editLoanId);
                }
            }
            catch (Exception ex)
            {
                Jobs.Log("Error[frmNewLoanShown]", ex);
            }
        }
Exemplo n.º 5
0
 private void camera_Click(object sender, EventArgs e)
 {
     try
     {
         if (cmbCameras.SelectedIndex >= 0)
         {
             if (camera.IsCapturing)
             {
                 camera.StopCapture();
                 if (bmpCapturedImg != null)
                 {
                     camera.Visible        = false;
                     pbCapturedImg.Image   = Image.FromHbitmap(bmpCapturedImg.GetHbitmap());
                     pbCapturedImg.Visible = true;
                 }
             }
             else
             {
                 if (!camera.Visible)
                 {
                     pbCapturedImg.Visible = false;
                     camera.Visible        = true;
                 }
                 camera.StartCapture((WebCameraId)(((ComboItem)cmbCameras.SelectedItem).Value));
             }
         }
     }
     catch (Exception ex)
     {
         Jobs.Log("Error[CameraClick]", ex);
     }
 }
Exemplo n.º 6
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            try
            {
                if (lvLoans.CheckedItems.Count == 0)
                {
                    btnPrint.Enabled = false;
                    return;
                }

                bool printAll = false;
                if (lvLoans.CheckedItems.Count > 1)
                {
                    DialogResult dr = MessageBox.Show(this, "Are you sure to print all checked details ?", "Print All Loans", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.Yes)
                    {
                        printAll = true;
                    }
                }
                if (lvLoans.CheckedItems.Count == 1 || printAll)
                {
                    foreach (ListViewItem li in lvLoans.CheckedItems)
                    {
                        printLoan(li.Tag.ToString(), null);
                    }
                }
            }
            catch (Exception ex)
            {
                Jobs.Log("Error[LoanPrintClick]", ex);
            }
        }
Exemplo n.º 7
0
        private void btnSetting_ContextMenu_Action(object sender, EventArgs e)
        {
            MenuItem mi = sender as MenuItem;

            if (mi.Text.StartsWith("&Check for updates"))
            {
                Jobs.Log("Updater Called", null);
                updater(this, Properties.Resources.uid, Properties.Resources.version);
            }
        }
Exemplo n.º 8
0
 private void btnNewLoan_Click(object sender, EventArgs e)
 {
     try
     {
         Jobs.Log("NewLoan_Click, Showing NewLoan Form", null);
         new frmNewLoan().ShowDialog(this);
         Jobs.Log("Refreshing Loan List", null);
         loadLoans();
     }
     catch (Exception ex)
     {
         Jobs.Log("Error[NewLoad_Click] ", ex);
     }
 }
Exemplo n.º 9
0
 private void frmNewLoan_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         if (camera.IsCapturing)
         {
             camera.StopCapture();
         }
         camera.Dispose();
     }
     catch (Exception ex)
     {
         Jobs.Log("Error[NewLoanFormClosing]", ex);
     }
 }
Exemplo n.º 10
0
 private void frmMain_Shown(object sender, EventArgs e)
 {
     try
     {
         Jobs.Log("frmMain Shown", null);
         Thread thread = new Thread(new ThreadStart(appStartup));
         thread.Start();
         Jobs.Log("AppStartupThread(Waiting) Started", null);
         WaitingDialog.showWaitingDialog(this, "Starting up...", "", false);
     }
     catch (Exception ex)
     {
         Jobs.Log("Error[frmMainShown]", ex);
     }
 }
Exemplo n.º 11
0
 public void setEditMode(String loanid)
 {
     try
     {
         Jobs.Log("NewLoan EditMode " + loanid, null);
         editMode           = true;
         editLoanId         = loanid;
         Text               = "Edit Loan";
         btnAdd.Text        = "&Save";
         btnAddNext.Visible = btnAddPrint.Visible = false;
     }
     catch (Exception ex)
     {
         Jobs.Log("Error[setEditMode]", ex);
     }
 }
Exemplo n.º 12
0
 private void threadLoadLoans(object searchFor)
 {
     try
     {
         Action act = () => { lvLoans.Items.Clear(); };
         Invoke(act);
         Jobs.Log("Scanning Loans and Adding in LoanList", null);
         Jobs.scanLoans(addLoanToLV, searchFor.ToString());
         act = () => { WaitingDialog.closeNow(); };
         Invoke(act);
     }
     catch (Exception ex)
     {
         Jobs.Log("Error[threadLoanLoans]", ex);
     }
 }
Exemplo n.º 13
0
 private void btnCapture_Click(object sender, EventArgs e)
 {
     try
     {
         if (camera.IsCapturing)
         {
             Jobs.Log("Camera Capture_Click", null);
             bmpCapturedImg = camera.GetCurrentImage();
             camera_Click(sender, e);
             //bmpCapturedImg.GetThumbnailImage(240, 320, emptyMethod, System.IntPtr.Zero).Save("temp1.bmp");
         }
     }
     catch (Exception ex)
     {
         Jobs.Log("Error[CameraCapture]", ex);
     }
 }
Exemplo n.º 14
0
 private void loadLoans(String searchFor)
 {
     try
     {
         Jobs.Log("LoadLoans Called", null);
         Thread thLoadLoans = new Thread(new ParameterizedThreadStart(threadLoadLoans));
         thLoadLoans.Name     = "Thread: LoadLoans";
         thLoadLoans.Priority = ThreadPriority.Highest;
         thLoadLoans.Start(searchFor);
         Jobs.Log("[loadLoans] Calling Thread", null);
         WaitingDialog.showWaitingDialog(this, "Scanning loans...", "", true);
     }
     catch (Exception ex)
     {
         Jobs.Log("Error[loadLoans]", ex);
     }
 }
Exemplo n.º 15
0
 private void lvLoans_DoubleClick(object sender, EventArgs e)
 {
     try
     {
         if (lvLoans.SelectedItems.Count == 1)
         {
             Jobs.Log("LoanEdit Called", null);
             frmNewLoan loan = new frmNewLoan();
             loan.setEditMode(lvLoans.SelectedItems[0].Tag.ToString());
             loan.ShowDialog(this);
             loadLoans();
         }
     }
     catch (Exception ex)
     {
         Jobs.Log("Error[LoanListDoubleClick]", ex);
     }
 }
Exemplo n.º 16
0
 private void txtSearch_TextChanged(object sender, EventArgs e)
 {
     try
     {
         Jobs.Log("LoanSearch Called", null);
         String searchFor = txtSearch.Text.Trim().ToLower();
         if (searchFor.Length > 2)
         {
             loadLoans(searchFor);
         }
         else if (searchFor.Length == 0)
         {
             loadLoans();
         }
     }
     catch (Exception ex)
     {
         Jobs.Log("Error[LoanSearchTB]", ex);
     }
 }
Exemplo n.º 17
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);
     }
 }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
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);
            }
        }