public string[] createAudiometryAppointment(CreateAudiometryAppointment StructData) { string[] returnValue = new string[2]; returnValue[0] = "0"; returnValue[1] = ""; DataBase Base = new DataBase(); using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString())) { try { Sqlconn.Open(); string sql = "INSERT INTO AudiometryAppointment (ReserveDate, StartTime, EndTime, ReserveID, StudentID, CheckItem, ItemOtherExplain, CheckContent, State, AssessWho1, " + "AssessWho2, Unit)" + "VALUES (@ReserveDate, @StartTime, @EndTime, @ReserveID, @StudentID, @CheckItem, @ItemOtherExplain, @CheckContent, @State, @AssessWho1, @AssessWho2, " + "@Unit)"; SqlCommand cmd = new SqlCommand(sql, Sqlconn); cmd.Parameters.Add("@ReserveDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(StructData.appDate); cmd.Parameters.Add("@StartTime", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.startTime); cmd.Parameters.Add("@EndTime", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.endTime); cmd.Parameters.Add("@ReserveID", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(StructData.authorID); cmd.Parameters.Add("@StudentID", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(StructData.studentID); cmd.Parameters.Add("@CheckItem", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.item); cmd.Parameters.Add("@ItemOtherExplain", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.itemExplain); cmd.Parameters.Add("@CheckContent", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.sContent); cmd.Parameters.Add("@State", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StructData.State); cmd.Parameters.Add("@AssessWho1", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(StructData.AssessWho1); cmd.Parameters.Add("@AssessWho2", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(StructData.AssessWho2); cmd.Parameters.Add("@Unit", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StructData.Unit); returnValue[0] = cmd.ExecuteNonQuery().ToString(); Sqlconn.Close(); } catch (Exception e) { returnValue[0] = "-1"; returnValue[1] = e.Message; } } return returnValue; }
public string[] setAudiometryAppointment(CreateAudiometryAppointment StructData) { string[] returnValue = new string[2]; returnValue[0] = "0"; returnValue[1] = ""; DataBase Base = new DataBase(); using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString())) { try { Sqlconn.Open(); /*string sql = "INSERT INTO AudiometryAppointment (ReserveDate, StartTime, EndTime, ReserveID, StudentID, CheckItem, ItemOtherExplain, CheckContent, State, AssessWho1, " + "AssessWho2, Unit, CreateDateTime, isDeleted)" + "VALUES (@ReserveDate, @StartTime, @EndTime, @ReserveID, @StudentID, @CheckItem, @ItemOtherExplain, @CheckContent, @State, @AssessWho1, @AssessWho2, " + "@Unit, @CreateDateTime, 0)"; */ //sql = "UPDATE CoursePlanTemplateLong SET TargetContent=@TargetContent WHERE CPTLID=@CPTLID AND CPTID=@CPTID AND isDeleted=0"; string sql = "UPDATE AudiometryAppointment SET ReserveDate=@ReserveDate, StartTime=@StartTime, EndTime=@EndTime, "+ "StudentID=@StudentID, CheckItem=@CheckItem, ItemOtherExplain=@ItemOtherExplain, CheckContent=@CheckContent, State=@State, "+ "AssessWho1=@AssessWho1, AssessWho2=@AssessWho2, Unit=@Unit WHERE ID=@ID AND isDeleted=0"; //"AssessWho1=@AssessWho1, AssessWho2=@AssessWho2, Unit=@Unit WHERE ID=@ID AND ReserveID=@ReserveID AND isDeleted=0"; SqlCommand cmd = new SqlCommand(sql, Sqlconn); cmd.Parameters.Add("@ID", SqlDbType.BigInt).Value = Chk.CheckStringtoInt64Function(StructData.ID); cmd.Parameters.Add("@ReserveDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(StructData.appDate); cmd.Parameters.Add("@StartTime", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.startTime); cmd.Parameters.Add("@EndTime", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.endTime); cmd.Parameters.Add("@ReserveID", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(StructData.authorID); cmd.Parameters.Add("@StudentID", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(StructData.studentID); cmd.Parameters.Add("@CheckItem", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.item); cmd.Parameters.Add("@ItemOtherExplain", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.itemExplain); cmd.Parameters.Add("@CheckContent", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.sContent); cmd.Parameters.Add("@State", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StructData.State); cmd.Parameters.Add("@AssessWho1", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(StructData.AssessWho1); cmd.Parameters.Add("@AssessWho2", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(StructData.AssessWho2); cmd.Parameters.Add("@Unit", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StructData.Unit); returnValue[0] = cmd.ExecuteNonQuery().ToString(); Sqlconn.Close(); } catch (Exception e) { returnValue[0] = "-1"; returnValue[1] = e.Message; } } return returnValue; }
public string[] setAudiometryAppointment(CreateAudiometryAppointment StructData) { Audiometry aDB = new Audiometry(); //if (int.Parse(aDB._StaffhaveRoles[1]) == 1) //{ return aDB.setAudiometryAppointment(StructData); //} //else //{ // return new string[2] { _noRole, _errorMsg }; //} }