private void Query(HttpContext context) { int page = int.Parse(context.Request["page"]); int pagesize = int.Parse(context.Request["rows"]); string mo_id = context.Request["mo_id"]; string prd_dep = context.Request["prd_dep"]; string prd_cdesc = context.Request["prd_cdesc"]; string now_date = context.Request["now_date"]; //mo_id = "102"; bool is_val = false; SQLHelp sh = new SQLHelp(); int frist = pagesize * (page - 1); //string strfaca = "select top " + pagesize + " * from student where " + code + " id not in( select top " + frist + " id from student ) "; string strSql = ""; strSql = "Select arrange_id,now_date, prd_dep, prd_mo, prd_item, urgent_status, arrange_machine, arrange_date, arrange_seq, order_qty" + ", order_date, req_time, req_qty, cpl_qty, wait_cpl_qty, prd_cpl_qty, dep_rep_date" + " From product_arrange Where arrange_seq>0 "; if (prd_dep != "" && prd_dep != null) { strSql += " And prd_dep='" + prd_dep + "'"; is_val = true; } if (now_date != "" && now_date != null) { strSql += " And now_date='" + now_date + "'"; is_val = true; } if (mo_id != "" && mo_id != null) { strSql += " And prd_mo='" + mo_id + "'"; is_val = true; } if (is_val == false) { strSql += " And prd_dep=''"; } //strSql += " And arrange_id Not In(select top " + frist + " arrange_id from product_arrange )"; strSql += " Order By arrange_seq"; string tablename = "prd_arrange"; DataSet ds = sh.ExecuteSqlReturnDataSet(strSql, tablename); DataTable dt = ds.Tables[0]; int count = dt.Rows.Count; //DataTable dt = sh.ExecuteSqlReturnDataTable(strSql); string strJson = Dataset2Json(ds, count);//DataSet数据转化为Json数据 //string strJson = DataTableJson(dt);//DataSet数据转化为Json数据 context.Response.Write(strJson); context.Response.End(); }
private void Query(HttpContext context) { string tb_type = context.Request["tb_type"]; string arrange_id = ""; //string prd_dep = context.Request["prd_dep"]; //string prd_mo = context.Request["prd_mo"]; //string prd_item = context.Request["prd_item"]; //string now_date = context.Request["now_date"]; string upd_type = "0"; //if(prd_dep==null) //{ HttpRequest request = System.Web.HttpContext.Current.Request; Uri Project_Id = request.UrlReferrer; string a1 = Project_Id.Query.ToString(); string[] urlPara = getUrlPara(a1); //prd_dep = urlPara[0]; //prd_mo = urlPara[1]; //prd_item = urlPara[2]; //now_date = urlPara[3]; arrange_id = urlPara[2]; //} bool is_val = false; //SQLHelp sh = new SQLHelp(); string strSql = ""; string msg = ""; string tablename = ""; if (tb_type == "hrm01") { //strSql = "Select a.hrm1wid,a.hrm1name,c.hrc5name,b.hrc4name" + // " From dgsql1.dghr.dbo.hrm01 a" + // " Inner Join dgsql1.dghr.dbo.hrc04 b On a.hrm1stat2=b.hrc4class" + // " Left Join dgsql1.dghr.dbo.hrc05 c On a.hrm1job=c.hrc5job" + // " Where a.hrm1state='1'"; //if (prd_dep != "" && prd_dep != null) //{ // strSql += " And b.wip_dep='" + prd_dep + "'"; // is_val = true; //} //if (is_val == false) // strSql += " And a.hrm1stat2=''"; //strSql += " Order By a.hrm1job,a.hrm1wid"; //tablename = "hrm01"; } else { if (tb_type == "prd01") { strSql = "Select b.worker_id,c.hrm1name,b.work_type_id,d.work_type_desc" + " From dgcf_pad.dbo.product_arrange a" + " Inner Join dgcf_pad.dbo.product_arrange_worker b On a.arrange_id=b.arrange_id" + " Left Join dgsql1.dghr.dbo.hrm01 c On b.worker_id COLLATE chinese_taiwan_stroke_CI_AS=c.hrm1wid" + " Left Join dgcf_pad.dbo.work_type d On b.work_type_id=d.work_type_id " + " Where a.arrange_id='" + arrange_id + "'"; tablename = "prd01"; } else { upd_type = "1"; string worker_id = context.Request["worker_id"]; string work_type_id = context.Request["work_type_id"].Trim(); if (tb_type == "upd_prd01") { BasePage bp = new BasePage(); string user_id = "admin";// bp.getUserName(); string crtim = System.DateTime.Now.ToString("yyyy/MM/dd HH:SS"); worker_id = worker_id.Trim().PadLeft(10, '0'); if (chkWorker(arrange_id, worker_id, work_type_id) == 0) { strSql = "Insert Into dgcf_pad.dbo.product_arrange_worker (arrange_id,worker_id,work_type_id,crusr)" + " Values (" + "'" + arrange_id + "','" + worker_id + "','" + work_type_id + "','" + user_id + "')";// + "','" + crtim,crtim } string result = sh.ExecuteSqlUpdate(strSql); if (result == "") { msg = "添加工號成功!"; } else { msg = "添加工號失敗!"; } } else { if (tb_type == "delete_prd01") { strSql = "Delete From dgcf_pad.dbo.product_arrange_worker Where arrange_id='" + arrange_id + "' And worker_id='" + worker_id + "' And work_type_id='" + work_type_id + "'"; string result = sh.ExecuteSqlUpdate(strSql); if (result == "") { msg = "刪除工號成功!"; } else { msg = "刪除工號失敗!"; } } } } } if (upd_type == "0") { DataSet ds = sh.ExecuteSqlReturnDataSet(strSql, tablename); DataTable dt = ds.Tables[0]; int count = dt.Rows.Count; //DataTable dt = sh.ExecuteSqlReturnDataTable(strSql); string strJson = Dataset2Json(ds, count); //DataSet数据转化为Json数据 //string strJson = DataTableJson(dt);//DataSet数据转化为Json数据 context.Response.Write(strJson); } else { context.Response.Write(msg); } context.Response.End(); }