protected void btnOk_Click(object sender, EventArgs e) { try { using (Neophotonics_webDbHelper GWdbHelper = new Neophotonics_webDbHelper()) { GWdbHelper.AddParameter("@GroupID", System.Data.SqlDbType.Int, Convert.ToInt32(hfHidden.Value));//Group ID GWdbHelper.Command.CommandType = System.Data.CommandType.StoredProcedure; GWdbHelper.Command.CommandText = "SP_Group_Delete"; int status = GWdbHelper.ExecuteScalarInt(); int errorNo = (int)GWdbHelper.Command.Parameters["@OPARAMERRNO"].Value; if (errorNo == 0) { Response.Redirect("BuildingView.aspx?RespMsg=Group Deleted Successfully", false); } else { Response.Redirect("BuildingView.aspx?RespMsg=Group Cannot be Deleted", false); } } hfHidden.Value = string.Empty; } catch (Exception ex) { } }
private void GetRoles(string strUserId) { using (Neophotonics_webDbHelper dbHelper = new Neophotonics_webDbHelper()) { dbHelper.AddParameter("@UserID", SqlDbType.VarChar, strUserId); dbHelper.Command.CommandType = System.Data.CommandType.StoredProcedure; dbHelper.Command.CommandText = "SP_Login_Roles"; DataSet UserSet = dbHelper.ExcuteDatset(dbHelper.Command); if (UserSet.Tables[0].Rows.Count > 0) { DataTable UserDT = UserSet.Tables[0]; Session["sessRolesList"] = UserDT; } } }
protected void btnDelet_Click(object sender, CommandEventArgs e) { string StrGroupId = Convert.ToString(e.CommandArgument); using (Neophotonics_webDbHelper GWdbHelper = new Neophotonics_webDbHelper()) { GWdbHelper.AddParameter("@GroupID", System.Data.SqlDbType.Int, Convert.ToInt32(StrGroupId)); //Group ID GWdbHelper.Command.CommandType = System.Data.CommandType.StoredProcedure; GWdbHelper.Command.CommandText = "SP_Group_Delete"; int status = GWdbHelper.ExecuteScalarInt(); int errorNo = (int)GWdbHelper.Command.Parameters["@OPARAMERRNO"].Value; if (errorNo == 0) { Response.Redirect("BuildingView.aspx?RespMsg=Group Deleted Successfully", false); } else { Response.Redirect("BuildingView.aspx?RespMsg=Group Cannot be Deleted", false); } } }
protected void btnAddBuilding_Click(object sender, EventArgs e) { string strScript = string.Empty; if (txtbuildingname.Text=="") { strScript = "<script>"; strScript = strScript + "alert('Please Enter Building Name.');"; strScript = strScript + "</script>"; ClientScript.RegisterStartupScript(this.GetType(), "clientscript", strScript.ToString()); return; } using (Neophotonics_webDbHelper BAdbHelper = new Neophotonics_webDbHelper()) { BAdbHelper.AddParameter("@BuildingName", SqlDbType.VarChar, txtbuildingname.Text); BAdbHelper.Command.CommandType = System.Data.CommandType.StoredProcedure; BAdbHelper.Command.CommandText = "SP_Building_Add"; int i = BAdbHelper.ExecuteNoneQuery(); Response.Redirect("~/Setup/BuildingView.aspx?RespMsg=Building Added Successfully", true); } }
protected void btnAddZone_Click(object sender, EventArgs e) { string strScript = ""; using (Neophotonics_webDbHelper BAdbHelper = new Neophotonics_webDbHelper()) { //Checkboxselection HH #region //if (rdtypeHH.Checked == true) //{ // if (txtdesc.Text.Length > 0) // { // string id = value.ToString(); // string[] ids = Regex.Split(id, "."); // string desc = txtdesc.ToString(); // string[] wordsdesc = Regex.Split(desc, "\r\n"); // foreach (string strval in wordsdesc) // { // string[] words = Regex.Split(value, "."); // BAdbHelper.AddParameter("@ZoneDescription", SqlDbType.VarChar, txtdesc.Text); // BAdbHelper.AddParameter("@BuildingId", SqlDbType.Int, drpBildingName.SelectedValue); // BAdbHelper.AddParameter("@ReaderId", SqlDbType.Int, ddReader.SelectedValue); // BAdbHelper.Command.CommandType = System.Data.CommandType.StoredProcedure; // BAdbHelper.Command.CommandText = "SP_Zone_Add"; // } // int i = BAdbHelper.ExecuteNoneQuery(); // Response.Redirect("~/Setup/ZoneView.aspx?RespMsg=Zone Added Successfully", true); // } //} #endregion if (drpBildingName.SelectedItem.Text == "-Select-" ) { strScript = "<script>"; strScript = strScript + "alert('Please select Building.');"; strScript = strScript + "</script>"; ClientScript.RegisterStartupScript(this.GetType(), "clientscript", strScript.ToString()); return; } if (ddReader.SelectedItem.Text == "-Select-") { strScript = "<script>"; strScript = strScript + "alert('Please select Hardware.');"; strScript = strScript + "</script>"; ClientScript.RegisterStartupScript(this.GetType(), "clientscript", strScript.ToString()); return; } if (txtdesc.Text == "") { strScript = "<script>"; strScript = strScript + "alert('Please Enter Description.');"; strScript = strScript + "</script>"; ClientScript.RegisterStartupScript(this.GetType(), "clientscript", strScript.ToString()); return; } try { BAdbHelper.AddParameter("@Type", SqlDbType.VarChar, rdtypeRD.Checked); BAdbHelper.AddParameter("@ZoneDescription", SqlDbType.VarChar, txtdesc.Text); BAdbHelper.AddParameter("@BuildingId", SqlDbType.Int, drpBildingName.SelectedValue); BAdbHelper.AddParameter("@ReaderId", SqlDbType.Int, ddReader.SelectedValue); BAdbHelper.Command.CommandType = System.Data.CommandType.StoredProcedure; BAdbHelper.Command.CommandText = "SP_Zone_Add"; DataSet ReaderDataSet = BAdbHelper.ExcuteDatset(BAdbHelper.Command); if (ReaderDataSet.Tables[0].Rows.Count > 0) { foreach (DataRow row in ReaderDataSet.Tables[0].Rows) { TRReaderServiceLib.ReaderInfo rdrInfo = new TRReaderServiceLib.ReaderInfo(); rdrInfo.ReaderName =row["DeviceName"].ToString(); rdrInfo.ReaderDescription = row["DeviceName"].ToString(); rdrInfo.IPAddress = row["DeviceIPAddress"].ToString(); rdrInfo.PortNo = uint.Parse( row["DevicePortNumber"].ToString()); rdrInfo.MAC = row["DeviceMAC"].ToString(); rdrInfo.LocationRef = row["LocationRef"].ToString(); rdrInfo.LocationDescription = row["LocationRef"].ToString(); rdrInfo.ReaderGroupId = int.Parse (row["ReaderGroupID"].ToString()); rdrInfo.ReaderTypeId =int.Parse( row["ReaderTypeID"].ToString()); rdrInfo.AntennaPower = int.Parse(row["AntennaPower"].ToString()); var res = AddReader(rdrInfo); } } } catch (Exception ex) { } Response.Redirect("~/Setup/ZoneView.aspx?RespMsg=Zone Added Successfully", true); } }
private void FillHardware(int type) { if (drpBildingName.Text != "-Select-") { buildingvalue = Convert.ToInt32(drpBildingName.SelectedItem.Value); using (Neophotonics_webDbHelper dbHelper = new Neophotonics_webDbHelper()) { dbHelper.AddParameter("@Type", System.Data.SqlDbType.Int, type); dbHelper.AddParameter("@Buildingid", System.Data.SqlDbType.Int, buildingvalue); dbHelper.Command.CommandType = System.Data.CommandType.StoredProcedure; dbHelper.Command.CommandText = "SP_FillHardware"; DataSet ZonelstDataSet = dbHelper.ExcuteDatset(dbHelper.Command); if (ZonelstDataSet.Tables[0].Rows.Count > 0) { if (type == 1) { //chklstHardware.DataSource = ZonelstDataSet.Tables[0]; //chklstHardware.DataTextField = "Devicename"; //chklstHardware.DataValueField = "readerId"; //chklstHardware.DataBind(); ddReader.DataSource = ZonelstDataSet.Tables[0]; ddReader.DataTextField = "Devicename"; ddReader.DataValueField = "readerId"; ddReader.DataBind(); ddReader.Items.Insert(0, "-Select-"); } if (type == 2) { ddReader.DataSource = ZonelstDataSet.Tables[0]; ddReader.DataTextField = "Devicename"; ddReader.DataValueField = "readerId"; ddReader.DataBind(); ddReader.Items.Insert(0, "-Select-"); } } } } }
private void FillBuilding() { using (Neophotonics_webDbHelper dbHelper = new Neophotonics_webDbHelper()) { dbHelper.Command.CommandType = System.Data.CommandType.StoredProcedure; dbHelper.Command.CommandText = "SP_FillBuilding"; DataSet ZonedrpDataSet = dbHelper.ExcuteDatset(dbHelper.Command); if (ZonedrpDataSet.Tables[0].Rows.Count > 0) { drpBildingName.DataSource = ZonedrpDataSet.Tables[0]; drpBildingName.DataTextField = "Building_description"; drpBildingName.DataValueField = "BuildingID"; drpBildingName.DataBind(); // drpBildingName.Items.Insert(0, "-Select-"); } } }
protected void btnAddReader_Click(object sender, EventArgs e) { string strScript = ""; if ( txtdevicename.Text == "") { strScript = "<script>"; strScript = strScript + "alert('Please Enter Device Name.');"; strScript = strScript + "</script>"; ClientScript.RegisterStartupScript(this.GetType(), "clientscript", strScript.ToString()); return; } if (drpdevicetype.SelectedItem.Text == "Reader" && txtdeviceip.Text == "") { strScript = "<script>"; strScript = strScript + "alert('Please Enter Device IP Address.');"; strScript = strScript + "</script>"; ClientScript.RegisterStartupScript(this.GetType(), "clientscript", strScript.ToString()); return; } if (txtdeviceip.Text != "") { if (txtdeviceip.Text.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Length == 4) { IPAddress ipAddr; if (IPAddress.TryParse(txtdeviceip.Text, out ipAddr)) { // IP is valid } else { txtdeviceip.Text = ""; strScript = "<script>"; strScript = strScript + "alert('Please Enter valid IP Address.');"; strScript = strScript + "</script>"; ClientScript.RegisterStartupScript(this.GetType(), "clientscript", strScript.ToString()); return; } // invalid IP } else { txtdeviceip.Text = ""; strScript = "<script>"; strScript = strScript + "alert('Please Enter valid IP Address.');"; strScript = strScript + "</script>"; ClientScript.RegisterStartupScript(this.GetType(), "clientscript", strScript.ToString()); return; } } if (drpdevicetype.SelectedItem.Text == "Handheld" && txtDeviceMac.Text == "") { strScript = "<script>"; strScript = strScript + "alert('Please Enter Device MAC Address.');"; strScript = strScript + "</script>"; ClientScript.RegisterStartupScript(this.GetType(), "clientscript", strScript.ToString()); return; } using (Neophotonics_webDbHelper BAdbHelper = new Neophotonics_webDbHelper()) { BAdbHelper.AddParameter("@DeviveType", SqlDbType.VarChar, drpdevicetype.SelectedItem.Text); BAdbHelper.AddParameter("@DeviceName", SqlDbType.VarChar, txtdevicename.Text); BAdbHelper.AddParameter("@DeviceMac", SqlDbType.VarChar, txtDeviceMac.Text); BAdbHelper.AddParameter("@DeviceIpAddress", SqlDbType.VarChar, txtdeviceip.Text); // BAdbHelper.AddParameter("@DevicePortNo", SqlDbType.VarChar, txtDeviceport.Text); BAdbHelper.AddParameter("@DeviceUniqueId", SqlDbType.VarChar, txtDeviceuniqueId.Text); BAdbHelper.AddParameter("@NoAntennas", SqlDbType.VarChar, txtantenna.Text); BAdbHelper.AddParameter("@Isactive", SqlDbType.VarChar,chkIsactive.Checked); BAdbHelper.Command.CommandType = System.Data.CommandType.StoredProcedure; BAdbHelper.Command.CommandText = "SP_Reader_Add"; int i = BAdbHelper.ExecuteNoneQuery(); Response.Redirect("~/Setup/ReaderView.aspx?RespMsg=Reader Added Successfully", true); } }
private void BuildingViewBind(int pageIndex, string filter = "") { using (Neophotonics_webDbHelper dbHelper = new Neophotonics_webDbHelper()) { dbHelper.AddParameter("@BuildingID", System.Data.SqlDbType.Int, 0); dbHelper.AddParameter("@PageIndex", System.Data.SqlDbType.Int, pageIndex); dbHelper.AddParameter("@PageSize", System.Data.SqlDbType.Int, Convert.ToInt32(ddlPageSize.SelectedValue)); dbHelper.Command.CommandType = System.Data.CommandType.StoredProcedure; dbHelper.Command.CommandText = "SP_Building_Select"; DataSet BuildingDataSet = dbHelper.ExcuteDatset(dbHelper.Command); if (BuildingDataSet.Tables[0].Rows.Count > 0) { BuildingViewGrid.DataSource = BuildingDataSet.Tables[0]; BuildingViewGrid.DataBind(); ddlPageSize.Visible = true; } else { BuildingDataSet.Tables[0].Rows.Add(BuildingDataSet.Tables[0].NewRow()); BuildingViewGrid.DataSource = BuildingDataSet; BuildingViewGrid.DataBind(); int columncount = BuildingViewGrid.Rows[0].Cells.Count; BuildingViewGrid.Rows[0].Cells.Clear(); BuildingViewGrid.Rows[0].Cells.Add(new TableCell()); BuildingViewGrid.Rows[0].Cells[0].ColumnSpan = columncount; BuildingViewGrid.Rows[0].Cells[0].Text = "No Records Found"; ddlPageSize.Visible = false; } int recordCount = Convert.ToInt32(BuildingDataSet.Tables[1].Rows[0][0]); this.PopulatePager(recordCount, pageIndex); } }