private void checkTime()
        {
            SpaMaster            MyMasterPage = (SpaMaster)Page.Master;
            DBConnectionHandler1 db           = new DBConnectionHandler1();
            SqlConnection        cn           = db.getconnection();

            cn.Open();
            SqlCommand cmd = new SqlCommand("select checkin_DateTime,user_name from checkin_manager where NRICno=@NRICno", cn);

            cmd.Parameters.AddWithValue("@NRICno", txtNricID2.Text);
            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                DateTime currentTime = DateTime.Now;
                DateTime DbTime      = dr.GetDateTime(0);
                double   diff        = (currentTime - DbTime).TotalHours;

                if (diff > 6)
                {
                    Label1.Visible = true;
                    MyMasterPage.ShowErrorMessage("Your Time is Over...");
                    ////Label1.Text = "Your Time is Over...";
                    //string Msg = "<script>confirm('Time Over');</script>";
                    //ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "confirm", Msg, false);
                }
            }
            //========================//
            dr.Close();
            dr.Dispose();
            cn.Close();
            //========================//
        }
Example #2
0
        protected void btnSave2_Click(object sender, EventArgs e)
        {
            string location_name = Session["location_id"].ToString();

            log4net.ILog logger = log4net.LogManager.GetLogger("File");
            try
            {
                if (Session["location_id"].ToString() != "")
                {
                    DBConnectionHandler1 db = new DBConnectionHandler1();
                    SqlConnection        cn = db.getconnection();
                    cn.Open();
                    SqlCommand cmd = new SqlCommand("update location set Operation_Name=@Operation_Name,O_cont=@O_cont,O_Mob=@O_Mob,O_Email=@O_Email,O_Fax=@O_Fax where Location_name=@Location_name", cn);
                    cmd.Parameters.AddWithValue("@Operation_Name", txtOperationName.Text.Trim());
                    cmd.Parameters.AddWithValue("@O_cont", txtOperationsContactTelephone.Text.Trim());
                    cmd.Parameters.AddWithValue("@O_Mob", txtOperationsContactMobile.Text.Trim());
                    cmd.Parameters.AddWithValue("@O_Email", txtOperationsContactEmail.Text.Trim());
                    cmd.Parameters.AddWithValue("@O_Fax", txtOperationsContactFax.Text.Trim());
                    cmd.Parameters.AddWithValue("@Location_name", txtAddLocation.Text.Trim());
                    if (cmd.ExecuteNonQuery() > 0)
                    {
                        cn.Close();
                    }
                    else
                    {
                        //lblerror.Visible = true;
                        //lblerror.Text = "please Fill First Information";
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //--------------image display---------------------------
            DBConnectionHandler1 bd = new DBConnectionHandler1();
            SqlConnection        cn = bd.getconnection();

            cn.Open();
            SqlCommand    cmd = new SqlCommand("select * from UploadLogo", cn);
            SqlDataReader dr  = cmd.ExecuteReader();

            if (dr.Read())
            {
                if (dr.GetString(0) != "")
                {
                    image1.ImageUrl = dr.GetString(0);
                    dr.Close();
                    cn.Close();
                }
            }
            //---------------------------=---------------------------
            String iBTID = string.Empty;

            if (!IsPostBack)
            {
                if (Request.QueryString["id"] != null)
                {
                    int id = Convert.ToInt32(Request.QueryString["id"].ToString());
                    PopulatePageCntrls(id);
                }
            }
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            getLocationIDByName(ddlocation2.SelectedValue.ToString());
            DBConnectionHandler1 db = new DBConnectionHandler1();
            SqlConnection        cn = db.getconnection();

            cn.Open();
            SqlCommand cmd = new SqlCommand("select GTSID from GaurdTourSystem2 where LocationID=@location", cn);

            cmd.Parameters.AddWithValue("@location", SearchLocID.Text);
            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                Session["location"] = dr.GetInt32(0); cmd.Dispose(); dr.Close(); cn.Close();
            }
            try
            {
                string time  = TimeSelector1.Date.TimeOfDay.ToString();
                string dtime = txtpatrotime.Text + " " + time;
                dal.executesql("Insert into GaurdTourSystem (Personnel,PatrolTime,Remark,Rout,GEvent,Reader,Check_Point,Personnel#,Check_Point#,GTSID) values('" + txtpersonnel.Text + "','" + dtime + "','" + txtremark.Text + "','" + txtrout.Text + "','" + txtevent.Text + "','" + txtreader.Text + "','" + txtchkpoint.Text + "','" + txtpersonnelNo.Text + "','" + txtCheckPoint.Text + "','" + Session["location"].ToString() + "')");
                //Response.Redirect("PatroTimeSystem.aspx");
                if (ddlocation1.SelectedValue.ToString() != "")
                {
                    Server.Transfer("PatroTimeSystem.aspx?BTID=" + ddlocation1.SelectedValue.ToString());
                }
                else
                {
                    Server.Transfer("PatroTimeSystem.aspx");
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #5
0
 private void DeleteItem(string argStaffid)
 {
     log4net.ILog logger = log4net.LogManager.GetLogger("File");
     try
     {
         DBConnectionHandler1 db = new DBConnectionHandler1();
         SqlConnection        cn = db.getconnection();
         cn.Open();
         SqlCommand cmd = new SqlCommand("select DGAID FROM vwDailyDeployment where MDate=@date and LocationID=@location and StaffID=@staffid", cn);
         cmd.Parameters.AddWithValue("@date", txtdatefrom.Text);
         cmd.Parameters.AddWithValue("@location", ddlSite.SelectedValue);
         cmd.Parameters.AddWithValue("@staffid", argStaffid);
         SqlDataReader dr = cmd.ExecuteReader();
         if (dr.Read())
         {
             long wgaid = dr.GetInt64(0);
             dal.executesql("delete from DailyGuardAssign where DGAID =" + wgaid);
         }
         //========================//
         dr.Close();
         dr.Dispose();
         //========================//
         cn.Close();
         //Server.Transfer("../ADMIN/CompleteForm.aspx");
         BindGuardSchedule(txtdatefrom.Text);
     }
     catch (Exception ex)
     {
         logger.Info(ex.Message);
     }
 }
Example #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String iBTID = string.Empty;

            if (!IsPostBack)
            {
                DBConnectionHandler1 bd = new DBConnectionHandler1();
                SqlConnection        cn = bd.getconnection();
                cn.Open();
                SqlCommand    cmd = new SqlCommand("select * from UploadLogo", cn);
                SqlDataReader dr  = cmd.ExecuteReader();
                if (dr.Read())
                {
                    if (dr.GetString(0) != "")
                    {
                        image1.ImageUrl = dr.GetString(0);
                        cn.Close();
                        dr.Close();
                    }
                }
                if (HttpContext.Current.Items[ContextKeys.CTX_UPDATE_URL] != null)
                {
                    string strURL = HttpContext.Current.Items[ContextKeys.CTX_UPDATE_URL].ToString();
                    //((SMSmaster)this.Master).FilterContent(strURL, btnsave.ID, SMSAppUtilities.SMSAppEnums.ContentType.Update);
                }
                if (HttpContext.Current.Items[ContextKeys.CTX_BT_ID] != null)
                {
                    iBTID = iBTID = HttpContext.Current.Items[ContextKeys.CTX_BT_ID].ToString();
                }

                PopulatePageCntrls(iBTID);
            }
        }
Example #7
0
      private void BindGridWithFilter()
      {
          try
          {
              DataSet dsitem          = new DataSet();
              DBConnectionHandler1 db = new DBConnectionHandler1();
              SqlConnection        cn = db.getconnection();


              //dsitem = dal.getdataset("select convert(varchar,LocationID)+' '+convert(varchar,GTSID) as Location,location.Location_name as LocationID,FileName,CurrentDate from GaurdTourSystem2,location where GaurdTourSystem2.LocationID=location.Location_id");
              dsitem = dal.getdataset("select Userinformation.Staff_ID,Userinformation.Role,location.Location_name as Location_ID from Userinformation,StaffLocationMap,location where NRICno='2222' and StaffLocationMap.StaffID=UserInformation.staff_ID and StaffLocationMap.LocationID=location.Location_id order by location.Location_name  Asc ");
              if (dsitem.Tables[0].Rows.Count > 0)
              {
                  gvItemTable.PageSize   = 20;
                  gvItemTable.DataSource = dsitem.Tables[0];
                  gvItemTable.DataBind();
              }
              else
              {
                  gvItemTable.DataSource = null;
                  gvItemTable.DataBind();
              }
          }
          catch (Exception ex)
          {
              // logger.Info(ex.Message);
          }
      }
        protected void Page_Load(object sender, EventArgs e)
        {
            //--------------image display---------------------------
            DBConnectionHandler1 bd = new DBConnectionHandler1();
            SqlConnection        cn = bd.getconnection();

            cn.Open();
            SqlCommand    cmd = new SqlCommand("select * from UploadLogo", cn);
            SqlDataReader dr  = cmd.ExecuteReader();

            if (dr.Read())
            {
                if (dr.GetString(0) != "")
                {
                    image1.ImageUrl = dr.GetString(0);
                    cn.Close();
                    dr.Close();
                }
            }
            //---------------------------=---------------------------
            String iBTID = string.Empty;

            if (!IsPostBack)
            {
                if (HttpContext.Current.Items[ContextKeys.CTX_UPDATE_URL] != null)
                {
                    string strURL = HttpContext.Current.Items[ContextKeys.CTX_UPDATE_URL].ToString();
                }
                if (HttpContext.Current.Items[ContextKeys.CTX_BT_ID] != null)
                {
                    iBTID = iBTID = HttpContext.Current.Items[ContextKeys.CTX_BT_ID].ToString();
                }
                PopulatePageCntrls(iBTID);
            }
        }
        private void fillavaible()
        {
            //DataAccessLayer dal = new DataAccessLayer();
            DBConnectionHandler1 db = new DBConnectionHandler1();
            SqlConnection        cn = db.getconnection();

            try
            {
                //---------first delete from monthly,weekly,dailyguardassign------------------
                string[] staffcount1 = staffcount.Text.Split(' ');
                if (cn.State == ConnectionState.Closed)
                {
                    cn.Open();
                }
                for (int i = 0; i < staffcount1.Length - 1; i++)
                {
                    SqlCommand cmd = new SqlCommand("select MGAID from MonthlyGuardAssignment where StaffID=@StaffID", cn);
                    cmd.Parameters.AddWithValue("@StaffID", staffcount1[i]);
                    SqlDataReader dr     = cmd.ExecuteReader();
                    long          mgaid1 = 0;
                    if (dr.Read())
                    {
                        mgaid1 = dr.GetInt64(0);
                        dr.Close();
                        dr.Dispose();
                        //cn.Close();
                    }
                    string         mgaid = Convert.ToString(mgaid1);
                    SqlParameter[] para  = new SqlParameter[1];
                    para[0] = new SqlParameter("@MGAID", long.Parse(mgaid));
                    dal.executeprocedure("usp_UnDeployMonthlyStaff", para);
                }
                cn.Close();
                //----------------------------------------------------------------------------
                if (dllshift.Text.ToString() != "0")
                {
                    for (int i = 0; i < staffcount1.Length - 1; i++)
                    {
                        Panel1.Visible = false;
                        long           mrid = long.Parse(dllshift.Text.ToString());
                        SqlParameter[] para = new SqlParameter[3];
                        para[0] = new SqlParameter("@StaffID", staffcount1[i]);
                        para[1] = new SqlParameter("@MRID", mrid);
                        para[2] = new SqlParameter("@Remark", txtremark.Text);
                        dal.executeprocedure("usp_DeployMonthlyStaff", para);
                    }
                }
                gvAvailableGuards.DataBind();
                gvAvailableSupervisor.DataBind();
                dlShiftAssignment1.DataBind();
                dlShiftAssignment.DataBind();
                ddlShift.SelectedValue = "0";
            }
            catch (Exception exc)
            {
                //dr.Close();
                //dr.Dispose();
                cn.Close();
            }
        }
Example #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     log4net.ILog logger = log4net.LogManager.GetLogger("File");
     try
     {
         if (!IsPostBack)
         {
             DBConnectionHandler1 bd = new DBConnectionHandler1();
             SqlConnection        cn = bd.getconnection();
             cn.Open();
             SqlCommand    cmd = new SqlCommand("select * from UploadLogo", cn);
             SqlDataReader dr  = cmd.ExecuteReader();
             if (dr.Read())
             {
                 if (dr.GetString(0) != "")
                 {
                     image1.ImageUrl = dr.GetString(0);
                     cn.Close();
                     dr.Close();
                 }
             }
             if (Request.QueryString["id"] != null)
             {
                 int id = Convert.ToInt32(Request.QueryString["id"].ToString());
                 PopulateFuntion(id);
             }
         }
     }
     catch (Exception ex)
     {
         logger.Info(ex.Message);
     }
 }
Example #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            log4net.ILog logger = log4net.LogManager.GetLogger("File");
            try
            {
                txtUserName.Focus();
                lblMsg.Visible = false;
                DBConnectionHandler1 db = new DBConnectionHandler1();
                cn = db.getconnection();
                cn.Open();
                String p;
                p = "select Description from log where ID='securityquestion'";
                SqlCommand    cmd1 = new SqlCommand(p, cn);
                SqlDataReader rec1 = cmd1.ExecuteReader();
                while (rec1.Read())
                {
                    if (!IsPostBack)
                    {
                        ddlSecQues.Items.Add(rec1.GetValue(0).ToString());
                    }
                }

                rec1.Close();
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
                cn.Close();
            }
        }
Example #12
0
        public string getLocationById(string name)
        {
            DBConnectionHandler1 db = new DBConnectionHandler1();
            SqlConnection        cn = db.getconnection();

            cn.Open();
            string     date = System.DateTime.Now.ToShortDateString();
            SqlCommand cmd  = new SqlCommand("select Location_id from location where Location_name=@location_name", cn);

            cmd.Parameters.AddWithValue("@location_name", name);
            SqlDataReader dr     = cmd.ExecuteReader();
            string        result = "";

            if (dr.Read())
            {
                if (dr.GetInt32(0) != 0)
                {
                    int x = dr.GetInt32(0);
                    result = Convert.ToString(x);
                    //========================//
                    dr.Close();
                    dr.Dispose();
                    //========================//
                    cn.Close();
                }
            }
            return(result);
        }
        //private void DeleteRecord()
        //{
        //    DataSet dsRisk1 = dal.getdataset("Select Risk_id From RiskSurvey1");
        //    {
        //        if (dsRisk1.Tables[0].Rows.Count > 0)
        //        {
        //            for (int j = 0; j < dsRisk1.Tables[0].Rows.Count; j++)
        //            {
        //                string RKid = dsRisk1.Tables[0].Rows[j][0].ToString();
        //                DataSet dsRiskId = dal.getdataset("Select Risk_id from RiskSurvey16 Where Risk_id = '" + RKid + "'");
        //                if (dsRiskId.Tables[0].Rows.Count > 0)
        //                {
        //                }
        //                else
        //                {
        //                    dal.executesql("Delete from RiskSurvey1 where Risk_id ='" + RKid + "' ");
        //                }
        //            }
        //        }
        //    }
        //}


        private void newriskid()
        {
            int id = 0;
            //SqlParameter[] para1 = new SqlParameter[0];
            //DataTable dtid = dal.executeprocedure("SP_getMaxRiskID", para1,false);
            DBConnectionHandler1 db = new DBConnectionHandler1();
            SqlConnection        cn = db.getconnection();

            cn.Open();
            DataSet        ds   = new DataSet();
            SqlDataAdapter adp  = new SqlDataAdapter("select isnull(MAX(Risk_id),'') from RiskSurvey1", cn);
            DataTable      dtid = new DataTable();

            adp.Fill(ds, "dtid");
            if (dtid.Rows.Count > 0)
            {
                id = Convert.ToInt32(dtid.Rows[0][0].ToString());
                id++;
                GlobalVar.Risk_ID = id;
            }
            else
            {
                GlobalVar.Risk_ID = 1;
            }
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (ddllocation.SelectedValue.ToString() != "")
                {
                    getLocationIDByName(ddllocation.SelectedValue.ToString());

                    DBConnectionHandler1 db = new DBConnectionHandler1();
                    SqlConnection        cn = db.getconnection();
                    cn.Open();
                    SqlCommand cmd  = new SqlCommand("update UserInformation set UserID=@UserID,UserPassword=@UserPassword where Staff_ID=@Staff_ID", cn);
                    SqlCommand cmd1 = new SqlCommand("update StaffLocationMap set LocationID=@LocationID where StaffID=@StaffID", cn);
                    cmd.Parameters.AddWithValue("@UserID", txtclientName.Text);
                    cmd.Parameters.AddWithValue("@UserPassword", txtpassword.Text);
                    cmd.Parameters.AddWithValue("@Staff_ID", staffid.Text);
                    cmd1.Parameters.AddWithValue("@LocationID", SearchLocID.Text);
                    cmd1.Parameters.AddWithValue("@StaffID", staffid.Text);
                    int result1 = cmd.ExecuteNonQuery();
                    result1 = cmd1.ExecuteNonQuery();
                    cmd.Dispose();
                    cmd1.Dispose();
                    cn.Close();
                    txtclientName.Text = "";
                    txtpassword.Text   = "";
                    lblmsg.Visible     = true;
                    lblmsg.Text        = "Update Successfully...!";
                }
                else
                {
                    getLocationIDByName(lbllocationid.Text);
                    DBConnectionHandler1 db = new DBConnectionHandler1();
                    SqlConnection        cn = db.getconnection();
                    cn.Open();
                    SqlCommand cmd  = new SqlCommand("update UserInformation set UserID=@UserID,UserPassword=@UserPassword where Staff_ID=@Staff_ID", cn);
                    SqlCommand cmd1 = new SqlCommand("update StaffLocationMap set LocationID=@LocationID where StaffID=@StaffID", cn);
                    cmd.Parameters.AddWithValue("@UserID", txtclientName.Text);
                    cmd.Parameters.AddWithValue("@UserPassword", txtpassword.Text);
                    cmd.Parameters.AddWithValue("@Staff_ID", staffid.Text);
                    cmd1.Parameters.AddWithValue("@LocationID", SearchLocID.Text);
                    cmd1.Parameters.AddWithValue("@StaffID", staffid.Text);
                    int result1 = cmd.ExecuteNonQuery();
                    result1 = cmd1.ExecuteNonQuery();
                    cmd.Dispose();
                    cmd1.Dispose();
                    cn.Close();
                    //Dal.executesql("update UserInformation set UserID=" + txtclientName.Text + " and UserPassword="******" where Staff_ID=" + staffid.Text);
                    //Dal.executesql("update StaffLocationMap set LocationID=" + SearchLocID.Text + " where StaffID=" + staffid.Text);
                    //txtpassword.Text = "";
                    txtclientName.Text = "";
                    txtpassword.Text   = "";
                    lblmsg.Visible     = true;
                    lblmsg.Text        = "Update Successfully...!";
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     log4net.ILog logger = log4net.LogManager.GetLogger("File");
     try
     {
         DBConnectionHandler1 bd = new DBConnectionHandler1();
         SqlConnection        cn = bd.getconnection();
         cn.Open();
         SqlCommand    cmd = new SqlCommand("select * from UploadLogo", cn);
         SqlDataReader dr  = cmd.ExecuteReader();
         if (dr.Read())
         {
             if (dr.GetString(0) != "")
             {
                 image1.ImageUrl = dr.GetString(0);
                 dr.Close();
                 cn.Close();
             }
         }
         if (!IsPostBack)
         {
         }
         string ctrlname  = Page.Request.Params.Get("__EVENTTARGET");
         string ctrlname1 = Page.Request.Params.Get("__eventargument");
         if (ctrlname != null)
         {
             string controlname = ctrlname;//.Split('$')[ctrlname.Split('$').Length - 1].ToString();
             if (!controlname.Contains("imdAdd") && !controlname.Contains("imgEdit") && !controlname.Contains("imgDelete") && !controlname.Contains("imglock256") && !controlname.Contains("CheckBox1"))
             {
                 if (controlname.ToUpper().Contains("gvLoctionTable".ToUpper()))
                 {
                     if (ctrlname1 != null)
                     {
                         if (ctrlname1.Contains("RowClick"))
                         {
                         }
                         else if (ctrlname1.ToUpper().Contains("FIRECOMMAND") || ctrlname1 == "")
                         {
                             BindGridWithFilter();
                         }
                         else
                         {
                         }
                     }
                 }
             }
         }
         else
         {
             BindGridWithFilter();
         }
         // BindGrid();
     }
     catch (Exception ex)
     {
         logger.Info(ex.Message);
     }
 }
Example #16
0
        public void insertdataintosql2(string f1, string f2, string f3, int f4)
        {
            DBConnectionHandler1 db = new DBConnectionHandler1();
            SqlConnection        cn = db.getconnection();

            cn.Open();
            string     query = "insert into GaurdTourSystem2 (LocationID,FileName,CurrentDate,temp) values('" + f1 + "','" + f2 + "','" + f3 + "','" + f4 + "')";
            SqlCommand cmd   = new SqlCommand(query, cn);

            cmd.ExecuteNonQuery();
            cn.Close();
        }
        private void PopulatePageCntrls(string argsBGID)
        {
            Int32            iCount = 0;
            GetNewKeyRequest ret    = null;

            log4net.ILog logger = log4net.LogManager.GetLogger("File");
            try
            {
                AdminBLL  objAdminBLL = new AdminBLL();
                GetNewKey objGetBillingTableRequest = new GetNewKey();
                objGetBillingTableRequest.key_no = argsBGID.ToString();

                objGetBillingTableRequest.WhereClause = " where Key_ID= '" + argsBGID + "' ";

                ret = objAdminBLL.GetNewKey(objGetBillingTableRequest);

                hdnBTID.Value = ret.Key[iCount].key_ID.ToString();
                //hdnBTID.Value = ret.Key[iCount].Description.ToString();

                txtKeyNo.Text   = ret.Key[iCount].key_ID.ToString();
                txtKeyDesc.Text = ret.Key[iCount].Description.ToString();

                txtKeyName.Text     = ret.Key[iCount].name.ToString();
                txtKeyPosition.Text = ret.Key[iCount].position.ToString();
                txtKeyNRIC.Text     = ret.Key[iCount].Staff_ID.ToString();
                //txtKeyConnt.Text = ret.Key[iCount].Staff_ID.ToString();

                //-------------------------------------------------------------------
                DBConnectionHandler1 db = new DBConnectionHandler1();
                SqlConnection        cn = db.getconnection();
                cn.Open();
                SqlCommand cmd = new SqlCommand("select NRICno from UserInformation where NRICno=@staffid", cn);
                cmd.Parameters.AddWithValue("@staffid", txtKeyNRIC.Text);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    txtKeyNRIC.Text = dr.GetString(0);
                    //txtKeyConnt.Text = "";
                    //========================//
                    dr.Close();
                    dr.Dispose();
                    //========================//
                    cn.Close();
                }
                //-------------------------------------------------------------------
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
            }
        }
Example #18
0
        public void replace(string id)
        {
            foreach (GridItem gr in gvAvailableGuards.Items)
            {
                if (((CheckBox)gr.Cells[0].FindControl("chkGuard")).Checked)
                {
                    string mdaid = ((CheckBox)gr.Cells[0].FindControl("chkGuard")).ToolTip;
                    Label3.Text = mdaid;
                    string staffid          = id;
                    string locationid       = ddlSite.SelectedValue;
                    string date             = txtdatefrom.Text;
                    DBConnectionHandler1 db = new DBConnectionHandler1();
                    SqlConnection        cn = db.getconnection();
                    cn.Open();
                    SqlCommand cmd = new SqlCommand("SELECT Shift FROM vwDailyDeployment where StaffID=@staffid", cn);
                    cmd.Parameters.AddWithValue("@staffid", staffid);
                    SqlDataReader dr    = cmd.ExecuteReader();
                    string        shift = "";

                    //  if(dr.Read())  change by gsp

                    while (dr.Read())
                    {
                        shift = dr.GetString(0);
                    }
                    //=========================================//
                    dr.Close();
                    dr.Dispose();
                    //=========================================//
                    cn.Close();

                    SqlParameter[] para = new SqlParameter[5];
                    para[0] = new SqlParameter("@StaffID", staffid);
                    para[1] = new SqlParameter("@MDate", date);
                    para[2] = new SqlParameter("@LocationID", locationid);
                    para[3] = new SqlParameter("@NewStaffID", Label3.Text);
                    para[4] = new SqlParameter("@shift", shift);
                    DataAccessLayer dal = new DataAccessLayer();
                    dal.executeprocedure("usp_ReplaceGuardFromDailyDuty1", para);
                    Label3.Text = "";
                    break;
                }
            }
            BindGuardSchedule(txtdatefrom.Text);
        }
Example #19
0
        public void insertdataintosql(string f1, string f2, string f3, string f4, string f5, string f6, string f7, string f8, string f9, string f10)
        {
            DBConnectionHandler1 db = new DBConnectionHandler1();
            SqlConnection        cn = db.getconnection();

            cn.Open();
            f2 = f2.Replace("'", "''");
            f3 = f3.Replace("'", "''");
            f4 = f4.Replace("'", "''");
            f1 = f1.Replace("'", "''");
            //string query = "insert into ALG_Exceldetails (F1,F2,F3,F4,F5,F6,F7,F8) values('" + f1 + "','" + f2 + "','" + f3 + "','" + f4 + "','" + f5 + "','" + f6 + "','" + f7 + "','" + f8 + "')";
            string     query = "insert into GaurdTourSystem (Personnel,Check_Point,PatrolTime,Remark,Rout,Reader,GEvent,Personnel#,Check_Point#,GTSID) values('" + f2 + "','" + f5 + "','" + f3 + "','" + f6 + "','" + f9 + "','" + f8 + "','" + f7 + "','" + f1 + "','" + f4 + "','" + f10 + "')";
            SqlCommand cmd   = new SqlCommand(query, cn);

            cmd.ExecuteNonQuery();

            cn.Close();
        }
Example #20
0
 private void DeleteItem(string argContractorId)
 {
     if (!string.IsNullOrEmpty(argContractorId))
     {
         DBConnectionHandler1 db = new DBConnectionHandler1();
         SqlConnection        cn = db.getconnection();
         cn.Open();
         SqlCommand cmd = new SqlCommand("delete from UserInformation where Staff_ID=@staffid", cn);
         cmd.Parameters.AddWithValue("@staffid", argContractorId);
         SqlCommand cmd1 = new SqlCommand("delete from StaffLocationMap where StaffID=@staffid", cn);
         cmd1.Parameters.AddWithValue("@staffid", argContractorId);
         int result1 = cmd.ExecuteNonQuery();
         int result2 = cmd1.ExecuteNonQuery();
         cmd.Dispose();
         cmd1.Dispose();
         cn.Close();
         BindGridWithFilter();
     }
 }
Example #21
0
 private void DeleteItem(string argContractorId, string BTid3)
 {
     getLocationIDByName(argContractorId);
     if (!string.IsNullOrEmpty(argContractorId))
     {
         DBConnectionHandler1 db = new DBConnectionHandler1();
         SqlConnection        cn = db.getconnection();
         cn.Open();
         SqlCommand cmd = new SqlCommand("delete from GaurdTourSystem where GTSID IN(select GTSID from GaurdTourSystem2 where LocationID=@location and GTSID=@gtsid)", cn);
         cmd.Parameters.AddWithValue("@location", argContractorId);
         cmd.Parameters.AddWithValue("@gtsid", BTid3);
         SqlCommand cmd1 = new SqlCommand("delete from GaurdTourSystem2 where LocationID=@location and GTSID=@gtsid", cn);
         cmd1.Parameters.AddWithValue("@location", argContractorId);
         cmd1.Parameters.AddWithValue("@gtsid", BTid3);
         int result1 = cmd.ExecuteNonQuery();
         int result2 = cmd1.ExecuteNonQuery();
         BindGridWithFilter();
         // HttpContext.Current.Items.Add(ContextKeys.CTX_COMPLETE, "DELETE");
         // Server.Transfer("../SMSAdmin/AlertUpdateComplete.aspx");
     }
 }
        public string getLocationIDByName1(string loc)
        {
            DBConnectionHandler1 db = new DBConnectionHandler1();
            SqlConnection        cn = db.getconnection();

            cn.Open();
            SqlCommand cmd = new SqlCommand("select Location_id from location where Location_name=@location", cn);

            cmd.Parameters.AddWithValue("@location", loc.ToString());
            SqlDataReader dr      = cmd.ExecuteReader();
            int           result1 = 0;
            string        result  = "";

            if (dr.Read())
            {
                result1 = dr.GetInt32(0);
                cn.Close();
                result = Convert.ToString(result1);
            }
            return(result);
        }
 protected void ImgView_Click(object sender, EventArgs e)
 {
     log4net.ILog logger = log4net.LogManager.GetLogger("File");
     try
     {
         if (ViewState["Lost_ID"] != null)
         {
             //view
             //--------------image display---------------------------
             DBConnectionHandler1 bd = new DBConnectionHandler1();
             SqlConnection        cn = bd.getconnection();
             cn.Open();
             SqlCommand    cmd = new SqlCommand("select * from UploadLogo", cn);
             SqlDataReader dr  = cmd.ExecuteReader();
             if (dr.Read())
             {
                 if (dr.GetString(0) != "")
                 {
                     image1.ImageUrl = dr.GetString(0);
                     dr.Close();
                     cn.Close();
                 }
             }
             //---------------------------=---------------------------
             String iBTID = string.Empty;
             if (HttpContext.Current.Items[ContextKeys.CTX_BT_ID] != null)
             {
                 iBTID = iBTID = HttpContext.Current.Items[ContextKeys.CTX_BT_ID].ToString();
             }
             PopulatePageCntrls(ViewState["Lost_ID"].ToString());
             // Fill();
             this.ModalPopupUpdate.Show();
             Session["ctrl"] = printview;
         }
     }
     catch (Exception ex)
     {
         logger.Info("LostFoundReport(ImgView_Click):" + ex.Message);
     }
 }
Example #24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            log4net.ILog logger = log4net.LogManager.GetLogger("File");
            try
            {
                String iBTID = string.Empty;

                if (!IsPostBack)
                {
                    DBConnectionHandler1 bd = new DBConnectionHandler1();
                    SqlConnection        cn = bd.getconnection();
                    cn.Open();
                    SqlCommand    cmd = new SqlCommand("select * from UploadLogo", cn);
                    SqlDataReader dr  = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        if (dr.GetString(0) != "")
                        {
                            image1.ImageUrl = dr.GetString(0);
                            cn.Close();
                            dr.Close();
                        }
                    }
                    if (HttpContext.Current.Items[ContextKeys.CTX_UPDATE_URL] != null)
                    {
                        string strURL = HttpContext.Current.Items[ContextKeys.CTX_UPDATE_URL].ToString();
                    }
                    if (HttpContext.Current.Items[ContextKeys.CTX_BT_ID] != null)
                    {
                        iBTID = iBTID = HttpContext.Current.Items[ContextKeys.CTX_BT_ID].ToString();
                    }

                    PopulatePageCntrls(iBTID);
                }
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
            }
        }
 protected void ImgView_Click(object sender, EventArgs e)
 {
     log4net.ILog logger = log4net.LogManager.GetLogger("File");
     try
     {
         if (ViewState["strCVID"] != null)
         {
             //view
             DBConnectionHandler1 bd = new DBConnectionHandler1();
             SqlConnection        cn = bd.getconnection();
             cn.Open();
             SqlCommand    cmd = new SqlCommand("select * from UploadLogo", cn);
             SqlDataReader dr  = cmd.ExecuteReader();
             if (dr.Read())
             {
                 if (dr.GetString(0) != "")
                 {
                     image1.ImageUrl = dr.GetString(0);
                     cn.Close();
                     dr.Close();
                 }
             }
             cn.Close();
             dr.Close();
             if (HttpContext.Current.Items[ContextKeys.CTX_UPDATE_URL] != null)
             {
                 string strURL = HttpContext.Current.Items[ContextKeys.CTX_UPDATE_URL].ToString();
             }
             PopulatePageCntrls(ViewState["strCVID"].ToString());
             // Fill();
             this.ModalPopupUpdate.Show();
             Session["ctrl"] = printview;
         }
     }
     catch (Exception ex)
     {
         logger.Info("AdminCappAsset(AssertImgUpdate_Click):" + ex.Message);
     }
 }
