Exemplo n.º 1
0
        public void Validate(Models.AppVGL01View data)
        {
            #region ki?m tra chi ti?t

            this._metaobject = Services.GlobalMeta.GetMetaObject(this._metalinename);
            this.ValidateLine(data.AppVGL01LineViews, data.AppVGL01LineViewz);

            #endregion

            #region ki?m tra thu?

            this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname);
            this.ValidateVAT(data.AppVGL01VATViews, data.AppVGL01VATViewz);
            #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");
        }
Exemplo n.º 2
0
 public ActionResult Edit(long id, Models.AppVGL01View 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));
     }
 }
Exemplo n.º 3
0
        public long Update(Models.AppVGL01View 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 appvgl01lineviews = data.AppVGL01LineViews.ToList();
                var appvgl01lineviewz = data.AppVGL01LineViewz.ToList();
                for (int i = 0; i < appvgl01lineviews.Count; i++)
                {
                    var itemz = appvgl01lineviewz[i];
                    var item  = appvgl01lineviews[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;

                        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.AppVGL01VATViews != null)
                {
                    this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname);


                    var appvgl01vatviews = data.AppVGL01VATViews.ToList();
                    var appvgl01vatviewz = data.AppVGL01VATViewz.ToList();
                    for (int i = 0; i < appvgl01vatviews.Count; i++)
                    {
                        var itemz = appvgl01vatviewz[i];
                        var item  = appvgl01vatviews[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;
                            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;
            }
        }
Exemplo n.º 4
0
        public long Insert(Models.AppVGL01View 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 appvgl01lineviews = data.AppVGL01LineViews.ToList();
                var appvgl01lineviewz = data.AppVGL01LineViewz.ToList();
                for (int i = 0; i < appvgl01lineviews.Count; i++)
                {
                    var itemz = appvgl01lineviewz[i];
                    if (itemz != -1)
                    {
                        var item = appvgl01lineviews[i];
                        item.DocumentID = data.DocumentID;
                        //item.AccountDebitLineID = data.AccountDebitID;
                        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.AppVGL01VATViews != null)
                {
                    this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname);

                    var appvgl01vatviews = data.AppVGL01VATViews.ToList();
                    var appvgl01vatviewz = data.AppVGL01VATViewz.ToList();
                    for (int i = 0; i < appvgl01vatviews.Count; i++)
                    {
                        var itemz = appvgl01vatviewz[i];
                        if (itemz != -1)
                        {
                            var item = appvgl01vatviews[i];
                            item.DocumentID = data.DocumentID;
                            //item.AccountDebitLineID = data.AccountDebitID;
                            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;
            }
        }