Ejemplo n.º 1
0
        private void frmVisitorGPProp_Load(object sender, EventArgs e)
        {
            this.Icon  = new Icon("Images/DTPL.ico");
            flgLoading = true;
            objWebCam  = new WebCamera();
            objWebCam.InitializeWebCam(ref picVideo);

            VisitorGP_OnInValid(sender, e);

            FillPurpose();
            if (objVisitorGP.IsNew)
            {
                this.Text += " [ NEW ]";
                ChangeCameraMode(true);
            }
            else
            {
                grbMain.Enabled            = false;
                this.Text                 += " [ " + objVisitorGP.VisitorName + " ]";
                btnAppointmentList.Enabled = false;
                btnVisitorList.Enabled     = false;
                btnEmpList.Enabled         = false;
                btnStartCam.Enabled        = false;
                btnCaptureImg.Enabled      = false;
            }
            txtGateDate.Text      = objVisitorGP.GateDate.ToShortDateString();
            dtpInTime.Text        = objVisitorGP.TimeIn.ToShortTimeString();
            lblAppointmentNo.Text = Convert.ToString(objVisitorGP.AppointmentNo);
            lblVisitorName.Text   = objVisitorGP.VisitorName;
            lblNoOfPersons.Text   = Convert.ToString(objVisitorGP.NoOfPersons);
            if (objVisitorGP.ExtraPersons > 0)
            {
                txtExPersons.Text = Convert.ToString(objVisitorGP.ExtraPersons);
            }
            cboPurpose.Text   = objVisitorGP.Purpose;
            lblCompany.Text   = objVisitorGP.CompanyName;
            lblAddress.Text   = objVisitorGP.Address;
            lblContactNo.Text = objVisitorGP.ContactNo;
            txtVehicleNo.Text = objVisitorGP.VehicleNo;

            lblToMeet.Text            = objVisitorGP.ToMeet;
            lblEmpDept.Text           = objVisitorGP.EmpDept;
            lblEmpContact.Text        = objVisitorGP.EmpMobile;
            txtDepositedMaterial.Text = objVisitorGP.DepositMaterial;
            txtCarryingMaterial.Text  = objVisitorGP.CarryMaterial;

            if (objVisitorGP.IsNew == false & objVisitorGP.VisitorImage != null)
            {
                MemoryStream mem = new MemoryStream(objVisitorGP.VisitorImage);
                picVisitorImg.Image   = Image.FromStream(mem);
                picVideo.Visible      = false;
                picVisitorImg.Visible = true;
            }
            else
            {
                picVideo.Visible      = false;
                picVisitorImg.Visible = true;
            }

            SubscribeToEvents();
            flgLoading = false;
            if (objVisitorGP.IsNew)
            {
                txtGateDate.Text    = DateTime.Now.ToShortDateString();
                dtpInTime.Value     = DateTime.Now;
                picVisitorImg.Image = UI.Properties.Resources.DefaultImage;

                MemoryStream ms = new MemoryStream();
                picVisitorImg.Image.Save(ms, ImageFormat.Jpeg);
                byte[] photo_aray = new byte[ms.Length];
                ms.Position = 0;
                ms.Read(photo_aray, 0, photo_aray.Length);
                objVisitorGP.VisitorImage = photo_aray;
                ms.Dispose();
            }
        }