Example #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            log4net.ILog logger = log4net.LogManager.GetLogger("File");
            try
            {
                Session["RoleID"]  = "0";
                Session["SubRole"] = null;
                Session["LCID"]    = null;
                Session["StaffID"] = null;
                if (!IsPostBack)
                {
                    Session[SMSAppUtilities.SessionKeys.SESSION_LOGIN_USER_PASSWORD] = null;
                    Session[SMSAppUtilities.SessionKeys.SESSION_LOGIN_USER_ID]       = null;
                    txtUsername.Focus();
                }

                #region Dynamically Displaying Logo
                DBConnectionHandler1 bd = new DBConnectionHandler1();
                SqlConnection        cn = bd.getconnection();
                cn.Open();
                SqlCommand    cmd = new SqlCommand("select ImagePath,fullpathname from UploadLogo", cn);
                SqlDataReader dr  = cmd.ExecuteReader();
                if (dr.Read())
                {
                    if (dr.GetString(0) != "")
                    {
                        imgHeaderLogo.ImageUrl = dr.GetString(0).ToString();
                        dr.Close();
                        cn.Close();
                    }
                }
                else
                {
                    imgHeaderLogo.ImageUrl = "../img/dsys_header_logo_new.png";
                }
                #endregion
            }
            catch (Exception ex) { logger.Info("Error:" + ex.Message); Response.Write(ex.Message); }
        }
