protected void Page_Load(object sender, EventArgs e) { if (this.User != null && this.User.Identity.IsAuthenticated) { string sql = "select count(*) as nr from AspNetCategoriiVizitate where iduser = @id"; SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-licentav1-2a6b1562-d107-4018-abaf-b5f96cb38543;AttachDbFilename=|DataDirectory|\aspnet-licentav1-2a6b1562-d107-4018-abaf-b5f96cb38543.mdf;Integrated Security=SSPI"); con.Open(); SqlCommand com = new SqlCommand(sql, con); com.Parameters.AddWithValue("id", HttpContext.Current.User.Identity.GetUserId()); int nr = 0; SqlDataReader r = com.ExecuteReader(); while (r.Read()) { nr = int.Parse(r["nr"].ToString()); } con.Close(); // Response.Write(nr.ToString()); if (nr < 500) { SqlDataSource1.SelectCommand = "exec sortarerelevanta2 @id"; SqlDataSource1.SelectParameters.Add("id", HttpContext.Current.User.Identity.GetUserId()); } else { SqlDataSource1.SelectCommand = "exec sortarerelevanta @id"; SqlDataSource1.SelectParameters.Add("id", HttpContext.Current.User.Identity.GetUserId()); } BindRepeater(); SqlDataSource1.DataBind(); } else { Response.Redirect("First"); } }
protected void BtnUpdate_Click(object sender, EventArgs e) { try { accountantCls.Cmd.Connection.ConnectionString = accountantCls.GetConnStr(); accountantCls.Cmd.CommandType = CommandType.StoredProcedure; accountantCls.Cmd.CommandText = "USP_Division_Edit"; accountantCls.Cmd.Parameters.Add("@DivisionId", SqlDbType.Int).Value = ViewState["EditId"]; accountantCls.Cmd.Parameters.Add("@DepartmentId", SqlDbType.Int).Value = _DepartmentList.SelectedValue; accountantCls.Cmd.Parameters.Add("@DIVDivisionName", SqlDbType.NVarChar).Value = _DivisionNameText.Text; accountantCls.Cmd.Parameters.Add("@DIVDescription", SqlDbType.NVarChar).Value = _DIVDescriptionText.Text; accountantCls.Cmd.Parameters.Add("@UserId", SqlDbType.Int).Value = Session["UserCode"].ToString(); class1.ErrorNo = 0; accountantCls.beginTrans(); int t = accountantCls.Cmd.ExecuteNonQuery(); BtnSave.Visible = true; BtnUpdate.Visible = false; accountantCls.commitTrans(); } catch (Exception ex) { accountantCls.rollBackTrans(); class1.ErrorDesc = ex.Message; class1.ErrorNo = -1; } finally { SqlDataSource1.DataBind(); GvCompany.DataBind(); } }
//protected void LinkButton3_Click(object sender, EventArgs e) //{ // if (e.CommandName == "Select") // { // } // int Id = Convert.ToInt32(GridView1.DataKeys[rowindex].Value); // TextBox ImageName = GridView1.FooterRow.FindControl("TextBox3") as TextBox; // string path = ""; // FileUpload Image = GridView1.FooterRow.FindControl("FileUpload3") as FileUpload; // if (Image.HasFile) // { // Image.PostedFile.SaveAs(Server.MapPath("~/images/" + Image.FileName)); // path = "~/images/" + Image.FileName; // } // SqlCommand sda = new SqlCommand("update Fileuploadgrid set ImageName='" + txtimagename.Text + "',Image='" + path + "' where Id='" + Id + "'", con); // con.Open(); // sda.ExecuteNonQuery(); // con.Close(); // Label1.Text = "Rows inserted successfully"; // SqlDataSource1.DataBind(); // GridView1.DataSourceID = null; // GridView1.DataSource = SqlDataSource1; // GridView1.DataBind(); //} protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { int Id = Convert.ToInt32(e.CommandArgument); TextBox ImageName = GridView1.FooterRow.FindControl("TextBox3") as TextBox; string path = ""; FileUpload Image = GridView1.FooterRow.FindControl("FileUpload3") as FileUpload; if (Image.HasFile) { Image.PostedFile.SaveAs(Server.MapPath("~/images/" + Image.FileName)); path = "~/images/" + Image.FileName; } SqlCommand sda = new SqlCommand("update Fileuploadgrid set ImageName='" + txtimagename.Text + "',Image='" + path + "' where Id='" + Id + "'", con); con.Open(); sda.ExecuteNonQuery(); con.Close(); Label1.Text = "Rows inserted successfully"; SqlDataSource1.DataBind(); GridView1.DataSourceID = null; GridView1.DataSource = SqlDataSource1; GridView1.DataBind(); } }
protected void LinkButton5_Click(object sender, EventArgs e) { TextBox QuizID = GridView1.FooterRow.FindControl("TextBox13") as TextBox; TextBox question = GridView1.FooterRow.FindControl("TextBox7") as TextBox; TextBox A = GridView1.FooterRow.FindControl("TextBox8") as TextBox; TextBox B = GridView1.FooterRow.FindControl("TextBox9") as TextBox; TextBox C = GridView1.FooterRow.FindControl("TextBox10") as TextBox; TextBox D = GridView1.FooterRow.FindControl("TextBox11") as TextBox; TextBox answer = GridView1.FooterRow.FindControl("TextBox12") as TextBox; String query = "set identity_insert admin_quiz ON;" + "insert into coursequiz2 (QuizID,question,A,B,C,D,answer) Values('" + QuizID.Text + "','" + question.Text + "','" + A.Text + "','" + B.Text + "','" + C.Text + "','" + D.Text + "','" + answer.Text + "')" + "SET IDENTITY_INSERT admin_quiz OFF;"; String mycon = "Data Source=NISHANT\\SQLEXPRESS;Initial Catalog=gls;Integrated Security=True"; SqlConnection con = new SqlConnection(mycon); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = query; cmd.Connection = con; cmd.ExecuteNonQuery(); Label9.Text = "New Row Inserted Successfully"; SqlDataSource1.DataBind(); GridView1.DataSource = SqlDataSource1; GridView1.DataBind(); }
protected void Button3_Click(object sender, EventArgs e) { try { int SubtotalProd; decimal totalPrecio; if (Convert.ToInt32(TextBox2.Text) > Convert.ToInt32(Totalprod)) { Response.Write("<script>alert('El valor ingresado es mayor al total del producto en el sistema')</script>"); } else { if (Convert.ToInt32(Totalprod) == Convert.ToInt32(TextBox2.Text)) { datos2.EliminarDetallV(Convert.ToInt32(IDdetalleVenta), Convert.ToInt32(Totalprod), Convert.ToInt32(idStock)); SqlDataSource1.SelectParameters["ID_Venta"].DefaultValue = TextBox1.Text; SqlDataSource1.DataBind(); Label3.Text = "Se ha devuelto: " + TextBox2.Text + " productos con exitos!"; } else { SubtotalProd = Convert.ToInt32(Totalprod) - Convert.ToInt32(TextBox2.Text); totalPrecio = Convert.ToDecimal(precio) * Convert.ToDecimal(SubtotalProd); datos2.EditarDetalleVenta(SubtotalProd, totalPrecio, Convert.ToInt32(IDdetalleVenta)); datos2.EditarStockDevol(Convert.ToInt32(TextBox2.Text), Convert.ToInt32(idStock)); SqlDataSource1.SelectParameters["ID_Venta"].DefaultValue = TextBox1.Text; SqlDataSource1.DataBind(); Label3.Text = "Se ha devuelto: " + TextBox2.Text + " productos con exitos!"; } } } catch { Response.Write("<script>alert('Hay un error!')</script>"); } }
protected void btnInsertar(object sender, EventArgs e) { Clases.Beans.Departamento d = new Clases.Beans.Departamento(); if (String.IsNullOrEmpty(TxtCodigoDepartamento.Text) || String.IsNullOrEmpty(TxtNombreDepartamento.Text) || String.IsNullOrEmpty(TxtDescripcionDepartamento.Text)) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); } else { d.Codigo_departamento = TxtCodigoDepartamento.Text; d.Nombre = TxtNombreDepartamento.Text; d.Descripcion = TxtDescripcionDepartamento.Text; md.crearDepartamento(d); TxtCodigoDepartamento.Text = ""; TxtNombreDepartamento.Text = ""; TxtDescripcionDepartamento.Text = ""; Response.Redirect("/Vistas/Catalogos/Departamento.aspx"); } SqlDataSource1.DataBind(); TablaDepartamento.DataBind(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { Label id = GridView1.Rows[e.RowIndex].FindControl("Label5") as Label; TextBox year = GridView1.Rows[e.RowIndex].FindControl("TextBox1") as TextBox; TextBox production = GridView1.Rows[e.RowIndex].FindControl("TextBox2") as TextBox; String mycon = "Data Source=.\\SQLEXPRESS;AttachDbFilename=D:\\ASP CHARTS\\Admin\\App_Data\\RiceDatabase.mdf;Integrated Security=True;User Instance=True"; String updatedata = "update Dhaka set year='" + year.Text + "', production='" + production.Text + "' where id=" + id.Text; SqlConnection con = new SqlConnection(mycon); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = updatedata; cmd.Connection = con; cmd.ExecuteNonQuery(); Label6.Text = "Row Data Has Been Updated Successfully"; GridView1.EditIndex = -1; SqlDataSource1.DataBind(); GridView1.DataSource = SqlDataSource1; GridView1.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { Label1.Text = ""; if (!FileUpload1.HasFile) { Label1.Text = "nehum arquivo selecionado"; ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Selecione um arquivo')", true); return; } string nmArq = @"c:\temp\_" + FileUpload1.FileName; FileUpload1.SaveAs(nmArq); System.IO.FileInfo arq = new System.IO.FileInfo(nmArq); if (arq.Extension.ToLower() != ".xtr") { Label1.Text = "arquivo deve ser de extensão .xtr"; ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('arquivo deve ser de extensão .xtr')", true); return; } RetornoANS ret = new RetornoANS(); string retorno = ret.processaRetornoANS(nmArq); if (retorno != "") { Label1.Text = retorno; ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('" + retorno + "')", true); } else { ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('processamento finalizado com sucesso')", true); Label1.Text = "processamento finalizado com sucesso"; TextBox1.Text = arq.Name.Substring(11, 2) + "/" + arq.Name.Substring(7, 4); TextBox2.Text = arq.Name.Substring(13, 4); SqlDataSource1.DataBind(); } }
protected void Button1_Click(object sender, EventArgs e) { try { enable(); Button1.Enabled = false; Obj_AddTest.Action = "AddTest"; Obj_AddTest.TestName = ddlUnitType.Text; Obj_AddTest.CourseId = Convert.ToInt32(ddlCourse.SelectedValue); Obj_AddTest.BranchId = Convert.ToInt32(ddlBranch.SelectedValue); Obj_AddTest.ClassId = Convert.ToInt32(ddlClass.SelectedValue); Obj_AddTest.TestMarks = txtmarks.Text; Obj_AddTest.TestDate = txt_Date.Text; Obj_AddTest.SubjectId = Convert.ToInt32(drpSubject.SelectedValue); Obj_AddTest.OrgId = Convert.ToInt32(Session["OrgId"].ToString()); Obj_AddTest.IsActive = 1; Obj_AddTest.PerQuestionMark = txtPerQmark.Text; int TestId = BAL_AddTest.AddTest(Obj_AddTest); // ViewState["TestId"] = TestId; if (TestId > 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Saved", "alert('Test added successfully !!! ')", true); //msgBox.ShowMessage("Test added successfully !!!", "Saved", UserControls.MessageBox.MessageStyle.Successfull); disable(); clear(); } if (TestId == -1) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Information", "alert('Record already exists!!! ')", true); //msgBox.ShowMessage("Record already exists!!!", "Information", UserControls.MessageBox.MessageStyle.Information); } } catch (Exception ex) { } SqlDataSource1.DataBind(); GridView1.DataBind(); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegiConnectionString"].ConnectionString); con.Open(); //reading the id_donacija from tipnadonacija and result putting in int iddonacija for next usage of iddonacija Label tip = GridView1.Rows[e.RowIndex].FindControl("Label2") as Label; string query = "select ID_donacija from Donacija where Tipnadonacija='" + tip.Text + "'"; SqlCommand idcmd = new SqlCommand(query, con); int iddonacija = Convert.ToInt32(idcmd.ExecuteScalar().ToString()); //when clicked Delete button these queries are going to be executed String upadetedata_podnesuvabaranje = "delete from Podnesuvabaranje where ID_donacija='" + iddonacija + "'"; String updatedata_donacija = "delete from Donacija where ID_donacija='" + iddonacija + "'"; //executing first query SqlCommand cmd = new SqlCommand(); cmd.CommandText = upadetedata_podnesuvabaranje; cmd.Connection = con; cmd.ExecuteNonQuery(); //executing secound query cmd.CommandText = updatedata_donacija; cmd.Connection = con; cmd.ExecuteNonQuery(); //writing that operation is succed tekst.Visible = true; tekst.Text = "Успешно бришење!"; //refreshing GridView1 with new data GridView1.EditIndex = -1; SqlDataSource1.DataBind(); GridView1.DataSource = SqlDataSource1; GridView1.DataBind(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { Label EmployeeCode = GridView1.Rows[e.RowIndex].FindControl("EmployeeCodeLabel") as Label; TextBox Fname = GridView1.Rows[e.RowIndex].FindControl("firstName") as TextBox; TextBox Lname = GridView1.Rows[e.RowIndex].FindControl("lastName") as TextBox; TextBox City = GridView1.Rows[e.RowIndex].FindControl("city") as TextBox; TextBox Country = GridView1.Rows[e.RowIndex].FindControl("country") as TextBox; TextBox Username = GridView1.Rows[e.RowIndex].FindControl("uName") as TextBox; TextBox AGE = GridView1.Rows[e.RowIndex].FindControl("age") as TextBox; string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString; if (BllObj.EmployeeUpdate(EmployeeCode.Text, Fname.Text, Lname.Text, City.Text, Country.Text, Username.Text, AGE.Text) == 0) { DataUpdatedLabel.Text = "Data Updated"; GridView1.EditIndex = -1; SqlDataSource1.DataBind(); GridView1.DataSource = BllObj.getUserByUsername((string)Session["Username"]); GridView1.DataBind(); } else { DataUpdatedLabel.Text = "Data not updated"; } }
protected void Drp_Filter_SelectedIndexChanged(object sender, EventArgs e) { if (Drp_Filter.SelectedValue == "0") { SqlDataSource1.SelectCommand = "SELECT docID, Category, Document FROM " + "DocumentMetaPlain GROUP BY docID, Category, " + "Document ORDER BY Category"; } else if (Drp_Filter.SelectedValue == "1") { SqlDataSource1.SelectCommand = "SELECT docID, Category, Document FROM " + "DocumentMetaPlain WHERE Category = 'Thesis' " + "GROUP BY docID, Category, Document ORDER BY Document"; } else if (Drp_Filter.SelectedValue == "2") { SqlDataSource1.SelectCommand = "SELECT docID, Category, Document FROM " + "DocumentMetaPlain WHERE Category = 'Capstone' " + "GROUP BY docID, Category, Document ORDER BY Document"; } else { SqlDataSource1.SelectCommand = "SELECT docID, Category, Document FROM " + "DocumentMetaPlain WHERE docID IN (SELECT DocumentID FROM Attachments) " + "GROUP BY docID, Category, Document ORDER BY Category"; } //SqlDataSource1.Select(null); SqlDataSource1.DataBind(); LvwDocuments.DataBind(); }
protected void btnRetrieve_Click(object sender, EventArgs e) { string userID = ddCustomers.SelectedItem.Value; SqlDataSource1.DataBind(); using (SqlConnection con = new SqlConnection(dbs)) { using (SqlCommand command = new SqlCommand("Select UserId, Status, Description, ReportDate, IncidentID from [Incident] where UserID = " + userID, con)) { using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { con.Open(); DataTable tbl = new DataTable(); adapter.Fill(tbl); lblCusID.Text = userID; lblDate.Text = tbl.Rows[0]["ReportDate"].ToString(); lblIncidentID.Text = libIncident.SelectedItem.Value; lblStatus.Text = tbl.Rows[0]["Status"].ToString(); txtDes.Text = tbl.Rows[0]["Description"].ToString(); con.Close(); } } } }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { if (ddCustomers.SelectedItem != null) { libIncident.Items.Clear(); SqlDataSource1.DataBind(); using (SqlConnection con = new SqlConnection(dbs)) { using (SqlCommand cmd = new SqlCommand("SELECT IncidentId, CONVERT(varchar(5),IncidentID) +', '+ Title +', '+ Status +', '+ CONVERT(varchar(5),ReportDate) as combind FROM [Incident] WHERE UserID = @UserID ", con)) { cmd.Parameters.AddWithValue("@UserID", ddCustomers.SelectedItem.Value); con.Open(); libIncident.DataTextField = "combind"; libIncident.DataValueField = "IncidentID"; libIncident.DataSource = cmd.ExecuteReader(); libIncident.DataBind(); //Change Incident ID when selected index change lblIncidentID.Text = libIncident.SelectedValue; con.Close(); } } } }
protected void Page_Load(object sender, EventArgs e) { MyClass my = new MyClass(); if (IsPostBack == false) { if (Session["College_id"] != null) { cid = int.Parse(Session["College_id"].ToString()); Label1.Text = cid.ToString(); Label2.Text = my.Get_College(cid); sql = "select * from " + Tbl_Name + " where COLLEGE_ID =" + cid + " "; SqlDataSource1.SelectCommand = sql; SqlDataSource1.DataBind(); } } //lblResult.Text = string.Empty; //A_Handler = new Order_MasterHandler(); ////if (IsPostBack == false) ////{ //// //Grid1.DataSource = A_Handler.GetOrder_MasterList(); //// //Grid1.DataBind(); //// if (Grid1.Rows.Count > 0) //// { //// lblRec.Text = "Total Records : " + Grid1.Rows.Count.ToString(); //// } //// else //// { //// lblRec.Text = "Record Not Found..."; //// } ////} }
protected void btnCambiar_Click(object sender, EventArgs e) { SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString()); SqlCommand cmd = new SqlCommand("SP_Update_Propietario", con1); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@inNombre", SqlDbType.VarChar, 100).Value = txtNombreCambiar.Text.ToString(); if (listaJuridicoCambiar.Text.CompareTo("Jurídico") == 0) { cmd.Parameters.Add("@inIdentificacion", SqlDbType.VarChar, 30).Value = 0; cmd.Parameters.Add("@inIdentificacionPersonaJ", SqlDbType.VarChar, 30).Value = txtNuevoIDCambiar.Text.ToString(); cmd.Parameters.Add("@inIdentificacionPJOriginal", SqlDbType.VarChar, 30).Value = txtIDCambiar.Text.ToString(); cmd.Parameters.Add("@inEsJuridico", SqlDbType.Int).Value = 1; cmd.Parameters.Add("@inIdentificacionOriginal", SqlDbType.VarChar, 30).Value = 0; cmd.Parameters.Add("@inValorTipoIdPersonaJ", SqlDbType.Int).Value = int.Parse(txtValorTDid.Text.ToString()); cmd.Parameters.Add("@inValorTipoId", SqlDbType.Int).Value = 0; cmd.ExecuteNonQuery(); con1.Close(); con1.Dispose(); SqlDataSource1.DataBind(); } else if (listaJuridicoCambiar.Text.CompareTo("Jurídico") != 0) { cmd.Parameters.Add("@inIdentificacionPersonaJ", SqlDbType.VarChar, 30).Value = 0; cmd.Parameters.Add("@inIdentificacion", SqlDbType.VarChar, 30).Value = txtNuevoIDCambiar.Text.ToString(); cmd.Parameters.Add("@inIdentificacionOriginal", SqlDbType.VarChar, 30).Value = txtIDCambiar.Text.ToString(); cmd.Parameters.Add("@inEsJuridico", SqlDbType.Int).Value = 0; cmd.Parameters.Add("@inIdentificacionPJOriginal", SqlDbType.VarChar, 30).Value = 0; cmd.Parameters.Add("@inValorTipoId", SqlDbType.Int).Value = int.Parse(txtValorTDid.Text.ToString()); cmd.Parameters.Add("@inValorTipoIdPersonaJ", SqlDbType.Int).Value = 0; cmd.ExecuteNonQuery(); con1.Close(); con1.Dispose(); SqlDataSource1.DataBind(); } }
protected void LinkButton5_Click(object sender, EventArgs e) { con.Open(); TextBox PCOURSEID = GridView1.FooterRow.FindControl("TextBox2") as TextBox; TextBox PCOURSE = GridView1.FooterRow.FindControl("TextBox3") as TextBox; TextBox AMOUNT = GridView1.FooterRow.FindControl("TextBox9") as TextBox; try { string q = "insert into PaidCourseTable(PCOURSEID,PCOURSE,AMOUNT) values('" + PCOURSEID.Text + "','" + PCOURSE.Text + "','" + AMOUNT.Text + "')"; SqlCommand cmd = new SqlCommand(q, con); cmd.ExecuteNonQuery(); } catch (Exception ex) { Response.Write("<script>alert('Duplicate Course ID is not allowed')</script>"); } Label7.Text = " New Row successfully Inserted"; SqlDataSource1.DataBind(); GridView1.DataSource = SqlDataSource1; GridView1.DataBind(); con.Close(); }
protected void Page_Load(object sender, EventArgs e) { //Label1.Visible = false; string updatedwntimeonload = @"Update IncidentsNew1 set downtime=cast((cast(cast(getdate() as float) - cast(opendate as float) as int) * 24) + datepart(hh, getdate() - opendate) as varchar(10)) + ':' + right('0' + cast(datepart(mi, getdate() - opendate) as varchar(2)), 2) where (callstatus='OPEN' or callstatus='DISPATCHED' or callstatus='RE-OPEN')"; obj.NonExecuteQuery(updatedwntimeonload); string upddwntime = @"Update IncidentsNew1 set Downtime=(Select CONVERT(varchar(5),datediff(s,opendate,resolveddate)/3600) + ':' + CONVERT(varchar(5),datediff(s,opendate,resolveddate)/3600%60)),DTStatus='SYN' where (CallStatus='RESOLVED' or CallStatus='CLOSE') and DTStatus='CRE'"; obj.NonExecuteQuery(upddwntime); //update query to replace '-' in downtime when it is calculated in negative //downtime is calculated in negative when opendate from application is greater than the current date string upddwntimenew = @"Update IncidentsNew1 set Downtime=REPLACE(downtime,'-','') where downtime like '%-%'"; obj.NonExecuteQuery(upddwntimenew); if (!Page.IsPostBack) { //status = ""; chkAll.Checked = true; for (int i = 0; i < ddcalltype.Items.Count; i++) { ddcalltype.Items[i].Selected = true; } ////ddcalltype1.Text = status.Remove("'"); ////Response.Write(ddcalltype1.Text); lblTotalSelectedEmailCount.Text = ddcalltype.Items.Count.ToString() + " item(s) selected"; //StartDate_CalendarExtender.EndDate = Convert.ToDateTime(DateTime.Now.Date.ToString("MM/dd/yyyy")); //EndDate_CalendarExtender.EndDate = Convert.ToDateTime(DateTime.Now.Date.ToString("MM/dd/yyyy")); string sessrole = ""; try { sessrole = Session["sess_role"].ToString(); } catch (Exception ee) { Response.Redirect("~/Login.aspx"); } dd_faultC.Items.Add("ALL"); dd_faultC.Items.FindByText("ALL").Value = "%"; string query1x = "Select distinct [faultcode] FROM [faultcode]"; obj.BindDropDown(dd_faultC, query1x); try { if (Request.QueryString["fault"].ToString() != "") { dd_faultC.Items.FindByText(Request.QueryString["fault"].ToString()).Selected = true; if (Request.QueryString["TAT"].ToString() == "true") { SqlDataSource1.SelectCommand = SqlDataSource1.SelectCommand.ToString().Replace("where", "where CONVERT(int,REPLACE(Downtime,':',''))<CONVERT(int,REPLACE(f.TAT,':','')) and "); SqlDataSource1.DataBind(); } else if (Request.QueryString["TAT"].ToString() == "false") { SqlDataSource1.SelectCommand = SqlDataSource1.SelectCommand.ToString().Replace("where", "where CONVERT(int,REPLACE(Downtime,':',''))>CONVERT(int,REPLACE(f.TAT,':','')) and "); SqlDataSource1.DataBind(); } else if (Request.QueryString["TAT"].ToString() == "both") { } } } catch { dd_faultC.Items.FindByValue("%").Selected = true; } //ddbank.DataBind(); ddbank.Items.Add("ALL"); ddbank.Items.FindByText("ALL").Value = "%"; ddbank.Items.FindByValue("%").Selected = true; string query1 = "Select distinct ltrim(rtrim(bankid)) FROM [atms]"; obj.BindDropDown(ddbank, query1); ddagency.Items.Add("ALL"); ddagency.Items.FindByText("ALL").Value = "%"; ddagency.Items.FindByValue("%").Selected = true; string query9 = "Select distinct client FROM [atms]"; obj.BindDropDown(ddagency, query9); //ddcity.DataBind(); //ddcity.Items.Add("ALL"); //ddcity.Items.FindByText("ALL").Value = "%"; //ddcity.Items.FindByValue("%").Selected = true; string query3 = "Select distinct [username] as [RCM] FROM [Users] where username like '" + Session["sess_username"] + "'"; obj.BindDropDown(ddcity, query3); ddzone.DataBind(); ddzone.Items.Add("ALL"); ddzone.Items.FindByText("ALL").Value = "%"; ddzone.Items.FindByValue("%").Selected = true; ddproject.Items.Add("ALL"); ddproject.Items.FindByText("ALL").Value = "%"; ddproject.Items.FindByValue("%").Selected = true; string queryx = "Select distinct project FROM [ATMs]"; obj.BindDropDown(ddproject, queryx); //ddcalltype.DataBind(); //ddcalltype.Items.Add("ALL"); //ddcalltype.Items.FindByText("ALL").Value = "%"; //ddcalltype.Items.FindByValue("%").Selected = true; ////ddcalltype.Items.Add("NO ISSUES"); ////ddcalltype.Items.FindByText("NO ISSUES").Value = "NO ISSUES"; //string query4 = "Select distinct ltrim(rtrim(callstatus)) as [callstatus] FROM [IncidentsNew1] order by callstatus asc"; //obj.BindDropDown(ddcalltype, query4); //dddowntime.DataBind(); dddowntime.Items.Add("ALL"); dddowntime.Items.FindByText("ALL").Value = "120000"; dddowntime.Items.Add("0-5 Days"); dddowntime.Items.FindByText("0-5 Days").Value = "11999"; dddowntime.Items.Add("6-10 Days"); dddowntime.Items.FindByText("6-10 Days").Value = "23999"; dddowntime.Items.Add("11-15 Days"); dddowntime.Items.FindByText("11-15 Days").Value = "35999"; dddowntime.Items.Add("16-20 Days"); dddowntime.Items.FindByText("16-20 Days").Value = "47999"; dddowntime.Items.Add("21-30 Days"); dddowntime.Items.FindByText("21-30 Days").Value = "71999"; dddowntime.Items.Add(">30 Days"); dddowntime.Items.FindByText(">30 Days").Value = "119999"; dddowntime.Items.FindByValue("120000").Selected = true; Label2.Text = "000"; //Label5.Text = "CLOSE"; //Label6.Text = "RESOLVED"; if (txtEndDate.Text == "") { Label4.Text = System.DateTime.Today.ToString("dd'/'MM'/'yyyy"); } if (txtStartDate.Text == "") { //Label3.Text = "01/09/2014"; Label3.Text = System.DateTime.Today.ToString("dd'/'MM'/'yyyy"); } string[] words = Label3.Text.Split('/'); Label5.Text = words[1] + '/' + words[0] + '/' + words[2]; string[] words1 = Label4.Text.Split('/'); Label6.Text = words1[1] + '/' + words1[0] + '/' + words1[2]; Hid1.Value = "%"; Hid2.Value = "%"; SqlDataSource1.SelectCommand = SqlDataSource1.SelectCommand.ToString().Replace("callstatus in (@callstatus)", "Callstatus like '%'"); SqlDataSource1.DataBind(); GridView1.AllowPaging = true; GridView1.AllowSorting = false; GridView1.DataSourceID = "SqlDataSource1"; GridView1.DataBind(); } else { for (int i = 0; i < ddcalltype.Items.Count; i++) { if (ddcalltype.Items[i].Selected == true) { status += ddcalltype.Items[i].Text + "','"; cnt++; } } if (cnt == 0) { status = ""; } lblTotalSelectedEmailCount.Text = cnt.ToString() + " item(s) selected"; if (status.Length > 3) { status = status.Remove(status.Length - 3); } if (txtEndDate.Text == "") { Label4.Text = System.DateTime.Today.ToString("dd'/'MM'/'yyyy"); } else { Label4.Text = txtEndDate.Text; } if (txtStartDate.Text == "") { //Label3.Text = "01/09/2014"; Label3.Text = System.DateTime.Today.ToString("dd'/'MM'/'yyyy"); } else { Label3.Text = txtStartDate.Text; } // ddcalltype1.Text = status; SqlDataSource1.SelectCommand = SqlDataSource1.SelectCommand.ToString().Replace("callstatus in (@callstatus)", "callstatus in ('" + status + "')"); SqlDataSource1.DataBind(); GridView1.DataSourceID = "SqlDataSource1"; GridView1.DataBind(); } }
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; SqlDataSource1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["status"] != null && Session["status"].ToString().Equals("1")) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorFunction", "errorMessages('Multumim! Votul tau a fost inregistrat','success');", true); Session.Remove("status"); } if (Session["editBook"] != null && Session["editBook"].ToString().Equals("1")) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorFunction", "errorMessages('Date cartii au fost actualizate cu succes!','success');", true); Session.Remove("editBook"); } } catch (Exception err) { } if (!Page.IsPostBack) { string q = Request.Params["q"]; if (q != null) { try { q = Server.UrlDecode(q); SqlDataSource1.SelectCommand = "SELECT Carti.Id AS CartiId, Carti.Titlu AS CartiTitlu, Carti.Poza_Coperta, Carti.Text_Descriere, Genuri.Gen, Autori.Prenume + ' ' + Autori.Nume AS NumeAutor, ROUND(AVG(ISNULL(NoteDateCartilor.Nota, 0)), 0) AS MedieNote FROM Carti INNER JOIN Genuri ON Carti.Id_Gen = Genuri.Id INNER JOIN Autori ON Carti.Id_Autor = Autori.Id LEFT JOIN NoteDateCartilor ON Carti.Id = NoteDateCartilor.Id_Carte WHERE Carti.Id = @q GROUP BY Carti.Id, Carti.Titlu, Carti.Poza_Coperta, Carti.Text_Descriere, Genuri.Gen, Autori.Prenume + ' ' + Autori.Nume"; SqlDataSource1.SelectParameters.Clear(); SqlDataSource1.SelectParameters.Add("q", q); SqlDataSource1.DataBind(); bool check = (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated; if (check) { string user = System.Web.Security.Membership.GetUser().ProviderUserKey.ToString(); string sqlVerif = "SELECT count(*) from PozeUseri where Id_user = @IdUser"; SqlConnection con = ConnectionFactory.getNewSqlConnection(); con.Open(); SqlCommand com = new SqlCommand(sqlVerif, con); com.Parameters.AddWithValue("IdUser", user); int userCount = (int)com.ExecuteScalar(); con.Close(); if (userCount > 0) { Image imagine = LoginView1.FindControl("ImgUserPicture2") as Image; imagine.ImageUrl = "~/pozeUseri/" + user + ".jpg"; } } SqlDataSource2.SelectCommand = "SELECT Comentarii.Id, Comentarii.Comentariu_Text, Comentarii.Data, Comentarii.Id_Carte, aspnet_Users.UserName, PozeUseri.Poza_User FROM aspnet_Users INNER JOIN Comentarii ON aspnet_Users.UserId = Comentarii.Id_User LEFT OUTER JOIN PozeUseri ON Comentarii.Id_User = PozeUseri.Id_User WHERE Comentarii.Id_Carte = @q"; SqlDataSource2.SelectParameters.Clear(); SqlDataSource2.SelectParameters.Add("q", q); SqlDataSource2.DataBind(); SqlDataSource3.SelectCommand = "SELECT TOP 10 Carti.Id AS CartiId, Carti.Titlu AS CartiTitlu, Carti.Poza_Coperta, Autori.Prenume + ' ' + Autori.Nume AS NumeAutor, Genuri.Gen FROM Carti INNER JOIN Genuri ON Carti.Id_Gen = Genuri.Id INNER JOIN Autori ON Carti.Id_Autor = Autori.Id WHERE (Genuri.Gen = (SELECT Genuri_1.Gen FROM Genuri AS Genuri_1 INNER JOIN Carti AS Carti_1 ON Genuri_1.Id = Carti_1.Id_Gen WHERE (Carti_1.Id = @q))) AND (Carti.Id <> (SELECT Id FROM Carti AS Carti_2 WHERE (Id = @q))) ORDER BY NEWID()"; SqlDataSource3.SelectParameters.Clear(); SqlDataSource3.SelectParameters.Add("q", q); SqlDataSource3.DataBind(); SqlDataSource4.SelectCommand = "SELECT Edituri.Editura, Edituri.Site_Editura FROM CartiApartinDeEdituri INNER JOIN Edituri ON CartiApartinDeEdituri.Id_Editura = Edituri.Id INNER JOIN Carti ON CartiApartinDeEdituri.Id_Carte = Carti.Id WHERE Carti.Id = @q"; SqlDataSource4.SelectParameters.Clear(); SqlDataSource4.SelectParameters.Add("q", q); SqlDataSource4.DataBind(); } catch (Exception err) { } } else { Response.Redirect("~/Home.aspx"); } } }
protected void ASPxGridView1_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e) { SqlDataSource1.DataBind(); ASPxGridView1.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { SqlDataSource1.SelectCommand = "SELECT IdJornada, Nombre, NombreAbreviado FROM Jornada WHERE (Nombre LIke '%" + TextBox4.Text + "%')"; SqlDataSource1.DataBind(); }
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e) { SqlDataSource1.DataBind(); DropDownList1.DataBind(); Getgridview(); }
protected void Button3_Click(object sender, EventArgs e) { try { if (Convert.ToInt32(TextBox2.Text) > Convert.ToInt32(Totalprod)) { Response.Write("<script>alert('El valor ingresado es mayor al total del producto en el sistema')</script>"); } else { if (Convert.ToInt32(Totalprod) == Convert.ToInt32(TextBox2.Text)) { // SubtotalProd = Convert.ToInt32(Totalprod) - Convert.ToInt32(TextBox2.Text); try { totalPrecio = Convert.ToDecimal(precio) * Convert.ToDecimal(SubtotalProd); SqlDataSource2.UpdateParameters["Monto"].DefaultValue = totalDirecto; SqlDataSource2.UpdateParameters["SaldoPendiente"].DefaultValue = totalDirecto; SqlDataSource2.UpdateParameters["ID_Credito"].DefaultValue = idCredito; SqlDataSource2.Update(); SqlDataSource2.DeleteParameters["ID_Credito"].DefaultValue = idCredito; SqlDataSource2.DeleteParameters["ID_Existencia"].DefaultValue = idStock; SqlDataSource2.Delete(); } catch { } datos2.EliminarDetallV(Convert.ToInt32(IDdetalleVenta), Convert.ToInt32(Totalprod), Convert.ToInt32(idStock)); SqlDataSource1.SelectParameters["ID_Venta"].DefaultValue = TextBox1.Text; SqlDataSource1.DataBind(); Label3.Text = "Se ha devuelto: " + TextBox2.Text + " productos con exitos!"; } else { decimal totalCredito = 0; SubtotalProd = Convert.ToInt32(Totalprod) - Convert.ToInt32(TextBox2.Text); totalPrecio = Convert.ToDecimal(precioProdConDescuento) * Convert.ToDecimal(SubtotalProd); datos2.EditarDetalleVenta(SubtotalProd, totalPrecio, Convert.ToInt32(IDdetalleVenta)); datos2.EditarStockDevol(Convert.ToInt32(TextBox2.Text), Convert.ToInt32(idStock)); try { totalCredito = precioProdConDescuento * Convert.ToDecimal(TextBox2.Text); SqlDataSource2.UpdateParameters["Monto"].DefaultValue = totalCredito.ToString(); SqlDataSource2.UpdateParameters["SaldoPendiente"].DefaultValue = totalCredito.ToString(); SqlDataSource2.UpdateParameters["ID_Credito"].DefaultValue = idCredito; SqlDataSource2.Update(); } catch { } SqlDataSource1.SelectParameters["ID_Venta"].DefaultValue = TextBox1.Text; SqlDataSource1.DataBind(); Label3.Text = "Se ha devuelto: " + TextBox2.Text + " productos con exitos!"; } } } catch { Response.Write("<script>alert('Hay un error!')</script>"); } }
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { //Busqueda por ejecucion en la consulta SqlDataSource1.SelectCommand = SqlDataSource1.SelectCommand = "SELECT OrdenMttoCorrectivo.* FROM OrdenMttoCorrectivo WHERE OrdenMttoCorrectivo.Ejecutado Like '%" + RadioButtonList1.Text + "%'"; SqlDataSource1.DataBind(); }
public void UpdateClass() { SqlDataSource1.DataBind(); DropDownList1.DataBind(); }
private void BindDetails() { SqlDataSource1.DataBind(); rptrDetails.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { SqlDataSource1.SelectCommand = "Select * from UserProfile inner join aspnet_Users on UserProfile.UserId = aspnet_Users.UserId where aspnet_Users.Username='******'"; SqlDataSource1.DataBind(); Repeater1.DataBind(); }
protected void Submit_Click(object sender, EventArgs e) { SqlDataSource1.DataBind(); GridView1.DataBind(); }
protected void UploadDocument(object sender, EventArgs e) { string input = "", DirRoot = "", filename = ""; int stringindex = 0, cut = 0; Boolean check = false; Button temp = (Button)sender; string idcut = temp.ID; int startind = idcut.LastIndexOf(@"_"); string cutstr = idcut.Substring(startind + 1, idcut.Length - startind - 1); FileUpload fuDocument = (FileUpload)this.FindControl("fuDocument_" + cutstr); if (fuDocument.HasFile) { input = fuDocument.FileName; stringindex = input.LastIndexOf(@"."); cut = input.Length - stringindex; DirRoot = input.Substring(stringindex + 1, cut - 1); SqlDataSource1.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; SqlDataSource1.SelectCommand = "select id,name from filename_extension"; SqlDataSource1.DataBind(); DataView ou1 = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty); for (int i = 0; i < ou1.Count; i++) { if (DirRoot.ToUpper() == ou1.Table.Rows[i]["name"].ToString().ToUpper()) { check = true; } } if (check) { int fileSize = fuDocument.PostedFile.ContentLength; // Allow only files less than (16 MB)=16777216 bytes to be uploaded. if (fileSize < 16777216) { SqlDataSource sql_insert = new SqlDataSource(); sql_insert.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; filename = DateTime.Now.ToString("yyyyMMddHHmmssffff") + @"." + DirRoot; //sql_insert.InsertCommand = "insert into filename_detail(filename,name)"; //sql_insert.InsertCommand += " values('~/fileplace/" + filename + "','" + fuDocument.FileName.ToString() + "')"; //sql_insert.Insert(); //Label1.Text += fuDocument.FileName.ToString() + " finish<br>"; fuDocument.SaveAs(Server.MapPath("fileplace") + "\\" + filename); Image img = (Image)this.FindControl("Image_" + cutstr); img.ImageUrl = "~/fileplace/" + filename; img.Visible = true; //GridView1.DataBind(); } else { ScriptManager.RegisterStartupScript(fuDocument, fuDocument.GetType(), "alert", "alert('File is out of memory 16MB!')", true); } } else { ScriptManager.RegisterStartupScript(fuDocument, fuDocument.GetType(), "alert", "alert('filename extension is not in role!')", true); } } }