public SubjectService(DBHelper dbHelper, ICompanyService company) { _dbHelper = dbHelper; _company = company; _curCompany = _company.GetCompanyWithCurrentUser(); }
public MVoucher GetCompanyLastVoucher() { MCompany com = _company.GetCompanyWithCurrentUser(); int lastVid = Convert.ToInt32(_dbHelper.ExecuteScalar(string.Format("select [VId] from [Finance_VoucherRecord] where [CompanyId] = '{0}' order by [CreateTime] desc", com.CompanyId.ToString("D")))); return(GetVoucher(lastVid)); }
public int SaveVoucherAbstracts(MVoucherAbstracts abstracts) { if (abstracts == null) { return(0); } string sql = string.Format("select * from [Finance_VoucherAbstractsRecord] where [AId] = {0}", abstracts.AId); DataTable dt = _dbHelper.ExecuteDataTable(sql); DataRow dr; if (dt.Rows.Count > 0) { dr = dt.Rows[0]; } else { MCompany com = _company.GetCompanyWithCurrentUser(); if (com == null) { return(-1); } dr = dt.NewRow(); dr["CompanyId"] = com.CompanyId; dr["Creator"] = _context.GetContext().CurrentUser.UserName; dr["CreateTime"] = DateTime.Now; dt.Rows.Add(dr); } dr["Abstracts"] = abstracts.Abstracts; return(_dbHelper.UpdateDatatable(dt, sql)); }
public async Task <IActionResult> OnPostEditMCompanyAsync(MCompany item1) { try { if (!TryValidateModel(item1)) { return(BadRequest(ModelState)); } var user = await _userManager.GetUserAsync(User); item1.UpdatedBy = user.Id; item1.UpdatedDate = DateTime.Now; await _mCompanyService.EditAsync(item1); Companies = await _mCompanyService.GetAllAsync(); return(Partial("MCompanyPartials/_MCompanyListPartial", Companies)); } catch (Exception ex) { _logger.LogError("Terjadi error : {@ex}", ex); return(BadRequest(ex.Message)); } }
/// <summary> /// 修改公司信息 /// </summary> /// <param name="info">公司信息实体</param> /// <returns>true:成功 false:失败</returns> public bool Update(MCompany info) { //<root><info bankid="编号" bankname="银行名称" accountname="开户名" accountcode="账户编号" /></root> StringBuilder banksxml = new StringBuilder(); banksxml.Append("<root>"); if (info.ComAccount != null && info.ComAccount.Count > 0) { foreach (var bank in info.ComAccount) { banksxml.AppendFormat("<info bankid=\"{0}\" bankname=\"{1}\" accountname=\"{2}\" accountcode=\"{3}\" />", bank.AccountId , Utils.ReplaceXmlSpecialCharacter(bank.BankName) , Utils.ReplaceXmlSpecialCharacter(bank.AccountName) , Utils.ReplaceXmlSpecialCharacter(bank.BankNo)); } } banksxml.Append("</root>"); DbCommand cmd = _db.GetStoredProcCommand("proc_Company_Update"); _db.AddInParameter(cmd, "CompanyId", DbType.AnsiStringFixedLength, info.Id); _db.AddInParameter(cmd, "WLogo", DbType.String, info.WLogo); _db.AddInParameter(cmd, "NLogo", DbType.String, info.NLogo); _db.AddInParameter(cmd, "CompanyName", DbType.String, info.Name); _db.AddInParameter(cmd, "CompanyEnName", DbType.String, info.EnName); _db.AddInParameter(cmd, "License", DbType.String, info.License); _db.AddInParameter(cmd, "FuZeRen", DbType.String, info.ContactName); _db.AddInParameter(cmd, "Type", DbType.String, info.Type); _db.AddInParameter(cmd, "Telephone", DbType.String, info.Tel); _db.AddInParameter(cmd, "Mobile", DbType.String, info.Mobile); _db.AddInParameter(cmd, "Fax", DbType.String, info.Fax); _db.AddInParameter(cmd, "Address", DbType.String, info.Address); _db.AddInParameter(cmd, "ZipCode", DbType.String, info.Zip); _db.AddInParameter(cmd, "WebSite", DbType.String, info.Domain); _db.AddInParameter(cmd, "BanksXML", DbType.String, banksxml.ToString()); _db.AddOutParameter(cmd, "RetCode", DbType.Int32, 4); _db.AddInParameter(cmd, "MLogo", DbType.String, info.MLogo); _db.AddInParameter(cmd, "GYSLogo", DbType.String, info.GYSLogo); _db.AddInParameter(cmd, "FXSLogo", DbType.String, info.FXSLogo); int sqlExceptionCode = 0; try { DbHelper.RunProcedure(cmd, _db); } catch (System.Data.SqlClient.SqlException e) { sqlExceptionCode = 0 - e.Number; } if (sqlExceptionCode < 0) { return(false); } return(Convert.ToInt32(this._db.GetParameterValue(cmd, "RetCode")) == 1); }
public IHttpActionResult Save([FromBody] MCompany com) { if (com == null) { return(BadRequest("不能保存空内容")); } return(Ok(_companyService.Save(com))); }
public int GetCompanyNewCertWordSn() { MCompany com = _company.GetCompanyWithCurrentUser(); if (com != null) { return(Convert.ToInt32(_dbHelper.ExecuteScalar(string.Format("select max([CertWordSn])+1 from [Finance_VoucherRecord] where [CompanyId] = '{0}'", com.CompanyId.ToString("D"))))); } return(1); }
/// <summary> /// 对象转化 /// </summary> /// <param name="company">Company</param> /// <returns>MAccount</returns> public static RegisterAccount ToRegisterAccount(this MCompany company) { return(new RegisterAccount { AccountName = company.CompanyName, AccountNO = company.CompanyAccountNo, Mail = company.CompanyAccountNo, Mobile = company.ContactPhone, Password = "******", PayPassword = "******" }); }
public List <MSubject> GetSubjectsForCompany() { MCompany com = _company.GetCompanyWithCurrentUser(); if (com != null) { DataTable dt = _dbHelper.ExecuteDataTable(string.Format("select * from [Finance_SubjectsRecord] where [CompanyId]='{0}'", com.CompanyId.ToString("D"))); return(Utility.Convert <MSubject>(dt)); } return(new List <MSubject>()); }
public MVoucher[] GetVouchers() { MCompany com = _company.GetCompanyWithCurrentUser(); if (com != null) { return(GetVouchers(com.CompanyId)); } else { return new MVoucher[] { } }; }
public List <MAuxAccounting> GetCurrentCompanyAuxAcc() { MCompany curCom = _company.GetCompanyWithCurrentUser(); if (curCom != null) { return(this.GetCompanyAuxAcc(curCom.CompanyId)); } else { return(new List <MAuxAccounting>()); } }
public List <MVoucherAbstracts> GetCompanyVoucherAbstracts() { MCompany com = _company.GetCompanyWithCurrentUser(); if (com == null) { return(new List <MVoucherAbstracts>()); } DataTable dt = _dbHelper.ExecuteDataTable(string.Format("select * from [Finance_VoucherAbstractsRecord] where [CompanyId] = '{0}'", com.CompanyId.ToString("D"))); return(Utility.Convert <MVoucherAbstracts>(dt)); }
public ActionResult Company() { if (_context.GetContext() == null || _context.GetContext().CurrentUser == null || _context.GetContext().HttpContext.Request.LogonUserIdentity.IsAnonymous) { return(new HttpUnauthorizedResult()); } MCompany com = _company.GetCompanyWithCurrentUser(); return(new ShapeResult(this, _services.New.Regist_Company( Company: com ))); }
public async Task <IActionResult> OnGetSearchAsync(MCompany company) { try { var result = await _mCompanyService.GetAsync(company); return(Partial("MCompanyPartials/_MCompanyListPartial", result)); } catch (Exception ex) { _logger.LogError("Terjadi error : {@ex}", ex); return(BadRequest(ex.Message)); } }
public List <MSummary> GetSummaryOfCompany() { MCompany com = _company.GetCompanyWithCurrentUser(); if (com == null) { return(new List <MSummary>()); } DataTable dt = _dbHelper.ExecuteDataTable(string.Format("select * from [Finance_SummaryRecord] where company = '{0}'", com.CompanyId.ToString("D"))); List <MSummary> summarys = Utility.Convert <MSummary>(dt); return(summarys); }
public MCompany GetCompany(Guid comId) { DataTable dt = _dbHelper.ExecuteDataTable(string.Format("select * from [Finance_CompanyRecord] where [CompanyId]='{0}'", comId.ToString("D"))); if (dt.Rows.Count == 0) { return(new MCompany()); } MCompany com = Utility.Convert <DataTable, List <MCompany> >(dt).FirstOrDefault(); com.Region = this.GetRegion(com.RegionId); return(com); }
/// <summary> /// 根据公司编号获取公司信息 /// </summary> /// <param name="companyId">公司编号</param> /// <param name="sysId">系统编号</param> /// <returns>公司信息实体</returns> public MCompany GetModel(string companyId, string sysId) { if (string.IsNullOrEmpty(companyId) || string.IsNullOrEmpty(sysId)) { return(null); } MCompany info = dal.GetModel(companyId, sysId); if (info != null) { info.ComAccount = new EyouSoft.BLL.ComStructure.BComAccount().GetList(companyId); } return(info); }
private int InitialCompanySubjects(MCompany com) { DataTable dt = _dbHelper.ExecuteDataTable(string.Format("select * from [Finance_SubjectsRecord] where [CompanyId]='{0}'", com.CompanyId)); int res = 0; if (dt.Rows.Count == 0) { string sql = "INSERT INTO [Finance_SubjectsRecord]([SubjectCode],[ParentSubjectCode],[Level],[SubjectName],[SubjectCategory],[CompanyId],[BalanceDirection],[BeginBalance],[EndBalance],[SubjectState]" + ",[NamePath],[CodePath],[Debit],[Credit],[SubjectAmount],[Creator],[CreateTime],[LastUpdate],[LastUpdateTime]) " + string.Format("SELECT[SubjectCode],[ParentSubjectCode],[Level],[SubjectName],[SubjectCategory],'{0}',[BalanceDirection],[BeginBalance]", com.CompanyId) + string.Format(",[EndBalance],[SubjectState],[NamePath],[CodePath],[Debit],[Credit],[SubjectAmount],'{0}',GETDATE(),[LastUpdate],[LastUpdateTime]", _context.GetContext().HttpContext.User.Identity.Name) + " FROM[Finance_SubjectsRecord] where [CompanyId]='00000000-0000-0000-0000-000000000000' "; res = _dbHelper.ExecuteNonQuery(sql); } return(res); }
/// <summary> /// 对象转化 /// </summary> /// <param name="mCompany">mCompany</param> /// <returns>Account</returns> public static Company ToCompany(this MCompany mCompany) { var company = new Company(mCompany.CompanyId) { CompanyAccountNo = mCompany.CompanyAccountNo, CompanyAddress = mCompany.CompanyAddress, CompanyName = mCompany.CompanyName, CompanyStatus = mCompany.CompanyStatus, ContactName = mCompany.ContactName, ContactPhone = mCompany.ContactPhone, ModifyTime = mCompany.ModifyTime, ParenttCompanyId = mCompany.ParenttCompanyId, CreateTime = mCompany.CreateTime }; return(company); }
/// <summary> /// 修改公司信息 /// </summary> /// <param name="item">公司信息实体</param> /// <returns>true:成功 false:失败</returns> public bool Update(MCompany info) { bool result = false; if (info != null && !string.IsNullOrEmpty(info.Id)) { result = dal.Update(info); if (result) { EyouSoft.BLL.SysStructure.BSysLogHandle.Insert("修改系统信息"); } EyouSoft.Cache.Facade.EyouSoftCache.Remove(string.Format(EyouSoft.Cache.Tag.TagName.ComSetting, info.Id)); } return(result); }
/// <summary> /// 对象转化 /// </summary> /// <param name="company">Company</param> /// <returns>TCompany</returns> public static MCompany ToMCompany(this TCompany company) { var tCompany = new MCompany { CompanyId = company.CompanyId, CompanyAccountNo = company.CompanyAccountNo, CompanyAddress = company.CompanyAddress ?? string.Empty, CompanyName = company.CompanyName, CompanyStatus = company.CompanyStatus, ContactName = company.ContactName ?? string.Empty, ContactPhone = company.ContactPhone ?? string.Empty, ModifyTime = company.ModifyTime, ParenttCompanyId = company.ParenttCompanyId, CreateTime = company.CreateTime }; return(tCompany); }
/// <summary> /// 对象转化 /// </summary> /// <param name="company">MCompany</param> /// <returns>TCompany</returns> public static TCompany ToTCompany(this MCompany company) { var tCompany = new TCompany { CompanyId = company.CompanyId, CompanyAccountNo = company.CompanyAccountNo, CompanyAddress = company.CompanyAddress, CompanyName = company.CompanyName, CompanyStatus = company.CompanyStatus, ContactName = company.ContactName, ContactPhone = company.ContactPhone, ModifyTime = company.ModifyTime, ParenttCompanyId = company.ParenttCompanyId, CreateTime = company.CreateTime }; return(tCompany); }
/// <summary> /// 根据公司编号获取公司信息 /// </summary> /// <param name="companyId">公司编号</param> /// <param name="sysId">系统编号</param> /// <returns>公司信息实体</returns> public MCompany GetModel(string companyId, string sysId) { string cmdText = "SELECT * FROM tbl_Company WHERE Id=@CompanyId "; DbCommand cmd = this._db.GetSqlStringCommand(cmdText); _db.AddInParameter(cmd, "CompanyId", DbType.AnsiStringFixedLength, companyId); MCompany info = null; using (IDataReader rdr = DbHelper.ExecuteReader(cmd, _db)) { if (rdr.Read()) { info = new MCompany(); info.Id = rdr["Id"].ToString(); info.SysId = rdr["SysId"].ToString(); info.WLogo = rdr["WLogo"].ToString(); info.NLogo = rdr["NLogo"].ToString(); info.Name = rdr["Name"].ToString(); info.Type = rdr["Type"].ToString(); info.EnName = rdr["EnName"].ToString(); info.License = rdr["License"].ToString(); info.ContactName = rdr["ContactName"].ToString(); info.Tel = rdr["Tel"].ToString(); info.Mobile = rdr["Mobile"].ToString(); info.Fax = rdr["Fax"].ToString(); info.Address = rdr["Address"].ToString(); info.Zip = rdr["Zip"].ToString(); info.Domain = rdr["Domain"].ToString(); info.IssueTime = rdr.GetDateTime(rdr.GetOrdinal("IssueTime")); info.Province = rdr["Province"].ToString(); info.City = rdr["City"].ToString(); info.Notes = rdr["Notes"].ToString(); info.MLogo = rdr["MLogo"].ToString(); info.GYSLogo = rdr["GYSLogo"].ToString(); info.FXSLogo = rdr["FXSLogo"].ToString(); } ; } return(info); }
public int SaveVoucher(MVoucher voucher) { string sql = string.Format("select * from [Finance_VoucherRecord] where [VId] = {0}", voucher.VId); DataTable dt = _dbHelper.ExecuteDataTable(sql); object newId = null; DataRow dr = dt.NewRow(); if (dt.Rows.Count > 0) { dr = dt.Rows[0]; newId = Convert.ToInt32(dr["VId"]); } else { MCompany com = _company.GetCompanyWithCurrentUser(); dr["CompanyId"] = com.CompanyId; dr["Creator"] = _context.GetContext().CurrentUser.UserName; dr["CreateTime"] = DateTime.Now; dt.Rows.Add(dr); } dr["CertWord"] = voucher.CertWord; dr["CertWordSn"] = voucher.CertWordSn; dr["VoucherTime"] = voucher.VoucherTime; dr["AttachedInvoices"] = voucher.AttachedInvoices; int res = _dbHelper.UpdateDatatable(dt, sql); if (newId == null) { newId = _dbHelper.ExecuteScalar("SELECT IDENT_CURRENT('Finance_VoucherRecord')"); } if (res > 0) { res += SaveVoucherDetail(Convert.ToInt32(newId), voucher.VoucherDetails); } return(res); }
public async Task <IActionResult> OnGetAddMCompanyPartialAsync() { try { var currentUser = await _userManager.GetUserAsync(User); var company = new MCompany { CreatedBy = currentUser.Id }; var tuple = (company, MCompanyPartial.Add); return(Partial("MCompanyPartials/_MCompanyFormPartial", tuple)); } catch (Exception ex) { _logger.LogError("Terjadi error : {@ex}", ex); return(BadRequest(ex.Message)); } }
public List <MCertWord> GetCompanyCertWords() { DataTable comDt = _dbHelper.ExecuteDataTable("select * from [Finance_CertificateWordRecord] where [CompanyId] is null"); MCompany com = _company.GetCompanyWithCurrentUser(); if (com != null) { DataTable dt = _dbHelper.ExecuteDataTable(string.Format("select * from [Finance_CertificateWordRecord] where [CompanyId] = '{0}'", com.CompanyId.ToString("D"))); foreach (DataRow dr in dt.Rows) { comDt.ImportRow(dr); } comDt.AcceptChanges(); } return(Utility.Convert <MCertWord>(comDt)); }
public int SaveSubject(MSubject subject) { MCompany com = _company.GetCompanyWithCurrentUser(); string sql = string.Format("select * from [Finance_SubjectsRecord] where [SubjectCode] = {0} and [CompanyId] = '{1}'", subject.SubjectCode, com.CompanyId.ToString()); DataTable dt = _dbHelper.ExecuteDataTable(sql); DataRow dr; if (dt.Rows.Count == 0) { dr = dt.NewRow(); dr["SubjectCode"] = subject.SubjectCode; dr["CompanyId"] = com.CompanyId; subject.SubjectState = 1; dt.Rows.Add(dr); } else { dr = dt.Rows[0]; } if (subject.ParentSubjectCode.HasValue) { dr["ParentSubjectCode"] = subject.ParentSubjectCode; } else { dr["ParentSubjectCode"] = DBNull.Value; } dr["Level"] = SubjectLevel(subject.SubjectCode); dr["SubjectName"] = subject.SubjectName; dr["SubjectCategory"] = subject.SubjectCategory; dr["BalanceDirection"] = subject.BalanceDirection; dr["BeginBalance"] = subject.BeginBalance; dr["EndBalance"] = subject.EndBalance; dr["SubjectState"] = subject.SubjectState; dr["NamePath"] = dr["NamePath"].ToString() + "," + subject.SubjectName; dr["CodePath"] = dr["CodePath"].ToString() + "," + subject.SubjectCode; int res = _dbHelper.UpdateDatatable(dt, sql); return(res); }
public MCompany GetCompanyWithCurrentUser() { if (_context.GetContext() == null || _context.GetContext().CurrentUser == null) { return(null); } DataTable dt = _dbHelper.ExecuteDataTable(string.Format("select * from [Finance_CompanyRecord] where [ContactsUserAccount] = {0}", _context.GetContext().CurrentUser.Id)); if (dt.Rows.Count == 0) { return(new MCompany()); } MCompany com = Utility.Convert <DataTable, List <MCompany> >(dt).FirstOrDefault(); com.Region = this.GetRegion(com.RegionId); return(com); }
public async Task <IActionResult> OnPostAddMCompanyAsync(MCompany Item1) { try { if (!TryValidateModel(Item1)) { var result = BadRequest(ModelState); return(result); } await _mCompanyService.AddAsync(Item1); Companies = await _mCompanyService.GetAllAsync(); return(Partial("MCompanyPartials/_MCompanyListPartial", Companies)); } catch (Exception ex) { _logger.LogInformation("Error : {@ex}", ex); return(BadRequest(ex.Message)); } }
public int Save(MCompany com) { string sql = string.Format("select * from [Finance_CompanyRecord] where [CompanyId] = '{0}'", com.CompanyId); DataTable dt = _dbHelper.ExecuteDataTable(sql); if (dt.Rows.Count == 0) { dt.Rows.Add(dt.NewRow()); dt.Rows[0]["CompanyId"] = Guid.NewGuid(); } else { if (dt.Rows[0]["ContactsUserAccount"].ToString() != _context.GetContext().CurrentUser.Id.ToString()) { Message = "无权修改"; return(0); } } dt.Rows[0]["ComFullName"] = com.ComFullName; dt.Rows[0]["ComShortName"] = com.ComShortName; dt.Rows[0]["RegionId"] = com.RegionId; dt.Rows[0]["ComAddress"] = com.ComAddress; dt.Rows[0]["ComTel"] = com.ComTel; dt.Rows[0]["ContactsName"] = com.ContactsName; dt.Rows[0]["ContactsMobile"] = com.ContactsMobile; dt.Rows[0]["ContactsEmail"] = com.ContactsEmail; dt.Rows[0]["ContactsUserAccount"] = _context.GetContext().CurrentUser.Id; int res = _dbHelper.UpdateDatatable(dt, sql); //新建公司要初始化该公司的财务科目 if (res > 0) { InitialCompanySubjects(com); } return(res); }