private void GetData() { try { AnatomyDataSource = new DoctorController().GetAnatomy().Tables[0]; AnatomyControl _Anatomy = null; foreach (DataRow dr in AnatomyDataSource.Rows) { _Anatomy = new AnatomyControl( dr["Code"].ToString(), Utility.sDbnull(dr["VN_ANATOMY_NAME"].ToString(), "NO NAME"), Utility.sDbnull(dr["EN_ANATOMY_NAME"].ToString(), "NO NAME"), Utility.Int32Dbnull(dr["STT"].ToString(), 0)); _Anatomy._OnClick += new AnatomyControl.OnClick(_Anatomy__OnClick); pnlAnatomyList.Controls.Add(_Anatomy); } cmdNew.Enabled = AnatomyDataSource.Rows.Count > 0; } catch { } }
private void cmdRegister_Click(object sender, EventArgs e) { if (!CheckValidData()) return; _ACtrl = new AnatomyControl(txtCode.Text.Trim(), txtVnName.Text.Trim(), txtEngName.Text.Trim(), Convert.ToInt32(txtSTT.Text.Trim())); DoctorController _Ctrl = new DoctorController(); ActionResult _ActionResult; if (Act == action.Insert) _ActionResult = _Ctrl.InsertAnatomy(_ACtrl.Code, _ACtrl.Vn_Name, _ACtrl.En_Name, _ACtrl.STT); else _ActionResult = _Ctrl.UpdateAnatomy(_ACtrl.Code, _ACtrl.Vn_Name, _ACtrl.En_Name, _ACtrl.STT); if (_ActionResult == ActionResult.Success) { this.DialogResult = DialogResult.OK; this.Close(); } if (_ActionResult == ActionResult.ExistedRecord) { errorProvider1.SetError(txtCode, "Đã tồn tại vị trí chụp có mã " + _ACtrl.Code + ". Đề nghị bạn nhập lại mã khác!"); Utility.FocusAndSelectAll(txtCode); } }
void InitControls() { try { int i = 0; DataRow[] arrDr = AP_DataSource.Select("DEVICE_ID=" + CurrDevice_ID.ToString(),"A_STT"); foreach (DataRow dr in arrDr) { if (!isExistAnatomy(dr["ANATOMY_CODE"].ToString())) { AnatomyControl _Anatomy = new AnatomyControl(dr["ANATOMY_CODE"].ToString(), Utility.sDbnull(dr["VN_ANATOMY_NAME"].ToString(), "NO NAME"), Utility.sDbnull(dr["EN_ANATOMY_NAME"].ToString(), "NO NAME"), Utility.Int32Dbnull(dr["A_STT"].ToString(), 0)); _Anatomy.Width = pnlAnatomyList.Width-25; _Anatomy._OnClick += new AnatomyControl.OnClick(_NewAnatomy__OnClick); pnlAnatomyList.Controls.Add(_Anatomy); _Anatomy.Size = new Size(191, 64); if (i == 0) _Anatomy._AnatomyObject.PerformClick(); i++; } } } catch { } finally { cmdDelProjection.Enabled = HasSelectedProjection(); cmdMakeAsEmerency.Enabled = cmdDelProjection.Enabled; pnlParams.Enabled = cmdDelProjection.Enabled; } }
void BuildProjectionOfAnatomy(AnatomyControl obj) { try { DataRow[] arrDR = AP_DataSource.Select("ANATOMY_CODE='" + obj.Code + "' AND PROJECTION_CODE<>'' AND DEVICE_ID=" + CurrDevice_ID.ToString(),"P_STT"); foreach (DataRow dr in arrDR) { ProjectionControl _NewProjection = new ProjectionControl( dr["PROJECTION_CODE"].ToString(), Utility.sDbnull(dr["VN_Projection_NAME"].ToString(), "NO NAME"), Utility.sDbnull(dr["EN_Projection_NAME"].ToString(), "NO NAME"), Utility.Int32Dbnull(0, 0),Utility.sDbnull(dr["IS_USED_FOR_EMERENCY"],"0")=="1"?true:false); _NewProjection.RAD_Code = Utility.sDbnull(dr["RAD_CODE"], ""); _NewProjection._OnClick += new ProjectionControl.OnClick(_NewProjection__OnClick); pnlProjectionList.Controls.Add(_NewProjection); } } catch { } }
void _NewAnatomy__OnClick(AnatomyControl obj) { try { _Anatomy = obj.Copy(); pnlProjectionList.Controls.Clear(); ResetPreviousSelectedObject(obj.Code); obj.isPressed = !obj.isPressed; _Anatomy.isPressed = obj.isPressed; cmdChooseProjection.Enabled = obj.isPressed; if (!obj.isPressed) { obj._AnatomyObject.BackColor = Color.WhiteSmoke; obj._AnatomyObject.ForeColor = Color.Black; } else { BuildProjectionOfAnatomy(obj); obj._AnatomyObject.BackColor = Color.SteelBlue; obj._AnatomyObject.ForeColor = Color.White; } } catch { } finally { cmdDeleteAnatomy.Enabled = HasSelectedAnatomy(); cmdDelProjection.Enabled = HasSelectedProjection(); cmdMakeAsEmerency.Enabled = cmdDelProjection.Enabled; pnlParams.Enabled = cmdDelProjection.Enabled; } }
void _Anatomy__OnClick(AnatomyControl obj) { try { ResetPreviousSelectedObject(obj.Code); obj.isPressed = !obj.isPressed; if (!obj.isPressed) { obj._AnatomyObject.BackColor = Color.WhiteSmoke; obj._AnatomyObject.ForeColor = Color.Black; } else { _currA = obj.Copy(); obj._AnatomyObject.BackColor = Color.SteelBlue; obj._AnatomyObject.ForeColor = Color.White; } cmdDel.Enabled = HasSelectedAnatomy(); cmdUpdate.Enabled = cmdDel.Enabled; } catch { } }
private bool HasSelectedAnatomy() { try { foreach (Control ctr in pnlAnatomyList.Controls) { AnatomyControl _Anatomy = ctr as AnatomyControl; if (_Anatomy.isPressed) return true; } _currA = null; return false; } catch { return false; } }
public AnatomyControl Copy() { AnatomyControl newObj = new AnatomyControl(this.Code, this.Vn_Name, this.En_Name,this.STT); return newObj; }
void InitControls() { try { int i = 0; DataRow[] arrDr = AP_DataSource.Select("1=1");//DEVICE_ID=" + CurrDevice_ID.ToString()); foreach (DataRow dr in arrDr) { if (!isExistAnatomy(dr["ANATOMY_CODE"].ToString())) { AnatomyControl _Anatomy = new AnatomyControl(dr["ANATOMY_CODE"].ToString(), Utility.sDbnull(dr["VN_ANATOMY_NAME"].ToString(), "NO NAME"), Utility.sDbnull(dr["EN_ANATOMY_NAME"].ToString(), "NO NAME"), Utility.Int32Dbnull(dr["A_STT"].ToString(), 0)); _Anatomy.Width = pnlAnatomyList.Width-10; _Anatomy._OnClick += new AnatomyControl.OnClick(_NewAnatomy__OnClick); pnlAnatomyList.Controls.Add(_Anatomy); if (i == 0) _Anatomy._AnatomyObject.PerformClick(); i++; } } } catch { } }
void BuildProjectionOfAnatomy(AnatomyControl obj) { try { DataRow[] arrDR = AP_DataSource.Select("ANATOMY_CODE='" + obj.Code + "' AND PROJECTION_CODE<>'' ");//AND DEVICE_ID=" + CurrDevice_ID.ToString()); foreach (DataRow dr in arrDR) { if (!isExistProjection(dr["PROJECTION_CODE"].ToString())) { ProjectionControl _NewProjection = new ProjectionControl(dr["PROJECTION_CODE"].ToString(), Utility.sDbnull(dr["VN_Projection_NAME"].ToString(), "NO NAME"), Utility.sDbnull(dr["EN_Projection_NAME"].ToString(), "NO NAME"), Utility.Int32Dbnull(0, 0), false); _NewProjection._OnClick += new ProjectionControl.OnClick(_NewProjection__OnClick); pnlProjectionList.Controls.Add(_NewProjection); if (dr["CHON"].ToString() == "1") _NewProjection._ProjectionObject.PerformClick(); } } } catch { } finally { } }
void _NewAnatomy__OnClick(AnatomyControl obj) { try { _Anatomy = obj.Copy(); pnlProjectionList.Controls.Clear(); ResetPreviousSelectedObject(obj.Code); obj.isPressed = !obj.isPressed; _Anatomy.isPressed = obj.isPressed; if (!obj.isPressed) { obj._AnatomyObject.BackColor = Color.WhiteSmoke; obj._AnatomyObject.ForeColor = Color.Black; } else { BuildProjectionOfAnatomy(obj); obj._AnatomyObject.BackColor = Color.SteelBlue; obj._AnatomyObject.ForeColor = Color.White; } } catch { } }
public frm_AddNewAnotomy(AnatomyControl _ACtrl) { InitializeComponent(); this._ACtrl = _ACtrl; txtSTT.KeyPress += new KeyPressEventHandler(_KeyPress); }