/// <summary> /// Cancel document /// </summary> protected virtual void Cancel() { if (btnCancel.Visibility == DevExpress.XtraBars.BarItemVisibility.Never || btnCancel.Enabled == false) { return; } this.MessageBox = new MessageBoxs(); IvsMessage message = new IvsMessage(CommonConstantMessage.COM_MSG_CONFIRM_CANCEL); this.MessageBox.Add(message); CommonData.MessageTypeResult result = this.MessageBox.Display(CommonData.MessageType.YesNo); if (result == CommonData.MessageTypeResult.Yes) { this.MessageBox = new MessageBoxs(); StockTransactionBl stockTransactionBl = new StockTransactionBl(); StockResult stockResult = stockTransactionBl.Cancel((ST_StockTransactionMasterDto)this.Dto); if (stockResult.ReturnCode == CommonData.StockReturnCode.Succeed) { message = new IvsMessage(CommonConstantMessage.COM_MSG_CANCEL_SUCCESSFULLY); this.MessageBox.Add(message); this.MessageBox.Display(CommonData.MessageType.Ok); this.CloseForm(); } else { lblErrorMessage.Text = ProcessStockException(stockResult); } } }
protected virtual void BackupOrRestore() { MessageBoxs msg = new MessageBoxs(); IvsMessage message = null; if (isBackup) { message = new IvsMessage("SYBK00_008"); } else { message = new IvsMessage("SYRT00_002"); } msg.Add(message); CommonData.MessageTypeResult result = msg.Display(CommonData.MessageType.YesNo); if (result == CommonData.MessageTypeResult.Yes) { //this.service = new Ivs.Core.Services.Services(); //this.service.Credentials = System.Net.CredentialCache.DefaultCredentials; //this.service.BackupOrRestoreCompleted += new Ivs.Core.Services.BackupOrRestoreCompletedEventHandler(service_BackupOrRestoreCompleted); //this.service.BackupOrRestoreAsync(this.isBackup, this.txtPath.Text); //backupService.BackupOrRestore(this.isBackup, this.txtPath.Text); this.btnOK.Enabled = false; } }
protected virtual bool Exit() { #region Logger Start log.GetLogger(this.Name.ToString()); log.Write(Logger.Level.Debug, "Exit Start"); #endregion Logger Start bool isExit = false; //Check Logout state bool isLogout = ApplicationState.GetValue <bool>("Logout"); if (!isLogout) { if (IsChanged) { this.MessageBox = new MessageBoxs(); IvsMessage message = null; message = new IvsMessage(CommonConstantMessage.COM_MSG_CONFIRM_EXIT); this.MessageBox.Add(message); CommonData.MessageTypeResult result = this.MessageBox.Display(CommonData.MessageType.YesNoCancel); if (result == CommonData.MessageTypeResult.Yes) { if (this.ValidateData() == CommonData.IsValid.Successful) { this.SaveData(); this.CloseForm(); isExit = true; } } else if (result == CommonData.MessageTypeResult.No) { this.CloseForm(); isExit = true; } } else { this.CloseForm(); isExit = true; } } else { this.CloseForm(); isExit = true; } return(isExit); #region Logger End log.Write(Logger.Level.Debug, "Exit End"); #endregion Logger End }
/// <summary> /// Confirm want to clear all data /// </summary> protected override void ClearOrReset() { if (this.IsFormChanged()) { this.MessageBox = new MessageBoxs(); IvsMessage message = new IvsMessage(CommonConstantMessage.COM_MSG_CONFIRM_CLEAR); this.MessageBox.Add(message); CommonData.MessageTypeResult result = this.MessageBox.Display(CommonData.MessageType.YesNo); if (result == CommonData.MessageTypeResult.No) { return; } } base.ClearOrReset(); }
protected virtual bool Exit() { #region Logger Start log.GetLogger(this.Name.ToString()); log.Write(Logger.Level.Debug, "Exit Start"); #endregion Logger Start bool isExit = false; if (IsChanged) { this.MessageBox = new MessageBoxs(); IvsMessage message = null; message = new IvsMessage("CMN010"); this.MessageBox.Add(message); CommonData.MessageTypeResult result = this.MessageBox.Display(CommonData.MessageType.YesNoCancel); if (result == CommonData.MessageTypeResult.Yes) { if (this.ValidateData() == CommonData.IsValid.Successful) { this.SaveData(); this.CloseForm(); isExit = true; } } if (result == CommonData.MessageTypeResult.No) { this.CloseForm(); isExit = true; } } else { this.CloseForm(); isExit = true; } return(isExit); #region Logger End log.Write(Logger.Level.Debug, "Exit End"); #endregion Logger End }
/// <summary> /// This method is called when click SaveAndClose button /// ViewMode is Edit: update data and not close form /// ViewMode is New: insert data and not close form /// </summary> protected virtual int SaveAndNotClose() { #region Logger Start log.GetLogger(this.Name.ToString()); log.Write(Logger.Level.Debug, "SaveAndClose Start"); #endregion Logger Start if (btnSaveAndClose.Visibility == DevExpress.XtraBars.BarItemVisibility.Never || btnSaveAndClose.Enabled == false) { return(CommonData.DbReturnCode.AccessDenied); } int iReturnCode = CommonData.DbReturnCode.Succeed; this.MessageBox = new MessageBoxs(); IvsMessage message = null; switch (this.ViewMode) { case CommonData.Mode.Edit: { if (this.ValidateData() == CommonData.IsValid.Successful) { this.lblErrorMessage.Text = CommonData.StringEmpty; message = new IvsMessage(CommonConstantMessage.COM_MSG_CONFIRM_SAVE); this.MessageBox.Add(message); MsgTypeResult = this.MessageBox.Display(CommonData.MessageType.YesNo); if (MsgTypeResult == CommonData.MessageTypeResult.Yes) { iReturnCode = this.SaveData(); if (iReturnCode == CommonData.DbReturnCode.Succeed) { //do nothing //this.CloseForm(); } } } else { iReturnCode = CommonData.DbReturnCode.ExceptionOccured; } } break; case CommonData.Mode.New: { if (this.ValidateData() == CommonData.IsValid.Successful) { this.lblErrorMessage.Text = CommonData.StringEmpty; message = new IvsMessage(CommonConstantMessage.COM_MSG_CONFIRM_SAVE); this.MessageBox.Add(message); MsgTypeResult = this.MessageBox.Display(CommonData.MessageType.YesNo); if (MsgTypeResult == CommonData.MessageTypeResult.Yes) { iReturnCode = this.SaveData(); if (iReturnCode == CommonData.DbReturnCode.Succeed) { //do nothing //this.CloseForm(); } this.SetControl(); } } else { iReturnCode = CommonData.DbReturnCode.ExceptionOccured; } } break; case CommonData.Mode.View: { this.CloseForm(); } break; } #region Logger End log.Write(Logger.Level.Debug, "SaveAndClose End"); #endregion Logger End return(iReturnCode); }
/// <summary> /// This method is called when click SaveAndNext button /// </summary> protected virtual void SaveAndNext() { #region Logger Start log.GetLogger(this.Name.ToString()); log.Write(Logger.Level.Debug, "SaveAndNext Start"); #endregion Logger Start int iReturnCode = CommonData.DbReturnCode.Succeed; if (btnSaveAndNext.Visibility == DevExpress.XtraBars.BarItemVisibility.Never || btnSaveAndNext.Enabled == false) { return; } this.MessageBox = new MessageBoxs(); IvsMessage message = null; switch (this.ViewMode) { case CommonData.Mode.Edit: { if (this.ValidateData() == CommonData.IsValid.Successful) { this.lblErrorMessage.Text = CommonData.StringEmpty; message = new IvsMessage(CommonConstantMessage.COM_MSG_CONFIRM_SAVE); this.MessageBox.Add(message); CommonData.MessageTypeResult result = this.MessageBox.Display(CommonData.MessageType.YesNo); if (result == CommonData.MessageTypeResult.Yes) { iReturnCode = this.SaveData(); if (iReturnCode == CommonData.DbReturnCode.Succeed) { this.LoadNextData(); } this.SetControl(); } } } break; case CommonData.Mode.New: { if (this.ValidateData() == CommonData.IsValid.Successful) { this.lblErrorMessage.Text = CommonData.StringEmpty; message = new IvsMessage(CommonConstantMessage.COM_MSG_CONFIRM_SAVE); this.MessageBox.Add(message); CommonData.MessageTypeResult result = this.MessageBox.Display(CommonData.MessageType.YesNo); if (result == CommonData.MessageTypeResult.Yes) { iReturnCode = this.SaveData(); if (iReturnCode == CommonData.DbReturnCode.Succeed) { this.LoadNextData(); } this.SetControl(); } } } break; case CommonData.Mode.View: { this.LoadNextData(); this.SetControl(); } break; } #region Logger End log.Write(Logger.Level.Debug, "SaveAndNext End"); #endregion Logger End }
/// <summary> /// Processing when click btnDelete /// </summary> protected virtual void DeleteData() { if (this.btnDelete.Visibility == DevExpress.XtraBars.BarItemVisibility.Never || this.btnDelete.Enabled == false) { return; } #region Logger Start log.GetLogger(this.Name.ToString()); log.Write(Logger.Level.Debug, "DeleteData Start"); #endregion Logger Start this.lblErrorMessage.Text = CommonData.StringEmpty; this.MessageBox = new MessageBoxs(); IvsMessage message = null; ListDto = GetSelectedRows(); if (ListDto.Count <= 0) { message = new IvsMessage("CMN008"); this.MessageBox.Add(message); this.MessageBox.Display(CommonData.MessageType.Ok); this.lblErrorMessage.Text = this.MessageBox.DisplayMessage; return; } message = new IvsMessage("CMN011"); this.MessageBox.Add(message); CommonData.MessageTypeResult result = this.MessageBox.Display(CommonData.MessageType.YesNo); if (result == CommonData.MessageTypeResult.Yes) { int iReturnCode = Bl.DeleteData(ListDto); /// Succeed: Delete successful, don't show message error, refresh Gird /// AccessDenied: Access denied, login to database fail(invalid username, invalid password), show message error /// InvalidHost: Invalid host, cannot find server(host) that set in app config file, show message error /// InvalidDatabase: Invalid database, cannot find database that set in DbConfig file, show message error /// LostConnection: Lost connection, cannot connect to database because lost connection, show message error /// DuplicateKey: Duplicate key: insert Primary Key or Unique Key that already exist in database, show message error /// ForgeignKeyNotExist: Forgeign key not exist: insert a foreign key that not exist in primary key, show message error /// ForeignKeyViolation: Foreign Key Violation: Foreign Key Violation (delete primary key that is foreign key in other table), show message error /// DataNotFound: Data not found: Delete or Update data that not exist in database, show message error /// ExceptionOccured: Exception occured: other exception if (iReturnCode == CommonData.DbReturnCode.Succeed) { message = new IvsMessage("CMN005"); this.MessageBox.Add(message); this.MessageBox.Display(CommonData.MessageType.Ok); // Resarch data after delete isResearch = true; this.SearchData(); isResearch = false; } else { ProcessDbExcetion(iReturnCode); } } #region Logger End log.Write(Logger.Level.Debug, "DeleteData End"); #endregion Logger End }
private void btnCancel_Click(object sender, EventArgs e) { _typeResult = CommonData.MessageTypeResult.Cancel; //this.Clear(); this.Close(); }
private void btnYes_Click(object sender, EventArgs e) { _typeResult = CommonData.MessageTypeResult.Yes; this.Clear(); this.Close(); }
/// <summary> /// Insert or update data to database /// </summary> protected override int SaveData() { this.ShowProgressBar(); this.MessageBox = new MessageBoxs(); IvsMessage message = null; StockResult stockResult = new StockResult(); ST_StockTransactionMasterDto stockMaster = (ST_StockTransactionMasterDto)this.Dto; stockMaster.SafetyStockFlag = this.SafetyStockFlag; //This is case ViewMode is Edit, system will update data to database if (this.ViewMode == CommonData.Mode.Edit) { ///UAT : Nếu ngày xuất và ngày nhận ko cùng 1 ngày => khi nhận sẽ có thông báo warning lên cho user biết > ///nếu user nhấn yes trên warning cho nhận nếu nhấn no trên warning ko cho nhận. if (FunctionGr == CommonData.FunctionGr.ST_ST_StockTransferArrivingInStorage) { if (Dto != null) { ST_StockTransactionMasterDto dtoMaster = (ST_StockTransactionMasterDto)Dto; if (dtoMaster.ShippingDate != dtoMaster.ArrivingDate) { message = new IvsMessage(CommonConstantMessage.COM_MSG_NOT_MATCH_WARNING, dtoMaster.ArrivingDateCtrl, dtoMaster.ShippingDateCtrl); this.MessageBox.Add(message); CommonData.MessageTypeResult result = this.MessageBox.Display(CommonData.MessageType.YesNo); if (result != CommonData.MessageTypeResult.Yes) { return(CommonData.DbReturnCode.DataNotFound); } } } } stockResult = Bl.UpdateTransactionData(stockMaster); if (stockResult.ReturnCode == CommonData.DbReturnCode.Succeed) { message = new IvsMessage(CommonConstantMessage.COM_MSG_UPDATE_SUCCESSFULLY); this.MessageBox.Add(message); this.MessageBox.Display(CommonData.MessageType.Ok); } else { this.ProcessStockException(stockResult); } } //This is case ViewMode is New, system will insert data to databas else if (this.ViewMode == CommonData.Mode.New) { stockResult = Bl.InsertTransactionData(stockMaster); if (stockResult.ReturnCode == CommonData.DbReturnCode.Succeed) { this.DocumentNumber = stockResult.DocumentNumber; //stockMaster.DocumentNumber = stockResult.DocumentNumber; //this.Dto = stockMaster; //stockMaster.DocumentNumber = stockResult.DocumentNumber; //this.ctrlHeader.Dto = stockMaster; message = new IvsMessage(CommonConstantMessage.COM_MSG_INSERT_SUCCESSFULLY); this.MessageBox.Add(message); this.MessageBox.Display(CommonData.MessageType.Ok); } else { if (this.SafetyStockFlag == false) { //Check warning safety dangerous //count number of safety dangerous int numOfSafetyDangerous = stockResult.ErrorList.Count(lt => lt.ReturnCode.Equals(CommonData.StockReturnCode.StockSafetyDangerous)); //check if total error is number of safety dangerous if (numOfSafetyDangerous > 0 && (numOfSafetyDangerous == stockResult.ErrorList.Count)) { //Show warning //message = new IvsMessage(CommonConstantMessage.COM_MSG_STOCK_SAFETY_DANGEROUS); for (int i = 0; i < stockResult.ErrorList.Count; i++) { switch (stockResult.ErrorList[i].ReturnCode) { case CommonData.StockReturnCode.StockSafetyDangerous: message = new IvsMessage(CommonConstantMessage.COM_MSG_STOCK_GRID_STOCK_SAFETY_DANGEROUS, stockResult.ErrorList[i].Line); this.MessageBox.Add(message); break; default: break; } } //this.MessageBox.Add(message); CommonData.MessageTypeResult result = this.MessageBox.Display(CommonData.MessageType.YesNo); if (result == CommonData.MessageTypeResult.Yes) { //Update SafetyFlag to not warning again. this.SafetyStockFlag = true; //Save again stockResult.ReturnCode = this.SaveData(); } } else { this.ProcessStockException(stockResult); } } else { this.ProcessStockException(stockResult); } } } this.HideProgressBar(); return(stockResult.ReturnCode); }
/// <summary> /// Insert or update data to database /// </summary> protected override int SaveData() { this.MessageBox = new MessageBoxs(); IvsMessage message = null; StockResult stockResult = new StockResult(); ST_StockTransactionMasterDto stockMaster = (ST_StockTransactionMasterDto)this.Dto; stockMaster.SafetyStockFlag = this.SafetyStockFlag; //This is case ViewMode is Edit, system will update data to database if (this.ViewMode == CommonData.Mode.Edit) { stockResult = Bl.UpdateTransactionData(stockMaster); if (stockResult.ReturnCode == CommonData.DbReturnCode.Succeed) { message = new IvsMessage(CommonConstantMessage.COM_MSG_UPDATE_SUCCESSFULLY); this.MessageBox.Add(message); this.MessageBox.Display(CommonData.MessageType.Ok); } else { this.ProcessStockException(stockResult); } } //This is case ViewMode is New, system will insert data to databas else if (this.ViewMode == CommonData.Mode.New) { stockResult = Bl.InsertTransactionData(stockMaster); if (stockResult.ReturnCode == CommonData.DbReturnCode.Succeed) { message = new IvsMessage(CommonConstantMessage.COM_MSG_INSERT_SUCCESSFULLY); this.MessageBox.Add(message); this.MessageBox.Display(CommonData.MessageType.Ok); } else { if (this.SafetyStockFlag == false) { //Check warning safety dangerous //count number of safety dangerous int numOfSafetyDangerous = stockResult.ErrorList.Count(lt => lt.ReturnCode.Equals(CommonData.StockReturnCode.StockSafetyDangerous)); //check if total error is number of safety dangerous if (numOfSafetyDangerous > 0 && (numOfSafetyDangerous == stockResult.ErrorList.Count)) { //Show warning message = new IvsMessage(CommonConstantMessage.COM_MSG_STOCK_SAFETY_DANGEROUS); this.MessageBox.Add(message); CommonData.MessageTypeResult result = this.MessageBox.Display(CommonData.MessageType.YesNo); if (result == CommonData.MessageTypeResult.Yes) { //Update SafetyFlag to not warning again. this.SafetyStockFlag = true; //Save again stockResult.ReturnCode = this.SaveData(); } } else { this.ProcessStockException(stockResult); } } else { this.ProcessStockException(stockResult); } } } return(stockResult.ReturnCode); }