コード例 #1
0
ファイル: BaseController.cs プロジェクト: tianzhihen18/hms
        /// <summary>
        /// 自定义事件cell_HandleResetDBValue
        /// </summary>
        /// <param name="sender"></param>
        protected virtual void cell_HandleResetDBValue(object sender)
        {
            LookUpEdit cell = sender as LookUpEdit;

            if (cell == null || cell.Properties.FieldName == null || (string.IsNullOrEmpty(this.ResetColFieldName) && this.ResetColFieldNameArr == null && this.ResetColFieldNameArr.Count == 0))
            {
                return;
            }
            if (IsSaving)
            {
                return;
            }
            string fieldName = FieldName(cell.Properties, cell.Properties.FieldName);

            if (cell.Properties.ParentGridView != null)
            {
                cell.Properties.ParentGridView.CloseEditor();
                cell.Properties.ParentGridView.SetRowCellValue(cell.Properties.ParentGridView.FocusedRowHandle, LookUpEditFieldName[fieldName], null);
                if ((fieldName == this.ResetColFieldName || this.ResetColFieldNameArr.IndexOf(fieldName) >= 0) && string.IsNullOrEmpty(GetFieldValueStr(cell.Properties.ParentGridView, cell.Properties.ParentGridView.FocusedRowHandle, fieldName)))
                {
                    foreach (string str in TextColFieldName)
                    {
                        cell.Properties.ParentGridView.SetRowCellValue(cell.Properties.ParentGridView.FocusedRowHandle, str, string.Empty);
                    }
                    foreach (string str in ValueColFieldName)
                    {
                        cell.Properties.ParentGridView.SetRowCellValue(cell.Properties.ParentGridView.FocusedRowHandle, str, null);
                    }
                }
            }
            else if (cell.Properties.ParentBandedGridView != null)
            {
                cell.Properties.ParentBandedGridView.CloseEditor();
                cell.Properties.ParentBandedGridView.SetRowCellValue(cell.Properties.ParentBandedGridView.FocusedRowHandle, LookUpEditFieldName[fieldName], null);
                if ((fieldName == this.ResetColFieldName || this.ResetColFieldNameArr.IndexOf(fieldName) >= 0) && !string.IsNullOrEmpty(GetFieldValueStr(cell.Properties.ParentBandedGridView, cell.Properties.ParentBandedGridView.FocusedRowHandle, fieldName)))
                {
                    foreach (string str in TextColFieldName)
                    {
                        cell.Properties.ParentBandedGridView.SetRowCellValue(cell.Properties.ParentBandedGridView.FocusedRowHandle, str, string.Empty);
                    }
                    foreach (string str in ValueColFieldName)
                    {
                        cell.Properties.ParentBandedGridView.SetRowCellValue(cell.Properties.ParentBandedGridView.FocusedRowHandle, str, null);
                    }
                }
            }
            else if (gridView != null)
            {
                gridView.CloseEditor();
                gridView.SetRowCellValue(gridView.FocusedRowHandle, LookUpEditFieldName[fieldName], null);
                if ((fieldName == this.ResetColFieldName || this.ResetColFieldNameArr.IndexOf(fieldName) >= 0) && string.IsNullOrEmpty(GetFieldValueStr(gridView, gridView.FocusedRowHandle, fieldName)))
                {
                    foreach (string str in TextColFieldName)
                    {
                        gridView.SetRowCellValue(gridView.FocusedRowHandle, str, string.Empty);
                    }
                    foreach (string str in ValueColFieldName)
                    {
                        gridView.SetRowCellValue(gridView.FocusedRowHandle, str, null);
                    }
                }
            }
            else if (gridViewBanded != null)
            {
                gridViewBanded.CloseEditor();
                gridViewBanded.SetRowCellValue(gridViewBanded.FocusedRowHandle, LookUpEditFieldName[fieldName], null);
                if ((fieldName == this.ResetColFieldName || this.ResetColFieldNameArr.IndexOf(fieldName) >= 0) && !string.IsNullOrEmpty(GetFieldValueStr(gridViewBanded, gridViewBanded.FocusedRowHandle, fieldName)))
                {
                    foreach (string str in TextColFieldName)
                    {
                        gridViewBanded.SetRowCellValue(gridViewBanded.FocusedRowHandle, str, string.Empty);
                    }
                    foreach (string str in ValueColFieldName)
                    {
                        gridViewBanded.SetRowCellValue(gridViewBanded.FocusedRowHandle, str, null);
                    }
                }
            }
        }
