private void TextBox_LostFocus(object sender, EventArgs e) { _textBox.Visible = false; _textBox.Parent = null; if (_textBox.Tag != null) { try { MedSheet control = base.GetCurrentControl as MedSheet; MedSheetCell cell = _textBox.Tag as MedSheetCell; MedSheetRow row = control.Rows[cell.RowIndex]; if ((cell.Value != null && cell.Value.ToString() != _textBox.Text) || (cell.Value == null && !string.IsNullOrEmpty(_textBox.Text.Trim()))) { cell.Value = _textBox.Text; if (cell.TimePoint.Date == DateTime.MinValue.Date) { throw new Exception("表格时间发生错误"); } SaveEditData(cell, row); RefreshData(); } } catch (Exception err) { // ExceptionHandler.Handle(err); } } _textBox.Tag = null; }
protected void EditValue(MedSheetCell cell) { MedSheet control = base.GetCurrentControl as MedSheet; _textBox.Text = ""; _textBox.Location = cell.DrawRectangel.Location; _textBox.Width = cell.DrawRectangel.Width; _textBox.Height = cell.DrawRectangel.Height; _textBox.Parent = control; MedSheetRow row = control.Rows[cell.RowIndex]; if (!string.IsNullOrEmpty(row.DictTableName) && !string.IsNullOrEmpty(row.DictValueFieldName)) { DataRow[] rows = BuildPopupItemsData(row.DictTableName, row.DictWhereString); string displayName = !string.IsNullOrEmpty(row.DisplayFieldName) ? row.DisplayFieldName.ToUpper() : row.DictValueFieldName.ToUpper(); //Dialog.ShowCustomSelection(rows, displayName, _textBox, // new System.Drawing.Size(_textBox.Width, 300), new EventHandler(delegate(object sender1, EventArgs e1) // { // if (sender1 is int) // { // int result = (int)sender1; // if (result > -1) // { // _textBox.Text = rows[result][row.DisplayFieldName].ToString(); // _textBox.Tag = cell; // TextBox_LostFocus(null, null); // } // } // })); } else { _textBox.BorderStyle = BorderStyle.FixedSingle; _textBox.Text = cell.Value == null ? "" : cell.Value.ToString(); _textBox.Tag = cell; _textBox.Visible = true; _textBox.Focus(); } }
protected void SaveEditData(MedSheetCell cell, MedSheetRow sheetRow) { //DataTable dtMonitorEx = base.DataSource["MED_PAT_MONITOR_DATA_EXT"]; //dtMonitorEx.TableName = "MED_PAT_MONITOR_DATA_EXT"; //AnesInformations.AnesthesiaEventDataTable anesEventTable = DataContext.GetCurrent().GetAnesthesiaEvent(_eventNo); ////base.DataSource["AnesthesiaEvent"] as AnesInformations.AnesthesiaEventDataTable; //if (sheetRow.ItemCode == "D") // 出液 -尿量 //{ // string itemname = "尿量"; // DataRow[] rows = anesEventTable.Select("ITEM_NAME = '" + itemname + "' and START_TIME='" + cell.TimePoint + "'", "START_TIME"); // if (rows.Length == 0 && !string.IsNullOrEmpty(_textBox.Text)) // { // AnesInformations.AnesthesiaEventRow eventRow = DataContext.GetCurrent().NewAnesthesiaEventRow(anesEventTable, 0); // eventRow.ITEM_CLASS = "D"; // eventRow.ITEM_NAME = itemname; // eventRow.DOSAGE_UNITS = "ml"; // eventRow.START_TIME = cell.TimePoint; // eventRow.DOSAGE = Convert.ToDecimal(_textBox.Text); // anesEventTable.Rows.Add(eventRow); // DataContext.GetCurrent().UpdateAnesthesiaEvent(anesEventTable); // } // else if (rows.Length > 0) // { // if (string.IsNullOrEmpty(_textBox.Text)) // rows[0].Delete(); // else // rows[0]["DOSAGE"] = Convert.ToDecimal(_textBox.Text); // DataContext.GetCurrent().UpdateAnesthesiaEvent(anesEventTable); // } //} //else //{ // double min = 0; // switch (sheetRow.ShowTimeInterval) // { // case MedShowTimeInterval.Fifiteen: // min = 15; // break; // case MedShowTimeInterval.Five: // min = 5; // break; // case MedShowTimeInterval.HalfHour: // min = 15; // break; // case MedShowTimeInterval.Hour: // min = 60; // break; // case MedShowTimeInterval.Ten: // min = 10; // break; // case MedShowTimeInterval.Twenty: // min = 20; // break; // } // DateTime dt = cell.TimePoint.AddMinutes(min); // DataRow[] rows = dtMonitorEx.Select("ITEM_CODE = '" + sheetRow.ItemCode + "' and TIME_POINT >='" + cell.TimePoint + "' and TIME_POINT < '" + dt + "'", "TIME_POINT ASC"); // if (rows.Length == 0 && !string.IsNullOrEmpty(_textBox.Text)) // { // string patientId = ExtendApplicationContext.Current.PatientContext.PatientID; // decimal visitId = ExtendApplicationContext.Current.PatientContext.VisitID; // decimal operId = ExtendApplicationContext.Current.PatientContext.OperID; // DataRow row = dtMonitorEx.NewRow(); // row["PATIENT_ID"] = patientId; // row["VISIT_ID"] = visitId; // row["OPER_ID"] = operId; // row["TIME_POINT"] = cell.TimePoint; // row["ITEM_CODE"] = sheetRow.ItemCode; // row["ITEM_VALUE"] = _textBox.Text; // row["RECORDING_DATE"] = System.DateTime.Now; // dtMonitorEx.Rows.Add(row); // new CommonDA().UpdateDataTable(dtMonitorEx); // } // else if (rows.Length > 0) // { // if (string.IsNullOrEmpty(_textBox.Text)) // rows[0].Delete(); // else // { // //MessageBox.Show(string.Format("{0}~{1},{2} Text is {3}",cell.TimePoint, dt, sheetRow.ItemCode, _textBox.Text)); // for (int i = 0; i < rows.Length; i++) // { // rows[i]["ITEM_VALUE"] = _textBox.Text; // rows[i]["RECORDING_DATE"] = System.DateTime.Now; // } // } // int result = new CommonDA().UpdateDataTable(dtMonitorEx); // //MessageBox.Show("result is " + result.ToString()); // } //} }