protected override void FillData() { DataTable dtResult = new DataTable(); CommonBl commonBl = new CommonBl(); ST_StockTransactionMasterDto dto = new ST_StockTransactionMasterDto(); dto.PeriodCdn = this.Period; dto.WarehouseCnd = this.WarehouseCode; dto.DocumentTypeCdn = this.DocumentType; dto.SampleShippingFlg = this.SampleShippingFlg; dto.TransactionSubCodeCnd = this.TransactionSubCode; dto.CompanyCodeCnd = this.CompanyCode; dto.IsCustomerCnd = this.IsCompleted; dto.OrderByDesc = this.OrderByDesc; commonBl.SelectDocumentData(dto, this.CheckAuthorization, out dtResult); if (dtResult.Columns.Count > 0) { if (this.HasNull) { DataRow newRow = dtResult.NewRow(); //newRow[0] = CommonData.StringEmpty; dtResult.Rows.InsertAt(newRow, 0); } } this.Properties.DataSource = dtResult; this.Properties.NullText = CommonData.StringEmpty; //this.EditValue = CommonData.StringEmpty; //base.FillData(); }
private void UpdateStockTransactionMasterForCountingPrint(int printCounted, string reason) { ST_StockTransactionMasterDto stockTransactionDto = this.ctrlHeader.Dto as ST_StockTransactionMasterDto; stockTransactionDto.DeliverySheetPrintCount = printCounted; stockTransactionDto.DeliverySheetRePrintReason = reason; new StockTransactionBl().UpdatePrint(stockTransactionDto); }
protected override void SetAuthorityControl() { //Not apply for Edit //Set authorization for Print ST_StockTransactionMasterDto currentDto = (ST_StockTransactionMasterDto)this.CurrentDto; if (currentDto != null) { //Set authorization for Print if (this.IsWarehouseAuthority(currentDto.WarehouseCode, CommonData.OperId.InventoryInquiry) == CommonData.IsAuthority.Deny) { this.btnInventory.Enabled = false; } //Set authorization for Print if (this.IsWarehouseAuthority(currentDto.WarehouseCode, CommonData.OperId.Print) == CommonData.IsAuthority.Deny) { this.btnPrintSheet.Enabled = false; } //Set authorization for Cancel if (this.IsWarehouseAuthority(currentDto.WarehouseCode, CommonData.OperId.Cancel) == CommonData.IsAuthority.Deny) { this.btnCancel.Enabled = false; } //Set authorization for Export if (this.IsWarehouseAuthority(currentDto.WarehouseCode, CommonData.OperId.Export) == CommonData.IsAuthority.Deny) { this.btnExport.Enabled = false; } //Set authorization for View PO && SO Price if ((currentDto.TransactionSubCode == CommonData.TransactionSubCode.SA_StockArrivingForPurchaseOrder && this.IsWarehouseAuthority(currentDto.WarehouseCode, CommonData.OperId.ViewPOPrice) == CommonData.IsAuthority.Deny) || (currentDto.TransactionSubCode == CommonData.TransactionSubCode.SH_StockShippingForDelivery && this.IsWarehouseAuthority(currentDto.WarehouseCode, CommonData.OperId.ViewSOPrice) == CommonData.IsAuthority.Deny)) { if (ctrlDetail != null) { this.ctrlDetail.ShowUnitPrice = false; this.ctrlDetail.ShowAmount = false; this.ctrlDetail.ShowGridColumn(); } if (ctrlDetail1 != null) { this.ctrlDetail1.ShowUnitPrice = false; this.ctrlDetail1.ShowAmount = false; this.ctrlDetail1.ShowGridColumn(); } } } }
/// <summary> /// Print delivery sheet /// </summary> protected virtual void PrintSheet(IvsUserControl masterControl) { if (this.btnPrintSheet.Visibility == DevExpress.XtraBars.BarItemVisibility.Never || this.btnPrintSheet.Enabled == false) { return; } StockTransactionBl stocktransactionBl = new StockTransactionBl(); stockMasterDto = (ST_StockTransactionMasterDto)this.Dto; transactionMasterControl = masterControl; DataTable stockMasterDt = new DataTable(); int rows = 0; int returnCode = stocktransactionBl.SearchMaster(stockMasterDto, out stockMasterDt, out rows); if (!CommonMethod.IsNullOrEmpty(stockMasterDt)) { printedCount = CommonMethod.ParseInt32(stockMasterDt.Rows[0][CommonKey.DeliverySheetPrintCount]); stockMasterDto.DeliverySheetPrintCount = printedCount; if (printedCount == 0) { printedCount = printedCount + 1; this.ShowReport(printedCount); this.UpdateStockTransactionMasterForCountingPrint(printedCount, string.Empty); var collection = masterControl.Controls.Find("txtPrintCount", true); if (collection.Length > 0) { Ivs.Controls.CustomControls.WinForm.IvsTextEdit chk = (Ivs.Controls.CustomControls.WinForm.IvsTextEdit)collection[0]; chk.Text = printedCount.ToString(); } } else { if (printedCount <= CommonData.PrintSheetDelivery.DeliverySheet) { ReasonPrintForm.ShowDialog(); } else { //Display message can not print more than four times. this.MessageBox = new MessageBoxs(); IvsMessage message = null; message = new IvsMessage(CommonConstantMessage.COM_MSG_CAN_NOT_PRINT, "4"); this.MessageBox.Add(message); this.MessageBox.Display(CommonData.MessageType.Ok); } } } }
protected override void SetAuthorityControl() { //Not apply for Edit //Set authorization for Print ST_StockTransactionMasterDto currentDto = (ST_StockTransactionMasterDto)this.CurrentDto; if (currentDto != null) { //Set authorization for Print if (this.IsWarehouseAuthority(currentDto.WarehouseCode, CommonData.OperId.InventoryInquiry) == CommonData.IsAuthority.Deny) { this.btnInventory.Enabled = false; } //Set authorization for Print if (this.IsWarehouseAuthority(currentDto.WarehouseCode, CommonData.OperId.Print) == CommonData.IsAuthority.Deny) { this.btnPrintSheet.Enabled = false; } //Set authorization for Cancel if (this.IsWarehouseAuthority(currentDto.WarehouseCode, CommonData.OperId.Cancel) == CommonData.IsAuthority.Deny) { this.btnCancel.Enabled = false; } //Set authorization for ViewPrice if (this.IsWarehouseAuthority(currentDto.WarehouseCode, CommonData.OperId.ViewPrice) == CommonData.IsAuthority.Deny) { if (ctrlDetail != null) { this.ctrlDetail.ShowUnitPrice = false; this.ctrlDetail.ShowAmount = false; this.ctrlDetail.ShowGridColumn(); } if (ctrlDetail1 != null) { this.ctrlDetail1.ShowUnitPrice = false; this.ctrlDetail1.ShowAmount = false; this.ctrlDetail1.ShowGridColumn(); } } } }
/// <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) { //Input cancel reason ReasonForm reasonForm = new ReasonForm(); reasonForm.ShowDialog(); if (reasonForm.MsgTypeResult == CommonData.MessageTypeResult.OK) { ST_StockTransactionMasterDto cancelDto = ((ST_StockTransactionMasterDto)this.Dto); cancelDto.CancelReason = reasonForm.Reason; this.MessageBox = new MessageBoxs(); StockTransactionBl stockTransactionBl = new StockTransactionBl(); StockResult stockResult = stockTransactionBl.Cancel(cancelDto); 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); } } } }
/// <summary> /// Override IsFormChanged method /// </summary> protected override bool IsFormChanged() { if (this.ListDto != null && this.ViewMode != CommonData.Mode.View) { ST_StockTransactionMasterDto oldDto = (ST_StockTransactionMasterDto)this.CurrentDto; ST_StockTransactionMasterDto newDto = (ST_StockTransactionMasterDto)this.Dto; if (oldDto.DepartmentCode != newDto.DepartmentCode) { return(true); } if (oldDto.WarehouseCode != newDto.WarehouseCode) { return(true); } if (oldDto.TransactionSupCode != newDto.TransactionSupCode) { return(true); } if (CommonMethod.ParseDate(oldDto.ShippingDate) != CommonMethod.ParseDate(newDto.ShippingDate)) { return(true); } if (CommonMethod.ParseDate(oldDto.ArrivingDate) != CommonMethod.ParseDate(newDto.ArrivingDate)) { return(true); } if (oldDto.PersonInChange != newDto.PersonInChange) { return(true); } if (oldDto.PostedPerson != newDto.PostedPerson) { return(true); } if (CommonMethod.ParseString(oldDto.PersonInChange2) != CommonMethod.ParseString(newDto.PersonInChange2)) { return(true); } if (CommonMethod.ParseDate(oldDto.PostedDate) != CommonMethod.ParseDate(newDto.PostedDate)) { return(true); } //if (oldDto.CustomerCode != newDto.CustomerCode) //{ // return true; //} //if (oldDto.SupplierCode != newDto.SupplierCode) //{ // return true; //} if (oldDto.CompanyCode != newDto.CompanyCode) { return(true); } if (CommonMethod.ParseString(oldDto.Description) != CommonMethod.ParseString(newDto.Description)) { return(true); } if (newDto.CheckDetails.Count > 0) { return(true); } if (newDto.CheckDetails1.Count > 0) { return(true); } } return(false); }
/// <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); }