protected override void Save() { if (txtNum.Text.Trim().Length == 0) { XtraMessageBox.Show("请输入编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (_dal.checkCurrent(comboType.Text, txtNum.Text.Trim())) { XtraMessageBox.Show("编号已存在,无法添加重复的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtMin.Text.Trim().Length == 0) { XtraMessageBox.Show("请输入最小值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtMin.Text.Trim().Length == 0) { XtraMessageBox.Show("请输入最大值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { _model = new DJK.Model.admin_Clarity(); _model.SourceMax = int.Parse(this.txtMax.Text.Trim()); _model.SourceMin = int.Parse(this.txtMin.Text.Trim()); _model.SourceNum = int.Parse(this.txtNum.Text.Trim()); _model.SourceTable = this.comboType.Text; CloseForm(); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DJK.Model.admin_Clarity DataRowToModel(DataRow row) { DJK.Model.admin_Clarity model = new DJK.Model.admin_Clarity(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["SourceTable"] != null) { model.SourceTable = row["SourceTable"].ToString(); } if (row["SourceNum"] != null && row["SourceNum"].ToString() != "") { model.SourceNum = int.Parse(row["SourceNum"].ToString()); } if (row["SourceMin"] != null && row["SourceMin"].ToString() != "") { model.SourceMin = int.Parse(row["SourceMin"].ToString()); } if (row["SourceMax"] != null && row["SourceMax"].ToString() != "") { model.SourceMax = int.Parse(row["SourceMax"].ToString()); } } return(model); }
public FrmAddSource() { InitializeComponent(); ShowButtonRight(new string[] { "Save", "Exit" }); _dal = new DJK.DAL.admin_Clarity(); _model = new DJK.Model.admin_Clarity(); initialData(); }
private void FrmAddSource_FormClosing(object sender, FormClosingEventArgs e) { if (_model != null) { if (_model.SourceTable == null) { _model = null; } } }
private double getDataValue(int formula, int medicalID, int dataMin, int dataMax) { double rtn = 0; List <DJK.Model.admin_MedicalSource> sourceList = dalSource.getModelList(medicalID); List <double> resultList = new List <double>(); foreach (DJK.Model.admin_MedicalSource model in sourceList) { DJK.Model.admin_Clarity clarity = dalClarity.GetModel(model.SourceID); string tableType = clarity.SourceTable; int sourceNum = (int)clarity.SourceNum; int sourceMin = (int)(clarity.SourceMin == null ? 0 : clarity.SourceMin); int sourceMax = (int)(clarity.SourceMax == null ? 150 : clarity.SourceMax); double sourceValue = 0; try { if (tableType == "info") { sourceValue = double.Parse(ipList[sourceNum - 1].value); } else { sourceValue = double.Parse(mpList[sourceNum - 1].value); } } catch (Exception ex) { sourceValue = 0; } double sourceResult = getSourceResult(sourceMin, sourceMax, sourceValue, dataMin, dataMax); resultList.Add(sourceResult); } if (resultList.Count == 0) { rtn = 0; } else { switch (formula) { case 1: rtn = MathEx.getMax(resultList); break; case 2: rtn = MathEx.getMax(resultList); break; default: rtn = 0; break; } } return(rtn); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DJK.Model.admin_Clarity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update admin_clarity set "); if (model.SourceTable != null) { strSql.Append("SourceTable='" + model.SourceTable + "',"); } else { strSql.Append("SourceTable= null ,"); } if (model.SourceNum != null) { strSql.Append("SourceNum=" + model.SourceNum + ","); } else { strSql.Append("SourceNum= null ,"); } if (model.SourceMin != null) { strSql.Append("SourceMin=" + model.SourceMin + ","); } else { strSql.Append("SourceMin= null ,"); } if (model.SourceMax != null) { strSql.Append("SourceMax=" + model.SourceMax + ","); } else { strSql.Append("SourceMax= null ,"); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where ID=" + model.ID + ""); int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(DJK.Model.admin_Clarity model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.SourceTable != null) { strSql1.Append("SourceTable,"); strSql2.Append("'" + model.SourceTable + "',"); } if (model.SourceNum != null) { strSql1.Append("SourceNum,"); strSql2.Append("" + model.SourceNum + ","); } if (model.SourceMin != null) { strSql1.Append("SourceMin,"); strSql2.Append("" + model.SourceMin + ","); } if (model.SourceMax != null) { strSql1.Append("SourceMax,"); strSql2.Append("" + model.SourceMax + ","); } strSql.Append("insert into admin_clarity("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); strSql.Append(";select @@IDENTITY"); object obj = DbHelperSQL.GetSingle(strSql.ToString()); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DJK.Model.admin_Clarity GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" ID,SourceTable,SourceNum,SourceMin,SourceMax "); strSql.Append(" from admin_clarity "); strSql.Append(" where ID=" + ID + ""); DJK.Model.admin_Clarity model = new DJK.Model.admin_Clarity(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
protected override void Exit() { _model = null; CloseForm(); }