private void btnSave_Click(object sender, EventArgs e) { // 檢查資料 if (CheckData()) { UDTWeightProportionDef newData = new UDTWeightProportionDef(); // 刪除舊資料 UDTTransfer.UDTWeightProportionDelete(_WeightProportionList); // 新增新資料 foreach (DataGridViewRow row in dgData.Rows) { int value = int.Parse(row.Cells[colPer.Index].Value.ToString()); string item=row.Cells[colItem.Index].Value.ToString(); switch (item) { case _Item1: newData.SS1_Weight = value; break; case _Item2: newData.SS2_Weight = value;break; case _Item3: newData.SS3_Weight = value; break; } } List<UDTWeightProportionDef> newDataList = new List<UDTWeightProportionDef>(); newDataList.Add(newData); UDTTransfer.UDTWeightProportionInsert(newDataList); // 關閉 MsgBox.Show("儲存成功!"); this.Close(); } else { MsgBox.Show("資料錯誤請修正後儲存!"); } }
void _bgLoadData_DoWork(object sender, DoWorkEventArgs e) { // 取的比重資料 foreach (UDTWeightProportionDef data in UDTTransfer.UDTWeightProportionSelect()) _wp = data; _RowDataList.Clear(); _RowDataList =(from data in UDTTransfer.GetStudentResultListByCourseIDList(_SelectCourseIDList) orderby data.CourseName,data.ScselectRec.SeatNo select data).ToList(); }