protected void Button1_Click(object sender, EventArgs e) { if (PUsername.Text != "" && PPassword.Text != "") { using (MD5 md5Hash = MD5.Create()) { string password = GetMd5Hash(md5Hash, PPassword.Text); PPassword.Text = password; } DataView obstaja = (DataView)SqlDataSource6.Select(DataSourceSelectArguments.Empty); if (!(obstaja[0][0].ToString()).Equals("0")) { DataView isAdmin = (DataView)SqlDataSource7.Select(DataSourceSelectArguments.Empty); if (((isAdmin[0][0].ToString()).Equals("1"))) { Session["UIme"] = PUsername.Text; Response.Redirect("Administration.aspx"); } else { PError.Text = "Nimate administratorske pravice"; } } else { PError.Text = "Ne obstaja user."; } } else { PError.Text = "Dopolnite obadva polja."; } }
protected void btnDeleteConfirm_Click(object sender, EventArgs e) { SqlDataSource7.DeleteCommandType = SqlDataSourceCommandType.Text; SqlDataSource7.DeleteCommand = "DELETE FROM dbo.profile WHERE (Pro_Id = @Pro_Id)"; SqlDataSource7.DeleteParameters.Add("Pro_Id", Request.QueryString["Pro_Id"]); SqlDataSource7.Delete(); Response.Redirect("Home.aspx"); }
protected void btnZapiszSpecjalnosc_Click(object sender, EventArgs e) { SqlDataSource7.InsertCommandType = SqlDataSourceCommandType.Text; SqlDataSource7.InsertCommand = "Insert into Specjalnosc (nazwa,stopien,Katedra_id_katedra) VALUES (@nazwa,@stopien,@Katedra_id_katedra)"; SqlDataSource7.InsertParameters.Clear(); SqlDataSource7.InsertParameters.Add("nazwa", tbNazwaSpecjalnosc.Text); SqlDataSource7.InsertParameters.Add("stopien", tbStopienSpecjalnosc.Text); SqlDataSource7.InsertParameters.Add("Katedra_id_katedra", ddlKatedraSpecjalnosc.SelectedValue.ToString()); SqlDataSource7.Insert(); pDodajSpecjalnosc.Visible = false; }
protected void Button10_Click(object sender, EventArgs e) { try { SqlDataSource2.Insert(); DataView dv = (DataView)SqlDataSource6.Select(DataSourceSelectArguments.Empty); DataTable dt = dv.ToTable(); Label1.Text = dt.Rows[0][0].ToString(); SqlDataSource7.Insert(); Response.Redirect("~/UserPage/UserElectricityServices.aspx"); } catch (Exception ee) { // Response.Redirect("~/MainPage/Home.aspx"); } }
/// <summary> /// Search button clicked. /// </summary> /// <param name="sender">The search button.</param> /// <param name="e">The event arguments.</param> protected void search_click(object sender, EventArgs e) { //cast the sender as a button Button button_sender = (Button)sender; //grab the group tag on the button string button_group = button_sender.ID.Substring(0, button_sender.ID.Length - 7); //get the value in the associated textbox from the post data and strip the tags string box_value = Server.HtmlEncode(Request.Form["ctl00$MainContent$" + button_group + "_textbx"]); //if the query value box is empty do nothing if (box_value.Trim().Length == 0 || box_value.Trim() == "Enter Search Term") { //do nothing return; } //select the product table from the database DataView productTable = (DataView)SqlDataSource7.Select(DataSourceSelectArguments.Empty); //filter data from the selected database table productTable.RowFilter = "Product_Name_Short = '" + box_value + "' " + "OR Product_Name_Long = '" + box_value + "' " + "OR Product_Name_Alias LIKE '%" + EscapeSQlLikeString(box_value) + "%'"; //create a dataview row DataRowView row = (DataRowView)productTable[0]; //create a product object Product product = new Product(); //set the product values product.Product_Name = box_value; product.Product_Number = row["Product_Number"].ToString(); //if the page is valid if (Page.IsValid) { //redirect to the associated product detail page Response.Redirect("~/ProductInfo_" + button_group.Replace("_", string.Empty) + ".aspx?Product_Number=" + product.Product_Number); } }
protected void AddTeacher(object sender, EventArgs e) { Page.ClientScript.RegisterStartupScript(GetType(), "id", "toggle_forms('TeacherSection')", true); if (Page.IsValid) { Stream str = FileUpload1.PostedFile.InputStream; BinaryReader br = new BinaryReader(str); Byte[] size = br.ReadBytes((int)str.Length); DBHandler.DBHandler db = new DBHandler.DBHandler(con); Entities.personalInfo t1 = new Entities.personalInfo() { pKId = TID.Value, passCode = TPassword.Value, firstName = TFirstName.Value, middleName = TMiddleName.Value, lastName = TLastName.Value, iAm = Session["School"].ToString(), phone = TPhoneNo.Value, emergencyContact = TEmergency.Value, cellNo = TMobNo.Value, eMail = TEmail.Value, enrollmentDate = TEnrollmentDate.Text, dOB = TDateOfBirth.Text, gender = Convert.ToInt32(TGender.SelectedIndex.ToString()), userType = TTypeOfUser.SelectedValue, isNew = IsNew.Checked, isActive = TIsActive.Checked, address1 = TAddress1.Value, address2 = TAddress2.Value, address3 = TAddress3.Value, fileName = Path.GetFileName(FileUpload1.PostedFile.FileName), recordFile = size, }; db.insertTest(t1); UpdateTeacher(); SqlDataSource7.DataBind(); GridView3.DataBind(); } }
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (DataBinder.Eval(e.Row.DataItem, "fb_id").ToString() == Session["fb_id"].ToString() || Session["user_group"].ToString() == "1") { } else { e.Row.Cells[6].Text = ""; e.Row.Cells[7].Text = ""; } if ((e.Row.RowState & DataControlRowState.Edit) > 0) { SqlDataSource5.SelectParameters["id"].DefaultValue = ((DropDownList)e.Row.FindControl("DropDownList1")).SelectedValue; SqlDataSource5.Select(DataSourceSelectArguments.Empty); DropDownList DdlCountry = (DropDownList)e.Row.FindControl("DropDownList2"); // bind DropDown manually DdlCountry.DataBind(); DdlCountry.SelectedValue = DataBinder.Eval(e.Row.DataItem, "id1").ToString(); SqlDataSource6.SelectParameters["id"].DefaultValue = ((DropDownList)e.Row.FindControl("DropDownList1")).SelectedValue; SqlDataSource6.Select(DataSourceSelectArguments.Empty); DropDownList DdlCountry2 = (DropDownList)e.Row.FindControl("DropDownList3"); // bind DropDown manually DdlCountry2.DataBind(); DdlCountry2.SelectedValue = DataBinder.Eval(e.Row.DataItem, "id2").ToString(); SqlDataSource7.SelectParameters["id"].DefaultValue = ((DropDownList)e.Row.FindControl("DropDownList1")).SelectedValue; SqlDataSource7.Select(DataSourceSelectArguments.Empty); DropDownList DdlCountry3 = (DropDownList)e.Row.FindControl("DropDownList4"); // bind DropDown manually DdlCountry3.DataBind(); DdlCountry3.SelectedValue = DataBinder.Eval(e.Row.DataItem, "id3").ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { //if (Context.User.Identity.Name.Contains('@')) //{ // int CharIndex = Context.User.Identity.Name.IndexOf('@'); // //Get current login user name as initiator // Label_Initiator.Text = Context.User.Identity.Name.Substring(0, CharIndex).ToUpper(); //} //else //{ // Label_Initiator.Text = Context.User.Identity.Name; //} Initiator = Context.User.Identity.Name.Substring(Context.User.Identity.Name.IndexOf('\\') + 1); IEnumerable rows = SqlDataSource7.Select(DataSourceSelectArguments.Empty); foreach (DataRowView row in rows) { Label_ID.Text = row[0].ToString(); DateTimeUTC = (DateTime)row[2]; } Label_DateTime.Text = DateTimeUTC.ToShortDateString() + " " + DateTimeUTC.ToShortTimeString(); try { AcquireNewItem(); } catch (Exception ex) { this.Response.Write(String.Format("<script>alert('{0}')</script>", ex.ToString())); } }
protected void Page_Load(object sender, EventArgs e) { Label2.Text = DateTime.Now.ToString("D"); Label14.Text = ""; Label16.Text = ""; Label33.Text = ""; Label34.Text = ""; Label35.Text = ""; Label36.Text = ""; Label24.Text = ""; Label47.Text = ""; DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty); foreach (DataRow dr in dv.Table.Rows) { Cname = (string)dv.Table.Rows[x][0]; Cadd = (string)dv.Table.Rows[x][1]; Ccomp = (string)dv.Table.Rows[x][2]; Label14.Text = Label14.Text + Cname; Label33.Text = Label33.Text + Cadd; Label34.Text = Label34.Text + Ccomp; Label16.Text = Label16.Text + Cname; Label35.Text = Label35.Text + Cadd; Label36.Text = Label36.Text + Ccomp; Label24.Text = Label24.Text + Cname; } Venue.Text = ""; VAdd.Text = ""; N.Text = ""; Label37.Text = ""; DataView dv1 = (DataView)SqlDataSource2.Select(DataSourceSelectArguments.Empty); foreach (DataRow dr in dv1.Table.Rows) { Vname = (string)dv1.Table.Rows[x][0]; Vadd = (string)dv1.Table.Rows[x][1]; Ename = (string)dv1.Table.Rows[x][2]; Edate = (DateTime)dv1.Table.Rows[x][3]; Venue.Text = Venue.Text + Vname; VAdd.Text = VAdd.Text + Vadd; N.Text = N.Text + Ename; Label37.Text = Edate.ToString("D"); } Label40.Text = ""; Label41.Text = ""; Label43.Text = ""; Label44.Text = ""; Label42.Text = ""; Label1.Text = ""; DataView dv2 = (DataView)SqlDataSource3.Select(DataSourceSelectArguments.Empty); foreach (DataRow dr in dv2.Table.Rows) { RF = (double)dv2.Table.Rows[x][0]; Total = (double)dv2.Table.Rows[x][4]; OE = (double)dv2.Table.Rows[x][1]; PB = (double)dv2.Table.Rows[x][2]; RPH = (double)dv2.Table.Rows[x][3]; DL = (DateTime)dv2.Table.Rows[x][5]; Label40.Text = Label40.Text + RF.ToString("n2"); Label41.Text = Label41.Text + Total.ToString("n2"); Label43.Text = Label43.Text + OE.ToString("n2"); Label44.Text = Label44.Text + PB.ToString("n2"); Label42.Text = Label42.Text + RPH.ToString("n2"); Label1.Text = DL.ToString("D"); } Label45.Text = ""; DataView dv3 = (DataView)SqlDataSource4.Select(DataSourceSelectArguments.Empty); foreach (DataRow dr in dv3.Table.Rows) { Edate = (DateTime)dv3.Table.Rows[x][0]; Estime = (TimeSpan)dv3.Table.Rows[x][1]; Eetime = (TimeSpan)dv3.Table.Rows[x][2]; Label45.Text = Edate.ToString("D") + ' ' + ConvertMode(Estime.ToString()) + ' ' + '-' + ' ' + ConvertMode(Eetime.ToString()); } Label46.Text = ""; DataView dv4 = (DataView)SqlDataSource5.Select(DataSourceSelectArguments.Empty); foreach (DataRow dr in dv4.Table.Rows) { Aname = (string)dv4.Table.Rows[x][0]; Ades = (string)dv4.Table.Rows[x][3]; qty = (int)dv4.Table.Rows[x][1]; Label46.Text = Label46.Text + ' ' + Ades + ' ' + qty.ToString() + ' ' + "pcs" + ", "; x++; } Label3.Text = ""; Label4.Text = ""; string check = Label46.Text; int lg = check.Length; if (x > 0) { Label3.Text = "<li> Amenity- "; check = check.Substring(0, lg - 2); Label46.Text = check + ";"; Label4.Text = "</li>"; } Label47.Text = ""; DataView dv5 = (DataView)SqlDataSource6.Select(DataSourceSelectArguments.Empty); foreach (DataRow dr in dv5.Table.Rows) { Fname = (string)dv5.Table.Rows[y][0]; Fdes = (string)dv5.Table.Rows[y][1]; Label47.Text = Label47.Text + Fname + ' ' + Fdes + ", "; y++; } string check2 = Label47.Text; int lg2 = check2.Length; Label5.Text = ""; Label6.Text = ""; if (y > 0) { Label5.Text = "<li> Facility- "; check2 = check2.Substring(0, lg2 - 2); Label47.Text = check2 + ";"; Label6.Text = "</li>"; } Label48.Text = ""; DataView dv6 = (DataView)SqlDataSource7.Select(DataSourceSelectArguments.Empty); foreach (DataRow dr in dv6.Table.Rows) { Fname = (string)dv6.Table.Rows[z][0]; Fdes = (string)dv6.Table.Rows[z][1]; Label48.Text = Label48.Text + Mname + ' ' + Mdes + ", "; z++; } string check3 = Label48.Text; int lg3 = check3.Length; if (lg3 != 0) { check3 = check3.Substring(0, lg3 - 2); Label48.Text = check3 + ";"; } }
protected void Button1_Click(object sender, EventArgs e) { DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty); DataRowView drv = dv[0]; Table1.Rows[1].Cells[0].Text = drv["BUGS"].ToString(); DataView dv1 = (DataView)SqlDataSource2.Select(DataSourceSelectArguments.Empty); DataRowView drv1 = dv1[0]; Table1.Rows[1].Cells[1].Text = drv1["BUGS"].ToString(); DataView dv2 = (DataView)SqlDataSource3.Select(DataSourceSelectArguments.Empty); DataRowView drv2 = dv2[0]; Table1.Rows[1].Cells[2].Text = drv2["BUGS"].ToString(); DataView dv3 = (DataView)SqlDataSource4.Select(DataSourceSelectArguments.Empty); DataRowView drv3 = dv3[0]; Table1.Rows[1].Cells[3].Text = drv3["BUGS"].ToString(); DataView dv5 = (DataView)SqlDataSource5.Select(DataSourceSelectArguments.Empty); DataRowView drv5 = dv5[0]; Table2.Rows[1].Cells[0].Text = drv5["BUGS"].ToString(); DataView dv6 = (DataView)SqlDataSource6.Select(DataSourceSelectArguments.Empty); DataRowView drv6 = dv6[0]; Table2.Rows[1].Cells[1].Text = drv6["BUGS"].ToString(); DataView dv7 = (DataView)SqlDataSource7.Select(DataSourceSelectArguments.Empty); DataRowView drv7 = dv7[0]; Table2.Rows[1].Cells[2].Text = drv7["BUGS"].ToString(); DataView dv8 = (DataView)SqlDataSource8.Select(DataSourceSelectArguments.Empty); DataRowView drv8 = dv8[0]; Table2.Rows[1].Cells[3].Text = drv8["BUGS"].ToString(); DataView dv9 = (DataView)SqlDataSource9.Select(DataSourceSelectArguments.Empty); DataRowView drv9 = dv9[0]; Table3.Rows[1].Cells[0].Text = drv9["BUGS"].ToString(); DataView dv10 = (DataView)SqlDataSource10.Select(DataSourceSelectArguments.Empty); DataRowView drv10 = dv10[0]; Table3.Rows[1].Cells[1].Text = drv10["BUGS"].ToString(); DataView dv11 = (DataView)SqlDataSource11.Select(DataSourceSelectArguments.Empty); DataRowView drv11 = dv11[0]; Table3.Rows[1].Cells[2].Text = drv11["BUGS"].ToString(); DataView dv12 = (DataView)SqlDataSource12.Select(DataSourceSelectArguments.Empty); DataRowView drv12 = dv12[0]; Table3.Rows[1].Cells[3].Text = drv12["BUGS"].ToString(); }
protected void RadButton3_Click(object sender, EventArgs e) { SqlDataSource7.Insert(); }
protected void timer1_tick(object sender, EventArgs e) { //if (0 > DateTime.Compare(DateTime.Now, DateTime.Parse(Session["timeout"].ToString()))) //{ //Aggiorna tabella SqlDataSource1.SelectCommand = "SELECT timestamp, pressione, temperatura, umidita, idsensore_ambientale FROM misura_ambientale WHERE idsensore_ambientale IN (SELECT idsensore FROM sensore_ambientale WHERE idluogo = (SELECT idluogo FROM palestra WHERE nome_centro = '" + DropDownList2.SelectedValue + "')) ORDER BY idmisura DESC LIMIT 20 "; SqlDataSource2.SelectCommand = "SELECT indice_attività, timestamp FROM misura_actigrafo WHERE idactigrafo = '" + DropDownList1.SelectedValue + "' AND timestamp BETWEEN timestamp(DATE_SUB(NOW(), INTERVAL 1 MINUTE)) AND timestamp(NOW()) "; SqlDataSource5.SelectCommand = "SELECT nome, cognome FROM utente WHERE actigrafo_idactigrafo = '" + DropDownList1.SelectedValue + "'"; SqlDataSource6.SelectCommand = "SELECT DISTINCT idsensore FROM storico_errore WHERE idsensore IN (SELECT idsensore FROM sensore_ambientale WHERE idluogo = (SELECT idluogo FROM palestra WHERE nome_centro = '" + DropDownList2.SelectedValue + "')) AND TIMESTAMP BETWEEN TIMESTAMP (DATE_SUB(NOW(), INTERVAL 1 MINUTE)) AND TIMESTAMP (NOW()) ORDER BY iderrore DESC LIMIT 1"; SqlDataSource7.SelectCommand = "SELECT DISTINCT * FROM storico_errore WHERE idsensore IN (SELECT idsensore FROM sensore_ambientale WHERE idluogo = (SELECT idluogo FROM palestra WHERE nome_centro = '" + DropDownList2.SelectedValue + "')) AND TIMESTAMP BETWEEN TIMESTAMP (DATE_SUB(NOW(), INTERVAL 1 MINUTE)) AND TIMESTAMP (NOW()) ORDER BY iderrore DESC LIMIT 1 "; SqlDataSource8.SelectCommand = "SELECT timestamp, pressione, temperatura, umidita, idsensore_ambientale FROM misura_ambientale WHERE idsensore_ambientale IN (SELECT idsensore FROM sensore_ambientale WHERE idluogo = (SELECT idluogo FROM palestra WHERE nome_centro = '" + DropDownList2.SelectedValue + "')) ORDER BY idmisura DESC LIMIT 1 "; GridView1.DataBind(); GridView2.DataBind(); Label1.Text = DateTime.Now.ToString(); DataSourceSelectArguments sr = new DataSourceSelectArguments(); DataSourceSelectArguments sr_2 = new DataSourceSelectArguments(); DataSourceSelectArguments sr_3 = new DataSourceSelectArguments(); //DataSourceSelectArguments sr_3 = new DataSourceSelectArguments(); //DataView dv_3 = (DataView)SqlDataSource7.Select(sr_3); DataView dv = (DataView)SqlDataSource5.Select(sr); DataView dv_2 = (DataView)SqlDataSource7.Select(sr_2); DataView dv_3 = (DataView)SqlDataSource2.Select(sr_3); DataTable dt = dv_3.ToTable(); if (dv.Count != 0) { Chart1.Series["Series1"].Name = dv[0][0].ToString() + " " + dv[0][1].ToString(); Chart1.Legends[0].Font = new System.Drawing.Font("Trebuchet MS", 15F, System.Drawing.FontStyle.Bold); } if (dv_2.Count != 0) { alarmLabel.ForeColor = System.Drawing.Color.Red; alarmLabel.Font.Size = 32; if (dv_2.Count < 2) { alarmLabel.Text = "Rilevate anomalie su " + dv_2.Count + " sensore ambientale"; } else { alarmLabel.Text = "Rilevate anomalie su " + dv_2.Count + " sensori ambientali"; } } else { alarmLabel.ForeColor = System.Drawing.Color.Green; alarmLabel.Font.Size = 12; alarmLabel.Text = "Nessuna anomalia rilevata"; } if (dv_3.Count > 0) { int num = int.Parse(dv_3[dv_3.Count - 1][0].ToString()); if (num == 1) { Image1.ImageUrl = "~/Models/Fermo.png"; } else if (num == 2) { Image1.ImageUrl = "~/Models/Lento.png"; } else if (num == 3) { Image1.ImageUrl = "~/Models/Moderato.png"; } else if (num == 4) { Image1.ImageUrl = "~/Models/Veloce.png"; } else if (num == 5) { Image1.ImageUrl = "~/Models/Vigoroso.png"; } } // ((Int32)DateTime.Parse(Session["timeout"].ToString()).Subtract(DateTime.Now).TotalMinutes).ToString(); //} }
protected void Page_Load(object sender, EventArgs e) { String y = "select DISTINCT [Year] from SchoolTable"; SqlDataSource9.SelectCommand = y; DataView dv = (DataView)SqlDataSource9.Select(new DataSourceSelectArguments()); for (int i = 0; i < dv.Count; i++) { if (dv[i][0] != DBNull.Value) { String year = (String)dv[i][0]; String sql1 = "select count(UnitName) from SchoolTable where UnitType='Cub' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource1.SelectCommand = sql1; DataView dv1 = (DataView)SqlDataSource1.Select(new DataSourceSelectArguments()); int cub = (int)dv1[0][0]; String sql2 = "select count(UnitName) from SchoolTable where UnitType='Scout' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource2.SelectCommand = sql2; DataView dv2 = (DataView)SqlDataSource2.Select(new DataSourceSelectArguments()); int scout = (int)dv2[0][0]; String sql3 = "select count(UnitName) from SchoolTable where UnitType='Rover' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource3.SelectCommand = sql3; DataView dv3 = (DataView)SqlDataSource3.Select(new DataSourceSelectArguments()); int rover = (int)dv3[0][0]; String sql4 = "select count(UnitName) from SchoolTable where UnitType='Bulbul' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource4.SelectCommand = sql4; DataView dv4 = (DataView)SqlDataSource4.Select(new DataSourceSelectArguments()); int bulbul = (int)dv4[0][0]; String sql5 = "select count(UnitName) from SchoolTable where UnitType='Guide' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource5.SelectCommand = sql5; DataView dv5 = (DataView)SqlDataSource5.Select(new DataSourceSelectArguments()); int guide = (int)dv5[0][0]; String sql6 = "select count(UnitName) from SchoolTable where UnitType='Ranger' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource6.SelectCommand = sql6; DataView dv6 = (DataView)SqlDataSource6.Select(new DataSourceSelectArguments()); int ranger = (int)dv6[0][0]; String sql7 = "select count(UnitName) from SchoolTable where UnitType='Bunny' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource7.SelectCommand = sql7; DataView dv7 = (DataView)SqlDataSource7.Select(new DataSourceSelectArguments()); int bunny = (int)dv7[0][0]; int total = cub + scout + rover + bulbul + guide + ranger + bunny; String sql9 = "select count(StudFullName) from StudentTable where UnitType='Cub' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource9.SelectCommand = sql9; DataView dv9 = (DataView)SqlDataSource9.Select(new DataSourceSelectArguments()); int cub1 = (int)dv9[0][0]; String sql10 = "select count(StudFullName) from StudentTable where UnitType='Scout' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource10.SelectCommand = sql10; DataView dv10 = (DataView)SqlDataSource10.Select(new DataSourceSelectArguments()); int scout1 = (int)dv10[0][0]; String sql11 = "select count(StudFullName) from StudentTable where UnitType='Rover' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource11.SelectCommand = sql11; DataView dv11 = (DataView)SqlDataSource11.Select(new DataSourceSelectArguments()); int rover1 = (int)dv11[0][0]; String sql12 = "select count(StudFullName) from StudentTable where UnitType='Bulbul' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource12.SelectCommand = sql12; DataView dv12 = (DataView)SqlDataSource12.Select(new DataSourceSelectArguments()); int bulbul1 = (int)dv12[0][0]; String sql13 = "select count(StudFullName) from StudentTable where UnitType='Guide' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource13.SelectCommand = sql13; DataView dv13 = (DataView)SqlDataSource13.Select(new DataSourceSelectArguments()); int guide1 = (int)dv13[0][0]; String sql14 = "select count(StudFullName) from StudentTable where UnitType='Ranger' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource14.SelectCommand = sql14; DataView dv14 = (DataView)SqlDataSource14.Select(new DataSourceSelectArguments()); int ranger1 = (int)dv14[0][0]; String sql15 = "select count(StudFullName) from StudentTable where UnitType='Bunny' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource15.SelectCommand = sql15; DataView dv15 = (DataView)SqlDataSource15.Select(new DataSourceSelectArguments()); int bunny1 = (int)dv7[0][0]; int total1 = cub1 + scout1 + rover1 + bulbul1 + guide1 + ranger1 + bunny1; String sql16 = "select count(UnitName) from SchoolTable where Year='" + year + "' AND Status='Activated'"; SqlDataSource16.SelectCommand = sql16; DataView dv16 = (DataView)SqlDataSource16.Select(new DataSourceSelectArguments()); int unit = (int)dv16[0][0]; String sql17 = "select SUM(khTotalContri) from SchoolTable where Year='" + year + "'"; SqlDataSource17.SelectCommand = sql17; DataView dv17 = (DataView)SqlDataSource17.Select(new DataSourceSelectArguments()); int amt; if (dv17[0][0] != DBNull.Value) { amt = (int)dv17[0][0]; } else { amt = 0; } String sql18 = "select count(SchoolName) from SchoolTable where Year='" + year + "' AND Status='Activated'"; SqlDataSource18.SelectCommand = sql18; DataView dv18 = (DataView)SqlDataSource18.Select(new DataSourceSelectArguments()); int sch = (int)dv18[0][0]; String sql19 = "select count(SchoolName) from SchoolTable where SchoolType='PrimarySchool' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource19.SelectCommand = sql19; DataView dv19 = (DataView)SqlDataSource19.Select(new DataSourceSelectArguments()); int sch1 = (int)dv19[0][0]; String sql20 = "select count(SchoolName) from SchoolTable where SchoolType='SecondarySchool' AND Year='" + year + "' AND Status='Activated'"; SqlDataSource20.SelectCommand = sql20; DataView dv20 = (DataView)SqlDataSource20.Select(new DataSourceSelectArguments()); int sch2 = (int)dv20[0][0]; int total3 = sch1 + sch2; String update = "Select * from StatisticalData where Year='" + year + "'"; SqlDataSource21.SelectCommand = update; DataView dv21 = (DataView)SqlDataSource21.Select(new DataSourceSelectArguments()); if (dv21.Count != 0) { String query = "update StatisticalData set Cub=" + cub + ", Scout=" + scout + ", Rover=" + rover + ", Bulbul=" + bulbul + ", Guide=" + guide + ", Ranger=" + ranger + ", Bunny=" + bunny + ", Total=" + total + ", Cub1=" + cub1 + ", Scout1=" + scout1 + ", Rover1=" + rover1 + ", Bulbul1=" + bulbul1 + ", Guide1=" + guide1 + ", Ranger1=" + ranger1 + ", Bunny1=" + bunny1 + ", Total1=" + total1 + ", TotalUnits=" + unit + ", CollectedFees=" + amt + ", TotalParticipatedSchools=" + sch + ", PrimarySchool=" + sch1 + ", SecondarySchool=" + sch2 + ", TotalMembers=" + total3 + " where Year='" + year + "'"; SqlDataSource22.UpdateCommand = query; int n = SqlDataSource22.Update(); } else { String insert1 = "insert into StatisticalData (Year, Cub, Scout, Rover, Bulbul, Guide, Ranger, Bunny, Total, Cub1, Scout1, Rover1, Bulbul1, Guide1, Ranger1, Bunny1, Total1, TotalUnits, CollectedFees, TotalParticipatedSchools, PrimarySchool, SecondarySchool, TotalMembers) Values('" + year + "'," + cub + "," + scout + "," + rover + "," + bulbul + "," + guide + "," + ranger + "," + bunny + "," + total + "," + cub1 + "," + scout1 + "," + rover1 + "," + bulbul1 + "," + guide1 + "," + ranger1 + "," + bunny1 + "," + total1 + "," + unit + "," + amt + "," + sch + "," + sch1 + "," + sch2 + "," + total3 + ")"; SqlDataSource8.InsertCommand = insert1; int n1 = SqlDataSource8.Insert(); } } } Server.Transfer("Statistical2.aspx"); }
protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e) { SqlDataSource7.Delete(); GridView2.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { ManageCookie mgCookie = new ManageCookie(); users ck = mgCookie.ReadCookies(); if (ck != null) { string strDeptID = ck.d_code; //Redirect Login users to pending page //redirectToPendingPage(); //string strDeptID = "01001"; string strProjectStatus = Request.QueryString["status"]; //keep project code in cookie for usage in follwing pages mgCookie.UpdateCookies("pj_status", strProjectStatus); string strSQL1 = "select * from dbo.department d, dbo.ministry m where d.mi_id = m.mi_id and d.d_code = '" + strDeptID + "'"; SqlDataSource4.SelectCommand = strSQL1; SqlDataSource4.DataBind(); DataView dv1 = (DataView)SqlDataSource4.Select(DataSourceSelectArguments.Empty); foreach (DataRow dRow in dv1.Table.Rows) { lblDeptCode.Text = dRow["mi_code"].ToString(); lblDeptName.Text = dRow["mi_name"].ToString(); lblDivisionCode.Text = dRow["d_code"].ToString(); lblDivisionName.Text = dRow["d_name"].ToString(); mgCookie.UpdateCookies("mi_id", dRow["mi_id"].ToString()); mgCookie.UpdateCookies("d_id", dRow["d_id"].ToString()); } if (!Page.IsPostBack) { string strSQL = string.Empty; strSQL = "SELECT pj_code from dbo.projects where d_id = " + strDeptID + " and pj_isinuse = 1 and pj_status = '" + strProjectStatus + "' and p_id = " + ck.p_id + " and mi_id is null and pj_name is null and pj_yut_id is null and pj_year is null"; SqlDataSource2.SelectCommand = strSQL; SqlDataSource2.DataBind(); DataView dv = (DataView)SqlDataSource2.Select(DataSourceSelectArguments.Empty); if (dv.Count > 0) { strSQL = "SELECT max(cast(substring(pj_code, 7, 3) as int)) from dbo.projects where d_id = " + strDeptID + " and pj_isinuse = 1 and pj_status = '" + strProjectStatus + "' and p_id = " + ck.p_id + " and mi_id is null and pj_name is null and pj_yut_id is null and pj_year is null"; } else { strSQL = "SELECT max(cast(substring(pj_code, 7, 3) as int)) + 1 from dbo.projects where d_id = " + strDeptID + " and pj_isinuse = 1 and pj_status = '" + strProjectStatus + "'"; } SqlDataSource2.SelectCommand = strSQL; SqlDataSource2.DataBind(); dv = (DataView)SqlDataSource2.Select(DataSourceSelectArguments.Empty); if (dv.Count > 0) { foreach (DataRow dRow in dv.Table.Rows) { if (dRow[0] != null && dRow[0].ToString() != string.Empty) { if (dRow[0].ToString().Length == 1) { lblProjectCode.Text = strDeptID + "-00" + dRow[0].ToString(); } else if (dRow[0].ToString().Length == 2) { lblProjectCode.Text = strDeptID + "-0" + dRow[0].ToString(); } else { lblProjectCode.Text = strDeptID + "-" + dRow[0].ToString(); } } else { lblProjectCode.Text = strDeptID + "-" + "001"; } } mgCookie.UpdateCookies("pj_code", lblProjectCode.Text); string strUID = ck.p_id; /************************************************************************************************** * insert projects table by setting projects.p_isinuse = 1, * this is to avoid conflict when creating more than 1 project at the same time by multiple users **************************************************************************************************/ SqlParameter pj_code = new SqlParameter("@pj_code", SqlDbType.NVarChar, 15); pj_code.Direction = ParameterDirection.Input; pj_code.Value = lblProjectCode.Text; SqlParameter p_id = new SqlParameter("@p_id", SqlDbType.Int); p_id.Direction = ParameterDirection.Input; p_id.Value = ck.p_id; SqlParameter pj_status = new SqlParameter("@pj_status", SqlDbType.NVarChar); pj_status.Direction = ParameterDirection.Input; pj_status.Value = strProjectStatus; SqlParameter d_id = new SqlParameter("@d_id", SqlDbType.NVarChar); d_id.Direction = ParameterDirection.Input; d_id.Value = strDeptID; insertParameters.Add(pj_code); insertParameters.Add(p_id); insertParameters.Add(pj_status); insertParameters.Add(d_id); try { //not insert when the existing record does not have input string strSQL11 = "select pj_id from projects where pj_code = '" + lblProjectCode.Text + "' and pj_status = '" + Request.QueryString["status"] + "'"; SqlDataSource7.SelectCommand = strSQL11; SqlDataSource7.DataBind(); DataView dv7 = (DataView)SqlDataSource7.Select(DataSourceSelectArguments.Empty); if (dv7.Table.Rows.Count == 0) { SqlDataSource3.Insert(); } else { mgCookie.UpdateCookies("pj_id", dv7.Table.Rows[0]["pj_id"].ToString()); } } catch (Exception ex) { //Elmah Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } } } } }