public void Validate(Models.AppVPO06View data) { #region ki?m tra chi ti?t this._metaobject = Services.GlobalMeta.GetMetaObject(this._metalinename); this.ValidateLine(data.AppVPO06LineViews, data.AppVPO06LineViewz); #endregion //#region ki?m tra thu? //this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname); //this.ValidateVAT(data.AppVPO06VATViews, data.AppVPO06VATViewz); //#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 Edit(long id, Models.AppVPO06View 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)); } }
//public long InsertVAT(Models.AppVPO06VATView data) //{ // try // { // SqlParameter[] parameters = ExConvert.Data2SqlParam(data, this._metaobject, this._paramnamevatoutput).ToArray(); // this._db.Database.ExecuteSqlCommand(this._storeNameVATI, parameters); // data.DocumentVATID = (long)parameters.GetValueSqlParam(this._paramnamevatoutput); // return data.DocumentVATID; // } // catch (Exception) // { // throw; // } //} public long Update(Models.AppVPO06View 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 appvpo06lineviews = data.AppVPO06LineViews.ToList(); var appvpo06lineviewz = data.AppVPO06LineViewz.ToList(); for (int i = 0; i < appvpo06lineviews.Count; i++) { var itemz = appvpo06lineviewz[i]; var item = appvpo06lineviews[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.MeasureRate = item.MeasureRate ?? 1; item.Quantity = item.Quantity0 * item.MeasureRate; 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.AppVPO06VATViews != null) //{ // this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname); // var appvpo06vatviews = data.AppVPO06VATViews.ToList(); // var appvpo06vatviewz = data.AppVPO06VATViewz.ToList(); // for (int i = 0; i < appvpo06vatviews.Count; i++) // { // var itemz = appvpo06vatviewz[i]; // var item = appvpo06vatviews[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; } }
public long Insert(Models.AppVPO06View 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 appvpo06lineviews = data.AppVPO06LineViews.ToList(); var appvpo06lineviewz = data.AppVPO06LineViewz.ToList(); for (int i = 0; i < appvpo06lineviews.Count; i++) { var itemz = appvpo06lineviewz[i]; if (itemz != -1) { var item = appvpo06lineviews[i]; item.DocumentID = data.DocumentID; item.MeasureRate = item.MeasureRate ?? 1; item.Quantity = item.Quantity0 * item.MeasureRate; //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.AppVPO06VATViews != null) //{ // this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname); // var appvpo06vatviews = data.AppVPO06VATViews.ToList(); // var appvpo06vatviewz = data.AppVPO06VATViewz.ToList(); // for (int i = 0; i < appvpo06vatviews.Count; i++) // { // var itemz = appvpo06vatviewz[i]; // if (itemz != -1) // { // var item = appvpo06vatviews[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; } }