/// <summary> /// This method is called when click ClearOrReset button /// </summary> protected virtual void ClearOrReset() { if (this.btnClear.Visibility == DevExpress.XtraBars.BarItemVisibility.Never || btnClear.Enabled == false) { return; } switch (this.ViewMode) { case CommonData.Mode.Edit: { #region Logger Start log.GetLogger(this.Name.ToString() + " " + "ResetData"); log.Write(Logger.Level.Info, "Start"); #endregion Logger Start object dto = Activator.CreateInstance(this.CurrentDto.GetType()); CommonMethod.Clone(this.CurrentDto, out dto); this.Dto = (IDto)dto; } break; case CommonData.Mode.New: { #region Logger Start log.GetLogger(this.Name.ToString() + " " + "ClearData"); log.Write(Logger.Level.Info, "Start"); #endregion Logger Start this.Dto = null; } break; case CommonData.Mode.View: { #region Logger Start log.GetLogger(this.Name.ToString() + " " + "ChangeMode"); log.Write(Logger.Level.Info, "Start"); #endregion Logger Start this.ViewMode = CommonData.Mode.Edit; this.SetLanguage(); } break; } this.SetControl(); #region Logger log.Write(Logger.Level.Info, "End"); #endregion Logger }
/// <summary> /// Load data for input control follow to viewMode /// </summary> protected virtual void LoadData() { if (DesignMode) { return; } this.Dto = null; if (this.ListDto != null && this.ListDto.Count > 0) { switch (this.ViewMode) { case CommonData.Mode.View: { object dto = Activator.CreateInstance(this.CurrentDto.GetType()); CommonMethod.Clone(this.CurrentDto, out dto); this.Dto = (IDto)dto; SettingIfSysData(this.CurrentDto); } break; case CommonData.Mode.Edit: { object dto = Activator.CreateInstance(this.CurrentDto.GetType()); CommonMethod.Clone(this.CurrentDto, out dto); this.Dto = (IDto)dto; } break; case CommonData.Mode.New: { if (ListDto != null && ListDto.Count > 0) { object dto = Activator.CreateInstance(this.CurrentDto.GetType()); CommonMethod.Clone(this.ListDto[0], out dto); this.Dto = (IDto)dto; //Copy Dto --> ListDto[0] after delete key property value object dto1 = Activator.CreateInstance(this.CurrentDto.GetType()); CommonMethod.Clone(this.Dto, out dto1); this.ListDto[0] = (IDto)dto1; } } break; default: break; } } else { ListDto = new List <IDto>(); object dto = Activator.CreateInstance(this.Dto.GetType()); CommonMethod.Clone(this.Dto, out dto); ListDto.Add((IDto)dto); } }
/// <summary> /// Load data of previous member in ListDto for input control /// </summary> protected virtual void LoadPreviousData() { if (ListDto != null && currentPosition > 0) { currentPosition--; object dto = Activator.CreateInstance(this.CurrentDto.GetType()); CommonMethod.Clone(this.CurrentDto, out dto); this.Dto = (IDto)dto; } }
/// <summary> /// Insert or update data to database /// </summary> protected virtual int SaveData() { this.ShowProgressBar(); this.MessageBox = new MessageBoxs(); IvsMessage message = null; int iReturnCode = -1; //This is case ViewMode is Edit, system will update data to database if (this.ViewMode == CommonData.Mode.Edit) { ReturnCode = iReturnCode = Bl.UpdateData(this.Dto); if (iReturnCode == CommonData.DbReturnCode.Succeed) { object dto = Activator.CreateInstance(this.CurrentDto.GetType()); CommonMethod.Clone(this.Dto, out dto); this.ListDto[currentPosition] = (IDto)dto; message = new IvsMessage(CommonConstantMessage.COM_MSG_UPDATE_SUCCESSFULLY); this.MessageBox.Add(message); this.MessageBox.Display(CommonData.MessageType.Ok); } else { this.ProcessDbExcetion(iReturnCode); } } //This is case ViewMode is New, system will insert data to databas else if (this.ViewMode == CommonData.Mode.New) { ReturnCode = iReturnCode = Bl.InsertData(this.Dto); if (iReturnCode == CommonData.DbReturnCode.Succeed) { message = new IvsMessage(CommonConstantMessage.COM_MSG_INSERT_SUCCESSFULLY); this.MessageBox.Add(message); this.MessageBox.Display(CommonData.MessageType.Ok); } else { this.ProcessDbExcetion(iReturnCode); } } this.HideProgressBar(); return(iReturnCode); }
/// <summary> /// Insert or update data to database /// </summary> protected virtual int SaveData() { this.MessageBox = new MessageBoxs(); IvsMessage message = null; int iReturnCode = -1; //This is case ViewMode is Edit, system will update data to database if (this.ViewMode == CommonData.Mode.Edit) { iReturnCode = Bl.UpdateData(this.Dto); if (iReturnCode == CommonData.DbReturnCode.Succeed) { object dto = Activator.CreateInstance(this.CurrentDto.GetType()); CommonMethod.Clone(this.Dto, out dto); this.ListDto[currentPosition] = (IDto)dto; message = new IvsMessage("CMN004"); this.MessageBox.Add(message); this.MessageBox.Display(CommonData.MessageType.Ok); } else { ProcessDbExcetion(iReturnCode); } } ////This is case ViewMode is New, system will insert data to databas else if (this.ViewMode == CommonData.Mode.New) { iReturnCode = Bl.InsertData(this.Dto); if (iReturnCode == CommonData.DbReturnCode.Succeed) { message = new IvsMessage("CMN003"); this.MessageBox.Add(message); this.MessageBox.Display(CommonData.MessageType.Ok); } else { ProcessDbExcetion(iReturnCode); } } return(iReturnCode); }
/// <summary> /// Load data of next member in ListDto for input control /// </summary> protected virtual void LoadNextData() { //This is case ViewMode is View or Edit if (this.ViewMode == CommonData.Mode.View || this.ViewMode == CommonData.Mode.Edit) { if (currentPosition < ListDto.Count - 1) { currentPosition++; object dto = Activator.CreateInstance(this.CurrentDto.GetType()); CommonMethod.Clone(this.CurrentDto, out dto); this.Dto = (IDto)dto; } } //This is case ViewMode is New else { this.Dto = null; ListDto = new List <IDto>(); object dto = Activator.CreateInstance(this.Dto.GetType()); CommonMethod.Clone(this.Dto, out dto); ListDto.Add((IDto)dto); } }