private void lvTextbook_DoubleClick(object sender, EventArgs e) { if (this.IsAdd) { MessageBox.Show("尚未添加完成"); return; } else if (this.IsEdit) { MessageBox.Show("尚未编辑完成"); return; } //MessageBox.Show(this.lvTeacher.SelectedItems[0].Text); int clickTeacherIndex = this.lvTextbook.SelectedIndices[0]; string clickTextbookID = this.TextbookList[clickTeacherIndex].Id; TextbookBelongCourse textbookBelongCourse = new TextbookBelongCourse(); textbookBelongCourse.Id = Guid.NewGuid().ToString("N"); textbookBelongCourse.Create = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); textbookBelongCourse.Modify = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); textbookBelongCourse.UkTextbookId = clickTextbookID; textbookBelongCourse.UkCourseId = this.currentCourseID; this.ITextbookFormReq.AddOneTextbookForCourse(textbookBelongCourse); this.TextbookSelList.Add(this.TextbookList[clickTeacherIndex]); this.lvTextbookSel.Items.Add(this.TextbookSelList.Last().Name); this.TextbookList.RemoveAt(clickTeacherIndex); this.lvTextbook.Items.RemoveAt(clickTeacherIndex); }
public void AddOneTextbookForCourse(TextbookBelongCourse tbc) { string insertSql = "INSERT INTO textbook_belong_course(textbook_belong_course.id,textbook_belong_course.utc8_create,textbook_belong_course.utc8_modify,textbook_belong_course.uk_textbook_id,textbook_belong_course.uk_course_id,textbook_belong_course.other)VALUES(@id, @create, @modife, @textbookId, @courseId, @other)"; MySqlConnection mySqlConnection = new MySqlConnection(Model.MySqlHelper.Conn); mySqlConnection.Open(); Model.MySqlHelper.ExecuteNonQuery(mySqlConnection, CommandType.Text, insertSql, new MySqlParameter("@id", tbc.Id), new MySqlParameter("@create", tbc.Create), new MySqlParameter("@modife", tbc.Modify), new MySqlParameter("@@textbookId", tbc.UkTextbookId), new MySqlParameter("@courseId", tbc.UkCourseId), new MySqlParameter("@other", tbc.Other)); mySqlConnection.Close(); }