コード例 #1
0
        //printing into spreadsheets
        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.ClearContent();
            Response.AppendHeader("content-disposition", "attachment; filename=EmployeesRent.xls");
            Response.ContentType = "application/excel";
            System.IO.StringWriter stringWriter = new System.IO.StringWriter();
            HtmlTextWriter         htw          = new HtmlTextWriter(stringWriter);

            RentGrid.HeaderRow.Style.Add("background-color", "#FFFFFF");
            foreach (TableCell tableCell in RentGrid.HeaderRow.Cells)
            {
                tableCell.Style["background-color"] = "#A55129";
            }
            foreach (GridViewRow gridViewRow in RentGrid.Rows)
            {
                gridViewRow.BackColor = System.Drawing.Color.White;
                foreach (TableCell gridViewRowTableCell in gridViewRow.Cells)
                {
                    gridViewRowTableCell.Style["background-color"] = "#FFF7E7";
                }
            }
            RentGrid.RenderControl(htw);
            Response.Write(stringWriter.ToString());
            Response.End();
        }
コード例 #2
0
        //Payment process is finally done here
        protected void Dataentry()
        {
            SqlConnection con2 = new SqlConnection(Strcon);

            con2.Open();
            SqlCommand cmd2 = new SqlCommand("Update rent set rent_amount = @rent_amount, rent_status='Paid', rent_paid_date=@rent_paid_date where emp_id = @emp_id ; ", con2);

            cmd2.Parameters.AddWithValue("@emp_id", EmpID.Text.Trim());
            cmd2.Parameters.AddWithValue("@rent_amount", RentAmount.Text.Trim());
            cmd2.Parameters.AddWithValue("@rent_paid_date", Month.Text.Trim());
            cmd2.ExecuteNonQuery();
            RentGrid.DataBind();
            con2.Close();
            ClearForm();
        }
コード例 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //This is to redirect the page if the user is not logged in
     if (string.IsNullOrEmpty((string)Session["role"]))
     {
         Response.Redirect("~/");
     }
     if (!IsPostBack)
     {
         SqlConnection connection = new SqlConnection(Strcon);
         connection.Open();
         SqlCommand Command = new SqlCommand("SELECT allocatedquarter.emp_id from allocatedquarter INNER JOIN rent ON allocatedquarter.emp_id=rent.emp_id WHERE rent.rent_status='Due'", connection);
         EmpID.DataSource = Command.ExecuteReader();
         EmpID.DataBind();
         EmpID.Items.Insert(0, new ListItem("Select a employee ID", ""));
         RentGrid.DataBind();
         connection.Close();
     }
 }