private void btnCancel_Click(object sender, EventArgs e)
 {
     CTBenhNhanExcercise ctEX = new CTBenhNhanExcercise();
     ctEX.IDExcercises = EX.ID;
     AddItemCallback(ctEX, false);
     this.Close();
 }
 private void btnOK_Click(object sender, EventArgs e)
 {
     CTBenhNhanExcercise ctEX = new CTBenhNhanExcercise();
     ctEX.IDExcercises = EX.ID;
     ctEX.Repeat = int.Parse(txtRepeat.Text);
     ctEX.Do = int.Parse(txtDo.Text);
     ctEX.Hold = int.Parse(txtHold.Text);
     if (EX.Move == 1)
     {
         ctEX.Direction = cboDirection.EditValue.ToString();
         ctEX.Range = cboRange.EditValue.ToString();
         ctEX.Resistance = cboResistance.EditValue.ToString();
     }
     if (EX.Move == 2)
     {
         ctEX.Direction = "";
         ctEX.Range = cboRange.EditValue.ToString();
         ctEX.Resistance = cboResistance.EditValue.ToString();
     }
     AddItemCallback(ctEX, true);
     this.Close();
 }
 private void AddItemCallback(CTBenhNhanExcercise CTBenhNhan, bool check)
 {
     //insert Chon
     if (check)
     {
         for (int i = 0; i < gridView_Excercise.DataRowCount; i++)
         {
             int ID = int.Parse(gridView_Excercise.GetRowCellValue(i, "ID").ToString());
             if (ID == CTBenhNhan.IDExcercises)
             {
                 gridView_Excercise.SetRowCellValue(i, "Hold", CTBenhNhan.Hold);
                 gridView_Excercise.SetRowCellValue(i, "Do", CTBenhNhan.Do);
                 gridView_Excercise.SetRowCellValue(i, "Repeat", CTBenhNhan.Repeat);
                 if (gridView_Excercise.GetRowCellValue(i, "Move") != null)
                 {
                     gridView_Excercise.SetRowCellValue(i, "Resistance", CTBenhNhan.Resistance);
                     gridView_Excercise.SetRowCellValue(i, "Range", CTBenhNhan.Range);
                     gridView_Excercise.SetRowCellValue(i, "Direction", CTBenhNhan.Direction);
                 }
                 gridView_Excercise.SetRowCellValue(i, "Prints", true);
             }
         }
     }
     else
     {
         for (int i = 0; i < gridView_Excercise.DataRowCount; i++)
         {
             int ID = int.Parse(gridView_Excercise.GetRowCellValue(i, "ID").ToString());
             if (ID == CTBenhNhan.IDExcercises)
             {
                 gridView_Excercise.SetRowCellValue(i, "Prints", check);
             }
         }
     }
 }
 public List<CTBenhNhanExcercise> GetInfCTBenhNhanExcercise()
 {
     List<CTBenhNhanExcercise> listExcercise = new List<CTBenhNhanExcercise>();
     for (int i = 0; i < gridView_Excercise.DataRowCount; i++)
     {
         bool flag = (bool)(gridView_Excercise.GetRowCellValue(i, "Prints"));
         if (flag)
         {
             CTBenhNhanExcercise cp = new CTBenhNhanExcercise();
             cp.IDExcercises = (int)(gridView_Excercise.GetRowCellValue(i, "ID"));
             cp.Do = (int)gridView_Excercise.GetRowCellValue(i, "Do");
             cp.Hold = (int)gridView_Excercise.GetRowCellValue(i, "Hold");
             cp.Repeat = (int)gridView_Excercise.GetRowCellValue(i, "Repeat");
             if (gridView_Excercise.GetRowCellValue(i, "Move") != null)
             {
                 cp.Resistance = gridView_Excercise.GetRowCellValue(i, "Resistance").ToString();
                 cp.Range = gridView_Excercise.GetRowCellValue(i, "Range").ToString();
                 cp.Direction = gridView_Excercise.GetRowCellValue(i, "Direction").ToString();
             }
             cp.IDCTBenhNhan = lblCTBenhNhan.Text;
             listExcercise.Add(cp);
         }
     }
     return listExcercise;
 }
Exemple #5
0
 public bool InsertCTBenhNhanExcercise(CTBenhNhanExcercise CTBenhNhanExcercise)
 {
     DataClassesDataContext data = new DataClassesDataContext(Connection);
     data.CTBenhNhanExcercises.InsertOnSubmit(CTBenhNhanExcercise);
     try
     {
         data.SubmitChanges();
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
 partial void DeleteCTBenhNhanExcercise(CTBenhNhanExcercise instance);
 partial void UpdateCTBenhNhanExcercise(CTBenhNhanExcercise instance);
 partial void InsertCTBenhNhanExcercise(CTBenhNhanExcercise instance);
 private void AddItemCallback(CTBenhNhanExcercise CTBenhNhan)
 {
     //insert Chon
     for (int i = 0; i < gridView_Excercise.DataRowCount; i++)
     {
             int ID=int.Parse(gridView_Excercise.GetRowCellValue(i, "ID").ToString());
             if (ID == CTBenhNhan.IDExcercises)
             {
                 gridView_Excercise.SetRowCellValue(i, "Hold", CTBenhNhan.Hold);
                 gridView_Excercise.SetRowCellValue(i, "Do", CTBenhNhan.Do);
                 gridView_Excercise.SetRowCellValue(i, "Repeat", CTBenhNhan.Repeat);
                 gridView_Excercise.SetRowCellValue(i, "Prints", true);
             }
     }
 }