Esempio n. 1
0
        protected void grdReceiptVouches_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
        {
            string[] args = e.Parameters.Split('|');
            switch (args[0])
            {
            case "delete":
                try
                {
                    if (args.Length > 1)
                    {
                        Guid recordId = Guid.Parse(args[1]);
                        ReceiptVouchesBO.DeleteLogical(recordId);
                        grdReceiptVouches.JSProperties.Add("cpEvent", "deleted");
                    }
                    else
                    {
                        throw new Exception("Must be pass id of the record");
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                break;

            default:
                break;
            }
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            session = XpoHelper.GetNewSession();
            dsReceiptVoucher.Session  = session;
            dsForeignCurrency.Session = session;
            dsVoucherAmount.Session   = session;

            voucherBO        = new VoucherBO();
            receiptVouchesBO = new ReceiptVouchesBO();
            //gridviewVoucherAllocation.SetAllocationGetter(
            //    new NAS.BO.Accounting.Configure.AllocationGetter.ReceiptVoucherAllocationGetter());
        }
        public bool ReceiptVoucherCreating_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   payer       = txtPayer.Text;
                Guid     sourceOrgId = cboSourceOrganization.Value != null ? (Guid)cboSourceOrganization.Value : Guid.Empty;
                Guid     targetOrgId = Utility.CurrentSession.Instance.AccessingOrganizationId;
                double   debit       = (double)spinAmount.Number;
                //Guid currencyId = (Guid)cboCurrency.Value;
                Guid   currencyId   = (Guid)gridlookupCurrency.GetSelectedCurrencyKey();
                double exchangeRate = (double)spinExchangeRate.Number;

                //Insert data to database
                ReceiptVouchesBO receiptVoucherBO = new ReceiptVouchesBO();
                receiptVoucherBO.Insert(VoucherId,
                                        code,
                                        issueDate,
                                        description,
                                        address,
                                        payer,
                                        sourceOrgId,
                                        targetOrgId,
                                        debit,
                                        currencyId,
                                        exchangeRate);
            }
            else if (transition.ToUpper().Equals(VoucherStateTransition.CancelTransition.TransitionName.ToUpper()))
            {
                voucherBO.DeleteTempObject(VoucherId);
            }
            return(true);
        }
