Exemple #1
0
        //protected void AddCheckInGuard(object sender, EventArgs e)
        //{
        //    AddNewCheckInRequest objAddCheckinRequest = new AddNewCheckInRequest();
        //    checkin objchickin = new checkin();

        //    objchickin.checkin_id = "1645";
        //    objchickin.UserID = txtID1.Text;
        //    objchickin.user_name = txtName1.Text;
        //    objchickin.telephone = txtTeleNo1.Text;
        //    objchickin.user_address = txtAddress1.Text;
        //    objchickin.company_from = txtCompanyFrom1.Text;
        //    objchickin.Vehicle_No = txtVehicleNo1.Text;
        //    objchickin.key_no =Convert.ToInt32(txtKeyNo1.Text);
        //    objchickin.user_image = "hdgfhsd";
        //    objchickin.remarks = txtRemarks1.Text;
        //    objchickin.Pass_No = "36757";
        //    objchickin.pass_type = txtPassNo1.Text;

        //    AdminBLL ws = new AdminBLL();
        //    ws.AddCheckinGaurd(objchickin);
        //    HttpContext.Current.Items.Add("COMPLETE", "INSERT");
        //    Server.Transfer("..//SMSADMIN//AddNewUserComplete.aspx");

        //}
        protected void AddCheckInVisitor(object sender, EventArgs e)
        {
            AddNewCheckInRequest objAddCheckinRequest = new AddNewCheckInRequest();
            checkin objchickin = new checkin();

            objchickin.checkin_id   = "23462";
            objchickin.UserID       = txtNricID2.Text;
            objchickin.user_name    = txtName2.Text;
            objchickin.telephone    = txtTeleNo2.Text;
            objchickin.user_address = txtAddress2.Text;
            objchickin.company_from = txtCompanyFrom2.Text;
            objchickin.Vehicle_No   = txtVehicleNo2.Text;
            objchickin.key_no       = Convert.ToInt32(txtKeyNo2.Text);
            objchickin.user_image   = "hdgfhsd";
            objchickin.remarks      = txtRemarks2.Text;
            objchickin.Pass_No      = "36757";
            objchickin.pass_type    = txtPassNo2.Text;
            //objchickin.to_visit = txtToVisit1.Text;
            objchickin.purpose = txtVisitorPurpose2.Text;


            AdminBLL ws = new AdminBLL();

            ws.AddCheckinVisitor(objchickin);
            HttpContext.Current.Items.Add("COMPLETE", "INSERT");
            Server.Transfer("..//SMSADMIN//AddNewUserComplete.aspx");
        }
Exemple #2
0
        protected void AddCheckInSalesman(object sender, EventArgs e)
        {
            AddNewCheckInRequest objAddCheckinRequest = new AddNewCheckInRequest();
            checkin objchickin = new checkin();

            objchickin.checkin_id   = "4654656";
            objchickin.UserID       = txtSalesmanID4.Text;
            objchickin.user_name    = txtName4.Text;
            objchickin.telephone    = txtTeleNo4.Text;
            objchickin.user_address = txtAddress4.Text;
            objchickin.company_from = txtCompanyfrom4.Text;
            objchickin.Vehicle_No   = txtVehicleNo4.Text;
            objchickin.key_no       = Convert.ToInt32(txtKeyNo4.Text);
            objchickin.user_image   = "hdgfhsd";
            objchickin.remarks      = txtRemarks4.Text;
            objchickin.Pass_No      = "36757";
            objchickin.pass_type    = txtPassType4.Text;
            objchickin.to_visit     = txtToVisit4.Text;

            AdminBLL ws = new AdminBLL();

            ws.AddCheckinsalesman(objchickin);
            HttpContext.Current.Items.Add("COMPLETE", "INSERT");
            Server.Transfer("..//SMSADMIN//AddNewUserComplete.aspx");
        }