Example #27
0
        protected void btnSearch3LocationAdd_Click(object sender, EventArgs e)
        {
            string location_name = Session["Location_name"].ToString();

            log4net.ILog logger = log4net.LogManager.GetLogger("File");
            try
            {
                if (Session["Location_name"].ToString() != "")
                {
                    btnNext2LocationAdd.Enabled  = true;
                    btnClear3LocationAdd.Enabled = true;
                    DBConnectionHandler1 db = new DBConnectionHandler1();
                    SqlConnection        cn = db.getconnection();
                    cn.Open();
                    SqlCommand cmd = new SqlCommand("update location set Management_Name=@Management_Name,M_cont=@M_cont,M_Mob=@M_Mob,M_Email=@M_Email,M_Fax=@M_Fax,Emergency_email=@Emergency_email where Location_name=@Location_name", cn);
                    cmd.Parameters.AddWithValue("@Management_Name", txtManagementName.Text.Trim());
                    cmd.Parameters.AddWithValue("@M_cont", txtlblManagementContactTelephone.Text.Trim());
                    cmd.Parameters.AddWithValue("@M_Mob", txtManagementContactMobile.Text.Trim());
                    cmd.Parameters.AddWithValue("@M_Email", txtManagementContactEmail.Text.Trim());
                    cmd.Parameters.AddWithValue("@M_Fax", txtManagementContactFax.Text.Trim());
                    cmd.Parameters.AddWithValue("@Emergency_email", txtEmergencyContactEmail.Text.Trim());
                    cmd.Parameters.AddWithValue("@Location_name", txtAddLocation.Text.Trim());
                    if (cmd.ExecuteNonQuery() > 0)
                    {
                        cn.Close();
                    }
                    else
                    {
                        lblerror.Visible = true;
                        lblerror.Text    = "please Fill First Information";
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
            }
        }
Example #28
0
        private string getLocationIDByName(string Name)
        {
            DBConnectionHandler1 db = new DBConnectionHandler1();
            SqlConnection        cn = db.getconnection();

            //string req = Request.Params["t1"].ToString();
            cn.Open();
            string     date = System.DateTime.Now.ToShortDateString();
            SqlCommand cmd  = new SqlCommand("SELECT Location_id from location where Location_name=@location_name", cn);

            cmd.Parameters.AddWithValue("@location_name", name);
            SqlDataReader dr     = cmd.ExecuteReader();
            string        result = "";

            if (dr.Read())
            {
                result = dr.getString(0);
                cn.Close();
            }
            return(result);

            cn.Close();
        }
        public void DownloadWordFormat()
        {
            log4net.ILog logger = log4net.LogManager.GetLogger("File");
            try
            {
                Int32  intcellCount  = gvItemTable.Columns.Count;
                string strContent    = "";
                string strHeaderText = "";
                // string strHtmlFile = "TxnHtmlFile";
                Response.ClearHeaders();
                Response.ClearContent();

                string datetime = string.Empty;
                datetime = Convert.ToString(System.DateTime.Now);

                string str = string.Empty;

                ////if (txteventid.Text != "")
                ////   str = ("   NRIC/FIN No. : " + txteventid.Text);
                //if (DropDownList2.Text != "")
                //    str = ("   Event Type : " + DropDownList2.Text);
                //if (ddllocation.Text != "")
                //    str = ("   Location : " + ddllocation.Text);
                //if (txtpersonincharg.Text != "")
                //    str = ("   Person In Charge : " + txtpersonincharg.Text);
                //if (txtdatefrom.Text != "" && txtdateto.Text != "")
                //    str = ("   Date  From :" + txtdatefrom.Text + "      To :" + txtdateto.Text);



                Response.AddHeader("content-disposition", string.Format("attachment;filename=Event.doc"));
                Response.Charset     = "";
                Response.ContentType = "text/html";
                StringWriter         sw = new StringWriter();
                DBConnectionHandler1 db = new DBConnectionHandler1();
                SqlConnection        cn = db.getconnection();
                cn.Open();
                SqlCommand    cmd      = new SqlCommand("select * from UploadLogo", cn);
                SqlDataReader dr       = cmd.ExecuteReader();
                string        filePath = "";
                if (dr.Read())
                {
                    if (dr.GetString(1).ToString() != "")
                    {
                        filePath = dr.GetString(1).ToString().Trim();
                        dr.Close();
                        cn.Close();
                    }
                }
                //string filePath = Server.MapPath("../../Images/Untitled.png");
                System.Drawing.Image imgPhoto = System.Drawing.Image.FromFile(filePath);
                string imagepath = string.Format("<img src='{0}' width='{1}' height='{2}'/>", filePath, imgPhoto.Width, imgPhoto.Height);
                Response.Write("<Center><table></Center>");
                Response.Write("<tr><td>" + imagepath + "</td></tr>");
                Response.Write("</table>");
                imgPhoto.Dispose();
                Response.Flush();
                sw.Write("<b><hr></hr></b>");

                sw.Write("<CAPTION><b><font size='+2'>Recent Check-In Report</font></b></CAPTION>");
                sw.Write("<CAPTION><br/></CAPTION>");
                sw.Write("<font size='+1'>Generated On : </font>");
                sw.Write("<font size='+1'>" + datetime + "</font>");
                sw.Write("<CAPTION><br/></CAPTION>");
                //sw.Write("<font size='+2'>Searching Parameter :</font> ");
                //sw.Write("<font size='+2'>"+str+"</font>");
                sw.Write("<CAPTION><br/></CAPTION>");
                sw.Write("<CAPTION><br/></CAPTION>");
                sw.Write("<table border =1>");



                sw.Write("<tr>");
                for (int i = 0; i < intcellCount; i++)
                {
                    strHeaderText = gvItemTable.Columns[i].HeaderText.ToString();
                    sw.Write("<th>");
                    sw.Write(strHeaderText);
                    sw.Write("</th>");
                    //sw.Write("<td>");
                    //sw.Write("&nbsp");
                    //sw.Write("</td>");
                }
                sw.Write("</tr>");

                foreach (GridDataItem grvRow in gvItemTable.Items)
                {
                    sw.Write("<tr>");
                    for (Int32 i = 0; i < intcellCount; i++)
                    {
                        strContent = grvRow.Cells[i + 2].Text.ToString();
                        sw.Write("<td>");
                        sw.Write(strContent);
                        sw.Write("</td>");
                        //sw.Write("<td>");
                        //sw.Write("&nbsp");
                        //sw.Write("</td>");
                    }
                    sw.Write("</tr>");
                }
                sw.Write("</table>");

                Response.Write(sw.ToString());
                Response.End();
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
            }
        }
        public void DownloadPDFFormat()
        {
            log4net.ILog logger = log4net.LogManager.GetLogger("File");
            try
            {
                Document pdfReport = new Document(PageSize.A4, 100, 91, 100, 93);
                System.IO.MemoryStream msReport = new System.IO.MemoryStream();
                PdfWriter writer = PdfWriter.GetInstance(pdfReport, msReport);
                pdfReport.Open();
                DBConnectionHandler1 db = new DBConnectionHandler1();
                SqlConnection        cn = db.getconnection();
                cn.Open();
                SqlCommand    cmd = new SqlCommand("select * from UploadLogo", cn);
                SqlDataReader dr  = cmd.ExecuteReader();
                if (dr.Read())
                {
                    if (dr.GetString(1).ToString() != "")
                    {
                        iTextSharp.text.Image image1 = iTextSharp.text.Image.GetInstance(@dr.GetString(1).ToString().Trim());
                        image1.SetAbsolutePosition(70, 100);
                        PdfContentByte by = writer.DirectContent;
                        PdfTemplate    tp = by.CreateTemplate(170, 190);
                        tp.AddImage(image1);
                        by.AddTemplate(tp, 175, 660);
                        dr.Close();
                        cn.Close();
                    }
                }
                string datetime = string.Empty;
                datetime = Convert.ToString(System.DateTime.Now);
                //Create Heading
                Phrase headerPhrase = new Phrase("                                     Recent Check-In Report                                                      ", FontFactory.GetFont("Garamond", 14));

                headerPhrase.Add("        Generated On : ");
                headerPhrase.Add(datetime);
                HeaderFooter header = new HeaderFooter(headerPhrase, false);
                header.Border    = Rectangle.NO_BORDER;
                header.Alignment = Element.ALIGN_CENTER;
                header.Alignment = Element.ALIGN_BOTTOM;
                pdfReport.Header = header;
                pdfReport.Add(headerPhrase);


                // Creates the Table
                PdfPTable ptData = new PdfPTable(gvItemTable.Columns.Count);
                ptData.SpacingBefore       = 8;
                ptData.DefaultCell.Padding = 1;

                float[] headerwidths = new float[gvItemTable.Columns.Count]; // percentage


                headerwidths[0] = 3.2F;
                headerwidths[1] = 3.2F;
                headerwidths[2] = 3.2F;
                headerwidths[3] = 3.2F;
                headerwidths[4] = 3.2F;
                headerwidths[5] = 3.2F;
                // headerwidths[6] = 3.2F;
                //headerwidths[7] = 3.2F;
                //headerwidths[8] = 3.2F;
                //headerwidths[9] = 3.2F;
                //headerwidths[10] = 3.2F;

                ptData.SetWidths(headerwidths);
                ptData.WidthPercentage = 100;
                ptData.DefaultCell.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
                ptData.DefaultCell.VerticalAlignment   = Element.ALIGN_MIDDLE;

                //Insert the Table Headers
                for (int intK = 0; intK < gvItemTable.Columns.Count; intK++)
                {
                    PdfPCell cell = new PdfPCell();
                    cell.BorderWidth     = 0.001f;
                    cell.BackgroundColor = new Color(200, 200, 200);
                    cell.BorderColor     = new Color(100, 100, 100);
                    cell.Phrase          = new Phrase(gvItemTable.Columns[intK].HeaderText.ToString(), FontFactory.GetFont("TIMES_ROMAN", BaseFont.WINANSI, 7, Font.BOLD));
                    ptData.AddCell(cell);
                }

                ptData.HeaderRows = 1;  // this is the end of the table header

                //Insert the Table Data

                for (int intJ = 0; intJ < gvItemTable.Items.Count; intJ++)
                {
                    for (int intK = 0; intK < gvItemTable.Columns.Count; intK++)
                    {
                        PdfPCell cell = new PdfPCell();
                        cell.BorderWidth     = 0.001f;
                        cell.BorderColor     = new Color(100, 100, 100);
                        cell.BackgroundColor = new Color(250, 250, 250);
                        if (gvItemTable.Items[intJ].Cells[intK + 2].Text.ToString() != "&nbsp;")
                        {
                            cell.Phrase = new Phrase(gvItemTable.Items[intJ].Cells[intK + 2].Text.ToString(), FontFactory.GetFont("TIMES_ROMAN", BaseFont.WINANSI, 6));
                        }
                        else
                        {
                            cell.Phrase = new Phrase("", FontFactory.GetFont("TIMES_ROMAN", BaseFont.WINANSI, 6));
                        }
                        ptData.AddCell(cell);
                    }
                }

                //Insert the Table

                pdfReport.Add(ptData);

                //Closes the Report and writes to Memory Stream

                pdfReport.Close();

                //Writes the Memory Stream Data to Response Object
                Response.Clear();
                // Response.AddHeader("content-disposition", string.Format("attachment;filename=" + ConfigurationManager.AppSettings["TxnInfoPdfFile"]));
                Response.AddHeader("content-disposition", string.Format("attachment;filename=RecentCheckedIn.pdf"));
                Response.Charset     = "";
                Response.ContentType = "application/pdf";
                Response.BinaryWrite(msReport.ToArray());
                Response.End();
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
            }
        }