public void Validate(Models.AppVCA02View data) { #region ki?m tra chi ti?t this._metaobject = Services.GlobalMeta.GetMetaObject(this._metalinename); this.ValidateLine(data.AppVCA02LineViews, data.AppVCA02LineViewz); #endregion #region ki?m tra thu? this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname); this.ValidateVAT(data.AppVCA02VATViews, data.AppVCA02VATViewz); #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"); }
public ActionResult Create(Models.AppVCA02View collection) { // TODO: Add insert logic here try { long outputId = _dataobject.Insert(collection); return(RedirectToAction(this.ActionReturn())); } catch (Exception ex) { Services.GlobalErrors.Parse(ModelState, _dataobject.Errors, ex); return(PartialView(this._updateview, collection)); } }
public long Update(Models.AppVCA02View 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 appvca02lineviews = data.AppVCA02LineViews.ToList(); var appvca02lineviewz = data.AppVCA02LineViewz.ToList(); for (int i = 0; i < appvca02lineviews.Count; i++) { var itemz = appvca02lineviewz[i]; var item = appvca02lineviews[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.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.AppVCA02VATViews != null) { this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname); var appvca02vatviews = data.AppVCA02VATViews.ToList(); var appvca02vatviewz = data.AppVCA02VATViewz.ToList(); for (int i = 0; i < appvca02vatviews.Count; i++) { var itemz = appvca02vatviewz[i]; var item = appvca02vatviews[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.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; } }
public long Insert(Models.AppVCA02View 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 appvca02lineviews = data.AppVCA02LineViews.ToList(); var appvca02lineviewz = data.AppVCA02LineViewz.ToList(); for (int i = 0; i < appvca02lineviews.Count; i++) { var itemz = appvca02lineviewz[i]; if (itemz != -1) { var item = appvca02lineviews[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.AppVCA02VATViews != null) { this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname); var appvca02vatviews = data.AppVCA02VATViews.ToList(); var appvca02vatviewz = data.AppVCA02VATViewz.ToList(); for (int i = 0; i < appvca02vatviews.Count; i++) { var itemz = appvca02vatviewz[i]; if (itemz != -1) { var item = appvca02vatviews[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; } }