示例#1
0
        //private void autoCompleteDoctor_currentChangeHandler(object sender, UIcontrol.completeArgs e)
        //{
        //    txtDoctorCode.Text = e.valueData == null ? "" : e.valueData.ToString();
        //    trn_teeth_hdr patientTeeth = BsPatientTeeth.OfType<trn_teeth_hdr>().FirstOrDefault();
        //    patientTeeth.tth_doctor_code = txtDoctorCode.Text;
        //}
        private void chList_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            clsSourceMaster      item   = (clsSourceMaster)chList.Items[e.Index];
            trn_teeth_doc_result result = BsTeethDoctor.OfType <trn_teeth_doc_result>().Where(x => x.mdr_id == item.val).FirstOrDefault();

            if (e.NewValue == CheckState.Checked)
            {
                if (result == null)
                {
                    BsTeethDoctor.Add(new trn_teeth_doc_result
                    {
                        mdr_id        = item.val,
                        tdr_create_by = username,
                        tdr_update_by = username
                    });
                }
            }
            else
            {
                if (result != null)
                {
                    BsTeethDoctor.Remove(result);
                }
            }
        }
示例#2
0
        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;
        }