public void SaveCompanyRegulations(CompanyRegulation companyRegulations, Account loginUser) { Validation(companyRegulations); using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew)) { try { // 删除公司规章 if (companyRegulations.CompanyRegulationsID > 0) { DalInstance.CompanyRegulationDalInstance.DeleteCompanyReguAppendixByCompanyRegulationsID(companyRegulations.CompanyRegulationsID); DalInstance.CompanyRegulationDalInstance.DeleteCompanyRegulationsByPKID(companyRegulations.CompanyRegulationsID); } // 新增公司规章 int companyReguID = DalInstance.CompanyRegulationDalInstance.InsertCompanyRegulations(companyRegulations); if (companyRegulations.AppendixList != null) { foreach (CompanyReguAppendix companyReguAppendix in companyRegulations.AppendixList) { companyReguAppendix.CompanyReguID = companyReguID; //新增公司规章附件 DalInstance.CompanyRegulationDalInstance.InsertCompanyReguAppendix(companyReguAppendix); } } ts.Complete(); } catch { throw MessageKeys.AppException(MessageKeys._DbError); } } }
private void btnOKClick(object sender, EventArgs e) { if (!Valid()) { return; } try { CompanyRegulation companyRegulations = new CompanyRegulation( _View.ComanyReguId, (ReguType)_View.SelectedReguType, _View.Title, _View.Content); companyRegulations.AppendixList = _View.CompanyReguAppendixList; BllInstance.CompanyRegulationBllInstance.SaveCompanyRegulations(companyRegulations, LoginUser); _View.ErrorMessageFromCompanyRegulations = "保存成功!"; } catch (ApplicationException ex) { _View.ErrorMessageFromCompanyRegulations = //" <img src='../../image/icon03.jpg' align='absmiddle'' /> " + ex.Message; } }
public CompanyRegulation GetCompanyRegulationsByType(ReguType type) { CompanyRegulation companyRegulations = null; SqlCommand cmd = new SqlCommand(); cmd.Parameters.Add(_ReguType, SqlDbType.Int).Value = type; using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetCompanyRegulationsByType", cmd)) { while (sdr.Read()) { string content = String.Empty; if (sdr[_DbContent] != DBNull.Value) { content = sdr[_DbContent].ToString(); } companyRegulations = new CompanyRegulation( Convert.ToInt32(sdr[_DbCompanyRegulationsID]), (ReguType)sdr[_DbReguType], sdr[_DbTitle].ToString(), content); companyRegulations.AppendixList = GetCompanyReguAppendixByCompanyRegulationsID(companyRegulations.CompanyRegulationsID); } } if (companyRegulations == null) { companyRegulations = new CompanyRegulation(type); } return(companyRegulations); }
private void GetCompanyRegulations(int SelectedReguType) { CompanyRegulation companyRegulations = BllInstance.CompanyRegulationBllInstance.GetCompanyRegulationsByType((ReguType)SelectedReguType, LoginUser); _View.ComanyReguId = companyRegulations.CompanyRegulationsID; _View.Title = companyRegulations.Title; _View.Content = companyRegulations.Content; _View.CompanyReguAppendixList = companyRegulations.AppendixList; }
public void Init(object sender, EventArgs e) { CompanyRegulation CompanyRegulation = BllInstance.CompanyRegulationBllInstance.GetCompanyRegulationsByType(_View.ReguType, LoginUser); _View.PageTitle = CompanyRegulation.Title; _View.Content = CompanyRegulation.Content; _View.AppendixList = CompanyRegulation.AppendixList; FindAppendixInDirectory(); }
/// <summary> /// 插入公司规章制度 /// </summary> /// <param name="obj">公司规章制度</param> /// <returns>pkid</returns> public int InsertCompanyRegulations(CompanyRegulation obj) { int pkid; SqlCommand cmd = new SqlCommand(); cmd.Parameters.Add(_CompanyRegulationsID, SqlDbType.Int).Direction = ParameterDirection.Output; cmd.Parameters.Add(_ReguType, SqlDbType.Int).Value = obj.CompanyReguType; cmd.Parameters.Add(_Title, SqlDbType.NVarChar, 100).Value = obj.Title; cmd.Parameters.Add(_Content, SqlDbType.Text).Value = obj.Content; SqlHelper.ExecuteNonQueryReturnPKID("CompanyRegulationsInsert", cmd, out pkid); obj.CompanyRegulationsID = pkid; return(pkid); }
public CompanyRegulation GetCompanyRegulationsByType(ReguType type, Account loginUser) { CompanyRegulation companyRegulations = DalInstance.CompanyRegulationDalInstance.GetCompanyRegulationsByType(type); if (companyRegulations.AppendixList != null) { for (int i = companyRegulations.AppendixList.Count - 1; i >= 0; i--) { if (!System.IO.File.Exists(companyRegulations.AppendixList[i].Directory)) { DalInstance.CompanyRegulationDalInstance.DeleteCompanyReguAppendixByPKID(companyRegulations.AppendixList[i].AppendixID); companyRegulations.AppendixList.RemoveAt(i); } } } return(companyRegulations); }
private void Validation(CompanyRegulation companyRegulations) { // 标题不能为空 if (string.IsNullOrEmpty(companyRegulations.Title)) { throw MessageKeys.AppException(MessageKeys._CompanyRegulations_Title_Null); } if (companyRegulations.AppendixList != null) { foreach (CompanyReguAppendix companyReguAppendix in companyRegulations.AppendixList) { // 附件名称 if (string.IsNullOrEmpty(companyReguAppendix.FileName)) { throw MessageKeys.AppException(MessageKeys._CompanyReguAppendix_FileName_Null); } if (string.IsNullOrEmpty(companyReguAppendix.Directory)) { throw MessageKeys.AppException(MessageKeys._CompanyReguAppendix_Directory_Null); } } } }
private void Init(object sender, EventArgs e) { _View.ReguTypeDataSrc = CompanyRegulation.GetAllReguType(); GetCompanyRegulations(_View.SelectedReguType); }