private void autoCompleteUC1_SelectedValueChanged(object sender, object e) { try { trn_teeth_hdr teeth = BsPatientTeeth.OfType <trn_teeth_hdr>().FirstOrDefault(); if (teeth != null) { if (e == null) { txtDoctorCode.Text = ""; teeth.tth_doctor_code = null; teeth.tth_doctor_license = null; teeth.tth_doctor_name_en = null; teeth.tth_doctor_name_th = null; } else { txtDoctorCode.Text = ((DoctorProfile)e).SSUSR_Initials; teeth.tth_doctor_code = ((DoctorProfile)e).SSUSR_Initials; teeth.tth_doctor_license = ((DoctorProfile)e).CTPCP_SMCNo; DoctorName dn = obj.GetDoctorName(((DoctorProfile)e).CTPCP_Desc); teeth.tth_doctor_name_en = dn.NameEN; teeth.tth_doctor_name_th = dn.NameTH; } } } catch (Exception ex) { Program.MessageError(this.Name, "autoCompleteUC1_SelectedValueChanged", ex, false); } }
public void EndEdit() { try { DateTime dateNow = Program.GetServerDateTime(); trn_teeth_hdr patientTeeth = BsPatientTeeth.OfType <trn_teeth_hdr>().FirstOrDefault(); if (patientTeeth.tth_create_by == null) { patientTeeth.tth_create_date = dateNow; } patientTeeth.tth_update_date = dateNow; List <trn_teeth_dtl> listTeethDtl = BSTeethDtl.OfType <trn_teeth_dtl>().OrderBy(x => x.ttd_teeth_up).ThenBy(x => x.ttd_teeth_location).ToList(); int seq = 0; listTeethDtl.ForEach(x => { x.ttd_seq = seq++; x.ttd_create_date = dateNow; x.ttd_update_date = dateNow; }); List <trn_teeth_doc_result> listTeethDoctor = BsTeethDoctor.OfType <trn_teeth_doc_result>().ToList(); listTeethDoctor.ForEach(x => { x.tdr_create_date = dateNow; x.tdr_update_date = dateNow; }); bsPatientRegis.EndEdit(); } catch (Exception ex) { Program.MessageError(this.Name, "SaveData", ex, false); } }
//yee test private void SetBindingSource() { var datateethbinding = (from t1 in db.trn_teeth_hdrs where t1.tpr_id == TprID select t1).FirstOrDefault(); if (datateethbinding != null) { TeethbindingSource1.DataSource = (from t1 in db.trn_teeth_hdrs where t1.tpr_id == TprID select t1).FirstOrDefault(); trn_teeth_hdr objtrnteethhdr = (trn_teeth_hdr)TeethbindingSource1.Current; Program.SetValueRadioGroup(GBGumfoState, objtrnteethhdr.tth_gum_of_state); Program.SetValueRadioGroup(GBbedTooth, objtrnteethhdr.tth_bad_tooth); Program.SetValueRadioGroup(GBThimbleofState, objtrnteethhdr.tth_thimble_of_state); trnteethdtlsBindingSource.DataSource = objtrnteethhdr.trn_teeth_dtls; ResetTeethbutton(); } else { TeethbindingSource1.DataSource = db.trn_teeth_hdrs; TeethbindingSource1.AddNew(); } }
private void selectProblem_Click(object sender, EventArgs e) { if (_PatientRegis != null) { if (sender.GetType() == typeof(Button)) { Button btn = (Button)sender; if (btn.Tag != null) { string[] tag = btn.Tag.ToString().Split(','); if (tag.Count() == 2) { string teeth_up = tag[0].ToString().Trim(); int teeth_location = Convert.ToInt32(tag[1]); List <trn_teeth_dtl> result_teeth = BSTeethDtl.OfType <trn_teeth_dtl>() .Where(x => x.ttd_teeth_up.Trim() == teeth_up && x.ttd_teeth_location == teeth_location).ToList(); List <DentalSelectProblemFrm.sourceProblem> old_problem = result_teeth.Select(x => new DentalSelectProblemFrm.sourceProblem { mdr_id = x.mdr_id, mdr_code = x.mdr_code }).ToList(); DentalSelectProblemFrm.selectProblem selectProblem = new DentalSelectProblemFrm.selectProblem { Selected = false, mhs_id = bsPatientRegis.OfType <trn_patient_regi>().FirstOrDefault().mhs_id, Problem = old_problem }; DentalSelectProblemFrm frm = new DentalSelectProblemFrm(); DentalSelectProblemFrm.selectProblem new_selected = frm.getProblem(selectProblem); if (new_selected.Selected == true) { List <DentalSelectProblemFrm.sourceProblem> new_problem = new_selected.Problem; List <trn_teeth_dtl> list_remove_dtl = BSTeethDtl.OfType <trn_teeth_dtl>() .Where(x => x.ttd_teeth_up.Trim() == teeth_up && x.ttd_teeth_location == teeth_location && !new_problem.Contains(new DentalSelectProblemFrm.sourceProblem { mdr_id = x.mdr_id, mdr_code = x.mdr_code })).ToList(); if (list_remove_dtl.Count() > 0) { list_remove_dtl.ForEach(x => BSTeethDtl.Remove(x)); } List <DentalSelectProblemFrm.sourceProblem> list_add_dtl = new_problem.Where(x => !old_problem.Contains(x)).ToList(); if (list_add_dtl.Count() > 0) { list_add_dtl.ForEach(x => { BSTeethDtl.Add(new trn_teeth_dtl { mdr_id = x.mdr_id, mdr_code = x.mdr_code, ttd_teeth_up = teeth_up, ttd_teeth_location = teeth_location, ttd_create_by = username, ttd_update_by = username }); }); } trn_teeth_hdr patient_teeth = BsPatientTeeth.OfType <trn_teeth_hdr>().FirstOrDefault(); patient_teeth.tth_bad_tooth_total = BSTeethDtl.OfType <trn_teeth_dtl>().Where(x => x.mdr_code != null && x.mdr_code.ToUpper() == "F").Count(); patient_teeth.tth_down_tooth_total = BSTeethDtl.OfType <trn_teeth_dtl>().Where(x => x.mdr_code != null && x.mdr_code.ToUpper() == "A").Count(); patient_teeth.tth_thimble_total = BSTeethDtl.OfType <trn_teeth_dtl>().Where(x => x.mdr_code != null && x.mdr_code.ToUpper() == "R").Count(); patient_teeth.tth_replace_tooth_total = BSTeethDtl.OfType <trn_teeth_dtl>().Where(x => x.mdr_code != null && x.mdr_code.ToUpper() == "S").Count(); patient_teeth.tth_thimble_out_total = BSTeethDtl.OfType <trn_teeth_dtl>().Where(x => x.mdr_code != null && x.mdr_code.ToUpper() == "C").Count(); patient_teeth.tth_put_tooth_total = BSTeethDtl.OfType <trn_teeth_dtl>().Where(x => x.mdr_code != null && x.mdr_code.ToUpper() == "X").Count(); List <string> result = new_problem.Select(x => x.mdr_code).ToList(); if (result.Count() > 0) { btn.Text = string.Join(",", result); } else { btn.Text = ""; } } } } } } }
private void Save(char strType) { Boolean saveIsCompleted = false; if (TeethbindingSource1.DataSource != null) { DateTime datenow = Program.GetServerDateTime(); try { trn_teeth_hdr objteethHdr = (trn_teeth_hdr)TeethbindingSource1.Current; objteethHdr.tth_type = strType; objteethHdr.tth_gum_of_state = Program.GetValueRadioTochar(GBGumfoState); objteethHdr.tth_bad_tooth = Program.GetValueRadio(GBbedTooth); objteethHdr.tth_thimble_of_state = Program.GetValueRadioTochar(GBThimbleofState); objteethHdr.tth_create_by = Program.CurrentUser.mut_username; objteethHdr.tth_create_date = datenow; objteethHdr.tth_update_by = objteethHdr.tth_create_by; objteethHdr.tth_update_date = objteethHdr.tth_create_date; objteethHdr.tpr_id = TprID; var objdeltrnteethdocresult = (from t1 in db.trn_teeth_doc_results where t1.tth_id == objteethHdr.tth_id select t1).ToList(); if (objdeltrnteethdocresult.Count != 0) { db.trn_teeth_doc_results.DeleteAllOnSubmit(objdeltrnteethdocresult); db.SubmitChanges(); } foreach (object itemChecked in chList.CheckedItems) { // เพิ่มรายการใหม่ trn_teeth_doc_result objnew = new trn_teeth_doc_result(); objnew.tdr_create_by = Program.CurrentUser.mut_username; objnew.tdr_create_date = datenow; objnew.tdr_update_date = datenow; objnew.tdr_update_by = objnew.tdr_create_by; objnew.tth_id = objteethHdr.tth_id; objnew.trn_teeth_hdr = objteethHdr; objnew.mdr_id = Convert.ToInt32(Program.GetCheckedListBoxValue(itemChecked, chList)); db.trn_teeth_doc_results.InsertOnSubmit(objnew); } trnteethdtlsBindingSource.EndEdit(); TeethbindingSource1.EndEdit(); db.SubmitChanges(); saveIsCompleted = true; } catch (Exception ex) { Program.MessageError("=>Save Teeth==>Try Submitchanges() :" + ex.Message); } if (saveIsCompleted == true) { lblMsg.Text = "Save data completed."; timer1.Enabled = true; } } //return saveIsCompleted; }
private void btntooth_Click(object sender, EventArgs e) { frmTeethProblems frm = new frmTeethProblems(); Button btnclick = (Button)sender; frm.GetDocResult = btnclick.Text; if (frm.ShowDialog() == DialogResult.OK) { string resultdata = frm.GetDocResult; string[] ListResultdata = resultdata.Split(','); string[] btnvalue = btnclick.Tag.ToString().Split(','); trn_teeth_hdr currentteethhdr = (trn_teeth_hdr)TeethbindingSource1.Current; IList <trn_teeth_dtl> objlist = (IList <trn_teeth_dtl>)trnteethdtlsBindingSource.List; //clear Old Select List <trn_teeth_dtl> objselect = objlist.Where(x => x.ttd_teeth_up.Trim() == btnvalue[0].Trim() && x.ttd_teeth_location == Convert.ToInt32(btnvalue[1]) ).ToList(); foreach (trn_teeth_dtl item in objselect) { objlist.Remove(item); if (item.ttd_id > 0) { db.trn_teeth_dtls.DeleteOnSubmit(item); } } //db.SubmitChanges(); //Add Item select if (resultdata != "") { int countitem = 0; string statusdata = ""; foreach (string itemrow in ListResultdata) { countitem = countitem + 1; trn_teeth_dtl dtx = new trn_teeth_dtl(); dtx.tth_id = currentteethhdr.tth_id; dtx.ttd_seq = countitem; dtx.ttd_teeth_location = Convert.ToInt32(btnvalue[1]); dtx.ttd_teeth_up = btnvalue[0]; string[] mdrData = itemrow.Split('|'); dtx.mdr_id = Convert.ToInt32(mdrData[0]); dtx.mdr_code = mdrData[1]; dtx.ttd_create_by = Program.CurrentUser.mut_username; dtx.ttd_create_date = Program.GetServerDateTime(); dtx.ttd_update_by = dtx.ttd_create_by; dtx.ttd_update_date = dtx.ttd_create_date; objlist.Add(dtx); if (statusdata == "") { statusdata += mdrData[1]; } else { statusdata += "," + mdrData[1]; } } btnclick.Text = statusdata; btnclick.BackColor = Color.Pink; } else { btnclick.Text = resultdata; btnclick.BackColor = Control.DefaultBackColor; } //Count summary currentteethhdr.tth_bad_tooth_total = objlist.Where(x => x.mdr_code != null && x.mdr_code.ToUpper() == "F").Count(); currentteethhdr.tth_down_tooth_total = objlist.Where(x => x.mdr_code != null && x.mdr_code.ToUpper() == "A").Count(); currentteethhdr.tth_thimble_total = objlist.Where(x => x.mdr_code != null && x.mdr_code.ToUpper() == "R").Count(); currentteethhdr.tth_replace_tooth_total = objlist.Where(x => x.mdr_code != null && x.mdr_code.ToUpper() == "E").Count(); currentteethhdr.tth_thimble_out_total = objlist.Where(x => x.mdr_code != null && x.mdr_code.ToUpper() == "C").Count(); currentteethhdr.tth_put_tooth_total = objlist.Where(x => x.mdr_code != null && x.mdr_code.ToUpper() == "X").Count(); } }