public int Update(Models.SysUserView data) { try { this.Validate(data); data.ModifiedBy = GlobalVariant.GetAppUser().UserID; data.ModifiedDateTime = DateTime.Now; var olddata = GetById(data.UserID); if (olddata.Name != data.Name || olddata.Password != data.Password) { data.Password = Accounting.Services.MD5.GenerateHashDigest(data.Name + data.Password); } SqlParameter pOriginal = ExConvert.ParseSqlParam(data, this._metaobject.GetMetaByColumnName(this._paramnameoutput), this._paramnameupdate); var parameters = ExConvert.Data2SqlParam(data, this._metaobject, pOriginal).ToArray(); this._db.Database.ExecuteSqlCommand(this._storeNameU, parameters); return(data.UserID); } catch (Exception) { throw; } }
public int Insert(Models.AppFixedAssetView data) { try { this.Validate(data); data.CreatedBy = GlobalVariant.GetAppUser().UserID; data.CreatedDateTime = DateTime.Now; SqlParameter[] parameters = ExConvert.Data2SqlParam(data, this._metaobject, this._paramnameoutput).ToArray(); this._db.Database.ExecuteSqlCommand(this._storeNameI, parameters); #region Xử lý line this._metaobject = Services.GlobalMeta.GetMetaObject(this._metalinename); var AppFixedAssetLineTables = data.AppFixedAssetLineTables.ToList(); var AppFixedAssetLineTablez = data.AppFixedAssetLineTablez.ToList(); for (int i = 0; i < AppFixedAssetLineTables.Count; i++) { var itemz = AppFixedAssetLineTablez[i]; if (itemz != -1) { var item = AppFixedAssetLineTables[i]; item.FixedAssetID = data.FixedAssetID; this.InsertLine(item); } } #endregion #region Xử lý VAT if (data.AppEquipmentTables != null) { this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname); var AppEquipmentTables = data.AppEquipmentTables.ToList(); var AppEquipmentTablez = data.AppEquipmentTablez.ToList(); for (int i = 0; i < AppEquipmentTables.Count; i++) { var itemz = AppEquipmentTablez[i]; if (itemz != -1) { var item = AppEquipmentTables[i]; item.FixedAssetID = data.FixedAssetID; this.InsertVAT(item); } } } #endregion return((int)parameters.GetValueSqlParam(this._paramnameoutput)); } catch (Exception) { throw; } }
public long UpdateVAT(Models.AppVPO05VATView data) { try { SqlParameter pOriginal = ExConvert.ParseSqlParam(data, this._metaobject.GetMetaByColumnName(this._paramnamevatoutput), this._paramnamevatupdate); var parameters = ExConvert.Data2SqlParam(data, this._metaobject, pOriginal).ToArray(); this._db.Database.ExecuteSqlCommand(this._storeNameVATU, parameters); return(data.DocumentVATID); } catch (Exception) { throw; } }
public long InsertVAT(Models.AppVPO05VATView 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 int UpdateLine(Models.AppFixedAssetLineTable data) { try { SqlParameter pOriginal = ExConvert.ParseSqlParam(data, this._metaobject.GetMetaByColumnName(this._paramnamelineoutput), this._paramnamelineupdate); var parameters = ExConvert.Data2SqlParam(data, this._metaobject, pOriginal).ToArray(); this._db.Database.ExecuteSqlCommand(this._storeNameLineU, parameters); return(data.FixedAssetLineID); } catch (Exception) { throw; } }
public int InsertVAT(Models.AppEquipmentTable data) { try { SqlParameter[] parameters = ExConvert.Data2SqlParam(data, this._metaobject, this._paramnamevatoutput).ToArray(); this._db.Database.ExecuteSqlCommand(this._storeNameVATI, parameters); data.EquipmentID = (int)parameters.GetValueSqlParam(this._paramnamevatoutput); return(data.EquipmentID); } catch (Exception) { throw; } }
public int InsertLine(Models.AppFixedAssetLineTable data) { try { SqlParameter[] parameters = ExConvert.Data2SqlParam(data, this._metaobject, this._paramnamelineoutput).ToArray(); this._db.Database.ExecuteSqlCommand(this._storeNameLineI, parameters); data.FixedAssetLineID = (int)parameters.GetValueSqlParam(this._paramnamelineoutput); return(data.FixedAssetLineID); } catch (Exception) { throw; } }
public int Insert(Models.AppExpenseTable data) { try { this.Validate(data); data.CreatedBy = GlobalVariant.GetAppUser().UserID; data.CreatedDateTime = DateTime.Now; SqlParameter[] parameters = ExConvert.Data2SqlParam(data, this._metaobject, this._paramnameoutput).ToArray(); this._db.Database.ExecuteSqlCommand(this._storeNameI, parameters); return((int)parameters.GetValueSqlParam(this._paramnameoutput)); } catch (Exception) { throw; } }
public IList <VcRuleCell> GetRules(BaseEntity Ety) { IList <VcRuleCell> Result = new List <VcRuleCell>(); List <KindIdent> KindIdents; Int32 RulesIdx; if (Find(Ety, out KindIdents, out RulesIdx)) { ExIList.Append <VcRuleCell>(KindIdents[RulesIdx].Rules, Result); return(Result); } else { KindIdent ki = new KindIdent(Ety.GetType().Name); foreach (OleDbDataReader Reader in ThisModule.OleDB.EachRows("select FRule, FTime from TRule " + " where FKind = '" + ki.Kind + "'" + " and FId = " + Ety.Id)) { VcRuleCell rt = new VcRuleCell(); //rt.Rule = (eRule)ExMath.Bound(Convert.ToInt32(Reader[0]), (Int32)eRule.crisscross, (Int32)eRule.excellent, (Int32)eRule.common); var rd = ExConvert.TryToInt32(Reader[0], 0); rt.Rule = rd <(Int32)eRule.crisscross || rd> (Int32) eRule.excellent ? eRule.common : (eRule)rd; rt.Time = VcTimeLogic.GetTimeFromInt32(Convert.ToInt32(Reader[1])); ki.Rules.Add(rt); } if (KindIdents == null) { KindIdents = new List <KindIdent>(); KindIdents.Add(ki); RuleBuf.Add(Ety.Id, KindIdents); } else { KindIdents.Add(ki); } ExIList.Append <VcRuleCell>(ki.Rules, Result); return(Result); } }
public int Update(Models.AppExpenseTable data) { try { this.Validate(data); data.ModifiedBy = GlobalVariant.GetAppUser().UserID; data.ModifiedDateTime = DateTime.Now; SqlParameter pOriginal = ExConvert.ParseSqlParam(data, this._metaobject.GetMetaByColumnName(this._paramnameoutput), this._paramnameupdate); var parameters = ExConvert.Data2SqlParam(data, this._metaobject, pOriginal).ToArray(); this._db.Database.ExecuteSqlCommand(this._storeNameU, parameters); return(data.ExpenseID); } catch (Exception) { throw; } }
//public string EncryptPassWord(string username,string password) //{ // return Accounting.Services.MD5.GenerateHashDigest(username + password); //} public int Insert(Models.SysUserView data) { try { this.Validate(data); data.CreatedBy = GlobalVariant.GetAppUser().UserID; data.CreatedDateTime = DateTime.Now; data.Password = Accounting.Services.MD5.GenerateHashDigest(data.Name + data.Password); SqlParameter[] parameters = ExConvert.Data2SqlParam(data, this._metaobject, this._paramnameoutput).ToArray(); this._db.Database.ExecuteSqlCommand(this._storeNameI, parameters); return((int)parameters.GetValueSqlParam(this._paramnameoutput)); } catch (Exception) { throw; } }
public AtomDtAccess(IDbAccess OleDB) { this.OleDB = OleDB; IsCourse = typeof(T) == typeof(EnSubject); Kind = typeof(T).Name; foreach (OleDbDataReader reader in OleDB.EachRows( "select Id, FName, FColor from TAtomAndGrp" + " where FKind = '" + Kind + "'")) { T ety = new T(); ety.Id = Convert.ToInt64(reader[0]); ety.Name = reader[1].ToString(); if (IsCourse) { (ety as EnSubject).Color = Color.FromArgb(ExConvert.TryToInt32(reader[2], 0)); } Entities.Add(ety.Id, ety); } }
public long Update(Models.AppVPO05View 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 appvpo05lineviews = data.AppVPO05LineViews.ToList(); var appvpo05lineviewz = data.AppVPO05LineViewz.ToList(); for (int i = 0; i < appvpo05lineviews.Count; i++) { var itemz = appvpo05lineviewz[i]; var item = appvpo05lineviews[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; 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.AppVPO05VATViews != null) { this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname); var appvpo05vatviews = data.AppVPO05VATViews.ToList(); var appvpo05vatviewz = data.AppVPO05VATViewz.ToList(); for (int i = 0; i < appvpo05vatviews.Count; i++) { var itemz = appvpo05vatviewz[i]; var item = appvpo05vatviews[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; } }
public long Insert(Models.AppVPO05View 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 appvpo05lineviews = data.AppVPO05LineViews.ToList(); var appvpo05lineviewz = data.AppVPO05LineViewz.ToList(); for (int i = 0; i < appvpo05lineviews.Count; i++) { var itemz = appvpo05lineviewz[i]; if (itemz != -1) { var item = appvpo05lineviews[i]; item.DocumentID = data.DocumentID; //item.AccountDebitLineID = data.AccountDebitID; item.AccountCreditLineID = data.AccountCreditID; 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; } this.InsertLine(item); } } #endregion #region X? lý VAT if (data.AppVPO05VATViews != null) { this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname); var appvpo05vatviews = data.AppVPO05VATViews.ToList(); var appvpo05vatviewz = data.AppVPO05VATViewz.ToList(); for (int i = 0; i < appvpo05vatviews.Count; i++) { var itemz = appvpo05vatviewz[i]; if (itemz != -1) { var item = appvpo05vatviews[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; } }
public ActionResult Notification(int Id) { try { #region mail cho người dùng var giftcard = _dataobject.GetById(Id); if (giftcard == null) { throw new Exception("phải chọn thẻ"); } if (giftcard.RecipientName == null) { throw new Exception("phải nhập tên người nhận"); } if (giftcard.RecipientEmail == null) { throw new Exception("phải nhập email người nhận"); } //IWebHelper webhelper = new WebHelper(this.HttpContext); //var urlactive = Url.Action("RegisterActive").Remove(0, 1); //string RegisterActiveUrl = string.Format("{0}{1}?id={2}", webhelper.GetStoreLocation(), urlactive, user.UserId); string emailto = giftcard.RecipientEmail; // xử lí tạm cần dùng một mẫu tạm để gửi cho khách hàng #region thiết lập token GlobalToken.setToken("SenGiftCard.RecipientEmail", giftcard.RecipientEmail); GlobalToken.setToken("SenGiftCard.RecipientName", giftcard.RecipientName); GlobalToken.setToken("SenGiftCard.SenderEmail", giftcard.SenderEmail); GlobalToken.setToken("SenGiftCard.SenderName", giftcard.SenderName); GlobalToken.setToken("SenGiftCard.Message", giftcard.Message); GlobalToken.setToken("SenGiftCard.GiftCardCouponCode", giftcard.GiftCardCouponCode); GlobalToken.setToken("SenGiftCard.Amount", ExConvert.Data2String(giftcard.Amount, "numeric", "n0", "")); #endregion string SenMessageTemplate_Name = "sengiftcard.notification"; var db = new SenContext(); var messagetemplate = db.SenMessageTemplates.SingleOrDefault(m => m.Name == SenMessageTemplate_Name && m.IsActive == true); var queuedemail = new WebApp.Models.SenQueuedEmail(); queuedemail.CreatedOnUtc = DateTime.UtcNow; queuedemail.EmailAccountId = messagetemplate.EmailAccountId; queuedemail.From = messagetemplate.SenEmailAccount.Email; queuedemail.FromName = messagetemplate.SenEmailAccount.DisplayName; queuedemail.Bcc = messagetemplate.BccEmailAddresses; queuedemail.Subject = GlobalToken.MappingToken(messagetemplate.Subject); queuedemail.To = emailto; queuedemail.ToName = giftcard.RecipientName; queuedemail.Priority = 0; queuedemail.Body = GlobalToken.MappingToken(messagetemplate.Body); db.SenQueuedEmails.Add(queuedemail); db.SaveChanges(); #endregion giftcard.IsRecipientNotified = true; _dataobject.Update(giftcard); } catch (Exception ex) { return(Json(new { ketqua = ex.Message })); } return(Json(new { ketqua = "Đã email Ok." })); }
public int Update(Models.AppFixedAssetView data) { try { this.Validate(data); data.ModifiedBy = GlobalVariant.GetAppUser().UserID; data.ModifiedDateTime = DateTime.Now; SqlParameter pOriginal = ExConvert.ParseSqlParam(data, this._metaobject.GetMetaByColumnName(this._paramnameoutput), this._paramnameupdate); 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 AppFixedAssetLineTables = data.AppFixedAssetLineTables.ToList(); var AppFixedAssetLineTablez = data.AppFixedAssetLineTablez.ToList(); for (int i = 0; i < AppFixedAssetLineTables.Count; i++) { var itemz = AppFixedAssetLineTablez[i]; var item = AppFixedAssetLineTables[i]; if (itemz != -1) { //có 2 trường hợp: 1 - thêm mới thường DocumentLineID==0, 2 - sửa dữ liệu cũ DocumentLineID<>0 item.FixedAssetID = data.FixedAssetID; if (item.FixedAssetLineID == 0) { this.InsertLine(item); } else { this.UpdateLine(item); } } else { //nếu xóa có 2 trường hợp : 1 - xóa dữ liệu có trước DocumentLineID<>0, 2 - xóa dữ liệu mới thêm DocumentLineID ==0 if (item.FixedAssetLineID > 0) { this.DeleteLine(item.FixedAssetLineID); } } } #endregion #region Xử lý thuế if (data.AppEquipmentTables != null) { this._metaobject = Services.GlobalMeta.GetMetaObject(this._metavatname); var AppEquipmentTables = data.AppEquipmentTables.ToList(); var AppEquipmentTablez = data.AppEquipmentTablez.ToList(); for (int i = 0; i < AppEquipmentTables.Count; i++) { var itemz = AppEquipmentTablez[i]; var item = AppEquipmentTables[i]; if (itemz != -1) { //có 2 trường hợp: 1 - thêm mới thường DocumentLineID==0, 2 - sửa dữ liệu cũ DocumentLineID<>0 item.FixedAssetID = data.FixedAssetID; if (item.EquipmentID == 0) { this.InsertVAT(item); } else { this.UpdateVAT(item); } } else { //nếu xóa có 2 trường hợp : 1 - xóa dữ liệu có trước DocumentLineID<>0, 2 - xóa dữ liệu mới thêm DocumentLineID ==0 if (item.EquipmentID > 0) { this.DeleteVAT(item.EquipmentID); } } } } #endregion return(data.FixedAssetID); } catch (Exception) { throw; } }