public List <ProposalTypeInfo> getProposalType(ProposalTypeSeachCriteria _criteria) { SqlConnectionFactory sqlConnection = new SqlConnectionFactory(); using (SqlConnection connection = sqlConnection.GetConnection()) { List <ProposalTypeInfo> ListProposalType = ProposalTypeDataLayer.GetInstance().getProposalType(connection, _criteria); return(ListProposalType); } }
public ActionMessage createProposalType(ProposalTypeInfo _ProposalType, string _userI) { ActionMessage ret = new ActionMessage(); if (_ProposalType.TypeCode.Trim() == string.Empty) { ret.isSuccess = false; ret.err.msgCode = "Internal Error"; ret.err.msgString = "Chưa nhập mã loại đề xuất "; } //else if (_ProposalType.SourceID == -1) //{ //} else { SqlConnectionFactory sqlConnection = new SqlConnectionFactory(); using (SqlConnection connection = sqlConnection.GetConnection()) { ProposalTypeSeachCriteria _criteria = new ProposalTypeSeachCriteria(); _criteria.TypeCode = _ProposalType.TypeCode; var chkProposalTypeInfo = getProposalType(_criteria); if (chkProposalTypeInfo.Count > 0) { ret.isSuccess = false; ret.err.msgCode = "Internal Error"; ret.err.msgString = "Trùng mã "; } else { try { ProposalTypeDataLayer.GetInstance().InsertProposalType(connection, _ProposalType, _userI); ret.isSuccess = true; } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "Internal Error"; ret.err.msgString = ex.ToString(); } } } } return(ret); }
public ActionMessage editProposalType(int id, ProposalTypeInfo _ProposalType, string _userU) { ActionMessage ret = new ActionMessage(); if (_ProposalType.TypeCode.Trim().Length == 0) { ret.isSuccess = false; ret.err.msgCode = "Internal Error"; ret.err.msgString = "Chưa nhập mã Khoa phòng"; } else { SqlConnectionFactory sqlConnection = new SqlConnectionFactory(); using (SqlConnection connection = sqlConnection.GetConnection()) { ProposalTypeSeachCriteria _criteria = new ProposalTypeSeachCriteria(); _criteria.TypeCode = _ProposalType.TypeCode; var chkProposalTypeInfo = getProposalType(_criteria); if (chkProposalTypeInfo.Count > 0) { ret.isSuccess = false; ret.err.msgCode = "Internal Error"; ret.err.msgString = "Trùng mã Khoa phòng"; } else { try { ProposalTypeDataLayer.GetInstance().UpdateProposalType(connection, id, _ProposalType, _userU); ret.isSuccess = true; } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "Internal Error"; ret.err.msgString = ex.ToString(); } } } } return(ret); }
public List <ProposalTypeInfo> getProposalType(SqlConnection connection, ProposalTypeSeachCriteria _criteria) { var result = new List <ProposalTypeInfo>(); using (var command = new SqlCommand("Select * " + " from tbl_ProposalType where 1 = 1 ", connection)) { if (!string.IsNullOrEmpty(_criteria.TypeID)) { command.CommandText += " and TypeID = @PTypeID"; AddSqlParameter(command, "@TypeID", _criteria.TypeID, System.Data.SqlDbType.Int); } if (!string.IsNullOrEmpty(_criteria.TypeCode)) { command.CommandText += " and TypeCode = @TypeCode"; AddSqlParameter(command, "@TypeCode", _criteria.TypeCode, System.Data.SqlDbType.NVarChar); } if (!string.IsNullOrEmpty(_criteria.TypeName)) { command.CommandText += " and TypeName like N'%" + _criteria.TypeName + "%' "; } command.CommandText += " order by TypeID "; WriteLogExecutingCommand(command); using (var reader = command.ExecuteReader()) { while (reader.Read()) { var info = new ProposalTypeInfo(); info.TypeID = GetDbReaderValue <int>(reader["TypeID"]); info.TypeCode = GetDbReaderValue <string>(reader["TypeCode"]); info.TypeName = GetDbReaderValue <string>(reader["TypeName"]); info.UserI = GetDbReaderValue <string>(reader["UserI"]); info.InTime = GetDbReaderValue <DateTime?>(reader["InTime"]); info.UserU = GetDbReaderValue <string>(reader["UserU"]); info.UpdateTime = GetDbReaderValue <DateTime>(reader["UpdateTime"]); result.Add(info); } } return(result); } }