protected void Button6_Click(object sender, EventArgs e) { if (IsPostBack) { String userID = TextBox2.Text; String userName = TextBox3.Text; String pwd = TextBox4.Text; String empUserid = "SELECT count(*) from loginDB where Id='" + TextBox2.Text + "'"; SqlCommand com = new SqlCommand(empUserid, conn); int temp = (int)com.ExecuteScalar(); Boolean errorEmpUserID = false; if (temp == 1 && !(TextBox2.Text.Equals(glob))) { Label7.Text = "User ID already used"; errorEmpUserID = true; } else if (TextBox2.Text.Length == 0) { Label7.Text = "Feed Admin's User ID"; errorEmpUserID = true; } else if (errorEmpUserID == false) { Label7.Text = ""; } empUserid = "SELECT count(*) from loginDB where username='******'"; com = new SqlCommand(empUserid, conn); int temp2 = (int)com.ExecuteScalar(); Boolean errorEmpUsername = false; if (temp2 == 1 && !(TextBox3.Text.Equals(glob2))) { Label8.Text = "Username already used"; errorEmpUsername = true; } else if (TextBox3.Text.Length == 0) { Label8.Text = "Feed Admin's Username"; errorEmpUsername = true; } else if (errorEmpUsername == false) { Label8.Text = ""; } Boolean errorPwd = false; if (pwd.Length == 0) { Label9.Text = "Feed Admin's Password"; errorPwd = true; } else if (errorPwd == false) { Label9.Text = ""; } if (errorEmpUserID == false && errorEmpUsername == false && errorPwd == false) { String password = ComputeHash(TextBox4.Text, new SHA256CryptoServiceProvider()); SqlCommand com3 = new SqlCommand("update loginDB set Id = '" + TextBox2.Text + "',username = '******', password = '******' where Id = '" + glob0 + "'", conn); com3.ExecuteScalar(); Response.Write("<font color = " + '"' + "green" + '"' + "><h2>Employee Updated Successfully </h2></font>"); Label4.Visible = false; Label5.Visible = false; Label6.Visible = false; Label7.Visible = false; Label8.Visible = false; Label9.Visible = false; TextBox2.Visible = false; TextBox3.Visible = false; TextBox4.Visible = false; Button6.Visible = false; Button7.Visible = false; Button8.Visible = false; TextBox1.Text = ""; GridView1.DataBind(); GridView2.DataBind(); GridView3.DataBind(); } } conn.Close(); }
protected void GridView1_RowCancelingEdit(object sender, System.Web.UI.WebControls.GridViewCancelEditEventArgs e) { //Setting the EditIndex property to -1 to cancel the Edit mode in Gridview GridView3.EditIndex = -1; GridView3.DataBind(); }
public void fetchdata() { string connectionString = ConfigurationManager.ConnectionStrings["mycon"].ConnectionString; SqlConnection con = new SqlConnection(connectionString); con.Open(); SqlCommand c = new SqlCommand("select papername from Publication where btype='General science' and published='Yes'", con); SqlDataReader rdr = c.ExecuteReader(); GridView1.DataSource = rdr; GridView1.DataBind(); GridView1.GridLines = GridLines.None; rdr.Close(); con.Close(); con.Open(); SqlCommand c2 = new SqlCommand("select papername from Publication where btype='Neuroscience & Psychology' and published='Yes'", con); SqlDataReader rdr2 = c2.ExecuteReader(); GridView2.DataSource = rdr2; GridView2.DataBind(); GridView2.GridLines = GridLines.None; rdr2.Close(); con.Close(); con.Open(); SqlCommand c3 = new SqlCommand("select papername from Publication where btype='Genetics & Molicular Biology' and published='Yes'", con); SqlDataReader rdr3 = c3.ExecuteReader(); GridView3.DataSource = rdr3; GridView3.DataBind(); GridView3.GridLines = GridLines.None; rdr3.Close(); con.Close(); con.Open(); SqlCommand c4 = new SqlCommand("select papername from Publication where btype='Biochemistry' and published='Yes'", con); SqlDataReader rdr4 = c4.ExecuteReader(); GridView4.DataSource = rdr4; GridView4.DataBind(); GridView4.GridLines = GridLines.None; rdr4.Close(); con.Close(); con.Open(); SqlCommand c5 = new SqlCommand("select papername from Publication where btype='Engineering' and published='Yes'", con); SqlDataReader rdr5 = c5.ExecuteReader(); GridView5.DataSource = rdr5; GridView5.DataBind(); GridView5.GridLines = GridLines.None; rdr5.Close(); con.Close(); con.Open(); SqlCommand c6 = new SqlCommand("select papername from Publication where btype='Chemistry' and published='Yes'", con); SqlDataReader rdr6 = c6.ExecuteReader(); GridView6.DataSource = rdr6; GridView6.DataBind(); GridView6.GridLines = GridLines.None; rdr6.Close(); con.Close(); con.Open(); SqlCommand c7 = new SqlCommand("select papername from Publication where btype='Physics' and published='Yes'", con); SqlDataReader rdr7 = c7.ExecuteReader(); GridView7.DataSource = rdr7; GridView7.DataBind(); GridView7.GridLines = GridLines.None; rdr7.Close(); con.Close(); con.Open(); SqlCommand c8 = new SqlCommand("select papername from Publication where btype='Material Sciences' and published='Yes'", con); SqlDataReader rdr8 = c8.ExecuteReader(); GridView8.DataSource = rdr8; GridView8.DataBind(); GridView8.GridLines = GridLines.None; rdr8.Close(); con.Close(); con.Open(); SqlCommand c9 = new SqlCommand("select papername from Publication where btype='Social & Political Science' and published='Yes'", con); SqlDataReader rdr9 = c9.ExecuteReader(); GridView9.DataSource = rdr9; GridView9.DataBind(); GridView9.GridLines = GridLines.None; rdr9.Close(); con.Close(); con.Open(); SqlCommand c10 = new SqlCommand("select papername from Publication where btype='Earth & Environmental Science' and published='Yes'", con); SqlDataReader rdr10 = c10.ExecuteReader(); GridView10.DataSource = rdr10; GridView10.DataBind(); GridView10.GridLines = GridLines.None; rdr10.Close(); con.Close(); con.Open(); SqlCommand c11 = new SqlCommand("select papername from Publication where btype='Chemical Engineering' and published='Yes'", con); SqlDataReader rdr11 = c11.ExecuteReader(); GridView11.DataSource = rdr11; GridView11.DataBind(); GridView11.GridLines = GridLines.None; rdr11.Close(); con.Close(); con.Open(); SqlCommand c12 = new SqlCommand("select papername from Publication where btype='Medical' and published='Yes'", con); SqlDataReader rdr12 = c12.ExecuteReader(); GridView12.DataSource = rdr12; GridView12.DataBind(); GridView12.GridLines = GridLines.None; rdr12.Close(); con.Close(); con.Open(); SqlCommand c13 = new SqlCommand("select papername from Publication where btype='Agri Food & Aqua' and published='Yes'", con); SqlDataReader rdr13 = c13.ExecuteReader(); GridView13.DataSource = rdr13; GridView13.DataBind(); GridView13.GridLines = GridLines.None; rdr13.Close(); con.Close(); con.Open(); SqlCommand c14 = new SqlCommand("select papername from Publication where btype='Immunology & Microbiology' and published='Yes'", con); SqlDataReader rdr14 = c14.ExecuteReader(); GridView14.DataSource = rdr14; GridView14.DataBind(); GridView14.GridLines = GridLines.None; rdr14.Close(); con.Close(); con.Open(); SqlCommand c15 = new SqlCommand("select papername from Publication where btype='Pharmaceutical Sciences' and published='Yes'", con); SqlDataReader rdr15 = c15.ExecuteReader(); GridView15.DataSource = rdr15; GridView15.DataBind(); GridView15.GridLines = GridLines.None; rdr15.Close(); con.Close(); con.Open(); SqlCommand c16 = new SqlCommand("select papername from Publication where btype='Informatics' and published='Yes'", con); SqlDataReader rdr16 = c16.ExecuteReader(); GridView16.DataSource = rdr16; GridView16.DataBind(); GridView16.GridLines = GridLines.None; rdr16.Close(); con.Close(); con.Open(); SqlCommand c17 = new SqlCommand("select papername from Publication where btype='Business and Management' and published='Yes'", con); SqlDataReader rdr17 = c17.ExecuteReader(); GridView17.DataSource = rdr17; GridView17.DataBind(); GridView17.GridLines = GridLines.None; rdr17.Close(); con.Close(); }
protected void Button1_Click(object sender, EventArgs e) { if (DropDownList1.SelectedItem == null || DropDownList2.SelectedItem == null || DropDownList3.SelectedItem == null || DropDownList4.SelectedItem == null || DropDownList5.SelectedItem == null) { Response.Redirect("~/NullPointer.aspx"); return; } con.Open(); OleDbCommand cmd = new OleDbCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT COUNT(DURATION_ID) FROM ADMISSION_AND_RELEASE_INFO WHERE HOS_ID = " + Mother.hospitalId + " AND PATIENT_ID = " + DropDownList4.SelectedItem.Text + " AND DURATION_ID = " + DropDownList5.SelectedItem.Text; cmd.Connection = con; int temp = Convert.ToInt32(cmd.ExecuteScalar().ToString()); con.Close(); if (temp == 1) { cmd = new OleDbCommand(); cmd.CommandType = CommandType.Text; cmd.Connection = con; string sql = "INSERT INTO RECORD1 VALUES(FOR_AUTO_INC_REC.NEXTVAL," + DropDownList4.SelectedItem.Text + "," + Mother.hospitalId + "," + DropDownList4.Text + "," + DropDownList1.SelectedItem.Text + "," + DropDownList5.SelectedItem.Text + ")"; con.Open(); cmd.CommandText = sql; cmd.ExecuteNonQuery(); con.Close(); sql = "INSERT INTO DISEASE VALUES (FOR_AUTO_INC_DIS.NEXTVAL," + Mother.hospitalId + "," + DropDownList2.SelectedItem.Text + "," + DropDownList4.SelectedItem.Text + "," + DropDownList5.SelectedItem.Text + ")"; con.Open(); cmd.CommandText = sql; cmd.ExecuteNonQuery(); con.Close(); sql = "INSERT INTO MEDICINE VALUES (FOR_AUTO_INC_MED.NEXTVAL," + Mother.hospitalId + "," + DropDownList3.SelectedItem.Text + "," + DropDownList4.SelectedItem.Text + "," + DropDownList5.SelectedItem.Text + ")"; con.Open(); cmd.CommandText = sql; cmd.ExecuteNonQuery(); con.Close(); con.Open(); sql = "select * from RECORD1"; OleDbDataAdapter oda = new OleDbDataAdapter(sql, con); DataTable dt = new DataTable(); oda.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); con.Close(); con.Open(); sql = "select * from MEDICINE"; oda = new OleDbDataAdapter(sql, con); dt = new DataTable(); oda.Fill(dt); GridView2.DataSource = dt; GridView2.DataBind(); con.Close(); con.Open(); sql = "select * from DISEASE"; oda = new OleDbDataAdapter(sql, con); dt = new DataTable(); oda.Fill(dt); GridView3.DataSource = dt; GridView3.DataBind(); con.Close(); Response.Redirect("~/OPS.aspx"); } else { Response.Redirect("~/Page.aspx"); } }
//кнопка Выполнить запрос protected void Button1_Click(object sender, EventArgs e) { // Создаем объект подключения conn = new OdbcConnection(); // Задаем параметр подключения – имя ODBC-источника conn.ConnectionString = "Dsn=PostgreSQL16"; // Подключаемся к БД conn.Open(); int chislo = 0; bool check; //Проверка введенного числа check = true; if (TextBox2.Text.Length != 0) { if (Int32.TryParse(TextBox2.Text.ToString(), out chislo) == false) { check = false; txtlog.Text = "Введено некорректное число!\n"; } } else { txtlog.Text = "Не введено число!\n"; check = false; } if (check == true) { // Определяем строку с текстом запроса string strSQL = " UPDATE pmib6602.spj1 " + " SET kol = kol + ? " + " WHERE n_spj IN " + " ( " + " SELECT " + " ( " + " SELECT n_spj " + " FROM pmib6602.spj1 " + " WHERE spj1.n_det = q.n_det AND spj1.n_izd = q.n_izd " + " ORDER BY spj1.date_post DESC, CAST(TRIM(LEADING 'N' FROM spj1.n_spj) AS INT) DESC " + " LIMIT 1 " + " ) " + " FROM pmib6602.q " + " WHERE q.n_izd = TRIM(?) " + " ) "; // Создаем объект запроса using (OdbcCommand cmd = new OdbcCommand(strSQL, conn)) { // Создаем первый параметр OdbcParameter par_kol = new OdbcParameter(); par_kol.ParameterName = "@vkolnew"; par_kol.OdbcType = OdbcType.Int; par_kol.Value = chislo; // Добавляем первый параметр в коллекцию cmd.Parameters.Add(par_kol); // Создаем второй параметр OdbcParameter par_izd = new OdbcParameter(); par_izd.ParameterName = "@vn_izd"; par_izd.OdbcType = OdbcType.Text; par_izd.Value = DropDownList1.SelectedValue.ToString(); // Добавляем второй параметр в коллекцию. cmd.Parameters.Add(par_izd); // Объявляем объект транзакции OdbcTransaction tx = null; try { // Начинаем транзакцию и извлекаем объект транзакции из объекта подключения. tx = conn.BeginTransaction(); // Включаем объект SQL-команды в транзакцию cmd.Transaction = tx; // Выполняем SQL-команду и получаем количество обработанных записей int i = cmd.ExecuteNonQuery(); // Подтверждаем транзакцию txtlog.Text += "Транзакция завершена\n"; tx.Commit(); txtlog.Text += "Обработано " + i + " запис(ь/и/ей)\n"; GridView3.Visible = true; } catch (Exception ex) { // При возникновении любой ошибки // Формируем сообщение об ошибке txtlog.Text += "Произошла ошибка...\n"; txtlog.Text += ex.Message; txtlog.Text += "\n"; // выполняем откат транзакции tx.Rollback(); GridView3.Visible = true; } } } // Закрываем соединение conn.Close(); //правую таблицу после запроса всегда обновляем GridView3.EditIndex = -1; GridView3.DataBind(); }
protected void btn_next_Click(object sender, EventArgs e) { int gamr = -1; string strwbNum = string.Empty; string strwbTaxCode = string.Empty; string strwbSupName = string.Empty; string strwbCost = string.Empty; string strwbSupID = string.Empty; string strwbIsSup = string.Empty; string strwbDate = string.Empty; foreach (GridViewRow gvrow in GridView1.Rows) { CheckBox chk = (CheckBox)gvrow.FindControl("wb_chkRow"); if (chk != null & chk.Checked) { string wb_num = (gvrow.Cells[3].FindControl("lbl_wb_num") as Label).Text; string wb_sellerTaxCode = (gvrow.Cells[3].FindControl("lbl_wb_sellerTaxCode") as Label).Text; string wb_sellerName = (gvrow.Cells[3].FindControl("lbl_wb_seller") as Label).Text; string wb_cost = (gvrow.Cells[3].FindControl("lbl_wb_cost") as Label).Text; DateTime wb_date = Convert.ToDateTime((gvrow.Cells[3].FindControl("lbl_wb_date") as Label).Text); strwbNum += wb_num; strwbTaxCode = wb_sellerTaxCode; strwbSupName = wb_sellerName; strwbCost = wb_cost; //get date value strwbDate = wb_date.ToString("yyyy.MM.dd"); } } SqlDataAdapter da0 = new SqlDataAdapter(@"select id, is_supplier, name, taxcode from suppliers where taxcode = '" + strwbTaxCode + "' ", con); DataTable dt0 = new DataTable(); da0.Fill(dt0); for (int i = 0; i < dt0.Rows.Count; i++) { strwbSupID = dt0.Rows[i]["id"].ToString(); strwbIsSup = dt0.Rows[i]["is_supplier"].ToString(); } if (dt0.Rows.Count == 0) { Response.Write("<script type='text/javascript'>alert('აღნიშნული მომწოდებელი ბაზაში არაა რეგისტრირებული, გთხოვთ დაარეგისტრირეთ მომხმარებელი')</script>"); } else { SqlDataAdapter da = new SqlDataAdapter(@"select * from (select products_code, name, unit_name, qty, unit_price, total_price from Grid where waybills_number in('" + strwbNum + "')) T1 INNER JOIN (select Id AS goods_id, name AS goods_name, product_code AS goods_code, suppliers_code from goods) T2 ON (T1.products_code = T2.goods_code OR T1.products_code = T2.suppliers_code OR (T1.products_code = T2.suppliers_code AND T1.name = t2.goods_name));", con); DataTable dt = new DataTable(); da.Fill(dt); GridView3.DataSource = dt; GridView3.DataBind(); GridView1.Visible = false; GridView3.Visible = true; wb_content.Visible = true; lbl_slrName.Text = strwbSupName; lbl_slrId.Text = strwbSupID; lbl_isSupplier.Text = (Convert.ToInt32(strwbIsSup) * Convert.ToInt32(gamr)).ToString(); lbl_wbCost.Text = strwbCost; lbl_wbDate.Text = strwbDate; lbl_wbNumber.Text = strwbNum; ShowPayTypes(); } }
protected void DDLTEMP_SelectedIndexChanged(object sender, EventArgs e) { String vID = Request.QueryString["ID"]; Hashtable vHashtable = new Hashtable(); vHashtable.Add("NAME", DDLTEMP.SelectedItem.Text); DataTable dt = DBManager.Get(vHashtable, "GET_TEMPLATE_NEWID"); if (DDLTEMP.SelectedItem.Text == "Screening") { GridView1.DataSource = dt; GridView1.DataBind(); Hashtable vHashtable1 = new Hashtable(); DataRow vDR1 = RetDR(DBManager.Get(vHashtable1, "TOTAL_SCTP_PRICE")); Hashtable vHashtable5 = new Hashtable(); vHashtable5.Add("NAME", DDLTEMP.SelectedItem.Text); DataTable dt5 = DBManager.Get(vHashtable5, "GET_TEMPLATE_QUANTITY"); DataTable dt6 = new DataTable(); var count = dt5.AsEnumerable().Where(r => r.Field <string>("Price") == "0" && r.Field <string>("Quantity") == "0"); if (count == null) { dt6 = count.CopyToDataTable(); } if (dt6.Rows.Count > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please Buy The Template First....!')", true); } else { } Link.Visible = true; Div1.Visible = false; Div2.Visible = false; Div3.Visible = false; } else if (DDLTEMP.SelectedItem.Text == "Assessment") { GridView2.DataSource = dt; GridView2.DataBind(); Hashtable vHashtable2 = new Hashtable(); DataRow vDR2 = RetDR(DBManager.Get(vHashtable2, "TOTAL_ASE_PRICE")); Hashtable vHashtable5 = new Hashtable(); vHashtable5.Add("NAME", DDLTEMP.SelectedItem.Text); DataTable dt5 = DBManager.Get(vHashtable5, "GET_TEMPLATE_QUANTITY"); DataTable dt6 = new DataTable(); var count = dt5.AsEnumerable().Where(r => r.Field <string>("Price") == "0" && r.Field <string>("Quantity") == "0"); if (count == null) { dt6 = count.CopyToDataTable(); } if (dt6.Rows.Count > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please Buy The Template First....!')", true); } else { } Link.Visible = false; Div1.Visible = true; } else if (DDLTEMP.SelectedItem.Text == "IEP Report") { GridView3.DataSource = dt; GridView3.DataBind(); Hashtable vHashtable3 = new Hashtable(); DataRow vDR3 = RetDR(DBManager.Get(vHashtable3, "TOTAL_IEPDT_PRICE")); Hashtable vHashtable5 = new Hashtable(); vHashtable5.Add("NAME", DDLTEMP.SelectedItem.Text); DataTable dt5 = DBManager.Get(vHashtable5, "GET_TEMPLATE_QUANTITY"); DataTable dt6 = new DataTable(); var count = dt5.AsEnumerable().Where(r => r.Field <string>("Price") == "0" && r.Field <string>("Quantity") == "0"); if (count == null) { dt6 = count.CopyToDataTable(); } if (dt6.Rows.Count > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please Buy The Template First....!')", true); } else { } Div1.Visible = false; Div3.Visible = false; Link.Visible = false; Div2.Visible = true; } else if (DDLTEMP.SelectedItem.Text == "Report Template") { GridView4.DataSource = dt; GridView4.DataBind(); Hashtable vHashtable5 = new Hashtable(); vHashtable5.Add("NAME", DDLTEMP.SelectedItem.Text); DataTable dt5 = DBManager.Get(vHashtable5, "GET_TEMPLATE_QUANTITY"); DataTable dt6 = new DataTable(); var count = dt5.AsEnumerable().Where(r => r.Field <string>("Price") == "0" && r.Field <string>("Quantity") == "0"); if (count == null) { dt6 = count.CopyToDataTable(); } if (dt6.Rows.Count > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please Buy The Template First....!')", true); } else { } Div1.Visible = false; Link.Visible = false; Div2.Visible = false; Div3.Visible = true; } }
protected void btn_go_click(object sender, EventArgs e) { try { DataSet countds = new DataSet(); lblerr.Text = ""; ds.Clear(); string sql = ""; DataTable dt = new DataTable(); DataTable dt1 = new DataTable(); ArrayList arr_staf = new ArrayList(); dt.Columns.Add("SNo", typeof(string)); dt.Columns.Add("User Name", typeof(string)); dt.Columns.Add("Login Date", typeof(string)); dt.Columns.Add("Login Used Count", typeof(string)); dt.Columns.Add("staff_code", typeof(string)); dt1.Columns.Add("S.No", typeof(int)); dt1.Columns.Add("Date", typeof(string)); dt1.Columns.Add("Count", typeof(string)); string fdtime = ""; string tdtime = ""; string dtime = DateTime.Now.ToString("HH:mm:ss"); string firstdate = Convert.ToString(tbstart_date.Text); string seconddate = Convert.ToString(tbend_date.Text); string[] splitdate = firstdate.Split('/'); string[] splitdate2 = seconddate.Split('/'); fdtime = splitdate[2].ToString() + "-" + splitdate[1].ToString() + "-" + splitdate[0].ToString() + " " + "00:00:00"; tdtime = splitdate2[2].ToString() + "-" + splitdate2[1].ToString() + "-" + splitdate2[0].ToString() + " " + dtime; if (ddluser.Items[0].Selected == true) { sql = "SELECT DISTINCT ld.staff_code, count(ld.staff_code) AS count , CONVERT(VARCHAR, cast(ld.dateandtime as date), 101) as date,um.Full_Name,um.Description,ld.flag FROM logindetails ld, UserMaster um where ld.staff_code=um.User_id and ld.dateandtime between '" + fdtime + "' and '" + tdtime + "' and ld.flag='0' GROUP BY ld.staff_code,cast(dateandtime as date),um.Full_Name,um.Description,flag "; } if (ddluser.Items[1].Selected == true) { if (sql == "") { sql = "SELECT DISTINCT ld.staff_code, count(ld.staff_code) AS count , CONVERT(VARCHAR, cast(ld.dateandtime as date), 101) as date,um.Full_Name,um.Description,ld.flag FROM logindetails ld, UserMaster um where ld.staff_code=um.User_id and ld.dateandtime between '" + fdtime + "' and '" + tdtime + "' and um.is_staff='1' and ld.flag='1' GROUP BY ld.staff_code,cast(dateandtime as date),um.Full_Name,um.Description,flag"; } else { sql = sql + " union SELECT DISTINCT ld.staff_code, count(ld.staff_code) AS count , CONVERT(VARCHAR, cast(ld.dateandtime as date), 101) as date,um.Full_Name,um.Description,ld.flag FROM logindetails ld, UserMaster um where ld.staff_code=um.User_id and ld.dateandtime between '" + fdtime + "' and '" + tdtime + "' and um.is_staff='1' and ld.flag='1' GROUP BY ld.staff_code,cast(dateandtime as date),um.Full_Name,um.Description,flag "; } } if (ddluser.Items[2].Selected == true) { if (sql == "") { sql = "SELECT DISTINCT ld.staff_code, count(ld.staff_code) AS count , CONVERT(VARCHAR, cast(ld.dateandtime as date), 101) as date,um.Stud_Name as Full_Name,'' Description,ld.flag FROM logindetails ld, registration um where ld.staff_code=um.Roll_No and ld.dateandtime between '" + fdtime + "' and '" + tdtime + "' and ld.flag='2' GROUP BY ld.staff_code,cast(dateandtime as date),um.Stud_Name,flag "; } else { sql = sql + " union SELECT DISTINCT ld.staff_code, count(ld.staff_code) AS count , CONVERT(VARCHAR, cast(ld.dateandtime as date), 101) as date,um.Stud_Name as Full_Name,'' Description,ld.flag FROM logindetails ld, registration um where ld.staff_code=um.Roll_No and ld.dateandtime between '" + fdtime + "' and '" + tdtime + "' and ld.flag='2' GROUP BY ld.staff_code,cast(dateandtime as date),um.Stud_Name,flag "; } } sql = sql + " order by flag desc;"; sql = sql + ";" + "select DISTINCT staff_code, count(staff_code) AS count , CONVERT(VARCHAR, cast(dateandtime as date), 101) as date from logindetails where dateandtime between '" + fdtime + "' and '" + tdtime + "' GROUP BY staff_code, CONVERT(VARCHAR, cast(dateandtime as date), 101) order by staff_code"; DataView dv_demand_data = new DataView(); ds = da.select_method_wo_parameter(sql, "Text"); int count = 0; int totalval = 0; string gridaddnewrow = ""; for (int d = 0; d < ds.Tables[0].Rows.Count; d++) { ds.Tables[1].DefaultView.RowFilter = "staff_code='" + ds.Tables[0].Rows[d]["staff_code"].ToString() + "'"; dv_demand_data = ds.Tables[1].DefaultView; int count4 = 0; count4 = dv_demand_data.Count; if (!arr_staf.Contains(ds.Tables[0].Rows[d]["staff_code"].ToString())) { arr_staf.Add(ds.Tables[0].Rows[d]["staff_code"].ToString()); if ("admin" == ds.Tables[0].Rows[d]["staff_code"].ToString().Trim().ToLower()) { DataRow dtrow = dt.NewRow(); dtrow[0] = "Admin"; dtrow[1] = "Admin"; dtrow[2] = "Admin"; dtrow[3] = "Admin"; dtrow[4] = "Admin"; dt.Rows.Add(dtrow); } else if ("1" == ds.Tables[0].Rows[d]["flag"].ToString().Trim().ToLower() && "admin" != ds.Tables[0].Rows[d]["staff_code"].ToString().Trim().ToLower() && gridaddnewrow == "") { DataRow dtrow = dt.NewRow(); gridaddnewrow = "1"; dtrow[0] = "Staff"; dtrow[1] = "Staff"; dtrow[2] = "Staff"; dtrow[3] = "Staff"; dtrow[4] = "Staff"; dt.Rows.Add(dtrow); //goto rowaddskip; } else if ("2" == ds.Tables[0].Rows[d]["flag"].ToString().Trim().ToLower() && gridaddnewrow != ds.Tables[0].Rows[d]["staff_code"].ToString() && gridaddnewrow == "1") { DataRow dtrow = dt.NewRow(); gridaddnewrow = "2"; dtrow[0] = "Student"; dtrow[1] = "Student"; dtrow[2] = "Student"; dtrow[3] = "Student"; dtrow[4] = "Student"; dt.Rows.Add(dtrow); // goto rowaddskip; } for (int i = 0; i < count4; i++) // poo 21.12.17 { DataRow dtrow1 = dt.NewRow(); count++; //dtrow1[0] = d + 1; // poo dtrow1[0] = count; // poo dtrow1[1] = ds.Tables[0].Rows[d]["Full_Name"].ToString(); //poo dtrow1[2] = dv_demand_data[i]["date"].ToString(); //poo //dtrow1[2] = ds.Tables[0].Rows[d]["date"].ToString(); //poo totalval = 0; if (count4 > 0) { if (arr_staf.Contains(ds.Tables[0].Rows[d]["staff_code"].ToString())) { //for (int i = 0; i < count4; i++) // poo 21.12.17 //{ //totalval = totalval + Convert.ToInt32(dv_demand_data[i]["count"]); totalval = Convert.ToInt32(dv_demand_data[i]["count"]); //} } } dtrow1[3] = totalval; //dtrow1[4] = dv_demand_data[i]["staff_code"].ToString(); //poo dtrow1[4] = ds.Tables[0].Rows[d]["staff_code"].ToString(); // poo dt.Rows.Add(dtrow1); } } } int a = dt.Rows.Count; if (a == 0) { GridView3.Visible = false; GridView4.Visible = false; lblerr.Visible = true; lblerr.Text = "No Records Found"; } else { lblerr.Text = ""; GridView3.DataSource = dt; GridView3.DataBind(); GridView3.Visible = true; GridView4.Visible = false; } } catch (Exception ex) { lblerr.Text = ex.ToString(); lblerr.Visible = true; } }
protected void Button4_Click(object sender, EventArgs e) { GridView3.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { DataTable TaskMembers; DataTable TaskOnly; string str = ""; if (Session["TaskOnly"] != null) { // Typecasting TaskOnly = (DataTable)Session["TaskOnly"]; } else { TaskOnly = new DataTable(); TaskOnly.Columns.Add("Task ID"); TaskOnly.Columns.Add("Task Details"); TaskOnly.Columns.Add("Task SDate"); TaskOnly.Columns.Add("Task EDate"); TaskOnly.Columns.Add("Task Preq"); } DataRow TaskRow; TaskRow = TaskOnly.NewRow(); TaskRow["Task ID"] = txtProjID.Text + "00" + GridView5.Rows.Count.ToString(); TaskRow["Task Details"] = txtTskDet.Text; TaskRow["Task SDate"] = txtTskSdate.Text; TaskRow["Task EDate"] = txtTskEdate.Text; TaskRow["Task Preq"] = txtTskPrq.Text; TaskOnly.Rows.Add(TaskRow); GridView5.DataSource = TaskOnly; GridView5.DataBind(); Session.Add("TaskOnly", TaskOnly); foreach (GridViewRow r in GridView4.Rows) ////check for checkboxes.. repeat indefinitely { ////Find the checkbox in the current row being pointed named as grdViewCheck CheckBox chk = (CheckBox)r.FindControl("cbSelect"); ////Print the value in the reponse for the cells[1] which is MMBR_PROM_ID if (chk != null && chk.Checked) { if (Session["TaskMembers"] != null) { //// Typecasting TaskMembers = (DataTable)Session["TaskMembers"]; } else { TaskMembers = new DataTable(); TaskMembers.Columns.Add("Task ID"); TaskMembers.Columns.Add("Task Assigned"); TaskMembers.Columns.Add("Task A to ID"); } DataRow MemberRow; MemberRow = TaskMembers.NewRow(); MemberRow["Task ID"] = GridView5.Rows[GridView5.Rows.Count - 1].Cells[0].Text; MemberRow["Task Assigned"] = r.Cells[2].Text + " " + r.Cells[3].Text; MemberRow["Task A to ID"] = r.Cells[1].Text; TaskMembers.Rows.Add(MemberRow); GridView3.DataSource = TaskMembers; GridView3.DataBind(); Session.Add("TaskMembers", TaskMembers); } ////IF-ELSE CHECKBOX END } //// END OF FOREACH LOOP-----------------------------------------------------================================= //http://asp.net-informations.com/gridview/checkbox.htm --------------------------------============================ }
public void ShowGridView3(string dateselected) { string[] avirooms1 = new string[15]; string[] avirooms2 = new string[15]; string[] reservedRooms = new string[15]; MySqlConnection conn3 = new MySqlConnection("Data Source= dcm.uhcl.edu;UserId=c563316su01g2;password=2702365;database=c563316su01g2"); try { conn3.Open(); if (conn3.State == ConnectionState.Open) { conn3.Close(); } conn3.Open(); string query3 = "Select * from room"; MySqlCommand cmd3 = new MySqlCommand(query3, conn3); MySqlDataReader datareader2 = cmd3.ExecuteReader(); int i = 0; while (datareader2.Read()) { string room = datareader2["roomno"].ToString(); var checkin = datareader2["checkindate"]; var checkout = datareader2["checkoutdate"]; if (((checkin is DBNull) && (checkout is DBNull))) { //f = true; avirooms1[i++] = room; } else { DateTime checki = Convert.ToDateTime(datareader2["checkindate"]); if (Calendar1.SelectedDate == checki.Date) { continue; } DateTime check = Convert.ToDateTime(datareader2["checkoutdate"]); if (check.Date <= Calendar1.SelectedDate) { avirooms1[i++] = room; } } } datareader2.Close(); MySqlConnection conn4 = new MySqlConnection("Data Source= dcm.uhcl.edu;UserId=c563316su01g2;password=2702365;database=c563316su01g2"); try { conn4.Open(); if (conn4.State == ConnectionState.Open) { conn4.Close(); } conn4.Open(); MySqlDataReader dr4 = null; MySqlCommand cmd4; int x = 0; for (int j = 0; j < avirooms1.Length; j++) { int flag = 0; string room = avirooms1[j]; if (room != null) { string query4 = "select roomno,checkindate,checkoutdate from reservation where roomno='" + room + "'"; cmd4 = new MySqlCommand(query4, conn4); dr4 = cmd4.ExecuteReader(); if (!dr4.HasRows) { flag = 1; } // avirooms2[x++] = room; else { while (dr4.Read()) { // if (flag == 0) // { var checkin = dr4["checkindate"]; var checkout = dr4["checkoutdate"]; DateTime checki = Convert.ToDateTime(dr4["checkindate"]); DateTime checko = Convert.ToDateTime(dr4["checkoutdate"]); if ((Calendar1.SelectedDate.Date < checki.Date) || (checko.Date <= Calendar1.SelectedDate.Date)) { if (!(reservedRooms.Contains(room))) { // avirooms2[x++] = room; //flag = 1; f = true; } else { //flag = 0; f = false; } } else { //flag = 0; f = false; reservedRooms[w] = room; w = w + 1; } // } } if (f == true) { avirooms2[x++] = room; } } dr4.Close(); } }//for,j } catch (Exception exp) { Response.Write(exp); } finally { conn4.Close(); conn4.Dispose(); MySqlConnection.ClearPool(conn4); } MySqlConnection conn5 = new MySqlConnection("Data Source= dcm.uhcl.edu;UserId=c563316su01g2;password=2702365;database=c563316su01g2"); try { conn5.Open(); if (conn5.State == ConnectionState.Open) { conn5.Close(); } conn5.Open(); MySqlDataAdapter sa3 = new MySqlDataAdapter(); DataTable dt5 = new DataTable(); for (int k = 0; k < avirooms2.Length; k++) { string room = avirooms2[k]; string query5 = "select roomno,roomtype from room where roomno='" + room + "'"; MySqlCommand cmd5 = new MySqlCommand(query5, conn5); cmd5.CommandType = CommandType.Text; sa3.SelectCommand = cmd5; sa3.Fill(dt5); Session["array"] = avirooms2; }//for,k if (dt5 != null && dt5.Rows.Count > 0) { GridView3.Visible = true; GridView3.DataSource = dt5; GridView3.DataBind(); }//if else { DataTable d = new DataTable(); d = null; GridView3.DataSource = d; GridView3.DataBind(); } } catch (Exception exp) { Response.Write(exp); } finally { conn5.Close(); conn5.Dispose(); MySqlConnection.ClearPool(conn5); } } catch (Exception exp) { Response.Write(exp); } finally { conn3.Close(); conn3.Dispose(); MySqlConnection.ClearPool(conn3); } }
private void Bindgrid3() { GridView3.DataSource = lpp.Query_ProType(TextBox1.Text, TextBox2.Text); GridView3.DataBind(); }
protected void ChooseProType_Click(object sender, EventArgs e) { Panel1.Visible = true; GridView3.DataSource = lpp.Query_ProType(TextBox1.Text, TextBox2.Text); GridView3.DataBind(); }
protected void searchprotype_Click(object sender, EventArgs e) { GridView3.DataSource = lpp.Query_ProType(TextBox1.Text, TextBox2.Text); GridView3.DataBind(); }
protected void GridView3_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView3.PageIndex = e.NewPageIndex; GridView3.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { //count total transcation of area for reason con.Open(); SqlCommand da1 = new SqlCommand("SELECT top 15 Temperature FROM [dataset] where name='" + DropDownList1.Text + "'", con); SqlDataReader dt1 = da1.ExecuteReader(); if (dt1.HasRows) { GridView1.DataSource = dt1; GridView1.DataBind(); } con.Close(); con.Open(); SqlCommand da = new SqlCommand("select top 5 Temperature from [dataset] where [name]='" + DropDownList1.Text + "' ", con); SqlDataReader dr = da.ExecuteReader(); while (dr.Read()) { string productname = dr[0].ToString(); top += productname + ","; txtvalue.Text = top.TrimEnd(','); } txtvalue.Text.TrimEnd(','); con.Close(); DataTable dt = new DataTable(); con.Open(); SqlCommand cmd1 = new SqlCommand("select top 5 name,Temperature from [dataset] where [name]='" + DropDownList1.Text + "' ", con); SqlDataAdapter sda = new SqlDataAdapter(cmd1); sda.Fill(dt); con.Close(); string[] x = new string[dt.Rows.Count]; int[] y = new int[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { x[i] = dt.Rows[i][0].ToString(); y[i] = Convert.ToInt32(dt.Rows[i][1]); } Chart1.Series[0].Points.DataBindXY(x, y); ForecastTable dt10 = TimeSeries.naive(GetInputforshirt(), 1, 6); GridView2.DataSource = dt10; GridView2.DataBind(); ForecastTable dt11 = TimeSeries.weightedMovingAverage(GetInputforshirt(), 1, (Decimal)0.05, (Decimal)0.15, (Decimal)0.8); GridView3.DataSource = dt11; GridView3.DataBind(); ForecastTable dt12 = TimeSeries.wellsweilderMovingaverage(GetInputforshirt(), 1, 2, 2); GridView6.DataSource = dt12; GridView6.DataBind(); con.Open(); SqlCommand da12 = new SqlCommand("select top 5 PulseRate from [dataset] where [name]='" + DropDownList1.Text + "' ", con); SqlDataReader dr1 = da12.ExecuteReader(); while (dr1.Read()) { string productname = dr1[0].ToString(); top1 += productname + ","; txtheartbeat.Text = top1.TrimEnd(','); } txtheartbeat.Text.TrimEnd(','); con.Close(); DataTable dt2 = new DataTable(); con.Open(); SqlCommand cmd2 = new SqlCommand("select top 5 name,PulseRate from [dataset] where [name]='" + DropDownList1.Text + "' ", con); SqlDataAdapter sda2 = new SqlDataAdapter(cmd2); sda2.Fill(dt2); con.Close(); ForecastTable dt102 = TimeSeries.naive(GetInputforheartbeat(), 1, 6); GridView4.DataSource = dt102; GridView4.DataBind(); ForecastTable dt112 = TimeSeries.weightedMovingAverage(GetInputforheartbeat(), 1, (Decimal)0.05, (Decimal)0.15, (Decimal)0.8); GridView5.DataSource = dt112; GridView5.DataBind(); foreach (GridViewRow row in GridView4.Rows) { string val = GridView3.Rows[5].Cells[2].Text; // Label2.Text = "Upcoming Of State:" + ddlarea.Text + "of crime:" + DropDownList1.Text + val; } }
/*public void GridViewBind() * { * EMPLOYEE_NO = Request.QueryString["EMPLOYEE_NO"]; * DEPARTMENT_NO = Request.QueryString["DEP_NO"]; * HRMANAGER = Request.QueryString["HRMNG"]; * GMANAGER = Request.QueryString["GM"]; * * SINMANAGER = Request.QueryString["SMNG"]; * FINANCEADMIN = Request.QueryString["FINADMIN"]; * * if (HRMANAGER == EMPLOYEE_NO) * { * No = 1; * //Response.Write(No); * } * else * if (GMANAGER == EMPLOYEE_NO) * { * No = 2; * //Response.Write(No); * } * else * * * if (SINMANAGER == EMPLOYEE_NO) * { * No = 2; * } * else * if (FINANCEADMIN == EMPLOYEE_NO) * { * No = 2; * } * * switch (No) * { * case 1: * dadapter = new OdbcDataAdapter("SELECT RECRUITMENT_FORM.RF_NO, RECRUITMENT_FORM.MNG_CREATER, DEPARTMENTS.DEP_NAME, "+ * "RECRUITMENT_FORM.POSITION_JUSTIFICATION, RECRUITMENT_FORM.NO_OF_CANDIDATE, RECRUITMENT_FORM.RF_DATE, "+ * "RECRUITMENT_FORM.SINGLE_JUSTIFICATION, DECODE(RECRUITMENT_FORM.RF_TYPE, 1, 'Permanent', 2, 'Temporary')RF_TYPE " + * "FROM RECRUITMENT_FORM, "+ * "DEPARTMENTS WHERE FORM_STATUS = '1' "+ * "AND RECRUITMENT_FORM.DEP_NO = DEPARTMENTS.DEP_NO", connectionString); * * dset = new DataSet(); * dadapter.Fill(dset); * GridView1.DataSource = dset.Tables[0]; * GridView1.DataBind(); * * RadioButtonList1.Items.Add(new ListItem("Approve", "2")); * RadioButtonList1.Items.Add(new ListItem("Reject", "3")); * break; * case 2: * dadapter = new OdbcDataAdapter("SELECT RECRUITMENT_FORM.RF_NO, RECRUITMENT_FORM.MNG_CREATER, DEPARTMENTS.DEP_NAME, " + * "RECRUITMENT_FORM.POSITION_JUSTIFICATION, RECRUITMENT_FORM.NO_OF_CANDIDATE, RECRUITMENT_FORM.RF_DATE, " + * "RECRUITMENT_FORM.SINGLE_JUSTIFICATION, DECODE(RECRUITMENT_FORM.RF_TYPE, 1, 'Permanent', 2, 'Temporary')RF_TYPE " + * "FROM RECRUITMENT_FORM, " + * "DEPARTMENTS WHERE FORM_STATUS = '2' " + * "AND RECRUITMENT_FORM.DEP_NO = DEPARTMENTS.DEP_NO", connectionString); * * dset = new DataSet(); * dadapter.Fill(dset); * GridView1.DataSource = dset.Tables[0]; * GridView1.DataBind(); * * RadioButtonList1.Items.Add(new ListItem("Approve", "4")); * RadioButtonList1.Items.Add(new ListItem("Reject", "5")); * break; * default: * Label_Message.Text = "There are no Requests..."; * break; * } * }*/ //1 /*public void GridViewBind() * { * EMPLOYEE_NO = Request.QueryString["EMPLOYEE_NO"]; * DEPARTMENT_NO = Request.QueryString["DEP_NO"]; * HRMANAGER = Request.QueryString["HRMNG"]; * GMANAGER = Request.QueryString["GM"]; * * SINMANAGER = Request.QueryString["SMNG"]; * FINANCEADMIN = Request.QueryString["FINADMIN"]; * * if (HRMANAGER == EMPLOYEE_NO) * { * No = 1; //3 * //Response.Write(No); * } * else * if (SINMANAGER == EMPLOYEE_NO) * { * No = 3; //2 * } * //else * if (GMANAGER == EMPLOYEE_NO) * { * No = 2; //5 * //Response.Write(No); * } * else * if (FINANCEADMIN == EMPLOYEE_NO) * { * No = 4; //4 * } * * switch (No) * { * case 1: // HR MANAGER 3 * dadapter = new OdbcDataAdapter("SELECT DISTINCT RECRUITMENT_FORM.RF_NO, RECRUITMENT_FORM.MNG_CREATER, DEPARTMENTS.DEP_NAME, " + * "RECRUITMENT_FORM.POSITION_JUSTIFICATION, RECRUITMENT_FORM.NO_OF_CANDIDATE, RECRUITMENT_FORM.RF_DATE, " + * "RECRUITMENT_FORM.SINGLE_JUSTIFICATION, DECODE(RECRUITMENT_FORM.RF_TYPE, 1, 'Permanent', 2, 'Temporary')RF_TYPE " + * "FROM RECRUITMENT_FORM, DEPARTMENTS WHERE RECRUITMENT_FORM.FORM_STATUS = '2' " + * "AND RECRUITMENT_FORM.DEP_NO = DEPARTMENTS.DEP_NO", connectionString); * * dset = new DataSet(); * dadapter.Fill(dset); * GridView1.DataSource = dset.Tables[0]; * GridView1.DataBind(); * * RadioButtonList1.Items.Add(new ListItem("Approve", "4")); * RadioButtonList1.Items.Add(new ListItem("Reject", "5")); * break; * case 2: //G MANAGER 5 * dadapter = new OdbcDataAdapter("SELECT DISTINCT RECRUITMENT_FORM.RF_NO, RECRUITMENT_FORM.MNG_CREATER, DEPARTMENTS.DEP_NAME, " + * "RECRUITMENT_FORM.POSITION_JUSTIFICATION, RECRUITMENT_FORM.NO_OF_CANDIDATE, RECRUITMENT_FORM.RF_DATE, " + * "RECRUITMENT_FORM.SINGLE_JUSTIFICATION, DECODE(RECRUITMENT_FORM.RF_TYPE, 1, 'Permanent', 2, 'Temporary')RF_TYPE " + * "FROM RECRUITMENT_FORM, DEPARTMENTS WHERE RECRUITMENT_FORM.FORM_STATUS = '6' " + * "AND RECRUITMENT_FORM.DEP_NO = DEPARTMENTS.DEP_NO", connectionString); * * dset2 = new DataSet(); * dadapter.Fill(dset2); * GridView3.DataSource = dset2.Tables[0]; * GridView3.DataBind(); * * RadioButtonList1.Items.Add(new ListItem("Approve", "8")); * RadioButtonList1.Items.Add(new ListItem("Reject", "9")); * break; * case 3: //SIN MANAGER (NEW) 2 * dadapter = new OdbcDataAdapter("SELECT DISTINCT RECRUITMENT_FORM.RF_NO, RECRUITMENT_FORM.MNG_CREATER, DEPARTMENTS.DEP_NAME, " + * "RECRUITMENT_FORM.POSITION_JUSTIFICATION, RECRUITMENT_FORM.NO_OF_CANDIDATE, RECRUITMENT_FORM.RF_DATE, " + * "RECRUITMENT_FORM.SINGLE_JUSTIFICATION, DECODE(RECRUITMENT_FORM.RF_TYPE, 1, 'Permanent', 2, 'Temporary')RF_TYPE " + * "FROM RECRUITMENT_FORM, DEPARTMENTS, EMPLOYEES WHERE RECRUITMENT_FORM.FORM_STATUS = '1' " + * "AND RECRUITMENT_FORM.DEP_NO = DEPARTMENTS.DEP_NO "+ * "AND RECRUITMENT_FORM.MNG_CREATER IN (SELECT MNG FROM EMP_MNG WHERE SMNG = '"+ SINMANAGER +"') ", connectionString); * * dset = new DataSet(); * dadapter.Fill(dset); * GridView1.DataSource = dset.Tables[0]; * GridView1.DataBind(); * * RadioButtonList1.Items.Add(new ListItem("Approve", "2")); * RadioButtonList1.Items.Add(new ListItem("Reject", "3")); * break; * case 4: //FINANCE ADMIN (NEW) 4 * dadapter = new OdbcDataAdapter("SELECT DISTINCT RECRUITMENT_FORM.RF_NO, RECRUITMENT_FORM.MNG_CREATER, DEPARTMENTS.DEP_NAME, " + * "RECRUITMENT_FORM.POSITION_JUSTIFICATION, RECRUITMENT_FORM.NO_OF_CANDIDATE, RECRUITMENT_FORM.RF_DATE, " + * "RECRUITMENT_FORM.SINGLE_JUSTIFICATION, DECODE(RECRUITMENT_FORM.RF_TYPE, 1, 'Permanent', 2, 'Temporary')RF_TYPE " + * "FROM RECRUITMENT_FORM, DEPARTMENTS WHERE RECRUITMENT_FORM.FORM_STATUS = '4' " + * "AND RECRUITMENT_FORM.DEP_NO = DEPARTMENTS.DEP_NO", connectionString); * * dset2 = new DataSet(); * dadapter.Fill(dset2); * GridView3.DataSource = dset2.Tables[0]; * GridView3.DataBind(); * * RadioButtonList1.Items.Add(new ListItem("Approve", "6")); * RadioButtonList1.Items.Add(new ListItem("Reject", "7")); * break; * default: * Label_Message.Text = "You aren't Authorized to See this Contents...";//"There are no Requests..."; * break; * } * }*/ //2 /* public void GridViewBind() * { * EMPLOYEE_NO = Request.QueryString["EMPLOYEE_NO"]; * DEPARTMENT_NO = Request.QueryString["DEP_NO"]; * HRMANAGER = Request.QueryString["HRMNG"]; * GMANAGER = Request.QueryString["GM"]; * * SINMANAGER = Request.QueryString["SMNG"]; * FINANCEADMIN = Request.QueryString["FINADMIN"]; * * if (HRMANAGER == EMPLOYEE_NO) * { * No = 1; //3 * //Response.Write(No); * dadapter = new OdbcDataAdapter("SELECT DISTINCT RECRUITMENT_FORM.RF_NO, RECRUITMENT_FORM.MNG_CREATER, DEPARTMENTS.DEP_NAME, " + * "RECRUITMENT_FORM.POSITION_JUSTIFICATION, RECRUITMENT_FORM.NO_OF_CANDIDATE, RECRUITMENT_FORM.RF_DATE, " + * "RECRUITMENT_FORM.SINGLE_JUSTIFICATION, DECODE(RECRUITMENT_FORM.RF_TYPE, 1, 'Permanent', 2, 'Temporary')RF_TYPE " + * "FROM RECRUITMENT_FORM, DEPARTMENTS WHERE RECRUITMENT_FORM.FORM_STATUS = '2' " + * "AND RECRUITMENT_FORM.DEP_NO = DEPARTMENTS.DEP_NO", connectionString); * * dset = new DataSet(); * dadapter.Fill(dset); * GridView1.DataSource = dset.Tables[0]; * GridView1.DataBind(); * * RadioButtonList1.Items.Clear(); * RadioButtonList1.Items.Add(new ListItem("Approve", "4")); * RadioButtonList1.Items.Add(new ListItem("Reject", "5")); * } * else * if (SINMANAGER == EMPLOYEE_NO) * { * No = 3; //2 * dadapter = new OdbcDataAdapter("SELECT DISTINCT RECRUITMENT_FORM.RF_NO, RECRUITMENT_FORM.MNG_CREATER, DEPARTMENTS.DEP_NAME, " + * "RECRUITMENT_FORM.POSITION_JUSTIFICATION, RECRUITMENT_FORM.NO_OF_CANDIDATE, RECRUITMENT_FORM.RF_DATE, " + * "RECRUITMENT_FORM.SINGLE_JUSTIFICATION, DECODE(RECRUITMENT_FORM.RF_TYPE, 1, 'Permanent', 2, 'Temporary')RF_TYPE " + * "FROM RECRUITMENT_FORM, DEPARTMENTS, EMPLOYEES WHERE RECRUITMENT_FORM.FORM_STATUS = '1' " + * "AND RECRUITMENT_FORM.DEP_NO = DEPARTMENTS.DEP_NO " + * "AND RECRUITMENT_FORM.MNG_CREATER IN (SELECT MNG FROM EMP_MNG WHERE SMNG = '" + SINMANAGER + "') ", connectionString); * * dset = new DataSet(); * dadapter.Fill(dset); * GridView1.DataSource = dset.Tables[0]; * GridView1.DataBind(); * * RadioButtonList1.Items.Clear(); * RadioButtonList1.Items.Add(new ListItem("Approve", "2")); * RadioButtonList1.Items.Add(new ListItem("Reject", "3")); * } * //else * if (GMANAGER == EMPLOYEE_NO) * { * No = 2; //5 * //Response.Write(No); * dadapter = new OdbcDataAdapter("SELECT DISTINCT RECRUITMENT_FORM.RF_NO, RECRUITMENT_FORM.MNG_CREATER, DEPARTMENTS.DEP_NAME, " + * "RECRUITMENT_FORM.POSITION_JUSTIFICATION, RECRUITMENT_FORM.NO_OF_CANDIDATE, RECRUITMENT_FORM.RF_DATE, " + * "RECRUITMENT_FORM.SINGLE_JUSTIFICATION, DECODE(RECRUITMENT_FORM.RF_TYPE, 1, 'Permanent', 2, 'Temporary')RF_TYPE " + * "FROM RECRUITMENT_FORM, DEPARTMENTS WHERE RECRUITMENT_FORM.FORM_STATUS = '6' " + * "AND RECRUITMENT_FORM.DEP_NO = DEPARTMENTS.DEP_NO", connectionString); * * dset2 = new DataSet(); * dadapter.Fill(dset2); * GridView3.DataSource = dset2.Tables[0]; * GridView3.DataBind(); * * RadioButtonList2.Items.Clear(); * RadioButtonList2.Items.Add(new ListItem("Approve", "8")); * RadioButtonList2.Items.Add(new ListItem("Reject", "9")); * } * else * if (FINANCEADMIN == EMPLOYEE_NO) * { * No = 4; //4 * dadapter = new OdbcDataAdapter("SELECT DISTINCT RECRUITMENT_FORM.RF_NO, RECRUITMENT_FORM.MNG_CREATER, DEPARTMENTS.DEP_NAME, " + * "RECRUITMENT_FORM.POSITION_JUSTIFICATION, RECRUITMENT_FORM.NO_OF_CANDIDATE, RECRUITMENT_FORM.RF_DATE, " + * "RECRUITMENT_FORM.SINGLE_JUSTIFICATION, DECODE(RECRUITMENT_FORM.RF_TYPE, 1, 'Permanent', 2, 'Temporary')RF_TYPE " + * "FROM RECRUITMENT_FORM, DEPARTMENTS WHERE RECRUITMENT_FORM.FORM_STATUS = '4' " + * "AND RECRUITMENT_FORM.DEP_NO = DEPARTMENTS.DEP_NO", connectionString); * * dset2 = new DataSet(); * dadapter.Fill(dset2); * GridView3.DataSource = dset2.Tables[0]; * GridView3.DataBind(); * * RadioButtonList2.Items.Clear(); * RadioButtonList2.Items.Add(new ListItem("Approve", "6")); * RadioButtonList2.Items.Add(new ListItem("Reject", "7")); * } * }*/ //3 public void GridViewBind() { EMPLOYEE_NO = Request.QueryString["EMPLOYEE_NO"]; DEPARTMENT_NO = Request.QueryString["DEP_NO"]; HRMANAGER = Request.QueryString["HRMNG"]; GMANAGER = Request.QueryString["GM"]; SINMANAGER = Request.QueryString["SMNG"]; FINANCEADMIN = Request.QueryString["FINADMIN"]; if (SINMANAGER == EMPLOYEE_NO) { No = 3; //2 dadapter = new OdbcDataAdapter("SELECT DISTINCT RECRUITMENT_FORM.RF_NO, RECRUITMENT_FORM.MNG_CREATER, DEPARTMENTS.DEP_NAME, " + "RECRUITMENT_FORM.POSITION_JUSTIFICATION, RECRUITMENT_FORM.NO_OF_CANDIDATE, RECRUITMENT_FORM.RF_DATE, " + "RECRUITMENT_FORM.SINGLE_JUSTIFICATION, DECODE(RECRUITMENT_FORM.RF_TYPE, 1, 'Permanent', 2, 'Temporary')RF_TYPE " + "FROM RECRUITMENT_FORM, DEPARTMENTS, EMPLOYEES WHERE RECRUITMENT_FORM.FORM_STATUS = '1' " + "AND RECRUITMENT_FORM.DEP_NO = DEPARTMENTS.DEP_NO " + "AND RECRUITMENT_FORM.MNG_CREATER IN (SELECT MNG FROM EMP_MNG WHERE SMNG = '" + SINMANAGER + "') ", connectionString); dset = new DataSet(); dadapter.Fill(dset); GridView1.DataSource = dset.Tables[0]; GridView1.DataBind(); RadioButtonList1.Items.Clear(); RadioButtonList1.Items.Add(new ListItem("Approve", "2")); RadioButtonList1.Items.Add(new ListItem("Reject", "3")); } else if (HRMANAGER == EMPLOYEE_NO) { No = 1; //3 dadapter = new OdbcDataAdapter("SELECT DISTINCT RECRUITMENT_FORM.RF_NO, RECRUITMENT_FORM.MNG_CREATER, DEPARTMENTS.DEP_NAME, " + "RECRUITMENT_FORM.POSITION_JUSTIFICATION, RECRUITMENT_FORM.NO_OF_CANDIDATE, RECRUITMENT_FORM.RF_DATE, " + "RECRUITMENT_FORM.SINGLE_JUSTIFICATION, DECODE(RECRUITMENT_FORM.RF_TYPE, 1, 'Permanent', 2, 'Temporary')RF_TYPE " + "FROM RECRUITMENT_FORM, DEPARTMENTS WHERE RECRUITMENT_FORM.FORM_STATUS = '2' " + "AND RECRUITMENT_FORM.DEP_NO = DEPARTMENTS.DEP_NO", connectionString); dset = new DataSet(); dadapter.Fill(dset); GridView1.DataSource = dset.Tables[0]; GridView1.DataBind(); RadioButtonList1.Items.Clear(); RadioButtonList1.Items.Add(new ListItem("Approve", "4")); RadioButtonList1.Items.Add(new ListItem("Reject", "5")); } if (FINANCEADMIN == EMPLOYEE_NO) { No = 4; //4 dadapter = new OdbcDataAdapter("SELECT DISTINCT RECRUITMENT_FORM.RF_NO, RECRUITMENT_FORM.MNG_CREATER, DEPARTMENTS.DEP_NAME, " + "RECRUITMENT_FORM.POSITION_JUSTIFICATION, RECRUITMENT_FORM.NO_OF_CANDIDATE, RECRUITMENT_FORM.RF_DATE, " + "RECRUITMENT_FORM.SINGLE_JUSTIFICATION, DECODE(RECRUITMENT_FORM.RF_TYPE, 1, 'Permanent', 2, 'Temporary')RF_TYPE " + "FROM RECRUITMENT_FORM, DEPARTMENTS WHERE RECRUITMENT_FORM.FORM_STATUS = '4' " + "AND RECRUITMENT_FORM.DEP_NO = DEPARTMENTS.DEP_NO", connectionString); dset2 = new DataSet(); dadapter.Fill(dset2); GridView3.DataSource = dset2.Tables[0]; GridView3.DataBind(); RadioButtonList2.Items.Clear(); RadioButtonList2.Items.Add(new ListItem("Approve", "6")); RadioButtonList2.Items.Add(new ListItem("Reject", "7")); } else if (GMANAGER == EMPLOYEE_NO) { No = 2; //5 //Response.Write(No); dadapter = new OdbcDataAdapter("SELECT DISTINCT RECRUITMENT_FORM.RF_NO, RECRUITMENT_FORM.MNG_CREATER, DEPARTMENTS.DEP_NAME, " + "RECRUITMENT_FORM.POSITION_JUSTIFICATION, RECRUITMENT_FORM.NO_OF_CANDIDATE, RECRUITMENT_FORM.RF_DATE, " + "RECRUITMENT_FORM.SINGLE_JUSTIFICATION, DECODE(RECRUITMENT_FORM.RF_TYPE, 1, 'Permanent', 2, 'Temporary')RF_TYPE " + "FROM RECRUITMENT_FORM, DEPARTMENTS WHERE RECRUITMENT_FORM.FORM_STATUS = '6' " + "AND RECRUITMENT_FORM.DEP_NO = DEPARTMENTS.DEP_NO", connectionString); dset2 = new DataSet(); dadapter.Fill(dset2); GridView3.DataSource = dset2.Tables[0]; GridView3.DataBind(); RadioButtonList2.Items.Clear(); RadioButtonList2.Items.Add(new ListItem("Approve", "8")); RadioButtonList2.Items.Add(new ListItem("Reject", "9")); } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { if (Session["Logged"] == null || Session["Logged"].ToString() == "None") { Response.Redirect("HomePage.aspx"); } if (Session["Logged"].ToString() == "Admin") { TextBox1.Visible = true; TextBox2.Visible = true; TextBox3.Visible = true; TextBox4.Visible = true; TextBox5.Visible = true; TextBox6.Visible = true; TextBox7.Visible = true; TextBox8.Visible = true; TextBox9.Visible = true; TextBox10.Visible = true; buttonInsert.Visible = true; TextBoxArrival.Visible = true; TextBoxBusOperator.Visible = true; TextBoxDeparture.Visible = true; TextBoxPrice.Visible = true; TextBoxDestination.Visible = true; TextBoxSeatsInsert.Visible = true; TextBoxSource.Visible = true; TextBoxSleeperType.Visible = true; TextBoxACType.Visible = true; GridView1.Visible = false; GridView2.Visible = true; GridView3.Visible = true; string sqlcmd = "SELECT * FROM Bookings"; SqlConnection con = new SqlConnection(cons); SqlDataAdapter ad = new SqlDataAdapter(sqlcmd, con); DataSet ds = new DataSet(); con.Open(); ad.Fill(ds); GridView2.DataSource = ds; GridView2.DataBind(); GridView3.DataBind(); con.Close(); } else { TextBox1.Visible = false; TextBox2.Visible = false; TextBox3.Visible = false; TextBox4.Visible = false; TextBox5.Visible = false; TextBox6.Visible = false; TextBox7.Visible = false; TextBox8.Visible = false; TextBox9.Visible = false; TextBox10.Visible = false; buttonInsert.Visible = false; TextBoxArrival.Visible = false; TextBoxBusOperator.Visible = false; TextBoxDeparture.Visible = false; TextBoxPrice.Visible = false; TextBoxDestination.Visible = false; TextBoxSeatsInsert.Visible = false; TextBoxSource.Visible = false; TextBoxSleeperType.Visible = false; TextBoxACType.Visible = false; GridView2.Visible = false; GridView3.Visible = false; GridView1.Visible = true; string sqlcmd = "SELECT Bookings.Id, Routes.Source, Routes.Destination, Routes.Departure, " + "Routes.Arrival, Routes.Price, Routes.BusOperator, Bookings.Seats, Routes.ACType, Routes.SleeperType " + "FROM Bookings INNER JOIN Routes ON Routes.Id = Bookings.RouteId WHERE Bookings.Username = '******'"; SqlConnection con = new SqlConnection(cons); SqlDataAdapter ad = new SqlDataAdapter(sqlcmd, con); DataSet ds = new DataSet(); con.Open(); ad.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); con.Close(); } SortDirection1 = "ASC"; SortDirection2 = "ASC"; } }
protected void btthongke2_Click1(object sender, EventArgs e) { GridView3.DataSource = bao_bus.getVendorNull(); GridView3.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if ((string)Session["user"] != null) { } else { Response.Redirect("Index2.aspx"); } decimal a1, a2, a4, a3; SqlConnection conn; //SqlDataAdapter da; // DataSet ds = new DataSet(); SqlCommand cmd = new SqlCommand(); SqlDataReader sr, sr1; string constr = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; conn = new SqlConnection(constr); cmd.Connection = conn; cmd.CommandText = "select total_items,laundry_money,laundry_date from Laundry where user_id= @user1 and laundry_status=@status"; cmd.Parameters.AddWithValue("@user1", (string)Session["user"]); cmd.Parameters.AddWithValue("@status", "unpaid"); conn.Open(); sr = cmd.ExecuteReader(); GridView1.DataSource = sr; GridView1.DataBind(); if (!sr.HasRows) { a1 = 0; Label2.Text = 0.ToString() + "/-Rs"; sr.Close(); conn.Close(); } else { // conn.Open(); sr.Close(); cmd.CommandText = "select sum(laundry_money) as money from Laundry where user_id=@user2 "; cmd.Parameters.AddWithValue("@user2", (string)Session["user"]); sr = cmd.ExecuteReader(); sr.Read(); //a1 = 0; // a1 = (int)sr["money"]; // else //{ Label2.Text = sr["money"].ToString() + "/-Rs"; a1 = (decimal)sr["money"]; //} sr.Close(); conn.Close(); } conn.Open(); cmd.CommandText = "select x.item_name,x.item_money,y.quantity,y.canteen_date from Canteen x inner join User_Canteen y on x.item_id =y.item_id where user_id=@user3 and y.canteen_status=@status1"; cmd.Parameters.AddWithValue("@user3", (string)Session["user"]); cmd.Parameters.AddWithValue("@status1", "unpaid"); sr = cmd.ExecuteReader(); GridView5.DataSource = sr; GridView5.DataBind(); if (!sr.HasRows) { a2 = 0; Label6.Text = 0.ToString() + "/-Rs"; sr.Close(); conn.Close(); } else { // conn.Open(); sr.Close(); cmd.CommandText = "select sum(x.item_money * y.quantity) as money from Canteen x inner join User_Canteen y on x.item_id =y.item_id where user_id=@user4 "; cmd.Parameters.AddWithValue("@user4", (string)Session["user"]); sr = cmd.ExecuteReader(); sr.Read(); //a1 = 0; // a1 = (int)sr["money"]; // else // { Label6.Text = sr["money"].ToString() + "/-Rs"; a2 = (decimal)sr["money"]; //} sr.Close(); conn.Close(); } conn.Open(); cmd.CommandText = "select penalty_subject,penalty_descrip,penalty_money,penalty_date from Penalty where user_id= @user5 and penalty_status=@status2"; cmd.Parameters.AddWithValue("@user5", (string)Session["user"]); cmd.Parameters.AddWithValue("@status2", "unpaid"); sr = cmd.ExecuteReader(); GridView2.DataSource = sr; GridView2.DataBind(); if (!sr.HasRows) { a3 = 0; Label4.Text = 0.ToString() + "/-Rs"; sr.Close(); conn.Close(); } else { // conn.Close(); // conn.Open(); sr.Close(); cmd.CommandText = "select sum(penalty_money) as money from Penalty where user_id=@user6 "; cmd.Parameters.AddWithValue("@user6", (string)Session["user"]); sr = cmd.ExecuteReader(); sr.Read(); //a1 = 0; // a1 = (int)sr["money"]; // else //{ // Label17.Text = "here"; Label4.Text = sr["money"].ToString() + "/-Rs"; a3 = (decimal)sr["money"]; //} sr.Close(); conn.Close(); } conn.Open(); cmd.CommandText = "select expense_descrip,expense_money,expense_date from Expense where user_id=@user7 and expense_status=@status3"; cmd.Parameters.AddWithValue("@user7", (string)Session["user"]); cmd.Parameters.AddWithValue("@status3", "unpaid"); sr = cmd.ExecuteReader(); GridView3.DataSource = sr; GridView3.DataBind(); if (!sr.HasRows) { a4 = 0; Label8.Text = 0.ToString() + "/-Rs"; sr.Close(); conn.Close(); } else { // conn.Open(); sr.Close(); cmd.CommandText = "select sum(expense_money) as money from Expense where user_id=@user8 "; cmd.Parameters.AddWithValue("@user8", (string)Session["user"]); sr = cmd.ExecuteReader(); sr.Read(); //a1 = 0; // a1 = (int)sr["money"]; // else //{ Label8.Text = sr["money"].ToString() + "/-Rs"; a4 = (decimal)sr["money"]; //} sr.Close(); conn.Close(); } decimal a = a1 + a2 + a3 + a4; // int a = Int32.Parse(Label2.Text) + Int32.Parse(Label4.Text) + Int32.Parse(Label6.Text) + Int32.Parse(Label8.Text); Label10.Text = a.ToString() + "/- Rs"; Label11.Text = "Pay your Expenses Regularly on first day of next Month to avoid Penalty "; Label11.ForeColor = System.Drawing.Color.Firebrick; }
//初始化试卷,从数据库中将试题取出 protected void InitData() { DataBase DB = new DataBase(); int paperID = int.Parse(Session["PaperID"].ToString()); SqlParameter[] Params1 = new SqlParameter[2]; Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选题"); //题目类型 DataSet ds1 = DB.GetDataSet("Proc_PaperDetailmr", Params1); if (ds1.Tables[0].Rows.Count > 0) //判断下是否有单选题 { GridView1.DataSource = ds1; GridView1.DataBind(); ((Label)GridView1.HeaderRow.FindControl("Label27")).Text = ((Label)GridView1.Rows[0].FindControl("Label4")).Text; } SqlParameter[] Params2 = new SqlParameter[2]; Params2[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params2[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "多选题"); //题目类型 DataSet ds2 = DB.GetDataSet("Proc_PaperDetailmr", Params2); if (ds2.Tables[0].Rows.Count > 0) { GridView2.DataSource = ds2; GridView2.DataBind(); ((Label)GridView2.HeaderRow.FindControl("Label28")).Text = ((Label)GridView2.Rows[0].FindControl("Label8")).Text; } SqlParameter[] Params3 = new SqlParameter[2]; Params3[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params3[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "判断题"); //题目类型 DataSet ds3 = DB.GetDataSet("Proc_PaperDetailmr", Params3); if (ds3.Tables[0].Rows.Count > 0) { GridView3.DataSource = ds3; GridView3.DataBind(); ((Label)GridView3.HeaderRow.FindControl("Label29")).Text = ((Label)GridView3.Rows[0].FindControl("Label12")).Text; } SqlParameter[] Params4 = new SqlParameter[2]; Params4[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params4[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "填空题"); //题目类型 DataSet ds4 = DB.GetDataSet("Proc_PaperDetailmr", Params4); if (ds4.Tables[0].Rows.Count > 0) { GridView4.DataSource = ds4; GridView4.DataBind(); ((Label)GridView4.HeaderRow.FindControl("Label45")).Text = ((Label)GridView4.Rows[0].FindControl("Label17")).Text; } SqlParameter[] Params5 = new SqlParameter[2]; Params5[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params5[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "问答题"); //题目类型 DataSet ds5 = DB.GetDataSet("Proc_PaperDetailmr", Params5); if (ds5.Tables[0].Rows.Count > 0) { GridView5.DataSource = ds5; GridView5.DataBind(); ((Label)GridView5.HeaderRow.FindControl("Label31")).Text = ((Label)GridView5.Rows[0].FindControl("Label37")).Text; } }
protected void getItemSummary() { try { SqlConnection dbConnection = new SqlConnection("Data Source=itksqlexp8;Integrated Security=true"); dbConnection.Open(); dbConnection.ChangeDatabase("nasa_SilentAuction_v1"); String q1 = "select count(*) as count from item"; SqlCommand q1Command = new SqlCommand(q1, dbConnection); String q2 = "select count(*) as count from item where itemstatus = 'SOLD' "; SqlCommand q2Command = new SqlCommand(q2, dbConnection); String q3 = "select count(*) as count from item where itemstatus = 'UNSOLD' "; SqlCommand q3Command = new SqlCommand(q3, dbConnection); String q4 = "select count(*) as count from item where paymentStatus = 'YES'"; SqlCommand q4Command = new SqlCommand(q4, dbConnection); String q5 = "select count(*) as count from item where paymentStatus = 'NO'"; SqlCommand q5Command = new SqlCommand(q5, dbConnection); DataTable table = new DataTable(); table.Columns.Add("Total Number of Items"); table.Columns.Add("Sold"); table.Columns.Add("UnSold"); table.Columns.Add("Paid"); table.Columns.Add("UnPaid"); DataRow row = table.NewRow(); SqlDataReader q1Reader = q1Command.ExecuteReader(); q1Reader.Read(); row["Total Number of Items"] = q1Reader["count"]; q1Reader.Close(); SqlDataReader q2Reader = q2Command.ExecuteReader(); q2Reader.Read(); row["Sold"] = q2Reader["count"]; q2Reader.Close(); SqlDataReader q3Reader = q3Command.ExecuteReader(); q3Reader.Read(); row["UnSold"] = q3Reader["count"]; q3Reader.Close(); SqlDataReader q4Reader = q4Command.ExecuteReader(); q4Reader.Read(); row["Paid"] = q4Reader["count"]; q4Reader.Close(); SqlDataReader q5Reader = q5Command.ExecuteReader(); q5Reader.Read(); row["UnPaid"] = q5Reader["count"]; q5Reader.Close(); table.Rows.Add(row); //bind datatable to gridview; GridView3.DataSource = table; GridView3.DataBind(); dbConnection.Close(); } catch (SqlException exception) { Response.Write("<p>Error code " + exception.Number + ": " + exception.Message + "</p>"); } }
protected void FillGrids() { SqlConnection conn = new SqlConnection("Server=10.20.55.34;database=Caborca;User=intranet;Password=Newl@b0ratorio;"); string noEst = Request.QueryString["estacion"]; if (TextBox1.Text == "" || TextBox1.Text == null) { TextBox1.Text = DateTime.Today.ToShortDateString(); } if (TextBox2.Text == "" || TextBox2.Text == null) { TextBox2.Text = DateTime.Today.ToShortDateString(); } TextBox2.Enabled = true; DateTime date1 = Convert.ToDateTime(TextBox1.Text), date2 = Convert.ToDateTime(TextBox2.Text); string fch1 = date1.ToShortDateString(), fch2 = date2.ToShortDateString(); string c = "select sum(pm1_1m)/count(pm1_1m) as pm1_1m,sum(pm1_5m)/count(pm1_5m) as pm1_5m,sum(pm1_15m)/count(pm1_15m) as pm1_15m,sum(pm1_1h)/count(pm1_1h) as pm1_1h from caborca_estacion_" + noEst + " where fecha >='" + fch1 + "' and fecha <='" + fch2 + "' "; string c1 = "select sum(pm2p5_1m)/count(pm2p5_1m) as pm2p5_1m,sum(pm2p5_5m)/count(pm2p5_5m) as pm2p5_5m,sum(pm2p5_15m)/count(pm2p5_15m) as pm2p5_15m,sum(pm2p5_1h)/count(pm2p5_1h) as pm2p5_1h from caborca_estacion_" + noEst + " where fecha >='" + fch1 + "' and fecha <='" + fch2 + "' "; string c2 = "select sum(pm10_1m)/count(pm10_1m) as pm10_1m,sum(pm10_5m)/count(pm10_5m) as pm10_5m,sum(pm10_15m)/count(pm10_15m) as pm10_15m,sum(pm10_1h)/count(pm10_1h) as pm10_1h from caborca_estacion_" + noEst + " where fecha >='" + fch1 + "' and fecha <='" + fch2 + "' "; string c3 = "select sum(temp)/count(temp) as temp from caborca_estacion_" + noEst + " where fecha >='" + fch1 + "' and fecha <='" + fch2 + "'"; #region grid1 try { conn.Open(); SqlCommand command = new SqlCommand(c, conn); SqlDataAdapter sDa = new SqlDataAdapter(command); DataTable dt = new DataTable(); sDa.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); } catch (Exception ex) { } finally { conn.Close(); } #endregion #region grid2 try { conn.Open(); SqlCommand command = new SqlCommand(c1, conn); SqlDataAdapter sDa = new SqlDataAdapter(command); DataTable dt = new DataTable(); sDa.Fill(dt); GridView2.DataSource = dt; GridView2.DataBind(); } catch (Exception ex) { } finally { conn.Close(); } #endregion #region grid3 try { conn.Open(); SqlCommand command = new SqlCommand(c2, conn); SqlDataAdapter sDa = new SqlDataAdapter(command); DataTable dt = new DataTable(); sDa.Fill(dt); GridView3.DataSource = dt; GridView3.DataBind(); } catch (Exception ex) { } finally { conn.Close(); } #endregion #region temp try{ conn.Open(); SqlCommand command = new SqlCommand(c3, conn); SqlDataReader reader; using (reader = command.ExecuteReader()) { if (reader.Read()) { decimal temp = Convert.ToDecimal(reader["temp"]); templbl.Text = "" + decimal.Round(temp, 0); } else { templbl.Text = "Null"; } } } catch { } finally { conn.Close(); } #endregion }
protected void Page_Load(object sender, EventArgs e) { if (Session["user"] != null) { string connetionString = null; SqlConnection cnn; connetionString = "Data Source=.;Initial Catalog=mySmile;Server=DESKTOP-GB2S5V2;Database=mySmile;Trusted_Connection=True;";//UserID=UserName;Password=Password"; cnn = new SqlConnection(connetionString); try { cnn.Open(); ////////////////upcomming/////////////////// String q = "select d.name,a.Dentist_id,a.Date,a.StartTime,a.EndTime,a.Appointment_id from appointment a , Dentist d where a.Dentist_id=d.Dentist_id and Date>=CONVERT(date, getdate()) and Patient_id='" + Session["user"].ToString() + "' and Canceled=0 "; SqlDataAdapter sqlDa = new SqlDataAdapter(q, cnn); DataTable dtbl = new DataTable(); sqlDa.Fill(dtbl); GridView1.DataSource = dtbl; GridView1.DataBind(); Label2.Visible = true; ////////////////old///////////////////////// String s = "select d.name,a.Dentist_id,a.Date,a.StartTime,a.EndTime from appointment a , Dentist d where a.Dentist_id=d.Dentist_id and Date <CONVERT(date, getdate()) and Patient_id='" + Session["user"].ToString() + "' and Canceled=0 "; SqlDataAdapter sqlDa2 = new SqlDataAdapter(s, cnn); DataTable dtbl2 = new DataTable(); sqlDa2.Fill(dtbl2); GridView2.DataSource = dtbl2; GridView2.DataBind(); Label1.Visible = true; //////////////canceled////////////////////// String l = "select d.name,a.Dentist_id,a.Date,a.StartTime,a.EndTime from appointment a , Dentist d where a.Dentist_id=d.Dentist_id and Patient_id='" + Session["pid"].ToString() + "' and Canceled=1 "; SqlDataAdapter sqlDa3 = new SqlDataAdapter(l, cnn); DataTable dtbl3 = new DataTable(); sqlDa3.Fill(dtbl3); GridView3.DataSource = dtbl3; GridView3.DataBind(); Label3.Visible = true; cnn.Close(); int r1 = Convert.ToInt32(GridView1.Rows.Count.ToString()); int r2 = Convert.ToInt32(GridView2.Rows.Count.ToString()); int r3 = Convert.ToInt32(GridView3.Rows.Count.ToString()); if (r1 > 0 || r2 > 0 || r3 > 0) { } else { noapplabel.Visible = true; Label3.Visible = false; Label2.Visible = false; Label1.Visible = false; } } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "MessageBox", "alert('Can not open connection !')" + ex, true); } } else { login.Visible = true; } }
//button edit block code ends here //GV view blocks update and edit starts here protected void GridView1_RowEditing(object sender, System.Web.UI.WebControls.GridViewEditEventArgs e) { //NewEditIndex property used to determine the index of the row being edited. GridView3.EditIndex = e.NewEditIndex; GridView3.DataBind(); }
protected void TextBox1_TextChanged(object sender, EventArgs e) { GridView3.DataSource = GetDataSource2(); GridView3.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { Session["TaskTable"] = MIS2000Lab_GetPageData(0); GridView3.DataSource = Session["TaskTable"]; GridView3.DataBind(); }
protected void AdmitCard_Click(object sender, ImageClickEventArgs e) { GridView3.DataSource = GetDataSource3(); GridView3.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { GridView3.DataSource = clientes; GridView3.DataBind(); }
protected void btnDelete_Command(object sender, CommandEventArgs e) { if (e.CommandName == "DeleteMessage") { SqlConnection conn = null; SqlDataReader reader = null; // instantiate and open connection conn = new SqlConnection(Reference.Constr); conn.Open(); int index = Convert.ToInt32(e.CommandArgument); // Retrieve the row that contains the button // from the Rows collection. GridViewRow row = GridView3.Rows[index]; LinkButton btnButton1 = sender as LinkButton; GridViewRow gvRow1 = (GridViewRow)btnButton1.NamingContainer; Company Obj = new Company(); Company_Management cDao = new Company_Management(); Label lb_msgId = (Label)gvRow1.FindControl("lb_CompanyID"); Obj = cDao.getCompanyByID(lb_msgId.Text); SqlCommand cmdCount = new SqlCommand("select count(*) as total from Advertisement as a inner join Company as c on a.companyID=c.CompanyID where c.CompanyID=@ID and a.status=1", conn); string CompanyName = Obj.Name; SqlParameter param1 = new SqlParameter(); param1.ParameterName = "@ID"; param1.Value = Obj.CompanyID.ToString(); cmdCount.Parameters.Add(param1); SqlDataAdapter sda1 = new SqlDataAdapter(); DataTable dt = new DataTable(); cmdCount.Connection = conn; sda1.SelectCommand = cmdCount; sda1.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { int count = (Convert.ToInt32(dt.Rows[i]["total"])); if (count == 0) { Boolean insCnt = cDao.deleteCompany(lb_msgId.Text); //VIC: never inform if the delete is successful or not? alertSuccess.Visible = true; DeleteError.Visible = false; createSuccess.Visible = false; updateSuccess.Visible = false; msgSuccess.Text = CompanyName + " Has Been Deleted Successfully!"; } else { DeleteError.Visible = true; alertSuccess.Visible = false; createSuccess.Visible = false; updateSuccess.Visible = false; DeleteLabel.Text = "Hi, there is/are " + count + " Advertisement(s) under " + CompanyName + ".Please Delete existing advertisement(s) first before proceeding to delete the company."; } } Database db = new Database(); SqlCommand cmd = new SqlCommand("Select * from [Company] where Status = 1"); // cmd.Parameters.AddWithValue("@paraType", (string)Session["userType"]); DataSet ds = db.getDataSet(cmd); GridView3.DataBind(); } }