Esempio n. 4
0
        protected void popReceiptVouchesEdit_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":
                ReceiptVouches tempReceiptVouches = ReceiptVouches.InitNewRow(session);
                popReceiptVouchesEdit.JSProperties["cpNewRecordId"]           = tempReceiptVouches.VouchesId.ToString();
                PrivateSession.Instance.ReceiptVoucherId                      = tempReceiptVouches.VouchesId;
                dsReceiptVouches.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.ReceiptVoucherId.ToString();
                dsVouchersAmount.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.ReceiptVoucherId.ToString();
                this.InvisibleCommandColumnGridviewIfApprovedCosting(grdVouchersAmount, "CommonOperations");
                ClearForm();
                txtCode.Text = artifactCodeRuleBO.GetArtifactCodeOfArtifactType(ArtifactTypeEnum.VOUCHER_RECEIPT);
                //DND 851
                dateIssuedDate.Value = DateTime.Now;


                //END DND
                break;

            case "edit":
                ClearForm();
                if (args.Length > 1)
                {
                    PrivateSession.Instance.ReceiptVoucherId = Guid.Parse(args[1]);
                    dsReceiptVouches.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.ReceiptVoucherId.ToString();
                    dsVouchersAmount.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.ReceiptVoucherId.ToString();
                    txtCode.Text = CurrentReceiptVouches.Code;
                    this.InvisibleCommandColumnGridviewIfApprovedCosting(grdVouchersAmount, "CommonOperations");
                    //DND
                    if (bo.searchOrgDefault(session, CurrentReceiptVouches.SourceOrganizationId.OrganizationId.ToString()))
                    {
                        popReceiptVouchesEdit.JSProperties.Add("cpIsDefaultSourceOrg", true);
                    }
                    else
                    {
                        popReceiptVouchesEdit.JSProperties.Add("cpIsDefaultSourceOrg", false);
                    }
                    //END DND
                }
                break;

            case "save":
                bool   isSuccess   = true;
                string recordIdStr = null;

                try
                {
                    //Check validation
                    if (!ASPxEdit.AreEditorsValid(frmReceiptVouches, true))
                    {
                        popReceiptVouchesEdit.JSProperties.Add("cpInvalid", true);
                        return;
                    }

                    //collect data for saving
                    string   code      = txtCode.Text;
                    DateTime issueDate = new DateTime();
                    if (!DateTime.TryParse(dateIssuedDate.Text, out issueDate))
                    {
                        issueDate = DateTime.Now;
                    }

                    string description = memoDescription.Text;
                    string address     = memoAddress.Text;
                    //2013-11-18 Khoa.Truong INS START
                    //Guid voucherTypeId = Guid.Parse(cbVouchesType.SelectedItem.Value.ToString());
                    //Guid sourceOrgId = Guid.Parse(cbSourceOrganization.SelectedItem.Value.ToString());
                    //2013-11-18 Khoa.Truong INS END

                    //2013-11-18 Khong.Truong DEL START
                    ////DND 851
                    Guid sourceOrgId;
                    bo = new ReceiptVouchesBO();     //ham dinh nghia ben NAS.BO
                    string cbVouchesType_name = cbVouchesType.Text;


                    if (cbSourceOrganization.Text == null || cbSourceOrganization.Text.Equals(""))
                    {
                        sourceOrgId = Guid.Parse(bo.searchOrganizationId(session));
                    }
                    else
                    {
                        string[] org_code = cbSourceOrganization.Text.ToString().Split('-');

                        org_code[0] = org_code[0].Trim();

                        sourceOrgId = Guid.Parse(bo.searchOrgId(session, org_code[0]));
                    }
                    Guid voucherTypeId = Guid.Parse(bo.searchVouchesTypeId(session, cbVouchesType_name));
                    ////END DND
                    //2013-11-18 Khong.Truong DEL END

                    string payer = txtPayer.Text;
                    //Logic to save data

                    if (args.Length > 1)
                    {
                        //Update mode
                        //Update general information
                        recordIdStr = args[1];
                        Guid             recordId         = Guid.Parse(recordIdStr);
                        ReceiptVouchesBO receiptVouchesBO = new ReceiptVouchesBO();
                        receiptVouchesBO.Update(PrivateSession.Instance.ReceiptVoucherId,
                                                code,
                                                issueDate,
                                                description,
                                                address,
                                                payer,
                                                Constant.ROWSTATUS_ACTIVE,
                                                sourceOrgId,
                                                Utility.CurrentSession.Instance.AccessingOrganizationId,
                                                voucherTypeId);
                    }
                    else
                    {
                        //Insert mode
                        ReceiptVouchesBO receiptVouchesBO = new ReceiptVouchesBO();
                        receiptVouchesBO.Insert(PrivateSession.Instance.ReceiptVoucherId,
                                                code,
                                                issueDate,
                                                description,
                                                address,
                                                payer,
                                                Constant.ROWSTATUS_ACTIVE,
                                                sourceOrgId,
                                                Utility.CurrentSession.Instance.AccessingOrganizationId,
                                                voucherTypeId);
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    throw;
                }
                finally
                {
                    popReceiptVouchesEdit.JSProperties.Add("cpCallbackArgs",
                                                           String.Format("{{ \"recordId\": \"{0}\", \"isSuccess\": {1} }}", recordIdStr, isSuccess.ToString().ToLower()));
                }
                break;

            default:
                break;
            }
        }
Esempio n. 5
0
 protected void grdVouchersAmount_RowDeleted(object sender, DevExpress.Web.Data.ASPxDataDeletedEventArgs e)
 {
     grdVouchersAmount.JSProperties["cpEvent"] = "rowCountChanged";
     ReceiptVouchesBO.UpdateSumOfDebit(PrivateSession.Instance.ReceiptVoucherId);
 }
Esempio n. 6
0
 protected void grdVouchersAmount_RowUpdated(object sender, DevExpress.Web.Data.ASPxDataUpdatedEventArgs e)
 {
     ReceiptVouchesBO.UpdateSumOfDebit(PrivateSession.Instance.ReceiptVoucherId);
 }