private void cmbState_SelectedIndexChanged(object sender, EventArgs e) { Class_Follow_State CurrentState = cmbState.SelectedItem as Class_Follow_State; if (CurrentState.Isfinished != "") { panel2.Enabled = false; } else { panel2.Enabled = true; } }
/// <summary> /// 获取状态实例 /// </summary> /// <returns></returns> public Class_Follow_State[] GetStateSet(DataSet ds) { if (ds.Tables[0].Rows.Count != 0) { Class_Follow_State[] state = new Class_Follow_State[ds.Tables[0].Rows.Count]; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { state[i] = new Class_Follow_State(); state[i].Id = ds.Tables[0].Rows[i]["Id"].ToString(); state[i].Des = ds.Tables[0].Rows[i]["des"].ToString(); state[i].Isfinished = ds.Tables[0].Rows[i]["isfinished"].ToString(); } return(state); } else { return(null); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { string[] temp = new string[2]; string thisTime = dtTime.Value.ToString("yyyy-MM-dd"); if (cmbState.SelectedItem == null) { App.Msg("请选择随访状态"); return; } Class_Follow_State state = cmbState.SelectedItem as Class_Follow_State; string Isfinished = "0"; if (state.Isfinished != "") { Isfinished = state.Isfinished; } else { if (rbtnEnd.Checked) { Isfinished = "1"; } else { Isfinished = "0"; } } if (IsNew) { temp[0] = "insert into T_FOLLOW_DOC_ATTACH(record_id,finish_time,creator_id,state,remark) values(" + recordId + ",to_date('" + thisTime + "','yyyy-MM-dd')," + App.UserAccount.UserInfo.User_id + "," + state.Id + ",'" + txtRemark.Text + "')"; } else { temp[0] = "update T_FOLLOW_DOC_ATTACH set finish_time=to_date('" + thisTime + "','yyyy-MM-dd'),creator_id=" + App.UserAccount.UserInfo.User_id + ",state=" + state.Id + ",remark='" + txtRemark.Text + "' where id=" + selectedId + ""; } if (Isfinished == "1") { temp[1] = "update T_FOLLOW_RECORD set actual_time=to_date('" + thisTime + "','yyyy-MM-dd'),state_id=" + state.Id + ",isfinished=" + Isfinished + " where id=" + recordId + ""; } else { if (IsLastModify == 1 || dgvAttach.Rows.Count == 0) { temp[1] = "update T_FOLLOW_RECORD set actual_time=null,state_id=" + state.Id + ",isfinished=" + Isfinished + " where id=" + recordId + ""; } else { temp[1] = ""; } } //判断是否已完成此次随访 string search = ""; search = App.ReadSqlVal("select finishtype from T_FOLLOW_INFO where id =(select solution_id from T_FOLLOW_RECORD where id=" + recordId + ")", 0, "finishtype"); if (Isfinished == "1") { if (search != "" && search != null) { if (search.IndexOf("次") != -1) { int NowTimes = 0; string tempNowTimes = App.ReadSqlVal("select count(*) 次数 from T_FOLLOW_RECORD where isfinished=1 and patient_id=" + pId + " and solution_id=" + sId + "", 0, "次数"); if (tempNowTimes != null && tempNowTimes != "") { NowTimes = Convert.ToInt32(tempNowTimes); } int FinishTimes = Convert.ToInt32(search.Substring(0, search.IndexOf("次"))); if (NowTimes == FinishTimes - 1) { string Exist = App.ReadSqlVal("select definefollows from T_FOLLOW_MANUALPATIENT where patient_id=" + pId + " and solution_id=" + sId + "", 0, "definifollows"); string AutoSet = ""; if (Exist != null) { AutoSet = "update T_FOLLOW_MANUALPATIENT set isadd=0 ,cancel_id=(select id from T_FOLLOW_CANCEL_REASON where des='完成随访'),state_id=null,update_time=to_date('" + App.GetSystemTime().ToShortDateString() + "','yyyy-MM-dd'),definefollows=null where patient_id=" + pId + " and solution_id=" + sId + ""; } if (Exist == null) { AutoSet = "insert into T_FOLLOW_MANUALPATIENT(patient_id,solution_id,isadd,update_time,cancel_id) select " + pId + "," + sId + ",0,to_date('" + App.GetSystemTime().ToShortDateString() + "','yyyy-MM-dd'),id from T_FOLLOW_CANCEL_REASON where des='完成随访'"; } App.ExecuteSQL(AutoSet); } } else { TimeSpan span = Convert.ToDateTime(thisTime) - Convert.ToDateTime(lTime); int totalDay = 0; if (search.IndexOf("年") != -1) { totalDay = Convert.ToInt32(search.Substring(0, search.IndexOf("年"))) * 365; } if (search.IndexOf("月") != -1) { totalDay = Convert.ToInt32(search.Substring(0, search.IndexOf("月"))) * 30; } if (search.IndexOf("天") != -1) { totalDay = Convert.ToInt32(search.Substring(0, search.IndexOf("天"))); } if (span.TotalDays >= totalDay) { string Exist = App.ReadSqlVal("select definefollows from T_FOLLOW_MANUALPATIENT where patient_id=" + pId + " and solution_id=" + sId + "", 0, "1"); string AutoSet = ""; if (Exist != null && Exist != "") { AutoSet = "update T_FOLLOW_MANUALPATIENT set isadd=0 ,cancel_id=(select id from T_FOLLOW_CANCEL_REASON where des='完成随访'),state_id=null,update_time=to_date('" + App.GetSystemTime().ToShortDateString() + "','yyyy-MM-dd'),definefollows=null where patient_id=" + pId + " and solution_id=" + sId + ""; } if (Exist == null) { AutoSet = "insert into T_FOLLOW_MANUALPATIENT(patient_id,solution_id,isadd,update_time,cancel_id) select " + pId + "," + sId + ",0,to_date('" + App.GetSystemTime().ToShortDateString() + "','yyyy-MM-dd'),id from T_FOLLOW_CANCEL_REASON where des='完成随访'"; } App.ExecuteSQL(AutoSet); } } } } try { App.ExecuteBatch(temp); App.Msg("成功"); IniControls(); ShowList(); } catch (Exception ex) { App.MsgErr(ex.Message); } }