コード例 #2
0
ファイル: BaseController.cs プロジェクト: tianzhihen18/hms
        /// <summary>
        /// 自定义事件cell_HandleDBValueChanged
        /// </summary>
        /// <param name="sender"></param>
        protected void cell_HandleDBValueChanged(object sender)
        {
            LookUpEdit cell = sender as LookUpEdit;

            if (cell == null || !cell.CellValueChanged)
            {
                return;
            }
            if (string.IsNullOrEmpty(cell.Properties.DBValue))
            {
                return;
            }

            string fieldName = FieldName(cell.Properties, cell.Properties.FieldName);

            cell.CellValueChanged = false;

            try
            {
                if (cell.Properties.ParentGridView != null)
                {
                    string strDisplay = cell.Properties.ParentGridView.GetRowCellDisplayText(cell.Properties.ParentGridView.FocusedRowHandle, fieldName);
                    if (strDisplay != cell.Properties.DisplayValue)
                    {
                        cell.Properties.ParentGridView.SetRowCellValue(cell.Properties.ParentGridView.FocusedRowHandle, fieldName, cell.Properties.DisplayValue);
                    }
                    cell.Properties.ParentGridView.SetRowCellValue(cell.Properties.ParentGridView.FocusedRowHandle, LookUpEditFieldName[fieldName], cell.Properties.DBValue);
                }
                else if (cell.Properties.ParentBandedGridView != null)
                {
                    string strDisplay = cell.Properties.ParentBandedGridView.GetRowCellDisplayText(cell.Properties.ParentBandedGridView.FocusedRowHandle, fieldName);
                    if (strDisplay != cell.Properties.DisplayValue)
                    {
                        cell.Properties.ParentBandedGridView.SetRowCellValue(cell.Properties.ParentBandedGridView.FocusedRowHandle, fieldName, cell.Properties.DisplayValue);
                    }
                    cell.Properties.ParentBandedGridView.SetRowCellValue(cell.Properties.ParentBandedGridView.FocusedRowHandle, LookUpEditFieldName[fieldName], cell.Properties.DBValue);
                }
                else if (gridView != null)
                {
                    string strDisplay = gridView.GetRowCellDisplayText(gridView.FocusedRowHandle, fieldName);
                    if (strDisplay != cell.Properties.DisplayValue)
                    {
                        gridView.SetRowCellValue(gridView.FocusedRowHandle, fieldName, cell.Properties.DisplayValue);
                    }
                    gridView.SetRowCellValue(gridView.FocusedRowHandle, LookUpEditFieldName[fieldName], cell.Properties.DBValue);
                }
                else if (gridViewBanded != null)
                {
                    string strDisplay = gridViewBanded.GetRowCellDisplayText(gridViewBanded.FocusedRowHandle, fieldName);
                    if (strDisplay != cell.Properties.DisplayValue)
                    {
                        gridViewBanded.SetRowCellValue(gridViewBanded.FocusedRowHandle, fieldName, cell.Properties.DisplayValue);
                    }
                    gridViewBanded.SetRowCellValue(gridViewBanded.FocusedRowHandle, LookUpEditFieldName[fieldName], cell.Properties.DBValue);
                }
            }
            catch { }

            if (cell.Properties.FieldName == "OrderCode" && GlobalHospital.HospitalCode == "0015" && cell.Properties.DBValue == GlobalParm.DESC_ORDER_CODE)
            {
                //EntityOrderDic tmpVo = GlobalDic.DataSourceOrderDic.FirstOrDefault(t => t.OrderName == "##");
                //if (tmpVo != null)
                //{
                //    EntityOrderDic dbRow = new EntityOrderDic();
                //    dbRow.OrderCode = cell.Properties.DBValue;
                //    dbRow.OrderName = cell.Properties.DisplayValue;

                //    dbRow.Spec = tmpVo.Spec;
                //    dbRow.TypeID = tmpVo.TypeID;
                //    dbRow.TypeName = tmpVo.TypeName;
                //    dbRow.Price = tmpVo.Price;
                //    dbRow.Amount = tmpVo.Amount;
                //    dbRow.Days = tmpVo.Days;
                //    dbRow.IsDrug = tmpVo.IsDrug;
                //    dbRow.Dosage = tmpVo.Dosage;
                //    dbRow.DosageScale = tmpVo.DosageScale;
                //    dbRow.DosageUnitID = tmpVo.DosageUnitID;
                //    dbRow.DosageUnitName = tmpVo.DosageUnitName;
                //    dbRow.UnitID = tmpVo.UnitID;
                //    dbRow.UnitName = tmpVo.UnitName;
                //    dbRow.FreqID = tmpVo.FreqID;
                //    dbRow.FreqName = tmpVo.FreqName;
                //    dbRow.ExecDeptID = tmpVo.ExecDeptID;
                //    dbRow.ExecDeptName = tmpVo.ExecDeptName;
                //    dbRow.PackSn = tmpVo.PackSn;
                //    dbRow.UsageID = tmpVo.UsageID;
                //    dbRow.UsageName = tmpVo.UsageName;
                //    dbRow.OrgSysCode = tmpVo.OrgSysCode;
                //    dbRow.PoisonClass = tmpVo.PoisonClass;
                //    dbRow.MedLimit = tmpVo.MedLimit;
                //    dbRow.SkinTestFlag = tmpVo.SkinTestFlag;
                //    dbRow.BaseMedFlag = tmpVo.BaseMedFlag;
                //    dbRow.PharmacyNo = tmpVo.PharmacyNo;
                //    dbRow.PharmacyName = tmpVo.PharmacyName;
                //    dbRow.PyCode = tmpVo.PyCode;
                //    dbRow.WbCode = tmpVo.WbCode;
                //    FillRowValueByDBRow(dbRow);
                //}
                //return;
            }

            if ((fieldName == this.ResetColFieldName || (this.ResetColFieldNameArr != null && this.ResetColFieldNameArr.IndexOf(fieldName) >= 0)) &&
                cell.Properties.DBRow != null)
            {
                if (cell.Properties.ParentGridView != null)
                {
                    FillRowValueByDBRow(cell.Properties.ParentGridView, cell.Properties.DBRow);
                }
                else
                {
                    FillRowValueByDBRow(cell.Properties.DBRow);
                }
            }
            else
            {
                FillRowValueByDBRow(cell.Properties.DBValue);
            }
        }
