コード例 #1
0
        public void Validate(Models.AppVCA04View data)
        {
            #region ki?m tra chi ti?t

            this._metaobject = Services.GlobalMeta.GetMetaObject(this._metalinename);
            this.ValidateLine(data.AppVCA04LineViews, data.AppVCA04LineViewz);

            #endregion

            #region ki?m tra thu?

            this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname);
            this.ValidateVAT(data.AppVCA04VATViews, data.AppVCA04VATViewz);
            #endregion

            #region Business logic validate
            #region Object validate
            this._metaobject = Services.GlobalMeta.GetMetaObject(this._metaname);
            this.ValidateMaster(data);
            #endregion

            #endregion

            //if (Errors.Count > 0) throw new InvalidOperationException("l?i nh?p s? li?u");
        }
コード例 #2
0
 public ActionResult Edit(long id, Models.AppVCA04View collection)
 {
     // TODO: Add insert logic here
     try
     {
         long outputId = _dataobject.Update(collection);
         return(RedirectToAction(this.ActionReturn()));
     }
     catch (Exception ex)
     {
         Services.GlobalErrors.Parse(ModelState, _dataobject.Errors, ex);
         return(PartialView(this._updateview, collection));
     }
 }
コード例 #3
0
        public long Update(Models.AppVCA04View data)
        {
            try
            {
                this.ValidateUpdate(data);
                this.Validate(data);

                data.ModifiedBy       = GlobalVariant.GetAppUser().UserID;
                data.ModifiedDateTime = DateTime.Now;

                SqlParameter pOriginal  = ExConvert.ParseSqlParam(data, this._metaobject.GetMetaByColumnName(this._paramnamemasteroutput), this._paramnamemasterupdate);
                var          parameters = ExConvert.Data2SqlParam(data, this._metaobject, pOriginal).ToArray();
                this._db.Database.ExecuteSqlCommand(this._storeNameU, parameters);

                #region X? lý line
                this._metaobject = Services.GlobalMeta.GetMetaObject(this._metalinename);


                var appvca04lineviews = data.AppVCA04LineViews.ToList();
                var appvca04lineviewz = data.AppVCA04LineViewz.ToList();
                for (int i = 0; i < appvca04lineviews.Count; i++)
                {
                    var itemz = appvca04lineviewz[i];
                    var item  = appvca04lineviews[i];

                    if (itemz != -1)
                    {
                        //có 2 tru?ng h?p: 1 - thêm m?i thu?ng DocumentLineID==0, 2 - s?a d? li?u cu DocumentLineID<>0
                        item.DocumentID = data.DocumentID;
                        //item.AccountDebitLineID = data.AccountDebitID;
                        item.AccountCreditLineID = data.AccountCreditID;

                        if (data.IsoCode == Services.GlobalVariant.GetSysOption()["IsoCode"].ToString())
                        {
                            item.Debit            = 0;
                            item.Credit           = 0;
                            item.ExchangeRateLine = 0;
                            item.AmountFC         = 0;
                        }


                        if (item.DocumentLineID == 0)
                        {
                            this.InsertLine(item);
                        }
                        else
                        {
                            this.UpdateLine(item);
                        }
                    }
                    else
                    {
                        //n?u xóa có 2 tru?ng h?p : 1 - xóa d? li?u có tru?c DocumentLineID<>0, 2 - xóa d? li?u m?i thêm DocumentLineID ==0
                        if (item.DocumentLineID > 0)
                        {
                            this.DeleteLine(item.DocumentLineID);
                        }
                    }
                }


                #endregion

                #region X? lý thu?
                if (data.AppVCA04VATViews != null)
                {
                    this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname);


                    var appvca04vatviews = data.AppVCA04VATViews.ToList();
                    var appvca04vatviewz = data.AppVCA04VATViewz.ToList();
                    for (int i = 0; i < appvca04vatviews.Count; i++)
                    {
                        var itemz = appvca04vatviewz[i];
                        var item  = appvca04vatviews[i];

                        if (itemz != -1)
                        {
                            //có 2 tru?ng h?p: 1 - thêm m?i thu?ng DocumentLineID==0, 2 - s?a d? li?u cu DocumentLineID<>0
                            item.DocumentID = data.DocumentID;
                            //item.AccountDebitLineID = data.AccountDebitID;
                            item.AccountCreditLineID = data.AccountCreditID;
                            if (data.IsoCode == Services.GlobalVariant.GetSysOption()["IsoCode"].ToString())
                            {
                                item.AmountFC    = 0;
                                item.AmountVATFC = 0;
                            }


                            if (item.DocumentVATID == 0)
                            {
                                this.InsertVAT(item);
                            }
                            else
                            {
                                this.UpdateVAT(item);
                            }
                        }
                        else
                        {
                            //n?u xóa có 2 tru?ng h?p : 1 - xóa d? li?u có tru?c DocumentLineID<>0, 2 - xóa d? li?u m?i thêm DocumentLineID ==0
                            if (item.DocumentVATID > 0)
                            {
                                this.DeleteVAT(item.DocumentVATID);
                            }
                        }
                    }
                }


                #endregion

                this._metaobject = Services.GlobalMeta.GetMetaObject(this._metaname);

                Services.Voucher.PostStoreProcedure(data.VoucherID, data.DocumentID);

                return(data.DocumentID);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #4
0
        public long Insert(Models.AppVCA04View data)
        {
            try
            {
                data.DocumentID = 0;
                //Ki?m tra thêm m?i ch?ng t? nhu trùng s? ho?c ngày khóa s?
                this.ValidateInsert(data);
                //Ki?m tra ki?u nh?p d? li?u
                this.Validate(data);

                #region x? lý master

                data.CreatedBy       = GlobalVariant.GetAppUser().UserID;
                data.CreatedDateTime = DateTime.Now;

                SqlParameter[] parameters = ExConvert.Data2SqlParam(data, this._metaobject, this._paramnamemasteroutput).ToArray();
                this._db.Database.ExecuteSqlCommand(this._storeNameI, parameters);
                data.DocumentID = (long)parameters.GetValueSqlParam(this._paramnamemasteroutput);

                #endregion

                #region X? lý line
                this._metaobject = Services.GlobalMeta.GetMetaObject(this._metalinename);

                var appvca04lineviews = data.AppVCA04LineViews.ToList();
                var appvca04lineviewz = data.AppVCA04LineViewz.ToList();
                for (int i = 0; i < appvca04lineviews.Count; i++)
                {
                    var itemz = appvca04lineviewz[i];
                    if (itemz != -1)
                    {
                        var item = appvca04lineviews[i];
                        item.DocumentID = data.DocumentID;
                        //item.AccountDebitLineID = data.AccountDebitID;
                        item.AccountCreditLineID = data.AccountCreditID;
                        if (data.IsoCode == Services.GlobalVariant.GetSysOption()["IsoCode"].ToString())
                        {
                            item.Debit            = 0;
                            item.Credit           = 0;
                            item.ExchangeRateLine = 0;
                            item.AmountFC         = 0;
                        }

                        this.InsertLine(item);
                    }
                }

                #endregion

                #region X? lý VAT
                if (data.AppVCA04VATViews != null)
                {
                    this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname);

                    var appvca04vatviews = data.AppVCA04VATViews.ToList();
                    var appvca04vatviewz = data.AppVCA04VATViewz.ToList();
                    for (int i = 0; i < appvca04vatviews.Count; i++)
                    {
                        var itemz = appvca04vatviewz[i];
                        if (itemz != -1)
                        {
                            var item = appvca04vatviews[i];
                            item.DocumentID = data.DocumentID;
                            //item.AccountDebitLineID = data.AccountDebitID;
                            item.AccountCreditLineID = data.AccountCreditID;
                            if (data.IsoCode == Services.GlobalVariant.GetSysOption()["IsoCode"].ToString())
                            {
                                item.AmountFC    = 0;
                                item.AmountVATFC = 0;
                            }

                            this.InsertVAT(item);
                        }
                    }
                }

                #endregion

                this._metaobject = Services.GlobalMeta.GetMetaObject(this._metaname);

                //Post vào sổ sách
                Services.Voucher.PostStoreProcedure(data.VoucherID, data.DocumentID);
                //cập nhật số chứng từ
                Services.Voucher.SaveVoucherNumber(data.VoucherID, data.VoucherNumber);
                return(data.DocumentID);
            }
            catch (Exception)
            {
                throw;
            }
        }