public bool PaymentVoucherCreating_PreTransitionCRUD(string transition) { //Save data before transit by 'Save' transition if (transition.ToUpper().Equals(VoucherStateTransition.SaveTransition.TransitionName.ToUpper())) { gridviewReceiptVoucherAllocation.GridView.UpdateEdit(); //Validate input data if (!ASPxEdit.ValidateEditorsInContainer(cpnReceiptVoucherEditingForm, "ReceiptVoucherEditingForm", false)) { return(false); } //Collects input data string code = txtCode.Text; DateTime issueDate = txtIssueDate.Date; string description = txtDescription.Text; string address = txtAddress.Text; string payee = txtPayer.Text; Guid sourceOrgId = Utility.CurrentSession.Instance.AccessingOrganizationId; Guid targetOrgId = cboSourceOrganization.Value != null ? (Guid)cboSourceOrganization.Value : Guid.Empty; double credit = (double)spinAmount.Number; //Guid currencyId = (Guid)cboCurrency.Value; Guid currencyId = (Guid)gridlookupCurrency.GetSelectedCurrencyKey(); double exchangeRate = (double)spinExchangeRate.Number; //Insert data to database PaymentVouchesBO paymentVoucherBO = new PaymentVouchesBO(); paymentVoucherBO.Insert(VoucherId, code, issueDate, description, address, payee, sourceOrgId, targetOrgId, credit, currencyId, exchangeRate); } else if (transition.ToUpper().Equals(VoucherStateTransition.CancelTransition.TransitionName.ToUpper())) { voucherBO.DeleteTempObject(VoucherId); } return(true); }
protected void popPaymentVoucherEdit_WindowCallback(object source, DevExpress.Web.ASPxPopupControl.PopupWindowCallbackArgs e) { string[] args = e.Parameter.Split('|'); ReceiptVouchesBO bo = new ReceiptVouchesBO(); //ham dinh nghia ben NAS.BO switch (args[0]) { //DND 851 case "cbo_click": if (args.Length > 1) { string textAdsress = ""; if (args[1].Equals("")) { textAdsress = ""; } else { string[] org_code = args[1].ToString().Split('-'); org_code[0] = org_code[0].Trim(); textAdsress = bo.searchOrgnAdress(session, org_code[0]); } memoAddress.Value = textAdsress; txtPayer.Focus(); } break; //END DND 851 case "new": PaymentVouches tempPaymentVouches = PaymentVouches.InitNewRow(session); popPaymentVoucherEdit.JSProperties["cpNewRecordId"] = tempPaymentVouches.VouchesId.ToString(); PrivateSession.Instance.PaymentVoucherId = tempPaymentVouches.VouchesId; dsPaymentVoucher.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.PaymentVoucherId.ToString(); dsVouchersAmount.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.PaymentVoucherId.ToString(); ClearForm(); txtCode.Text = artifactCodeRuleBO.GetArtifactCodeOfArtifactType(ArtifactTypeEnum.VOUCHER_PAYMENT); dateIssuedDate.Value = DateTime.Now; //DND 851 break; case "edit": ClearForm(); if (args.Length > 1) { PrivateSession.Instance.PaymentVoucherId = Guid.Parse(args[1]); dsPaymentVoucher.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.PaymentVoucherId.ToString(); dsVouchersAmount.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.PaymentVoucherId.ToString(); txtCode.Text = CurrentPaymentVouches.Code; //DND if (bo.searchOrgDefault(session, CurrentPaymentVouches.TargetOrganizationId.OrganizationId.ToString())) { popPaymentVoucherEdit.JSProperties.Add("cpIsDefaultSourceOrg", true); } else { popPaymentVoucherEdit.JSProperties.Add("cpIsDefaultSourceOrg", false); } //END DND } break; case "save": bool isSuccess = true; string recordIdStr = null; try { //Check validation if (!ASPxEdit.AreEditorsValid(frmPaymentVoucher, true)) { popPaymentVoucherEdit.JSProperties.Add("cpInvalid", true); return; } //2013-11-18 Khoa.Truong DEL START //DND 851 Guid targetOrgId; bo = new ReceiptVouchesBO(); //ham dinh nghia ben NAS.BO string cbVouchesType_name = cbVouchesType.Text; if (cbTargetOrganization.Text == null || cbTargetOrganization.Text.Equals("")) { targetOrgId = Guid.Parse(bo.searchOrganizationId(session)); } else { string[] org_code = cbTargetOrganization.Text.ToString().Split('-'); org_code[0] = org_code[0].Trim(); targetOrgId = Guid.Parse(bo.searchOrgId(session, org_code[0])); } Guid voucherTypeId = Guid.Parse(bo.searchVouchesTypeId(session, cbVouchesType_name)); //END DND //2013-11-18 Khoa.Truong DEL START //collect data for saving string code = txtCode.Text; DateTime issueDate = DateTime.Parse(dateIssuedDate.Text); string description = memoDescription.Text; string address = memoAddress.Text; //2013-11-18 Khoa.Truong INS START //Guid voucherTypeId = Guid.Parse(cbVouchesType.SelectedItem.Value.ToString()); //Guid targetOrgId = Guid.Parse(cbTargetOrganization.SelectedItem.Value.ToString()); //2013-11-18 Khoa.Truong INS END string payee = txtPayer.Text; //Logic to save data if (args.Length > 1) { //Update mode //Update general information recordIdStr = args[1]; Guid recordId = Guid.Parse(recordIdStr); PaymentVouchesBO.Update(PrivateSession.Instance.PaymentVoucherId, code, issueDate, description, address, payee, Constant.ROWSTATUS_ACTIVE, Utility.CurrentSession.Instance.AccessingOrganizationId, targetOrgId, voucherTypeId); } else { //Insert mode PaymentVouchesBO.Insert(PrivateSession.Instance.PaymentVoucherId, code, issueDate, description, address, payee, Constant.ROWSTATUS_ACTIVE, Utility.CurrentSession.Instance.AccessingOrganizationId, targetOrgId, voucherTypeId); } } catch (Exception ex) { isSuccess = false; throw; } finally { popPaymentVoucherEdit.JSProperties.Add("cpCallbackArgs", String.Format("{{ \"recordId\": \"{0}\", \"isSuccess\": {1} }}", recordIdStr, isSuccess.ToString().ToLower())); } break; default: break; } }