コード例 #3
0
ファイル: BaseController.cs プロジェクト: tianzhihen18/hms
        /// <summary>
        /// 自定义事件cell_KeyDown
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void cell_KeyDown(object sender, KeyEventArgs e)
        {
            LookUpEdit cell = sender as LookUpEdit;

            if (cell == null)
            {
                return;
            }
            if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Space)
            {
                string fieldName  = FieldName(cell.Properties, cell.Properties.FieldName);
                string strDisplay = string.Empty;
                try
                {
                    if (cell.Properties.ParentGridView != null)
                    {
                        strDisplay = cell.Properties.ParentGridView.GetRowCellDisplayText(cell.Properties.ParentGridView.FocusedRowHandle, fieldName);
                    }
                    else if (cell.Properties.ParentBandedGridView != null)
                    {
                        strDisplay = cell.Properties.ParentBandedGridView.GetRowCellDisplayText(cell.Properties.ParentBandedGridView.FocusedRowHandle, fieldName);
                    }
                    else if (gridView != null)
                    {
                        strDisplay = gridView.GetRowCellDisplayText(gridView.FocusedRowHandle, fieldName);
                    }
                    else if (gridViewBanded != null)
                    {
                        strDisplay = gridViewBanded.GetRowCellDisplayText(gridViewBanded.FocusedRowHandle, fieldName);
                    }
                }
                catch { }
                if (!string.IsNullOrEmpty(fieldName) && !string.IsNullOrEmpty(strDisplay) && LookUpEditFieldName.ContainsKey(fieldName))
                {
                    string strValue = string.Empty;
                    if (cell.Properties.ParentGridView != null)
                    {
                        strValue = GetFieldValueStr(cell.Properties.ParentGridView, cell.Properties.ParentGridView.FocusedRowHandle, LookUpEditFieldName[fieldName]);
                    }
                    else if (cell.Properties.ParentBandedGridView != null)
                    {
                        strValue = GetFieldValueStr(cell.Properties.ParentBandedGridView, cell.Properties.ParentBandedGridView.FocusedRowHandle, LookUpEditFieldName[fieldName]);
                    }
                    else if (gridView != null)
                    {
                        strValue = GetFieldValueStr(gridView, gridView.FocusedRowHandle, LookUpEditFieldName[fieldName]);
                    }
                    else if (gridViewBanded != null)
                    {
                        strValue = GetFieldValueStr(gridViewBanded, gridViewBanded.FocusedRowHandle, LookUpEditFieldName[fieldName]);
                    }
                    if (!string.IsNullOrEmpty(strValue) && string.IsNullOrEmpty(cell.Properties.DBValue))
                    {
                        cell.Properties.DBValue      = strValue;
                        cell.Properties.DisplayValue = strDisplay;
                    }
                }
            }
            else
            {
                if (e.Control && (e.KeyCode == Keys.Delete || e.KeyCode == Keys.D))
                {
                    if (cell.Properties.ParentGridView != null && cell.Properties.ParentBindingSource != null)
                    {
                        DeleteRow(cell.Properties.ParentGridView, cell.Properties.ParentBindingSource, cell.Properties.ParentGridView.FocusedRowHandle);
                    }
                    else
                    {
                        DeleteCurrentRow();
                    }
                }
            }
        }