protected void ButtonUpdateShop_Click(object sender, EventArgs e) { string connectionString = ConfigurationManager.ConnectionStrings["conStr"].ToString(); SqlConnection con = new SqlConnection(connectionString); try { con.Open(); } catch (Exception) { con.Close(); return; throw; } if (string.IsNullOrEmpty(TextBoxProfit.Text)) { TextBoxProfit.Text = "NULL"; } if (string.IsNullOrEmpty(TextBoxManagerID.Text)) { TextBoxManagerID.Text = "NULL"; } SqlCommand c1 = new SqlCommand("Update Shop_T set Profit=" + TextBoxProfit.Text + ", ManagerID=" + TextBoxManagerID.Text + " where ShopName='" + TextBoxFirstShopName.Text + "'", con); c1.ExecuteNonQuery(); SqlCommand c2 = new SqlCommand("Delete from Shop_Phone_Number_T where ShopName='" + TextBoxFirstShopName.Text + "'", con); c2.ExecuteNonQuery(); using (StringReader reader = new StringReader(TextBoxPhone.Text)) { string line; while ((line = reader.ReadLine()) != null) { SqlCommand c3 = new SqlCommand("INSERT INTO Shop_Phone_Number_T (ShopName, PhoneNumber) VALUES('" + TextBoxFirstShopName.Text + "', " + line + ")", con); c3.ExecuteNonQuery(); } } SqlCommand c4 = new SqlCommand("Delete from Shops_Items_T where ShopName='" + TextBoxFirstShopName.Text + "'", con); c4.ExecuteNonQuery(); using (StringReader reader = new StringReader(TextBoxItem.Text)) { string line; while ((line = reader.ReadLine()) != null) { SqlCommand c5 = new SqlCommand("INSERT INTO Shops_Items_T (ShopName, Barcode) VALUES('" + TextBoxFirstShopName.Text + "', '" + line + "')", con); c5.ExecuteNonQuery(); } } DataSet ds = new DataSet(); string sqlstr = "select * from Shop_T where ShopName='" + TextBoxFirstShopName.Text + "'"; SqlDataAdapter da = new SqlDataAdapter(sqlstr, con); da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); DataSet ds2 = new DataSet(); string sqlstr2 = "select * from Shop_Phone_Number_T where ShopName='" + TextBoxFirstShopName.Text + "'"; SqlDataAdapter da2 = new SqlDataAdapter(sqlstr2, con); da2.Fill(ds2); GridView2.DataSource = ds2; GridView2.DataBind(); DataSet ds3 = new DataSet(); string sqlstr3 = "select * from Shops_Items_T where ShopName='" + TextBoxFirstShopName.Text + "'"; SqlDataAdapter da3 = new SqlDataAdapter(sqlstr3, con); da3.Fill(ds3); GridView3.DataSource = ds3; GridView3.DataBind(); con.Close(); shopUpdate.Visible = false; newTables.Visible = true; }
private void GridViewBind() { GridView1.DataSource = MyUtils.BookBoard(10); GridView1.DataBind(); }
protected void Search_Click(object sender, EventArgs e) { GridView1.DataSource = MyUtils.BookBoard(10); GridView1.DataBind(); }
protected void Button3_Click(object sender, EventArgs e) { string tempcell = cusCellTxt.Text; DateTime tdt; int tempAmount = 0; int tempCredit = 0; int tempDebit = 0; try { using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities()) { var cu = (from c in dbobj.Customers where c.CellNumber == tempcell select c).ToList(); GridView1.DataSource = cu; GridView1.DataBind(); if (GridView1.Rows.Count != 0) { fundTxt.Enabled = true; int tempCustId = Convert.ToInt32(GridView1.Rows[0].Cells[0].Text); var si = (from s in dbobj.SaleInvoices where s.CustomerId == tempCustId && s.Status != "Cleared" select s).ToList(); GridView2.DataSource = si; GridView2.DataBind(); if (datepicker.Text != "") { if (datepicker1.Text != "") { tdt = DateTime.Parse(datepicker1.Text); } else { tdt = System.DateTime.Now; } DateTime fdt = DateTime.Parse(datepicker.Text); var cusRep = dbobj.sp_Customer_Report(tempCustId, fdt, tdt).ToList(); ctlGridView.DataSource = cusRep; ctlGridView.DataBind(); for (int i = 0; i < ctlGridView.Rows.Count; i++) { if (ctlGridView.Rows[i].Cells[0].Text != "Fund Deposit") { tempAmount += Convert.ToInt32(ctlGridView.Rows[i].Cells[2].Text); } tempCredit += Convert.ToInt32(ctlGridView.Rows[i].Cells[3].Text); tempDebit += Convert.ToInt32(ctlGridView.Rows[i].Cells[4].Text); } tSaleTxt.Text = tempAmount.ToString(); tCredTxt.Text = tempCredit.ToString(); tRecTxt.Text = tempDebit.ToString(); List <int> tempInvId = new List <int>(); var tempInv = (from i in dbobj.SaleInvoices where i.CustomerId == tempCustId & i.Date >= fdt & i.Date < tdt select i).ToList(); for (int i = 0; i < tempInv.Count; i++) { tempInvId.Add(tempInv[i].SaleInvoicId); } List <saleProduct> sp = new List <saleProduct>(); for (int i = 0; i < tempInvId.Count; i++) { int myinvId = tempInvId[i]; var saleProductList = dbobj.sp_sale_detail(myinvId).ToList(); for (int j = 0; j < saleProductList.Count; j++) { if (sp.Count >= 1) { for (int k = 0; k < sp.Count; k++) { if (sp[k].ProductNm == saleProductList[j].ProductName) { sp[k].ProductQnty = (Convert.ToInt32(sp[k].ProductQnty) + Convert.ToInt32(saleProductList[j].Quatity)); sp[k].ProductCost = sp[k].ProductQnty * Convert.ToInt32(saleProductList[j].Rate); flag = 1; break; } } if (flag == 0) { sp.Add(new saleProduct { ProductNm = saleProductList[j].ProductName, ProductQnty = saleProductList[j].Quatity, ProductCost = saleProductList[j].Rate * saleProductList[j].Quatity }); } flag = 0; } else { sp.Add(new saleProduct { ProductNm = saleProductList[j].ProductName, ProductQnty = saleProductList[j].Quatity, ProductCost = saleProductList[j].Rate * saleProductList[j].Quatity }); } } } gw4.DataSource = sp; gw4.DataBind(); } } } } catch (Exception) { } }
protected void Button1_Click(object sender, EventArgs e) { SqlDataSource1.Insert(); GridView1.DataBind(); }
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e) { GridView1.PageIndex = e.NewSelectedIndex; GridView1.DataBind(); }
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { // Cancel the edit GridView1.EditIndex = -1; GridView1.DataBind(); }
private void BindData() { GridView1.DataSource = empHandler.GetEmployeeList(); GridView1.DataBind(); }
protected void Button2_Click(object sender, EventArgs e) { //this is for add area if (DropDownList1.SelectedIndex == 0) { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Please Select City');", true); //Response.Write("<script>alert('Please Select City')</script>"); TextBox2.Text = ""; } else { if (Std_chk.Checked == true) { std = 1; } else { std = 0; } if (avg_chk.Checked == true) { avg = 1; } else { avg = 0; } if (poor_chk.Checked == true) { poor = 1; } else { poor = 0; } if (is_ff_chk.Checked == true) { is_ff = 1; } else { is_ff = 0; } string s = "insert into delivery_area values('" + DropDownList1.Text + "','" + TextBox2.Text + "'," + std + "," + avg + "," + poor + "," + is_ff + ")"; dc.setdata(s); DataSet ds2 = new DataSet(); string a = "select * from delivery_area"; ds2 = dc.getdata(a); GridView2.DataSource = ds2; GridView2.DataBind(); GridView1.DataSource = ds2; GridView1.DataBind(); DropDownList1.SelectedIndex = 0; TextBox2.Text = ""; Std_chk.Checked = false; avg_chk.Checked = false; poor_chk.Checked = false; is_ff_chk.Checked = false; Label2.Text = "List Of Delivery Area"; } }
protected void BindView(int qishu) { Maticsoft.BLL.shangke_view sk_v_bll = new BLL.shangke_view(); GridView1.DataSource = sk_v_bll.GetList("[peixunban_id]= " + qishu); GridView1.DataBind(); }
public void actualizar() { //GridView1.DataSource = ""; GridView1.DataBind(); }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { int SelectedTeacherId = Convert.ToInt16(DropDownList1.SelectedValue); try { teacher = DataRepository.TeacherProvider.GetByAspnetMembershipUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString()))[0]; // customer = DataRepository.CustomerProvider.GetByAspnetMembershipUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString()))[0]; //customerprofile = DataRepository.CustomerProfileProvider.GetByCustomerId(customer.CustomerId)[0]; } catch { // customerprofile = DataRepository.CustomerProfileProvider.GetByCustomerId(teacher.TeacherId)[0]; } CustomerSite siteid; int x = 0; DataTable dt = new DataTable(); dt.Columns.Add("Count", typeof(int)); dt.Columns.Add("First Name", typeof(string)); dt.Columns.Add("Last Name", typeof(string)); dt.Columns.Add("Email Address", typeof(string)); dt.Columns.Add("Facility", typeof(string)); dt.Columns.Add("ExpirationDate", typeof(string)); dt.Columns.Add("TeacherType", typeof(int)); dt.Columns.Add("Tier", typeof(int)); try { DataTable dtathlets = _sprintAthleteEdit.GetPrimaryAthletsCoach(SelectedTeacherId); DataTable dtathlets1 = _sprintAthleteEdit.GetSecondaryAthlets_Coach(SelectedTeacherId); #region [Primary Coach Data] if (dtathlets != null) { foreach (DataRow row in dtathlets.Rows) { DataRow r = dt.NewRow(); string userrolename = string.Empty; int customerid = Convert.ToInt32(row["CustomerId"]); AthleteSearched = DataRepository.CustomerProvider.GetByCustomerId(customerid); Guid MemGuid = new Guid(AthleteSearched.AspnetMembershipUserId.ToString()); MembershipUser user = Membership.GetUser(MemGuid); string[] userrole = Roles.GetRolesForUser(user.UserName); userrolename = userrole[0]; if (userrolename == "Athletes") { string custid = row["CustomerId"].ToString(); x++; r["First Name"] = row["FirstName"].ToString(); r["Last Name"] = row["LastName"].ToString(); r["Email Address"] = row["Email"].ToString(); DateTime date = new DateTime(); date = Convert.ToDateTime(row["MemberShipExpiration"]); string onlydate = date.Month + "/" + date.Day + "/" + date.Year; r["ExpirationDate"] = onlydate; // r["Status"] = row["MemberShipStatus"].ToString(); r["Count"] = x.ToString(); customerprofile = DataRepository.CustomerProfileProvider.GetByCustomerId(Convert.ToInt16(custid))[0]; if (!string.IsNullOrEmpty(customerprofile.InitialTeacher.ToString())) { r["Tier"] = customerprofile.InitialTeacher;//tier number of athlete } else { r["Tier"] = Convert.ToInt16(null); } r["TeacherType"] = 1; siteid = DataRepository.CustomerSiteProvider.GetByCustomerSiteId(customerprofile.CustomerSite); r["Facility"] = siteid.SiteName.ToString(); dt.Rows.Add(r); } } } #endregion [Primary Coach Data] #region [Secondary Coach Data] if (dtathlets1 != null) { foreach (DataRow row in dtathlets1.Rows) { DataRow r = dt.NewRow(); string userrolename1 = string.Empty; int customerid1 = Convert.ToInt32(row["CustomerId"]); AthleteSearched = DataRepository.CustomerProvider.GetByCustomerId(customerid1); Guid MemGuid1 = new Guid(AthleteSearched.AspnetMembershipUserId.ToString()); MembershipUser user1 = Membership.GetUser(MemGuid1); string[] userrole1 = Roles.GetRolesForUser(user1.UserName); userrolename1 = userrole1[0]; if (userrolename1 == "Athletes") { string custid = row["CustomerId"].ToString(); x++; r["First Name"] = row["FirstName"].ToString(); r["Last Name"] = row["LastName"].ToString(); r["Email Address"] = row["Email"].ToString(); DateTime date = new DateTime(); date = Convert.ToDateTime(row["MemberShipExpiration"]); string onlydate = date.Month + "/" + date.Day + "/" + date.Year; r["ExpirationDate"] = onlydate; //r["Status"] = row["MemberShipStatus"].ToString(); r["Count"] = x.ToString(); customerprofile = DataRepository.CustomerProfileProvider.GetByCustomerId(Convert.ToInt16(custid))[0]; if (!string.IsNullOrEmpty(customerprofile.InitialTeacher.ToString())) { r["Tier"] = customerprofile.InitialTeacher;//tier number of athlete } else { r["Tier"] = Convert.ToInt16(null); } r["TeacherType"] = 2; siteid = DataRepository.CustomerSiteProvider.GetByCustomerSiteId(customerprofile.CustomerSite); r["Facility"] = siteid.SiteName.ToString(); dt.Rows.Add(r); } } } #endregion [Secondary Coach Data] } catch (Exception ex) { ex.Message.ToString(); } DataTable AthleteData = dt; GridView1.DataSource = AthleteData; GridView1.DataBind(); }
protected void OnPaging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; GridView1.DataBind(); }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { GridView1.DataBind(); }
public void getgrid() { plantname(); //collectdatble.Columns.Add("Plantcode"); //collectdatble.Columns.Add("PlantName"); //collectdatble.Columns.Add("procureData"); //collectdatble.Columns.Add("ClosingStock"); //collectdatble.Columns.Add("RouteTime"); //collectdatble.Columns.Add("CashCollection"); //collectdatble.Rows.Clear(); //collectdatble.Columns.Clear(); collectdatble.Columns.Add("Plant"); collectdatble.Columns.Add("Details"); //collectdatble.Rows.Add("RouteTime","SAP"); //collectdatble.Rows.Add("CashCollection","SAP"); //collectdatble.Rows.Add("GarberTesting","SAP"); //collectdatble.Rows.Add("LiveData",""); foreach (DataRow pro in dtplant.Rows) { ptcode = pro[0].ToString(); ptname = pro[1].ToString(); //GridView1.Rows[0].Cells[1].Text = ptcode; procurementimport(); if (procurement.Rows.Count > 0) { procuimp = "Received"; // GridView1.Rows[2].Cells[1].Text = procuimp; } else { procuimp = "Pending"; } ClosingStock(); if (closingStock.Rows.Count > 0) { stockClosing = "Received"; } else { stockClosing = "Pending"; } RouteTimeMaintanance(); if (route.Rows.Count > 0) { timemaintanance = "Received"; } else { timemaintanance = "Pending"; } cashcollections(); if (cashcoll.Rows.Count > 0) { cash = "Received"; } else { cash = "Pending"; } garbertes(); if (garbertest.Rows.Count > 0) { Garcbertesting = "Received"; } else { Garcbertesting = "Pending"; } comprresss(); if (cmpruntime.Rows.Count > 0) { compress = "Received"; } else { compress = "Pending"; } Rechilll(); if (milkrechilling.Rows.Count > 0) { milkrechil = "Received"; } else { milkrechil = "Pending"; } genseee(); if (GensetPowerDiesel.Rows.Count > 0) { Genset = "Received"; } else { Genset = "Pending"; } } collectdatble.Rows.Add("Plantcode", ptcode); collectdatble.Rows.Add("PlantName", ptname); collectdatble.Rows.Add("procureData", procuimp); collectdatble.Rows.Add("ClosingStock", stockClosing); collectdatble.Rows.Add("RouteTime", timemaintanance); collectdatble.Rows.Add("CashCollection", cash); collectdatble.Rows.Add("GarberTesting", Garcbertesting); collectdatble.Rows.Add("compressor", compress); collectdatble.Rows.Add("Rechilling", milkrechil); collectdatble.Rows.Add("GensetPowerDiesel", Genset); GridView1.DataSource = collectdatble; GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { try { conn = new SqlConnection("Data Source=ROSTON-PC\\SQLEXPRESS;Initial Catalog=volcania;Integrated Security=True;Context Connection=False"); // conn = new SqlConnection("Data Source=190.190.200.100,1433; Network Library=DBMSSOCN;Initial Catalog=volcania;"); conn.Open(); s = Session["c"].ToString(); s1 = Session["c1"].ToString(); query = "SELECT * FROM compare WHERE name='" + s + "'"; cmd = new SqlCommand(query, conn); dr = cmd.ExecuteReader(); while (dr.Read()) { name = dr[0].ToString(); Label1.Text = dr[1].ToString(); //dr[2] for image Label3.Text = dr[3].ToString(); Label4.Text = dr[4].ToString(); Label5.Text = dr[5].ToString(); Label6.Text = dr[6].ToString(); Label7.Text = dr[7].ToString(); Label8.Text = dr[8].ToString(); Label9.Text = dr[9].ToString(); Label10.Text = dr[10].ToString(); Label11.Text = dr[11].ToString(); Label12.Text = dr[12].ToString(); Label13.Text = dr[13].ToString(); Label14.Text = dr[14].ToString(); Label15.Text = dr[15].ToString(); Label16.Text = dr[16].ToString(); Label17.Text = dr[17].ToString(); Label18.Text = dr[18].ToString(); Label19.Text = dr[19].ToString(); Label20.Text = dr[20].ToString(); Label21.Text = dr[21].ToString(); Label22.Text = dr[22].ToString(); Label23.Text = dr[23].ToString(); } dr.Close(); query1 = "select * from compare where name='" + s1 + "'"; cmd1 = new SqlCommand(query1, conn); dr1 = cmd1.ExecuteReader(); while (dr1.Read()) { name1 = dr1[0].ToString(); Label2.Text = dr1[1].ToString(); //dr1[2] for image Label24.Text = dr1[3].ToString(); Label25.Text = dr1[4].ToString(); Label26.Text = dr1[5].ToString(); Label27.Text = dr1[6].ToString(); Label28.Text = dr1[7].ToString(); Label29.Text = dr1[8].ToString(); Label30.Text = dr1[9].ToString(); Label31.Text = dr1[10].ToString(); Label32.Text = dr1[11].ToString(); Label33.Text = dr1[12].ToString(); Label34.Text = dr1[13].ToString(); Label35.Text = dr1[14].ToString(); Label36.Text = dr1[15].ToString(); Label37.Text = dr1[16].ToString(); Label38.Text = dr1[17].ToString(); Label39.Text = dr1[18].ToString(); Label40.Text = dr1[19].ToString(); Label41.Text = dr1[20].ToString(); Label42.Text = dr1[21].ToString(); Label43.Text = dr1[22].ToString(); Label44.Text = dr1[23].ToString(); } dr1.Close(); cmd2 = new SqlCommand(query, conn); dr2 = cmd2.ExecuteReader(); GridView1.DataSource = dr2; GridView1.DataBind(); dr2.Close(); cmd3 = new SqlCommand(query1, conn); dr3 = cmd3.ExecuteReader(); GridView2.DataSource = dr3; GridView2.DataBind(); dr3.Close(); marquee = "<marquee bgcolor='blue'><h1><font color='white'>" + name + "</font></h1></marquee>"; Literal1.Text = marquee; marquee1 = "<marquee bgcolor='blue'><h1><font color='white'>" + name1 + "</font></h1></marquee>"; Literal2.Text = marquee1; } catch (Exception ae) { Label1.Text = "Error" + ae; } finally { conn.Close(); } }
private void Import_To_Grid(string FilePath, string Extension, string isHDR) { string conStr = ""; switch (Extension) { case ".xls": //Excel 97-03 conStr = ConfigurationManager.ConnectionStrings["Excel03ConString"].ConnectionString; break; case ".xlsx": //Excel 07 conStr = ConfigurationManager.ConnectionStrings["Excel07ConString"].ConnectionString; break; } conStr = String.Format(conStr, FilePath, isHDR); OleDbConnection connExcel = new OleDbConnection(conStr); OleDbCommand cmdExcel = new OleDbCommand(); OleDbDataAdapter oda = new OleDbDataAdapter(); DataTable dt = new DataTable(); cmdExcel.Connection = connExcel; //Get the name of First Sheet connExcel.Open(); DataTable dtExcelSchema; dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); string SheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString(); connExcel.Close(); //Read Data from First Sheet connExcel.Open(); cmdExcel.CommandText = "SELECT * From [" + SheetName + "]"; oda.SelectCommand = cmdExcel; oda.Fill(dt); connExcel.Close(); //Bind Data to GridView GridView1.Caption = Path.GetFileName(FilePath); GridView1.DataSource = dt; GridView1.DataBind(); }
protected void btnAddQuestion_Click(object sender, EventArgs e) //כפתור הוסף שאלה { XmlDocument myDoc = new XmlDocument(); myDoc.Load(Server.MapPath("XML/GameXML.xml")); //מונה רשימת השאלות XmlNode XmlNumOfQuestions; XmlNumOfQuestions = myDoc.SelectSingleNode("quizTree/topic[@GameCode='" + lblGameCode.Text + "']/@NumOfQuestions"); int QuestionCount = Convert.ToUInt16(XmlNumOfQuestions.InnerXml); string strQuestionCount = Convert.ToString(++QuestionCount); //מוצא את האידי הקיים ומעלה ב1 XmlNumOfQuestions.InnerXml = strQuestionCount; //עדכון מספר השאלות למשחק - NumOfQuestions lblQid.Text = strQuestionCount; //יצירת שאלה חדשה XmlElement newQuestion = myDoc.CreateElement("question"); newQuestion.SetAttribute("id", strQuestionCount); // הוספת אי די לשאלה //גזע השאלה XmlElement QuestionTag = myDoc.CreateElement("questionText"); XmlText QuestionTagText = myDoc.CreateTextNode(txtQuestion.Text); QuestionTag.AppendChild(QuestionTagText); newQuestion.AppendChild(QuestionTag); //תמונה לשאלה string ImgUrl = ImageButton5.ImageUrl; string endOfImgName = ImgUrl.Substring(ImageButton5.ImageUrl.Length - 11); if (endOfImgName != "ImgIcon.png") { XmlElement QuestionImg = myDoc.CreateElement("img"); XmlText QuestionImgUrl = myDoc.CreateTextNode(ImageButton5.ImageUrl); QuestionImg.AppendChild(QuestionImgUrl); newQuestion.AppendChild(QuestionImg); } else { XmlElement QuestionImg = myDoc.CreateElement("img"); XmlText QuestionImgUrl = myDoc.CreateTextNode(""); QuestionImg.AppendChild(QuestionImgUrl); newQuestion.AppendChild(QuestionImg); } XmlElement Answers = myDoc.CreateElement("answers"); //הוספת מס' תשובות לשאלה Answers.SetAttribute("NumOfAnswers", lblNumOfAns.Text); newQuestion.AppendChild(Answers); int NumOfAns = Convert.ToInt16(lblNumOfAns.Text); for (int i = 1; i <= NumOfAns; i++) { XmlElement Answer = myDoc.CreateElement("answer"); XmlText AnswerText = myDoc.CreateTextNode(((TextBox)FindControl("txtAnswer" + i.ToString())).Text); Answer.AppendChild(AnswerText); Answers.AppendChild(Answer); } //מציאת הענף אליו נרצה להוסיף את הענף החדש + הוספה myDoc.SelectSingleNode("/quizTree/topic[@GameCode='" + lblGameCode.Text + "']/questions").AppendChild(newQuestion); myDoc.Save(Server.MapPath("XML/GameXML.xml")); // שמירת העץ החדש XmlDataSource1.Save(); GridView1.DataBind(); btnClean_Click(sender, e); //ניקוי תיבות הטקסט }
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e) { dt.DefaultView.Sort = e.SortExpression; GridView1.DataSource = dt.DefaultView.ToTable(); GridView1.DataBind(); }
protected void btnUpdate_Click(object sender, EventArgs e) //כפתור שמירת עדכן שאלה { if (lblQid.Text != "") {//אם זה לא השאלה הראשונה שנבחרה אז צובע את הישנה חזרה בצבע לבן int LastBtnInt = Convert.ToInt16(lblQid.Text) - 1; Button LastBtn = (Button)GridView1.Rows[LastBtnInt].FindControl("QuestionText"); LastBtn.BackColor = System.Drawing.Color.FromArgb(255, 255, 255); } XmlDocument myDoc = new XmlDocument(); //טעינת העץ myDoc.Load(Server.MapPath("XML/GameXML.xml")); XmlNode xmlQuestion; //הפנייה לשאלה עצמה xmlQuestion = myDoc.SelectSingleNode("quizTree/topic[@GameCode='" + lblGameCode.Text + "']/questions/question[@id='" + lblQid.Text + "']"); XmlNode xmlQuestionText; //טקסט השאלה xmlQuestionText = myDoc.SelectSingleNode("quizTree/topic[@GameCode='" + lblGameCode.Text + "']/questions/question[@id='" + lblQid.Text + "']/questionText"); xmlQuestionText.InnerXml = txtQuestion.Text; XmlNode xmlQuestionImg; //תמונה לשאלה xmlQuestionImg = myDoc.SelectSingleNode("quizTree/topic[@GameCode='" + lblGameCode.Text + "']/questions/question[@id='" + lblQid.Text + "']/img"); string ImgUrl = ImageButton5.ImageUrl; string endOfImgName = ImgUrl.Substring(ImageButton5.ImageUrl.Length - 11); if (endOfImgName != "ImgIcon.png") { xmlQuestionImg.InnerXml = ImageButton5.ImageUrl; } else { xmlQuestionImg.InnerXml = ""; } //מוחק את התשובות שהיו XmlNode node = myDoc.SelectSingleNode("quizTree/topic[@GameCode='" + lblGameCode.Text + "']/questions/question[@id='" + lblQid.Text + "']/answers"); node.ParentNode.RemoveChild(node); //פעולת המחיקה //מזין מחדש את התשובות //המטרה בשיטה זו - לא משנה אם מס' התשובות גדל או קטן, תמונה או טקסט XmlElement Answers = myDoc.CreateElement("answers"); //הוספת מס' תשובות לשאלה Answers.SetAttribute("NumOfAnswers", lblNumOfAns.Text); int NumOfAns = Convert.ToInt16(lblNumOfAns.Text); for (int i = 1; i <= NumOfAns; i++) { XmlElement Answer = myDoc.CreateElement("answer"); XmlText AnswerText = myDoc.CreateTextNode(((TextBox)FindControl("txtAnswer" + i.ToString())).Text); Answer.AppendChild(AnswerText); Answers.AppendChild(Answer); } //הוספת התשובות החדשות xmlQuestion.AppendChild(Answers); myDoc.Save(Server.MapPath("XML/GameXML.xml")); // שמירת העץ החדש XmlDataSource1.Save(); GridView1.DataBind(); btnClean_Click(sender, e); //ניקוי תיבות הטקסט btnAddQuestion.Visible = true; btnAddQuestion.Enabled = false; btnUpdate.Visible = false; }
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { GridView1.EditIndex = e.NewEditIndex; GridView1.DataBind(); }
private void GetDataAndCreateChartBySun() { DataTable dtCount = AddSQLStringToDAL.GetDataTableBysql("select * from TabDepartmentSum"); string[] AllCount = new string[dtCount.Rows.Count]; for (int i = 0; i < dtCount.Rows.Count; i++) { AllCount[i] = dtCount.Rows[i]["Sum"].ToString(); } string[] AllDepartment = { "会计系", "信息工程系", "经济管理系", "商务外语系", "食品工程系", "机械工程系", "建筑工程系" }; string[] AllData = new string[AllDepartment.Length]; string[] AllLate = new string[AllDepartment.Length]; string[] AllAttendance = new string[AllDepartment.Length]; string[] AllEarly = new string[AllDepartment.Length]; string[] AllLeave = new string[AllDepartment.Length]; for (int i = 0; i < AllDepartment.Length; i++) { DataTable dt = InitialDataTable(AllDepartment[i]); AllData[i] = dt.Rows[dt.Rows.Count - 1]["合计"].ToString(); //最后一行 AllLeave[i] = dt.Rows[dt.Rows.Count - 1]["请假人数"].ToString(); AllAttendance[i] = dt.Rows[dt.Rows.Count - 1]["旷课人数"].ToString(); AllEarly[i] = dt.Rows[dt.Rows.Count - 1]["早退人数"].ToString(); AllLate[i] = dt.Rows[dt.Rows.Count - 1]["迟到人数"].ToString(); } DataTable dt111 = DataAnalysis.CreateDataTableReplaceChart(AllDepartment, AllCount, AllAttendance, AllLate, AllEarly, AllLeave, AllData); string[] AllDataRate = new string[AllDepartment.Length]; string[] AllAttendanceRate = new string[AllDepartment.Length]; string[] AllLeaveRate = new string[AllDepartment.Length]; string[] AllLateRate = new string[AllDepartment.Length]; string[] AllEarlyRate = new string[AllDepartment.Length]; for (int i = 0; i < dt111.Rows.Count; i++) { AllDataRate[i] = dt111.Rows[i]["总缺勤率"].ToString(); AllAttendanceRate[i] = dt111.Rows[i]["旷课率"].ToString(); AllLeaveRate[i] = dt111.Rows[i]["请假率"].ToString(); AllLateRate[i] = dt111.Rows[i]["迟到率"].ToString(); AllEarlyRate[i] = dt111.Rows[i]["早退率"].ToString(); } GridView1.DataSource = dt111; GridView1.DataBind(); if (Session["CurrentWeek"].ToString() == "01") { string s1 = DrawChart("总缺勤率", AllDepartment, AllDataRate, Session["CurrentWeek"].ToString()); this.phDepartmentEachCompare.Controls.Add(new LiteralControl(s1)); string s2 = DrawChart("旷课率", AllDepartment, AllAttendanceRate, Session["CurrentWeek"].ToString()); this.phAttendance.Controls.Add(new LiteralControl(s2)); string s3 = DrawChart("请假率", AllDepartment, AllLeaveRate, Session["CurrentWeek"].ToString()); this.phLeave.Controls.Add(new LiteralControl(s3)); string s4 = DrawChart("迟到率", AllDepartment, AllLateRate, Session["CurrentWeek"].ToString()); this.phLate.Controls.Add(new LiteralControl(s4)); string s5 = DrawChart("早退率", AllDepartment, AllEarlyRate, Session["CurrentWeek"].ToString()); this.phEarly.Controls.Add(new LiteralControl(s5)); } else { string s1 = DrawChart("总缺勤率", AllDepartment, AllDataRate, "01-" + Session["CurrentWeek"].ToString()); this.phDepartmentEachCompare.Controls.Add(new LiteralControl(s1)); string s2 = DrawChart("旷课率", AllDepartment, AllAttendanceRate, "01-" + Session["CurrentWeek"].ToString()); this.phAttendance.Controls.Add(new LiteralControl(s2)); string s3 = DrawChart("请假率", AllDepartment, AllLeaveRate, "01-" + Session["CurrentWeek"].ToString()); this.phLeave.Controls.Add(new LiteralControl(s3)); string s4 = DrawChart("迟到率", AllDepartment, AllLateRate, "01-" + Session["CurrentWeek"].ToString()); this.phLate.Controls.Add(new LiteralControl(s4)); string s5 = DrawChart("早退率", AllDepartment, AllEarlyRate, "01-" + Session["CurrentWeek"].ToString()); this.phEarly.Controls.Add(new LiteralControl(s5)); } }
protected void btnUpload_Click(object sender, EventArgs e) { if (conn_sql.State == ConnectionState.Closed) { conn_sql.Open(); } string filePath = ConfigurationManager.AppSettings["FilePath"].ToString(); string filename = string.Empty; string new_filePath = ""; if (fileUpload.HasFile) { try { string[] allowedFile = { ".XLS", ".XLSX" }; string FileExt = System.IO.Path.GetExtension(fileUpload.PostedFile.FileName); bool isValidFile = allowedFile.Contains(FileExt); if (!isValidFile) { lblMessage.Text = FileExt; } else { filename = Path.GetFileName(Server.MapPath(fileUpload.FileName)); fileUpload.SaveAs(Server.MapPath(filePath) + filename); new_filePath = Server.MapPath(filePath) + filename; OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + new_filePath + ";Extended Properties='Excel 12.0 XML;';"); con.Open(); //excel from storage OleDbCommand ExcelCommand = new OleDbCommand("SELECT * FROM [Sheet3$]", con); OleDbDataAdapter ExcelAdapter = new OleDbDataAdapter(ExcelCommand); DataSet ExcelDataSet = new DataSet(); ExcelAdapter.Fill(ExcelDataSet); gvStorage.DataSource = ExcelDataSet.Tables[0]; gvStorage.DataBind(); //insert to database storage try { for (int i = 0; i < gvStorage.Rows.Count; i++) { string storage_location = gvStorage.Rows[i].Cells[0].Text; string warehouse = gvStorage.Rows[i].Cells[1].Text; if (warehouse.Trim() == " ") { warehouse = string.Empty; } SqlCommand cmd = new SqlCommand("insert into storage(storage_location,warehouse) values(@Storage_location,@Warehouse)", conn_sql); cmd.Parameters.AddWithValue("@Storage_location", storage_location); cmd.Parameters.AddWithValue("@Warehouse", warehouse); cmd.ExecuteNonQuery(); } } catch (Exception ex) { lblMessage.Text += ex.Message; }; if (ExcelDataSet.Tables.Count == 0) { lblMessage.Text += "Storage Failed"; } else { lblMessage.Text += "Storage Success! "; } //excel from detail_cs ExcelCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", con); ExcelAdapter = new OleDbDataAdapter(ExcelCommand); ExcelDataSet = new DataSet(); ExcelAdapter.Fill(ExcelDataSet); //deleting rows if all cell are empty for (int i = 5; i < 24; i++) { ExcelDataSet.Tables[0].Rows.RemoveAt(i); } GridView1.DataSource = ExcelDataSet.Tables[0]; GridView1.DataBind(); //insert to database detail_cs try { for (int k = 1; k < GridView1.Rows.Count; k++) { string exception = GridView1.Rows[k].Cells[0].Text; string material = GridView1.Rows[k].Cells[1].Text; string plant = GridView1.Rows[k].Cells[2].Text; string storage_location = GridView1.Rows[k].Cells[3].Text; string material_description = GridView1.Rows[k].Cells[4].Text; string base_unit_of_measure = GridView1.Rows[k].Cells[5].Text; string batch = GridView1.Rows[k].Cells[6].Text; string unrestricted = GridView1.Rows[k].Cells[7].Text; string in_quality_insp = GridView1.Rows[k].Cells[8].Text; string blocked = GridView1.Rows[k].Cells[9].Text; string total_stock = GridView1.Rows[k].Cells[10].Text; string market = GridView1.Rows[k].Cells[11].Text; string week = GridView1.Rows[k].Cells[12].Text; string year = GridView1.Rows[k].Cells[13].Text; string warehouse = GridView1.Rows[k].Cells[14].Text; if (exception.Trim() == " ") { exception = string.Empty; } if (material.Trim() == " ") { material = string.Empty; } if (plant.Trim() == " ") { plant = string.Empty; } if (material_description.Trim() == " ") { material_description = string.Empty; } if (base_unit_of_measure.Trim() == " ") { base_unit_of_measure = string.Empty; } if (batch.Trim() == " ") { batch = string.Empty; } if (market.Trim() == " ") { market = string.Empty; } if (year.Trim() == " ") { year = string.Empty; } if (storage_location != string.Empty) { SqlCommand cmd = new SqlCommand("insert into detail_cs(exception,material,plant,storage_location,material_description,base_unit_of_measure,batch,unrestricted,in_quality,blocked,total_stock,market,week,year,warehouse) values(@Exception,@Material,@Plant,@Storage_Location,@Material_Description,@Base_Unit_Of_Measure,@Batch,@Unrestricted,@In_Quality,@Blocked,@Total_Stock,@Market,@Week,@Year,@Warehouse)", conn_sql); cmd.Parameters.AddWithValue("@Exception", exception); cmd.Parameters.AddWithValue("@Material", material); cmd.Parameters.AddWithValue("@Plant", plant); cmd.Parameters.AddWithValue("@Storage_Location", storage_location); cmd.Parameters.AddWithValue("@Material_Description", material_description); cmd.Parameters.AddWithValue("@Base_Unit_Of_Measure", base_unit_of_measure); cmd.Parameters.AddWithValue("@Batch", batch); cmd.Parameters.AddWithValue("@Unrestricted", Convert.ToInt32(unrestricted)); cmd.Parameters.AddWithValue("@In_Quality", Convert.ToInt32(in_quality_insp)); cmd.Parameters.AddWithValue("@Blocked", Convert.ToInt32(blocked)); cmd.Parameters.AddWithValue("@Total_Stock", Convert.ToInt32(total_stock)); cmd.Parameters.AddWithValue("@Market", market); cmd.Parameters.AddWithValue("@Week", Convert.ToInt32(week)); cmd.Parameters.AddWithValue("@Year", year); cmd.Parameters.AddWithValue("@Warehouse", warehouse); cmd.ExecuteNonQuery(); } } } catch (Exception ex) { Label1.Text += ex.Message; }; if (ExcelDataSet.Tables.Count == 0) { lblMessage.Text += "Detail_CS Failed!!"; } else { lblMessage.Text += "Detail_CS Success!!"; } con.Close(); } } catch (Exception ex) { lblMessage.Text = ex.Message; } } }
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; BindIssueGVDetails(); GridView1.DataBind(); }
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; GridView1.DataSource = expirebplist; GridView1.DataBind(); }
public void SetGridData(IEnumerable <ListCourseGridViewModel> vm) { GridView1.DataSource = vm; GridView1.DataBind(); }
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; GridView1.DataSource = MyUtils.BookBoard(10); GridView1.DataBind(); }
private void LoadDataToUI() { GridView1.DataSource = m_AuthService.GetLoginUserList("1=1 ORDER BY ArrivedDate"); GridView1.DataBind(); }
protected void Button3_Click(object sender, EventArgs e) { SqlConnection conc = new SqlConnection(ConfigurationManager.ConnectionStrings["DBconnect"].ConnectionString); conc.Open(); if (DropDownList1.SelectedValue == "Employee") { string qurey = "Delete employee where emp_id='" + TextBox3.Text + "'"; SqlCommand cmd = new SqlCommand(qurey, conc); try { if (cmd.ExecuteNonQuery() < 1) { Response.Write("Employee dosen't exsist."); } else { GridView1.DataBind(); GridView2.DataBind(); GridView3.DataBind(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Response.Write(errorMessages.ToString()); } } else if (DropDownList1.SelectedValue == "Department") { string qurey = "Delete Department where deptno='" + TextBox3.Text + "'"; SqlCommand cmd = new SqlCommand(qurey, conc); try { if (cmd.ExecuteNonQuery() < 1) { Response.Write("Department dosen't exsist."); } else { GridView1.DataBind(); GridView2.DataBind(); GridView3.DataBind(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Response.Write(errorMessages.ToString()); } } else if (DropDownList1.SelectedValue == "Colour") { string qurey = "Delete Colour where Colour_id='" + TextBox3.Text + "'"; SqlCommand cmd = new SqlCommand(qurey, conc); try { if (cmd.ExecuteNonQuery() < 1) { Response.Write("Colour dosen't exsist."); } else { GridView1.DataBind(); GridView2.DataBind(); GridView3.DataBind(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Response.Write(errorMessages.ToString()); } } else if (DropDownList1.SelectedValue == "Customer") { string qurey = "Delete Customer where Customer_id='" + TextBox3.Text + "'"; SqlCommand cmd = new SqlCommand(qurey, conc); try { if (cmd.ExecuteNonQuery() < 1) { Response.Write("Customer dosen't exsist."); } else { GridView1.DataBind(); GridView2.DataBind(); GridView3.DataBind(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Response.Write(errorMessages.ToString()); } } else if (DropDownList1.SelectedValue == "Car_Sold") { string qurey = "Delete Car_sold where chassis_no='" + TextBox3.Text + "'"; SqlCommand cmd = new SqlCommand(qurey, conc); try { if (cmd.ExecuteNonQuery() < 1) { Response.Write("Chassis number dosen't exsist."); } else { GridView1.DataBind(); GridView2.DataBind(); GridView3.DataBind(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Response.Write(errorMessages.ToString()); } } else if (DropDownList1.SelectedValue == "Car") { string qurey = "Delete Car where Car_id='" + TextBox3.Text + "'"; SqlCommand cmd = new SqlCommand(qurey, conc); try { if (cmd.ExecuteNonQuery() < 1) { Response.Write("Car dosen't exsist."); } else { GridView1.DataBind(); GridView2.DataBind(); GridView3.DataBind(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Response.Write(errorMessages.ToString()); } } }
public void GridViewBind() { string str1 = " WHERE B.UI_LX='企业' AND DL_RQ BETWEEN '" + hkdb.GetStr(txtSdate.Text) + "' AND '" + hkdb.GetStr(txtEdate.Text) + "'"; //个人权限 if (hkdb.StrIx("603091", Session["roleqx"].ToString())) { str1 = str1 + " AND DL_ID='" + this.Session["userid"] + "'"; } //部门权限 if (hkdb.StrIx("603092", Session["roleqx"].ToString())) { if (this.Session["bmglqx"].ToString() == "Y") { string cal = ""; SqlDataReader dr_bm = SqlHelper.ExecuteReader("EXEC sp_RECUR_BM '" + this.Session["deptid"].ToString() + "'"); while (dr_bm.Read()) { if (string.IsNullOrEmpty(cal)) { cal = dr_bm["bm_id"].ToString(); } else { cal = cal + "','" + dr_bm["bm_id"].ToString(); } } dr_bm.Close(); str1 = str1 + " AND DL_ID IN(SELECT UI_ID FROM YH WHERE UI_SSBM IN('" + cal + "'))"; } else { str1 = str1 + " AND DL_ID IN(SELECT UI_ID FROM YH WHERE UI_SSBM='" + this.Session["deptid"] + "')"; } } if (!string.IsNullOrEmpty(rysq.Text)) { str1 = str1 + " AND (DL_ID LIKE '%" + hkdb.GetStr(rysq.Text) + "%' OR UI_DESC LIKE '%" + hkdb.GetStr(rysq.Text) + "%')"; } if (!string.IsNullOrEmpty(ipdz.Text)) { str1 = str1 + " AND DL_IP='" + hkdb.GetStr(ipdz.Text) + "'"; } if (!string.IsNullOrEmpty(dlzt.SelectedValue)) { str1 = str1 + " AND DL_ZT='" + dlzt.SelectedValue + "'"; } if (!string.IsNullOrEmpty(jrmk.Text)) { str1 = str1 + " AND OPEN_MK='" + hkdb.GetStr(jrmk.Text) + "'"; } if (!string.IsNullOrEmpty(dl_rk.SelectedValue)) { str1 = str1 + " AND dl_rk='" + dl_rk.SelectedValue + "'"; } AspNetPager1.RecordCount = (int)SqlHelper.ExecuteScalar("SELECT COUNT(*) FROM HK_DLRZ A LEFT OUTER JOIN YH B ON (A.DL_ID=B.UI_ID) " + str1 + ""); DataSet ds = SqlHelper.ExecuteDs("SELECT A.*,B.UI_DESC,C.MODU_MC FROM HK_DLRZ A LEFT OUTER JOIN YH B ON (A.DL_ID=B.UI_ID) LEFT OUTER JOIN HK_MODU C ON (A.OPEN_MK=C.MODU_ID) " + str1 + " ORDER BY DL_RQ DESC", AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize); GridView1.DataSource = ds; GridView1.DataBind(); }