public string SaveDraft(Stream s) { string ret = "0"; try { var sr = new StreamReader(s); string text = sr.ReadToEnd(); DraftVo data = JsonConvert.DeserializeObject <DraftVo>(text); string sql = "select count(*) as num from Draft where ConsultID=" + data.ConsultID; DataTable dt = op.ExecuteDataTable(sql, CommandType.Text, null); if (dt.Rows[0]["num"].ToString() == "0") { sql = "insert into Draft(ConsultID,Diagnosis,DraftTime,UserID,Diagnosis_Remark, z_Mirror) Values('" + data.ConsultID + "','" + data.Diagnosis + "','" + DateTime.Now + "','" + data.UserID + "','" + data.Diagnosis_Remark + "','" + data.Mirror + "')"; } else { sql = "update Draft set Diagnosis='" + data.Diagnosis + "',DraftTime='" + DateTime.Now + "',Diagnosis_Remark='" + data.Diagnosis_Remark + "', z_Mirror='" + data.Mirror + "' where ConsultID='" + data.ConsultID + "' and UserID='" + data.UserID + "'"; } op.AddCommandText(sql); sql = "update Cases set z_Mirror='" + data.Mirror + "' where ConsultID=" + data.ConsultID; op.AddCommandText(sql); op.ExecuteForTransaction(); ret = "1"; } catch { } return(ret); }