Ejemplo n.º 1
0
 private void UI_DeleteFavorite(object sender, string e)
 {
     if (MessageBox.Show("Do you want to Delete '" + e + "'?", e, MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         try
         {
             ExamResultUI ui = sender as ExamResultUI;
             if (ui != null)
             {
                 using (InhCheckupDataContext cdc = new InhCheckupDataContext())
                 {
                     mst_autocomplete_physical_exam mst = cdc.mst_autocomplete_physical_exams
                                                          .Where(x => x.mape_type == ui.AutoCompleteType &&
                                                                 x.mst_user_type.mut_username == _username &&
                                                                 x.mape_description == e)
                                                          .FirstOrDefault();
                     if (mst != null)
                     {
                         cdc.mst_autocomplete_physical_exams.DeleteOnSubmit(mst);
                         cdc.SubmitChanges();
                     }
                     List <string> tmp = ui.AutoCompleteListThList;
                     tmp.Remove(e);
                     ui.AutoCompleteListThList = tmp;
                 }
             }
         }
         catch (Exception ex)
         {
             Program.MessageError("ExamCheckupUC", "UI_DeleteText", ex, false);
         }
     }
 }
Ejemplo n.º 2
0
        private void UI_AddFavorite(object sender, string e)
        {
            try
            {
                DateTime     dateNow = Program.GetServerDateTime();
                ExamResultUI ui      = sender as ExamResultUI;
                if (ui != null)
                {
                    using (InhCheckupDataContext cdc = new InhCheckupDataContext())
                    {
                        int mut_id = cdc.mst_user_types.Where(x => x.mut_username == _username)
                                     .Select(x => x.mut_id)
                                     .FirstOrDefault();

                        mst_autocomplete_physical_exam mst = cdc.mst_autocomplete_physical_exams
                                                             .Where(x => x.mape_type == ui.AutoCompleteType &&
                                                                    x.mut_id == mut_id &&
                                                                    x.mape_description == e)
                                                             .FirstOrDefault();
                        if (mst == null)
                        {
                            mst                  = new mst_autocomplete_physical_exam();
                            mst.mape_type        = ui.AutoCompleteType;
                            mst.mut_id           = mut_id;
                            mst.mape_active      = true;
                            mst.mape_description = e;
                            mst.mape_create_date = dateNow;
                            cdc.mst_autocomplete_physical_exams.InsertOnSubmit(mst);
                            cdc.SubmitChanges();
                        }
                        List <string> tmp = ui.AutoCompleteListThList;
                        tmp.Add(e);
                        ui.AutoCompleteListThList = tmp;
                        MessageBox.Show("Add '" + ui.ResultTH + "' to favorite Complete.");
                    }
                }
            }
            catch (Exception ex)
            {
                Program.MessageError("ExamCheckupUC", "UI_DeleteText", ex, false);
            }
        }