public static object addcertificate(string _uid, string _pwd, string postString, ref string error) { Entity.MsSQL.T_MarkUser _user = Dal.MsSQL.T_MarkUser.GetModel(_uid, _pwd); if (_user != null) { Entity.Request.addcertificate _certificate = Untity.HelperJson.DeserializeObject <Entity.Request.addcertificate>(postString); Entity.MsSQL.T_Certificate _model = new Entity.MsSQL.T_Certificate() { CategoryName = _certificate.CategoryName, ExamSubject = _certificate.ExamSubject, StartTime = Untity.HelperDataCvt.strToDatetime(_certificate.StartTime), EndTime = Untity.HelperDataCvt.strToDatetime(_certificate.EndTime), Describe = _certificate.Describe, ExamResult = _certificate.ExamResult, NormalResult = _certificate.NormalResult }; long _id = Dal.MsSQL.T_Certificate.Add(_model); if (!string.IsNullOrEmpty(_certificate.SubjectIds)) { foreach (var _subjcetid in _certificate.SubjectIds.Split(',')) { Entity.MsSQL.T_CertifiSubject _subject = new Entity.MsSQL.T_CertifiSubject() { }; } } return(_id.ToString()); } else { error = "账号失效,请重新登陆"; return("-1"); } }
public static object updatecertifisubject(string _uid, string _pwd, string postString, ref string error) { Entity.MsSQL.T_MarkUser _user = Dal.MsSQL.T_MarkUser.GetModel(_uid, _pwd); if (_user != null) { Entity.Request.handelcertifisubject _certifisubject = Untity.HelperJson.DeserializeObject <Entity.Request.handelcertifisubject>(postString); long existcount = Dal.MsSQL.T_CertifiSubject.GetCertifiSubjectCount(_certifisubject.ID, _certifisubject.CertificateId, _certifisubject.SubjectId); if (existcount > 0) { error = "该课程此证书已包含,无法继续操作"; return("-1"); } Entity.MsSQL.T_CertifiSubject _model = new Entity.MsSQL.T_CertifiSubject() { ID = Untity.HelperDataCvt.strToLong(_certifisubject.ID), SubjectId = _certifisubject.SubjectId, NormalResult = _certifisubject.NormalResult, ExamResult = _certifisubject.ExamResult, IsNeedExam = _certifisubject.IsNeedExam, ExamLength = Untity.HelperDataCvt.strToIni(_certifisubject.ExamLength) }; return(Dal.MsSQL.T_CertifiSubject.Update(_model).ToString()); } else { error = "账号失效,请重新登陆"; return("-1"); } }
public static long Add(Entity.MsSQL.T_CertifiSubject model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_CertifiSubject("); strSql.Append("CertificateId,SubjectId,NormalResult,ExamResult,IsNeedExam,ExamLength)"); strSql.Append(" values ("); strSql.Append("@CertificateId,@SubjectId,@NormalResult,@ExamResult,@IsNeedExam,@ExamLength)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CertificateId", SqlDbType.VarChar, 100), new SqlParameter("@SubjectId", SqlDbType.VarChar, 100), new SqlParameter("@NormalResult", SqlDbType.VarChar, 100), new SqlParameter("@ExamResult", SqlDbType.VarChar, 100), new SqlParameter("@IsNeedExam", SqlDbType.Char, 1), new SqlParameter("@ExamLength", SqlDbType.BigInt) }; parameters[0].Value = model.CertificateId; parameters[1].Value = model.SubjectId; parameters[2].Value = model.NormalResult; parameters[3].Value = model.ExamResult; parameters[4].Value = model.IsNeedExam; parameters[5].Value = model.ExamLength; object obj = Untity.HelperMsSQL.ExecuteScalar(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt64(obj)); } }
public static bool Update(Entity.MsSQL.T_CertifiSubject model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_CertifiSubject set "); strSql.Append("SubjectId=@SubjectId,"); strSql.Append("NormalResult=@NormalResult,"); strSql.Append("ExamResult=@ExamResult,"); strSql.Append("IsNeedExam=@IsNeedExam,"); strSql.Append("ExamLength=@ExamLength "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@SubjectId", SqlDbType.VarChar, 100), new SqlParameter("@NormalResult", SqlDbType.VarChar, 100), new SqlParameter("@ExamResult", SqlDbType.VarChar, 100), new SqlParameter("@IsNeedExam", SqlDbType.Char, 1), new SqlParameter("@ExamLength", SqlDbType.BigInt), new SqlParameter("@ID", SqlDbType.BigInt) }; parameters[0].Value = model.SubjectId; parameters[1].Value = model.NormalResult; parameters[2].Value = model.ExamResult; parameters[3].Value = model.IsNeedExam; parameters[4].Value = model.ExamLength; parameters[5].Value = model.ID; int rows = Untity.HelperMsSQL.ExecuteQuery(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }