//保留原值 protected void btnRetain_Click(object sender, EventArgs e) { try { List<string> list = new List<string>(); CommonFunction comFun = new CommonFunction(); string strTaskid = ViewState["taskidArray"].ToString(); string[] arrTaskID = strTaskid.Split(','); //保留原值 int count = this.gridViewData.Rows.Count; string sql = string.Empty; for (int i = 0; i < count; i++) { string strColName = this.gridViewData.Rows[i].Cells[0].Text; string dataType = comFun.getDataType("T_LM_PLAN", strColName); string strColValue = this.gridViewData.Rows[i].Cells[1].Text; if (i == (count - 1)) { if (dataType == "NUMBER" || dataType == "LONG") { sql += strColName + "=" + strColValue + ""; } else if (dataType == "DATE") { sql += strColName + "= to_date('" + strColValue + "', 'yyyy-mm-dd hh24:mi:ss.ff')"; } else if (dataType.IndexOf("TIMESTAMP")>0) { sql += strColName + "= to_timestamp('" + strColValue + "', 'yyyy-mm-dd hh24:mi:ss.ff')"; } else { sql += strColName + "='" + strColValue + "'"; } } else { if (dataType == "NUMBER" || dataType == "LONG") { sql += strColName + "=" + strColValue + ","; } else if (dataType == "DATE") { sql += strColName + "= to_date('" + strColValue + "', 'yyyy-mm-dd hh24:mi:ss.ff')" + ","; } else if (dataType.IndexOf("TIMESTAMP") > 0) { sql += strColName + "= to_timestamp('" + strColValue + "', 'yyyy-mm-dd hh24:mi:ss.ff')" + ","; } else { sql += strColName + "='" + strColValue + "',"; } } } sql.Trim(','); sql = "update t_lm_plan set " + sql + " where ID = " + this.hidplanid.Value.Trim(); list.Add(sql); string strTaskID = arrTaskID[0];//第一个taskid的值 string strNow = string.Format("{0:yyyy-MM-dd HH:mm:ss}", System.DateTime.Now); string sqlTask = "update t_lm_proc_exam set TASK_STATUS=1,TASK_APPROVEREJECT=0,TASK_CURPROCUSER='******',TASK_UPDATETIME=to_timestamp('" + strNow + "','yyyy-mm-dd hh24:mi:ss.ff') where TASK_ID=" + strTaskID; list.Add(sqlTask); if (arrTaskID.Length > 1) { //修改别的taskid的值。 for (int j = 1; j < arrTaskID.Length; j++) { string strOtherTaskID = arrTaskID[j]; string sqlTask0 = "update t_lm_proc_exam set TASK_STATUS=1,TASK_APPROVEREJECT=2,TASK_CURPROCUSER='******',TASK_UPDATETIME=to_timestamp('" + strNow + "','yyyy-mm-dd hh24:mi:ss.ff') where TASK_ID=" + strOtherTaskID; list.Add(sqlTask0); } } DbHelperOra.ExecuteSqlTran(list); //this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "key", "alert('保留原值成功!');", true); this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "key0", "<script>alert('保留原值成功!');if(window.opener!=null){window.opener.href=window.opener.href;}window.opener = null; window.close();</script>"); } catch(Exception ex) { string msg = ex.Message; //this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "key", "alert('保留原值失败!');", true); // ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('保留原值成功!');if(window.opener.window.opener!=null){window.opener.window.opener.location.href=window.opener.window.opener.location.href;}window.opener.close();self.close();</script>"); this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "key", "<script>alert('保留原值失败!');if(window.opener!=null){window.opener.href=window.opener.href;}window.opener = null; window.close();</script>"); } }