edit_deal.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:7k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- using System.Data.SqlClient;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- public partial class web_data_repair_select_edit_deal : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- public void bind()
- {
- string str_company = dl_company.SelectedItem.ToString().Trim();
- string str_department = dl_department.SelectedValue.ToString().Trim();
- string str_type = dl_type.SelectedItem.ToString().Trim();
- string str_name = dl_name.SelectedItem.ToString().Trim();
- string str_b_time = b_time.Text.ToString().Trim();
- string str_e_time = e_time.Text.ToString().Trim();
- SqlConnection conn = dbConnection.getConnection();
- string sqlstr = "select f.form_id as form_id,f.apply_time as apply_time,f.finish_time as finish_time,f.total_result as total_result,g.department_id as department_id from OA_REPAIR_FORM as f,OA_REPAIR_FORM_DETAIL as g where g.form_id=f.form_id ";
- conn.Open();
- DataSet ds = new DataSet();
- DataTable dt = new DataTable();
- dt.Columns.Add("form_id", typeof(string));
- dt.Columns.Add("department", typeof(string));
- dt.Columns.Add("applytime", typeof(string));
- dt.Columns.Add("finish_date", typeof(string));
- dt.Columns.Add("total_result", typeof(string));
- if (!(str_company.Equals("所有厂商")))
- {
- sqlstr = sqlstr + " and g.company='" + str_company + "'";
- }
- if(!(dl_department.SelectedItem.ToString().Equals("所有门店")))
- {
- sqlstr = sqlstr + " and g.department_id='" + str_department + "'";
- }
- if (!(str_type.Equals("所有类型")))
- {
- sqlstr = sqlstr + " and g.eq_type='" + str_type + "'";
- }
- if (!(str_name.Equals("所有设备")))
- {
- sqlstr = sqlstr + " and g.eq_detail='" + str_name + "'";
- }
- if((!(str_b_time.Equals("")))&&(!(str_e_time.Equals(""))))
- {
- sqlstr = sqlstr + " and (f.form_id between '" + str_b_time + "' and '" + str_e_time + "')";
- }
- sqlstr = sqlstr + "order by f.form_id desc";
- SqlCommand sqlcom = new SqlCommand(sqlstr,conn);
- SqlDataReader dr = sqlcom.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- DataRow row = dt.NewRow();
- row["form_id"] = dr["form_id"].ToString();
- row["applytime"] = SetTime(dr["apply_time"].ToString());
- row["finish_date"] = SetTime(dr["finish_time"].ToString());
- row["total_result"] = dr["total_result"].ToString();
- SqlConnection conn1 = dbConnection.getConnection();
- conn1.Open();
- SqlCommand sqlcom1 = new SqlCommand("select name from OA_DEPARTMENT where id=" + Convert.ToInt32(dr["department_id"]), conn1);
- SqlDataReader dr1 = sqlcom1.ExecuteReader();
- if (dr1.HasRows)
- {
- while (dr1.Read())
- {
- row["department"] = dr1["name"].ToString();
- }
- }
- dr1.Close();
- conn1.Close();
- dt.Rows.Add(row);
- }
- }
- ds.Tables.Add(dt);
- dr.Close();
- conn.Close();
- GridView1.DataSource = ds;
- GridView1.DataBind();
- GridView1.DataKeyNames = new string[] { "form_id" };
- }
- public string SetTime(string s)
- {
- string year = "";
- string month = "";
- string day = "";
- string hour = "";
- string minite = "";
- string second = "";
- if (s.Length == 14)
- {
- year = s.Substring(0, 4).ToString();
- month = s.Substring(4, 2).ToString();
- day = s.Substring(6, 2).ToString();
- hour = s.Substring(8, 2).ToString();
- minite = s.Substring(10, 2).ToString();
- second = s.Substring(12, 2).ToString();
- return year + "-" + month + "-" + day + " " + hour + ":" + minite + ":" + second;
- }
- else
- {
- return s;
- }
- }
- protected void ShowMessageBox(string strMessage)
- {
- Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
- }
- protected void Enddate_SelectionChanged(object sender, EventArgs e)
- {
- Enddate.Visible = false;
- string year = Enddate.SelectedDate.Year.ToString();
- string month =Enddate.SelectedDate.Month.ToString();
- if (month.Length == 1)
- {
- month = "0" + month;
- }
- string day = Enddate.SelectedDate.Day.ToString();
- if (day.Length == 1)
- {
- day = "0" + day;
- }
- e_time.Text = year + month + day + "000000";
- e_time.Focus();
- }
- protected void Begindate_SelectionChanged(object sender, EventArgs e)
- {
- Begindate.Visible = false;
- string year = Begindate.SelectedDate.Year.ToString();
- string month = Begindate.SelectedDate.Month.ToString();
- if (month.Length == 1)
- {
- month = "0" + month;
- }
- string day = Begindate.SelectedDate.Day.ToString();
- if (day.Length == 1)
- {
- day = "0" + day;
- }
- b_time.Text = year + month + day + "000000";
- b_time.Focus();
- }
- protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
- {
- if (Enddate.Visible == true)
- {
- Enddate.Visible = false;
- Enddate.Focus();
- }
- else
- {
- Enddate.Visible = true;
- Enddate.Focus();
- }
- }
- protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
- {
- if (Begindate.Visible == true)
- {
- Begindate.Visible = false;
- Begindate.Focus();
- }
- else
- {
- Begindate.Visible = true;
- Begindate.Focus();
- }
- }
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- e.Row.Attributes.Add("onmouseover", "this.style.cursor='pointer';");
- e.Row.Attributes.Add("onclick", "location.href='edit.aspx?form_id=" + GridView1.DataKeys[e.Row.RowIndex].Value.ToString() + "'");
- }
- }
- protected void btn_ok_Click(object sender, EventArgs e)
- {
- bind();
- }
- protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
- {
- GridView1.PageIndex = e.NewPageIndex;
- bind();
- }
- }