Exemple #6
0
 public void AddCheckinStaff(checkin objcheckin)
 {
     try
     {
         AdminDAL objAdminDAL = new AdminDAL();
         objAdminDAL.AddCheckinStaff(objcheckin);
     }
     catch (Exception es)
     {
         throw es;
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            log4net.ILog logger = log4net.LogManager.GetLogger("File");
            try
            {
                SpaMaster MyMasterPage = (SpaMaster)Page.Master;
                if (!IsPostBack)
                {   //check checkin Time
                    AddNewCheckInRequest objAddCheckinRequest = new AddNewCheckInRequest();
                    checkin objcheckin = new checkin();
                    objcheckin.Checkin_DateTime = DateTime.Now;
                    DateTime dt = (DateTime)objcheckin.Checkin_DateTime;
                    //   Session["dt"] = 3600;



                    txtNricID2.Focus();
                    fillKeyNo();
                    fillPassNo();
                }

                Label1.Visible   = false;
                lblerror.Visible = false;
                lblerr1.Visible  = false;
                lblerr2.Visible  = false;
                lblerr3.Visible  = false;
                lblerr4.Visible  = false;
                lblerr5.Visible  = false;
                lblerr6.Visible  = false;
                // Label2.Visible = false;
                if (Session["LCID"] != null)
                {
                    // objchickin.LocationID = int.Parse(Session["LCID"].ToString());

                    Location = Session["LCID"].ToString();
                }
                else
                {
                    MyMasterPage.ShowErrorMessage("Please select Location first!!!");
                    //lblerror.Visible = true;
                    //lblerror.Text = "Please select Location first!!!";
                }
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
            }
        }
 private bool registerEmployee(employees e)
 {
     try
     {
         using (smartclocksrldbEntities db = new smartclocksrldbEntities())
         {
             if (!this.Cache.Contains(e.id))
             {
                 checkin oCheckin = new checkin
                 {
                     employeeID   = e.id,
                     checkDate    = DateTime.Now.Date,
                     checkHour    = DateTime.Now.ToString("HH:mm:ss"),
                     observations = null
                 };
                 db.checkin.Add(oCheckin);
                 db.SaveChanges();
                 lblStatus.Text      = "Check In";
                 lblStatus.ForeColor = Color.LightGreen;
                 this.Cache.Add(e.id);
                 return(true);
             }
             else
             {
                 checkout oCheckout = new checkout
                 {
                     employeeID   = e.id,
                     checkDate    = DateTime.Now.Date,
                     checkHour    = DateTime.Now.ToString("HH:mm:ss"),
                     observations = null
                 };
                 db.checkout.Add(oCheckout);
                 db.SaveChanges();
                 lblStatus.Text      = "Check Out";
                 lblStatus.ForeColor = Color.LightGreen;
                 this.Cache.Remove(e.id);
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error " + ex.Message);
         return(false);
     }
 }
Exemple #10
0
        protected void AddCheckInContractor(object sender, EventArgs e)
        {
            log4net.ILog logger = log4net.LogManager.GetLogger("File");
            try
            {
                SpaMaster            SM = (SpaMaster)Page.Master;
                AddNewCheckInRequest objAddCheckinRequest = new AddNewCheckInRequest();
                checkin objchickin = new checkin();
                String  ZipRegex   = "^[a-z A-Z 0-9]+$";
                if (txtNricID3.Text.Trim() != "")
                {
                    SqlParameter[] para = new SqlParameter[1];
                    para[0]       = new SqlParameter("@NRICno", SqlDbType.VarChar, 100);
                    para[0].Value = txtNricID3.Text.Trim();
                    DataTable dt1 = dal.executeprocedure("SP_getCheckinIDbyNRICNo", para, false);
                    if (dt1.Rows.Count > 0)
                    {
                        long           CHECKIN_ID = Convert.ToInt64(dt1.Rows[0]["checkin_id"].ToString());
                        SqlParameter[] para2      = new SqlParameter[1];
                        para2[0]       = new SqlParameter("@checkin_id", SqlDbType.BigInt, 100);
                        para2[0].Value = CHECKIN_ID;
                        DataTable dt3 = dal.executeprocedure("SP_GetCheckoutIDbyCheckInID", para2, false);
                        if (dt3.Rows.Count == 0)
                        {
                            //  lblerror.Visible = true;
                            //  lblerror.Text = "NRIC/FIN No. Already Checked In ..!";
                            //  lblerr1.Visible = true;
                            SM.ShowErrorMessage("NRIC/FIN No. Already Checked In ..!");
                            return;
                            // throw new Exception();
                        }
                    }
                }
                else
                {
                    objchickin.NRICno = "";
                    // lblerr2.Visible = true;
                    // lblerror.Visible = true;
                    //  lblerror.Text = "Please Fill NRIC no.!!";
                    SM.ShowErrorMessage("Please Fill NRIC no.!!");
                    return;
                }
                if (Session["CaptureImagePath"] != null)
                {
                    objchickin.ImagePath = Session["CaptureImagePath"].ToString();
                }
                else if (Session["CaptureImage"] != null)
                {
                    objchickin.ImagePath = Session["CaptureImage"].ToString();
                    //Session["CaptureImage"] = null;
                }

                if (Session["LCID"] != null)
                {
                    objchickin.LocationID = int.Parse(Session["LCID"].ToString());
                    // Session["LCID"] = null;
                }

                if (txtKeyNo3.Text.Trim() != "")
                {
                    objchickin.Key_no = txtKeyNo3.Text;
                    UpdateKeyStatus();
                }
                else
                {
                    objchickin.Key_no = "";
                }
                if (txtPassNo3.Text.Trim() != "")
                {
                    objchickin.Pass_No = txtPassNo3.Text.Trim();
                    UpdatePassStatus();
                }

                if (txtTeleNo3.Text.Trim() != "")
                {
                    objchickin.telephone = txtTeleNo3.Text.Trim();
                    //UpdatePassStatus();
                }
                else
                {
                    objchickin.telephone = "";
                }
                if (txtName3.Text.Trim() != "")
                {
                    objchickin.user_name = txtName3.Text.Trim();
                    //UpdatePassStatus();
                }

                if (txtServingAt1.Text.Trim() != "")
                {
                    objchickin.to_visit = txtServingAt1.Text.Trim();
                    //UpdatePassStatus();
                }
                else
                {
                    objchickin.to_visit = "";
                }
                if (txtNricID3.Text.Trim() != "")
                {
                    //objchickin.Pass_No = txtPassNo3.Text;//PassOccupied();
                    objchickin.to_visit   = txtServingAt1.Text; // tovisit();
                    objchickin.Vehicle_No = txtVehicleNo3.Text; //addVehicle();
                    objchickin.telephone  = txtTeleNo3.Text;    //AddTelephone();

                    objchickin.NRICno       = txtNricID3.Text;
                    objchickin.user_name    = txtName3.Text;
                    objchickin.user_address = txtAddress3.Text;
                    objchickin.company_from = txtCompanyfrom3.Text;
                    objchickin.remarks      = txtRemarks3.Text;
                    objchickin.pass_type    = cmbContractorPass.Text;
                    objchickin.purpose      = txtpurpose.Text;
                    objchickin.Item_Declear = txtItemDeclear3.Text;

                    /*string time = string.Empty;
                     * time = ConfigurationManager.AppSettings.Get("SPATime");
                     * double newtime = Convert.ToDouble(time);
                     * objchickin.Checkin_DateTime = DateTime.Now.AddHours(newtime);*/
                    objchickin.Checkin_DateTime = DateTime.Now;
                    objchickin.Role             = txtrole.Text;

                    AdminBLL ws = new AdminBLL();
                    // ws.AddCheckinVisitor(objchickin);
                    ws.AddCheckinContractor(objchickin);

                    HttpContext.Current.Items.Add("COMPLETE", "INSERT");
                    SM.ShowErrorMessage("Contractor Check In successfully");
                    return;
                    // Server.Transfer("..//SMSADMIN//AlertUpdateComplete.aspx");
                }
                else
                {
                    // lblerr3.Visible = true;
                    //lblerror.Visible = true;
                    //lblname.Visible = true;
                    //lblerror.Text = "Please Fill All the (*) fields!!";
                    SM.ShowErrorMessage("Please Fill All the (*) fields!!");
                    return;
                }
            }


            catch (Exception ex)
            {
                logger.Info(ex.Message);
            }
        }
Exemple #11
0
        protected void btnThumbCheckIn_Click(object sender, EventArgs e)
        {
            log4net.ILog logger  = log4net.LogManager.GetLogger("File");
            bool         success = false;

            try
            {
                Template   template1  = new Template();
                FeatureSet featureSet = new FeatureSet();

                SqlParameter[] para = new SqlParameter[1];

                // para[0] = new SqlParameter("@Role", txtrole.Text);
                DataTable dt = dal.executeprocedure("usp_GetRoleThumbPrints", para, false);

                foreach (DataRow dr in dt.Rows)
                {
                    template1 = new DPFP.Template();
                    template1.DeSerialize((byte[])dr["ThumbImage"]);

                    featureSet = new DPFP.FeatureSet();
                    featureSet.DeSerialize(HexsToArray(hdnFP.Value));
                    if (VerifyFingerprints(template1, featureSet))
                    {
                        DataTable dtcheckin = dal.getdata("select checkin_id from checkin_manager where UserID = '" + dr["Staff_ID"].ToString() + "' ");
                        if (dtcheckin.Rows.Count > 0)
                        {
                            DataTable dtcheckout = dal.getdata("select checkout_id from checkout_manager where checkin_id = '" + dtcheckin.Rows[0][0].ToString() + "' ");
                            if (dtcheckout.Rows.Count == 0)
                            {
                                lblerror.Visible = true;
                                lblerror.Text    = "Security Officer is Already Checked in.Please Contact Your SuperVisor..!";
                                // lblerr1.Visible = true;
                                throw new Exception();
                            }
                        }
                        AddNewCheckInRequest objAddCheckinRequest = new AddNewCheckInRequest();
                        checkin objchickin = new checkin();
                        objchickin.telephone = dr["Phone"].ToString();
                        objchickin.UserID    = dr["Staff_ID"].ToString();
                        // objchickin.Role = txtrole.Text;
                        objchickin.user_name        = dr["FirstName"].ToString();
                        objchickin.Checkin_DateTime = DateTime.Now;
                        objchickin.NRICno           = dr["NRICno"].ToString();
                        if (Session["LCID"] != null && Session["LCID"].ToString() != "0")
                        {
                            objchickin.LocationID = int.Parse(Session["LCID"].ToString());
                        }
                        AdminBLL ws = new AdminBLL();
                        ws.AddCheckinGaurd(objchickin);
                        tblThumbInfo.Style.Add(HtmlTextWriterStyle.Display, "");
                        lblFin.Text   = dr["NRICno"].ToString();
                        lblName.Text  = dr["FirstName"].ToString();
                        lblPhone.Text = dr["Phone"].ToString();
                        if (dr["ImagePathName"] != null && dr["ImagePathName"].ToString() != "")
                        {
                            UserImage.ImageUrl = dr["ImagePathName"].ToString();
                            UserImage.Visible  = true;
                        }
                        else
                        {
                            UserImage.Visible = false;
                        }
                        success = true;
                        tblThumbInfo.Style.Add(HtmlTextWriterStyle.Display, "block");
                        break;
                        HttpContext.Current.Items.Add("COMPLETE", "INSERT");
                    }
                }
                if (!success)
                {
                    if (!(lblerror.Text.ToLower().Contains("already")))
                    {
                        lblerror.Text    = "Invalid Thumbprint. Please Put Correct Finger.";
                        lblerror.Visible = true;
                    }
                }
                else
                {
                    lblerror.Text    = "You Have Successfully Checked In";
                    lblerror.Visible = true;
                }
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
                if (!(lblerror.Text.ToLower().Contains("already")))
                {
                    lblerror.Text = "Error Has Occured. Please Thumbprint Again.";
                }
                lblerror.Visible = true;
            }
        }
Exemple #12
0
        protected void btncheckin_Click(object sender, EventArgs e)
        {
            SpaMaster SM = (SpaMaster)Page.Master;

            log4net.ILog logger = log4net.LogManager.GetLogger("File");
            try
            {
                AddNewCheckInRequest objAddCheckinRequest = new AddNewCheckInRequest();
                checkin objchickin = new checkin();
                string  NRICNO     = txtNricID3.Text.Trim();
                string  ROLE       = txtrole.Text.Trim();
                string  STAFFID    = string.Empty;

                SqlParameter[] para1 = new SqlParameter[2];
                para1[0]       = new SqlParameter("@NRICNO", SqlDbType.VarChar, 100);
                para1[0].Value = NRICNO;
                para1[1]       = new SqlParameter("@ROLE", SqlDbType.VarChar, 100);
                para1[1].Value = ROLE;

                DataTable dt = dal.executeprocedure("SP_GetStaffidbyNRICRole", para1, false);
                if (dt.Rows.Count > 0)
                {
                    STAFFID = dt.Rows[0]["Staff_ID"].ToString();
                    SqlParameter[] para = new SqlParameter[1];
                    para[0]       = new SqlParameter("@UserID", SqlDbType.VarChar, 100);
                    para[0].Value = STAFFID;
                    DataTable dt1 = dal.executeprocedure("SP_GetCheckInIDbyUserid", para, false);
                    if (dt1.Rows.Count > 0)
                    {
                        long           CHECKIN_ID = Convert.ToInt64(dt1.Rows[0]["checkin_id"].ToString());
                        SqlParameter[] para2      = new SqlParameter[1];
                        para2[0]       = new SqlParameter("@checkin_id", SqlDbType.BigInt, 100);
                        para2[0].Value = CHECKIN_ID;
                        DataTable dt3 = dal.executeprocedure("SP_GetCheckoutIDbyCheckInID", para2, false);
                        if (dt3.Rows.Count == 0)
                        {
                            //lblerror.Visible = true;
                            //lblerror.Text = "NRIC/FIN No. Already Checked In ..!";
                            //lblerr1.Visible = true;
                            SM.ShowErrorMessage("NRIC/FIN No. Already Checked In ..!");
                            return;
                            //throw new Exception();
                        }
                    }
                }
                else
                {
                    //lblerror.Visible = true;
                    //lblerror.Text = "No Operation Manager with this NRIC/FIN No. exists in database !";
                    //lblerr1.Visible = true;
                    SM.ShowErrorMessage("No Operation Manager with this NRIC/FIN No. exists in database !");
                    return;
                    //throw new Exception();
                }

                objchickin.telephone = txtTeleNo3.Text;
                objchickin.UserID    = STAFFID;
                objchickin.Role      = ROLE;
                objchickin.user_name = txtName3.Text.Trim();
                objchickin.NRICno    = NRICNO;

                /*string time = string.Empty;
                 * time = ConfigurationManager.AppSettings.Get("SPATime");
                 * double newtime = Convert.ToDouble(time);
                 * objchickin.Checkin_DateTime = DateTime.Now.AddHours(newtime);*/
                objchickin.Checkin_DateTime = DateTime.Now;
                if (Session["LCID"] != null && Session["LCID"].ToString() != "0")
                {
                    objchickin.LocationID = int.Parse(Session["LCID"].ToString());
                }
                else
                {
                    //lblerror.Visible = true;
                    //lblerror.Text = "You must login as either supervisor or Operation Manager..!";
                    //lblerr1.Visible = true;
                    SM.ShowErrorMessage("Select Location Firstly..");
                    return;
                    //throw new Exception();
                }

                AdminBLL ws = new AdminBLL();
                ws.AddCheckinGaurd(objchickin);

                HttpContext.Current.Items.Add("COMPLETE", "INSERT");
                SM.ShowErrorMessage("Check In Successfully..!");
                // Server.Transfer("..//SMSADMIN//AlertUpdateComplete.aspx");
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
            }
        }
        protected void AddCheckInVisitor(object sender, EventArgs e)
        {
            log4net.ILog logger = log4net.LogManager.GetLogger("File");
            try
            {
                SpaMaster            MyMasterPage         = (SpaMaster)Page.Master;
                AddNewCheckInRequest objAddCheckinRequest = new AddNewCheckInRequest();
                checkin objchickin = new checkin();


                SqlParameter[] para = new SqlParameter[1];
                para[0]       = new SqlParameter("@NRICno", SqlDbType.VarChar, 100);
                para[0].Value = txtNricID2.Text.Trim();
                DataTable dt1 = dal.executeprocedure("SP_getCheckinIDbyNRICNo", para, false);
                if (dt1.Rows.Count > 0)
                {
                    long           CHECKIN_ID = Convert.ToInt64(dt1.Rows[0]["checkin_id"].ToString());
                    SqlParameter[] para2      = new SqlParameter[1];
                    para2[0]       = new SqlParameter("@checkin_id", SqlDbType.BigInt, 50);
                    para2[0].Value = CHECKIN_ID;
                    DataTable dt3 = dal.executeprocedure("SP_GetCheckoutIDbyCheckInID", para2, false);
                    if (dt3.Rows.Count == 0)
                    {
                        MyMasterPage.ShowErrorMessage("NRIC/FIN No. Already Checked In ..!");
                        //lblerror.Visible = true;
                        //lblerror.Text = "NRIC/FIN No. Already Checked In ..!";
                        //lblerr1.Visible = true;
                        return;
                    }
                }



                if (Session["CaptureImagePath"] != null)
                {
                    objchickin.ImagePath = Session["CaptureImagePath"].ToString();
                }
                else if (Session["CaptureImage"] != null)
                {
                    objchickin.ImagePath = Session["CaptureImage"].ToString();
                    //Session["CaptureImage"] = null;
                    // return;
                }

                if (txtKeyNo2.SelectedValue.Trim() != "")
                {
                    objchickin.Key_no = txtKeyNo2.Text;
                    UpdateKeyStatus();
                }

                if (txtTeleNo2.Text.Trim() != "")
                {
                    objchickin.telephone = txtTeleNo2.Text.Trim();
                    //UpdatePassStatus();
                }

                if (txtToVisit2.Text.Trim() != "")
                {
                    objchickin.to_visit = txtToVisit2.Text.Trim();
                    ////UpdatePassStatus();
                }

                if (txtPassNo2.SelectedValue.Trim() != "")
                {
                    objchickin.Pass_No = txtPassNo2.Text.Trim();
                    UpdatePassStatus();
                }


                if (txtNricID2.Text.Trim() != "")
                {
                    objchickin.NRICno = txtNricID2.Text.Trim();
                    // UpdatePassStatus();
                }
                else
                {
                    objchickin.NRICno = "";
                    MyMasterPage.ShowErrorMessage("please Fill NRICno. first !!");
                    return;
                    //lblerr1.Visible = true;
                    //lblerror.Visible = true;
                    //lblerror.Text = "please Fill NRICno. first !!";
                }

                if (txtNricID2.Text.Trim() != "")
                {
                    objchickin.to_visit     = txtToVisit2.Text.Trim();
                    objchickin.Vehicle_No   = txtVehicleNo2.Text.Trim();
                    objchickin.telephone    = txtTeleNo2.Text.Trim();
                    objchickin.NRICno       = txtNricID2.Text.Trim();
                    objchickin.user_name    = txtName2.Text.Trim();
                    objchickin.user_address = txtAddress2.Text.Trim();
                    objchickin.company_from = txtCompanyFrom2.Text.Trim();
                    objchickin.remarks      = txtRemarks2.Text.Trim();
                    objchickin.pass_type    = cmbvisitorPass.Text.Trim();
                    objchickin.purpose      = txtVisitorPurpose2.Text.Trim();
                    objchickin.Item_Declear = txtItemDeclear2.Text.Trim();

                    objchickin.Checkin_DateTime = DateTime.Now;
                    //objchickin.Checkin_DateTime = DateTime.Now;
                    objchickin.Role = txtrole.Text;

                    if (Location != null)
                    {
                        objchickin.LocationID = int.Parse(Location);
                    }
                    else
                    {
                        MyMasterPage.ShowErrorMessage("Please select Location first!!!");
                        return;
                        //lblerror.Visible = true;
                        //lblerror.Text = "Please select Location first!!!";
                    }

                    AdminBLL ws = new AdminBLL();
                    ws.AddCheckinVisitor(objchickin);
                    checktime1();
                    UpdatePre_visitors(txtName2.Text, Convert.ToDateTime(DateTime.Now.ToShortDateString()), DateTime.Now.ToShortTimeString().ToString());
                    HttpContext.Current.Items.Add("COMPLETE", "INSERT");
                    MyMasterPage.ShowErrorMessage("Check In Successfully");
                }
                else
                {
                    MyMasterPage.ShowErrorMessage("Please Fill all the fields!!!");
                    //lblerror.Visible = true;
                    //lblerror.Text = "Please Fill all the fields!!!";
                }
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
            }
        }
Exemple #14
0
        protected void btnThumbCheckIn_Click(object sender, EventArgs e)
        {
            SpaMaster SM = (SpaMaster)Page.Master;

            log4net.ILog logger  = log4net.LogManager.GetLogger("File");
            bool         success = false;

            try
            {
                Template       template1  = new Template();
                FeatureSet     featureSet = new FeatureSet();
                SqlParameter[] para       = new SqlParameter[1];

                // para[0] = new SqlParameter("Staff_ID", "4D1614C3A02F");
                para[0] = new SqlParameter("Staff_ID", Session["StaffID1"].ToString());
                DataTable dt = dal.executeprocedure("usp_GetRoleThumbPrints", para, false);
                foreach (DataRow dr in dt.Rows)
                {
                    featureSet = new DPFP.FeatureSet();
                    featureSet.DeSerialize(HexsToArray(hdnFP.Value));
                    template1 = new DPFP.Template();
                    template1.DeSerialize((byte[])dr["ThumbImage"]);
                    if (VerifyFingerprints(template1, featureSet))
                    {
                        DataTable dtcheckin = dal.getdata("select checkin_id from checkin_manager where UserID = '" + dr["Staff_ID"].ToString() + "' ");
                        if (dtcheckin.Rows.Count > 0)
                        {
                            DataTable dtcheckout = dal.getdata("select checkout_id from checkout_manager where checkin_id = '" + dtcheckin.Rows[0][0].ToString() + "' ");
                            if (dtcheckout.Rows.Count == 0)
                            {
                                //lblerror.Visible = true;
                                //lblerror.Text = "Security Officer is Already Checked in.Please Contact Your SuperVisor..!";
                                //lblerr1.Visible = true;
                                SM.ShowErrorMessage("Security Officer is Already Checked in.Please Contact Your SuperVisor..!");
                                return;
                                // throw new Exception();
                            }
                        }

                        AddNewCheckInRequest objAddCheckinRequest = new AddNewCheckInRequest();
                        checkin objchickin = new checkin();
                        objchickin.telephone        = dr["Phone"].ToString();
                        objchickin.UserID           = dr["Staff_ID"].ToString();
                        objchickin.Role             = txtrole.Text;
                        objchickin.user_name        = dr["FirstName"].ToString();
                        objchickin.Checkin_DateTime = DateTime.Now;
                        objchickin.NRICno           = dr["NRICno"].ToString();
                        if (Session["LCID"] != null && Session["LCID"].ToString() != "0")
                        {
                            objchickin.LocationID = int.Parse(Session["LCID"].ToString());
                        }
                        //=========================================//
                        DBConnectionHandler1 db = new DBConnectionHandler1();
                        SqlConnection        cn = db.getconnection();
                        cn.Open();
                        if (cn.State == ConnectionState.Open)
                        {
                        }
                        else
                        {
                            cn.Open();
                        }
                        SqlCommand cmd = new SqlCommand("select code from location where Location_id=@location", cn);
                        cmd.Parameters.AddWithValue("@location", int.Parse(Session["LCID"].ToString()));
                        SqlDataReader dr1            = cmd.ExecuteReader();
                        string        AssignmentCode = string.Empty;
                        if (dr1.Read())
                        {
                            AssignmentCode = dr1.GetString(0);
                        }
                        string         CurrDate = DateTime.Now.ToShortDateString();
                        string[]       Splitter = CurrDate.Split('/');
                        int            Date     = Convert.ToInt32(Splitter[1].ToString());
                        SqlParameter[] para3    = new SqlParameter[5];
                        para3[0]       = new SqlParameter("@Nric", SqlDbType.VarChar, 100);
                        para3[0].Value = dr["NRICno"].ToString();
                        para3[1]       = new SqlParameter("@AssignmentCode", SqlDbType.VarChar, 200);
                        para3[1].Value = AssignmentCode;
                        para3[2]       = new SqlParameter("@Day", SqlDbType.Int, 100);
                        para3[2].Value = Date;
                        para3[3]       = new SqlParameter("@Month", SqlDbType.Int, 100);
                        para3[3].Value = DateTime.Now.Month;
                        para3[4]       = new SqlParameter("@WorkMonth", SqlDbType.VarChar, 100);
                        para3[4].Value = Month[DateTime.Now.Month - 1] + " " + DateTime.Now.Year;
                        DataTable dt2 = new DataTable();



                        dt2 = dal.executeprocedure("SP_AddSalaryInterface", para3, false);
                        //objchickin.Role = txtrole.Text;
                        //==========================================//
                        AdminBLL ws = new AdminBLL();
                        ws.AddCheckinGaurd(objchickin);
                        tblThumbInfo.Style.Add(HtmlTextWriterStyle.Display, "");
                        lblFin.Text   = dr["NRICno"].ToString();
                        lblName.Text  = dr["FirstName"].ToString();
                        lblPhone.Text = dr["Phone"].ToString();
                        if (dr["ImagePathName"] != null && dr["ImagePathName"].ToString() != "")
                        {
                            UserImage.ImageUrl = dr["ImagePathName"].ToString();
                            UserImage.Visible  = true;
                        }
                        else
                        {
                            UserImage.Visible = false;
                        }
                        success = true;
                        tblThumbInfo.Style.Add(HtmlTextWriterStyle.Display, "block");
                        break;
                        HttpContext.Current.Items.Add("COMPLETE", "INSERT");
                    }
                }
                if (!success)
                {
                    if (!(lblerror.Text.ToLower().Contains("already")))
                    {
                        //lblerror.Text = "Invalid Thumbprint. Please Put Correct Finger.";
                        //lblerror.Visible = true;
                        SM.ShowErrorMessage("Invalid Thumbprint. Please Put Correct Finger.");
                    }
                }
                else
                {
                    //lblerror.Text = "You Have Successfully Checked In";
                    //lblerror.Visible = true;
                    SM.ShowErrorMessage("You Have Successfully Checked In");
                }
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
                if (!(lblerror.Text.ToLower().Contains("already")))
                {
                    //lblerror.Text = "Error Has Occured. Please Thumbprint Again.";
                    SM.ShowErrorMessage("Error Has Occured. Please Thumbprint Again.");
                }
                // lblerror.Visible = true;
            }
        }
Exemple #15
0
        protected void btncheckin_Click(object sender, EventArgs e)
        {
            SpaMaster SM = (SpaMaster)Page.Master;

            log4net.ILog logger = log4net.LogManager.GetLogger("File");
            try
            {
                if (Session["user_role"].ToString() == "Supervisor" || Session["user_role"].ToString() == "Security Officer" || Session["user_role"].ToString() == "Operations Manager")
                {
                    AddNewCheckInRequest objAddCheckinRequest = new AddNewCheckInRequest();
                    checkin objchickin = new checkin();
                    string  NRICNO     = txtNricID3.Text.Trim();
                    //string ROLE = txtrole.Text.Trim();
                    string STAFFID = string.Empty;
                    if (Session["user_role"].ToString() == "Operations Manager")
                    {
                        txtrole.Text = "Security Officer";
                    }
                    SqlParameter[] para1 = new SqlParameter[2];
                    para1[0]       = new SqlParameter("@NRICNO", SqlDbType.VarChar, 100);
                    para1[0].Value = NRICNO;
                    para1[1]       = new SqlParameter("@ROLE", SqlDbType.VarChar, 100);
                    para1[1].Value = txtrole.Text;
                    DataTable dt = new DataTable();



                    dt = dal.executeprocedure("SP_GetStaffidbyNRICRole", para1, false);
                    objchickin.Role = txtrole.Text;

                    if (dt.Rows.Count > 0)
                    {
                        STAFFID = dt.Rows[0]["Staff_ID"].ToString();
                        SqlParameter[] para = new SqlParameter[1];
                        para[0]       = new SqlParameter("@UserID", SqlDbType.VarChar, 100);
                        para[0].Value = STAFFID;
                        DataTable dt1 = dal.executeprocedure("SP_GetCheckInIDbyUserid", para, false);
                        if (dt1.Rows.Count > 0)
                        {
                            long           CHECKIN_ID = Convert.ToInt64(dt1.Rows[0]["checkin_id"].ToString());
                            SqlParameter[] para2      = new SqlParameter[1];
                            para2[0]       = new SqlParameter("@checkin_id", SqlDbType.BigInt, 100);
                            para2[0].Value = CHECKIN_ID;
                            DataTable dt3 = dal.executeprocedure("SP_GetCheckoutIDbyCheckInID", para2, false);
                            if (dt3.Rows.Count == 0)
                            {
                                //lblerror.Visible = true;
                                //lblerror.Text = "NRIC/FIN No. Already Checked In ..!";
                                //lblerr1.Visible = true;
                                SM.ShowErrorMessage("NRIC/FIN No. Already Checked In ..!");
                                return;
                                // throw new Exception();
                            }
                        }
                    }
                    else
                    {
                        //lblerror.Visible = true;
                        //lblerror.Text = "No security officer with this NRIC/FIN No. exists in database !";
                        //lblerr1.Visible = true;
                        SM.ShowErrorMessage("No security officer with this NRIC/FIN No. exists in database !");
                        return;
                    }
                    //=========================================//
                    DBConnectionHandler1 db = new DBConnectionHandler1();
                    SqlConnection        cn = db.getconnection();
                    cn.Open();
                    if (cn.State == ConnectionState.Open)
                    {
                    }
                    else
                    {
                        cn.Open();
                    }
                    SqlCommand cmd = new SqlCommand("select code from location where Location_id=@location", cn);
                    cmd.Parameters.AddWithValue("@location", int.Parse(Session["LCID"].ToString()));
                    SqlDataReader dr             = cmd.ExecuteReader();
                    string        AssignmentCode = string.Empty;
                    if (dr.Read())
                    {
                        AssignmentCode = dr.GetString(0);
                    }
                    string         CurrDate = DateTime.Now.ToShortDateString();
                    string[]       Splitter = CurrDate.Split('/');
                    int            Date     = Convert.ToInt32(Splitter[1].ToString());
                    SqlParameter[] para3    = new SqlParameter[5];
                    para3[0]       = new SqlParameter("@Nric", SqlDbType.VarChar, 100);
                    para3[0].Value = NRICNO;
                    para3[1]       = new SqlParameter("@AssignmentCode", SqlDbType.VarChar, 200);
                    para3[1].Value = AssignmentCode;
                    para3[2]       = new SqlParameter("@Day", SqlDbType.Int, 100);
                    para3[2].Value = Date;
                    para3[3]       = new SqlParameter("@Month", SqlDbType.Int, 100);
                    para3[3].Value = DateTime.Now.Month;
                    para3[4]       = new SqlParameter("@WorkMonth", SqlDbType.VarChar, 100);
                    para3[4].Value = Month[DateTime.Now.Month - 1] + " " + DateTime.Now.Year;
                    DataTable dt2 = new DataTable();



                    dt2             = dal.executeprocedure("SP_AddSalaryInterface", para3, false);
                    objchickin.Role = txtrole.Text;
                    //==========================================//

                    objchickin.telephone = txtTeleNo3.Text;
                    objchickin.UserID    = STAFFID;
                    //objchickin.Role =TextsecOff.Text;
                    objchickin.user_name = txtName3.Text.Trim();
                    objchickin.NRICno    = NRICNO;

                    /*string time = string.Empty;
                     * time = ConfigurationManager.AppSettings.Get("SPATime");
                     * double newtime = Convert.ToDouble(time);
                     * objchickin.Checkin_DateTime = DateTime.Now.AddHours(newtime);*/
                    objchickin.Checkin_DateTime = DateTime.Now;
                    if (Session["LCID"] != null && Session["LCID"].ToString() != "0")
                    {
                        objchickin.LocationID = int.Parse(Session["LCID"].ToString());
                    }
                    else
                    {
                        //lblerror.Visible = true;
                        //lblerror.Text = "You must login as either supervisor or security officer or Operation Manager..!";
                        //lblerr1.Visible = true;
                        SM.ShowErrorMessage("You must login as either supervisor or security officer or Operation Manager..!");
                        return;
                        //throw new Exception();
                    }


                    AdminBLL ws = new AdminBLL();
                    ws.AddCheckinGaurd(objchickin);

                    HttpContext.Current.Items.Add("COMPLETE", "INSERT");
                    SM.ShowErrorMessage("Check In Successfully..!");
                    return;
                    // Server.Transfer("..//SMSADMIN//AlertUpdateComplete.aspx");
                }
                else
                {
                    //lblerror.Visible = true;
                    //lblerror.Text = "You must login as either supervisor or security officer or Operation Manager..!";
                    //lblerr1.Visible = true;
                    SM.ShowErrorMessage("You must login as either supervisor or security officer or Operation Manager..!");
                }
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
            }
        }