Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                IsLoginBackOffice();

                _UserList = new List <Viewuserlogin>();
                using (InhToDoListDataContext dbc = new InhToDoListDataContext())
                {
                    //แสดง file ที่มีการ upload ไปแล้ว
                    _UserList = (from t1 in dbc.mst_user_logins
                                 where t1.mul_user_login != "Admin"
                                 select new Viewuserlogin
                    {
                        Userlogin = t1.mul_user_login,
                        FirstName = t1.mul_fname,
                        Lastname = t1.mul_lname,
                        Market = (t1.mut_id == 1) ? true : false,
                        HPC = (t1.mut_id == 2) ? true : false,
                        Collection = (t1.mut_id == 3) ? true : false,
                        ContactCenter = (t1.mut_id == 4) ? true : false,
                        IsEdit = t1.mul_permit.ToString().Trim(),
                        IsActive = (t1.mut_status != null && t1.mut_status == 'A') ? true : false,
                        Status = "O"
                    }).ToList();
                    showGridUser();
                }
            }
        }
Ejemplo n.º 2
0
 private void LoadType()
 {
     try
     {
         List <CompType> result = new List <CompType> {
             new CompType {
                 id = 0, name = ""
             }
         };
         DDType.DataTextField  = "name";
         DDType.DataValueField = "id";
         DDType.DataSource     = result;
         using (InhToDoListDataContext context = new InhToDoListDataContext())
         {
             result.AddRange(context.mst_types
                             .Where(x => x.mst_status == 'A')
                             .Select(x => new CompType
             {
                 id   = x.mst_id,
                 name = x.mst_tname
             }).ToList());
         }
         DDType.DataBind();
     }
     catch (Exception ex)
     {
     }
     //var objmstid = (from tid in dbc.mst_types select new { id = tid.mst_id, name = tid.mst_tname }).ToList();
     //DDType.DataTextField = "name";
     //DDType.DataValueField = "id";
     //DDType.DataSource = objmstid;
     //DDType.DataBind();
     //DDType.Items.Insert(0, String.Empty);
     //DDType.SelectedIndex = 0;
 }
Ejemplo n.º 3
0
 public static void CheckPolicy(string TypeCode)
 {
     if (Constant.CurrentUserLogin != "")
     {//ถ้ายังไม่ได้ login ให้ ไปหน้า login
         using (InhToDoListDataContext dbc = new InhToDoListDataContext())
         {
             var objpolicy = (from t1 in dbc.mst_user_logins
                              where t1.mul_user_login == Constant.CurrentUserLogin &&
                              t1.mst_user_type.mut_code == TypeCode
                              select t1).Count();
             if (objpolicy > 0)
             {
                 return;
             }
             else
             {
                 if (Constant.CurrentUserLogin == "Admin")
                 {
                     return;
                 }
                 HttpContext.Current.Response.Redirect("frmHome.aspx");
             }
         }
     }
     else
     {
         string[] strpath  = HttpContext.Current.Request.Url.AbsolutePath.Split('/');
         string   pagename = strpath[strpath.Length - 1];
         string   qs       = HttpContext.Current.Request.Url.Query;
         HttpContext.Current.Response.Redirect(Constant.DefaultPageLogin + "?backurl=" + Constant.URLEnCode(pagename + qs));
     }
 }
Ejemplo n.º 4
0
 private void LoadLacation()
 {
     try
     {
         List <Location> result = new List <Location> {
             new Location {
                 id = 0, name = ""
             }
         };
         DDLocation.DataTextField  = "name";
         DDLocation.DataValueField = "id";
         DDLocation.DataSource     = result;
         using (InhToDoListDataContext context = new InhToDoListDataContext())
         {
             result.AddRange(context.mst_checkup_locations
                             .Where(x => x.mcl_status == 'A')
                             .Select(x => new Location
             {
                 id   = x.mcl_id,
                 name = x.mcl_ename
             }).ToList());
         }
         DDLocation.DataBind();
     }
     catch (Exception ex)
     {
     }
     //var objloc = (from loc in dbc.mst_checkup_locations select new { id = loc.mcl_id, name = loc.mcl_tname + "/" + loc.mcl_ename }).ToList();
     //DDLocation.DataTextField = "name";
     //DDLocation.DataValueField = "id";
     //DDLocation.DataSource = objloc;
     //DDLocation.DataBind();
     //DDLocation.Items.Insert(0, String.Empty);
     //DDLocation.SelectedIndex = 0;
 }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["username"]) && !string.IsNullOrEmpty(Request.QueryString["otp"]))
                {
                    string username = Request.QueryString["username"].ToString();
                    string otp      = Request.QueryString["otp"].ToString();
                    using (InhToDoListDataContext dbc = new InhToDoListDataContext())
                    {
                        var user = dbc.mst_user_logins
                                   .Where(x => x.mul_user_login.ToUpper() == username.ToUpper() &&
                                          x.mut_status == 'A')
                                   .Select(x => new
                        {
                            x.mst_user_type.mut_code,
                            x.mul_fname
                        }).FirstOrDefault();

                        var mst_otp = dbc.mst_user_otps.Where(x => x.mul_user_login == username && x.mul_otp == otp).FirstOrDefault();

                        if (user != null && mst_otp != null)
                        {
                            mst_otp.mul_expire = funcCls.GetServerDateTime();
                            dbc.SubmitChanges();

                            Constant.CurrentUserLogin     = username;
                            Constant.CurrentPageLogin     = user.mut_code;
                            Constant.CurrentUserLoginName = user.mul_fname;

                            switch (Constant.CurrentPageLogin)
                            {
                            case "MKT":
                                Response.Redirect(this.Page.ResolveClientUrl("~/frmmktNew.aspx"));
                                break;

                            case "HPC":
                                Response.Redirect(this.Page.ResolveClientUrl("~/frm_hpc.aspx"));
                                break;

                            case "CLT":
                                Response.Redirect(this.Page.ResolveClientUrl("~/frm_collection.aspx"));
                                break;

                            case "CTC":
                                Response.Redirect(this.Page.ResolveClientUrl("~/frm_contact_center.aspx"));
                                break;
                            }
                        }
                        else
                        {
                            lbalertmsg.Text = "UserName & Password incorrect. Please try again";
                            txtUser.Text    = username;
                            txtpass.Text    = "";
                            txtUser.Focus();
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
 public static List <string> GetMasterCompanyListEng(string cname)
 {
     try
     {
         string strSearch = cname.Trim().ToLower();
         if (strSearch.Length >= 2)
         {
             using (InhToDoListDataContext dbc = new InhToDoListDataContext())
             {
                 List <string> result = dbc.mst_companies
                                        .Where(x => x.mco_ename.ToLower().Contains(strSearch))
                                        .Select(x => x.mco_tname).Distinct().ToList();
                 //var objcomp = (from comp in dbc.mst_companies
                 //               where
                 //                  comp.mco_ename.ToLower().Contains(cname.ToLower()) && comp.mco_status == 'A'
                 //               select new { cname = comp.mco_ename }).ToList();
                 return(result);
             }
         }
         else
         {
             return(new List <string>());
         }
     }
     catch
     {
         return(new List <string>());
     }
 }
Ejemplo n.º 7
0
 private void showReadOnly(string StatusPage)
 {
     using (InhToDoListDataContext dbc = new InhToDoListDataContext())
     {
         var objpolicy = (from t1 in dbc.mst_user_logins
                          where t1.mul_user_login == Constant.CurrentUserLogin &&
                          t1.mst_user_type.mut_code == StatusPage
                          select t1);
         if (objpolicy.Count() > 0)
         {
             var currentuser = objpolicy.FirstOrDefault();
             if (currentuser.mul_permit == 'W')
             {
                 btnEdit.Visible = true;
             }
         }
         else
         {
             if (Constant.CurrentUserLogin == "Admin")
             {
                 return;
             }
         }
     }
 }
Ejemplo n.º 8
0
 public static List <string> AutoCompletePayor(string txt)
 {
     try
     {
         string strSearch = txt.Trim().ToLower();
         if (strSearch.Length >= 2)
         {
             using (InhToDoListDataContext dbc = new InhToDoListDataContext())
             {
                 List <string> result = dbc.mst_payors
                                        .Where(x => x.msp_name.ToLower().Contains(strSearch))
                                        .Select(x => x.msp_name).Distinct().ToList();
                 //List<string> result = (from msp in dbc.mst_payors
                 //                       where msp.msp_name.ToLower().Contains(txt.ToLower())
                 //                       select msp.msp_name).ToList();
                 return(result);
             }
         }
         else
         {
             return(new List <string>());
         }
     }
     catch
     {
         return(new List <string>());
     }
 }
Ejemplo n.º 9
0
        public static List <mst_checkup_location> getListHpcSite()
        {
            List <mst_checkup_location> site = new List <mst_checkup_location>();
            InhToDoListDataContext      tdc  = new InhToDoListDataContext();

            site = tdc.mst_checkup_locations.ToList();
            return(site);
        }
Ejemplo n.º 10
0
        public List <string> AutoCompleteCompanyCode(string txt)
        {
            InhToDoListDataContext tdc   = new InhToDoListDataContext();
            List <string>          payor = (from msc  in tdc.mst_companies
                                            where msc.mco_code.Contains(txt)
                                            select msc.mco_code).ToList();

            return(payor);
        }
Ejemplo n.º 11
0
        public List <string> AutoCompletePayor(string txt)
        {
            InhToDoListDataContext tdc   = new InhToDoListDataContext();
            List <string>          payor = (from msp in tdc.mst_payors
                                            where msp.msp_name.ToLower().Contains(txt.ToLower())
                                            select msp.msp_name).ToList();

            return(payor);
        }
Ejemplo n.º 12
0
 public static DateTime GetServerDateTime()
 {
     using (InhToDoListDataContext dbc = new InhToDoListDataContext())
     {
         //var EnCulture = CultureInfo.CreateSpecificCulture("en-US");
         DateTime nowdatetime = dbc.ExecuteQuery <DateTime>("select GetDate()").FirstOrDefault();//.ToString(EnCulture));
         return(nowdatetime);
     }
 }
Ejemplo n.º 13
0
 public trn_company_detail getCompanyDetail(string code)
 {
     using (InhToDoListDataContext tdc = new InhToDoListDataContext())
     {
         trn_company_detail tcd = tdc.trn_company_details
                                  .Where(x => x.tcd_code == code)
                                  .OrderByDescending(x => x.tcd_create_date).FirstOrDefault();
         return(tcd);
     }
 }
Ejemplo n.º 14
0
 public List <string> getListDep(string code)
 {
     using (InhToDoListDataContext tdc = new InhToDoListDataContext())
     {
         int tcd_id = tdc.trn_company_details
                      .Where(x => x.tcd_code == code)
                      .OrderByDescending(x => x.tcd_create_date)
                      .Select(x => x.tcd_id).FirstOrDefault();
         List <string> tmp = tdc.trn_name_checks
                             .Where(x => x.tcd_id == tcd_id)
                             .OrderBy(x => x.tnc_department)
                             .Select(x => x.tnc_department).Distinct().ToList();
         tmp.Insert(0, "");
         return(tmp);
     }
 }
Ejemplo n.º 15
0
 public trn_name_check getNameCheck(string hn_no)
 {
     using (InhCheckupDataContext cdc = new InhCheckupDataContext())
     {
         trn_patient tpt = cdc.trn_patients.Where(x => x.tpt_hn_no == hn_no).FirstOrDefault();
         if (tpt != null)
         {
             using (InhToDoListDataContext tdc = new InhToDoListDataContext())
             {
                 trn_name_check tnc = tdc.trn_name_checks.Where(x => x.tnc_fname == tpt.tpt_first_name && x.tnc_lname == tpt.tpt_last_name).OrderByDescending(x => x.tnc_create_date).FirstOrDefault();
                 return(tnc);
             }
         }
     }
     return(null);
 }
Ejemplo n.º 16
0
 public List <ObjCompany> getListCompany()
 {
     using (InhToDoListDataContext tdc = new InhToDoListDataContext())
     {
         List <ObjCompany> obj = tdc.sp_get_company()
                                 .Select(x => new ObjCompany
         {
             code = x.tcd_code,
             name = x.tcd_tname
         }).ToList();
         obj.Insert(0, new ObjCompany {
             code = "", name = ""
         });
         return(obj);
     }
 }
Ejemplo n.º 17
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (InhToDoListDataContext dbc = new InhToDoListDataContext())
     {
         var objcurrentuser = (from t1 in dbc.mst_user_logins
                               where t1.mul_user_login == Constant.CurrentUserLogin
                               select t1).FirstOrDefault();
         if (objcurrentuser != null)
         {
             //Convert1.ToString(objcurrentuser.mul_lname)
             lbllogin_detail.Text = String.Format(Convert1.ToString(objcurrentuser.mul_fname) +
                                                  " " + Constant.CurrentUserLoginName +
                                                  " : เข้าสู่ระบบเมื่อ {0:dd/MM/yyyy HH:mm}", DateTime.Now);
         }
     }
 }
Ejemplo n.º 18
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            txtSearch.Text       = txtSearch.Text.Trim();
            txtUserLogin.Enabled = true;
            string strsearch = txtSearch.Text.ToLower();

            //_UserList = new List<Viewuserlogin>();
            using (InhToDoListDataContext dbc = new InhToDoListDataContext())
            {
                //แสดง file ที่มีการ upload ไปแล้ว
                _UserList = (from t1 in dbc.mst_user_logins
                             where t1.mul_user_login != "Admin" &&
                             (t1.mul_user_login.ToLower().Contains(strsearch) ||
                              t1.mul_fname.ToLower().Contains(strsearch) ||
                              t1.mul_lname.ToLower().Contains(strsearch) ||
                              (t1.mul_fname + " " + t1.mul_lname).ToLower().Contains(strsearch)
                             )
                             select new Viewuserlogin
                {
                    Userlogin = t1.mul_user_login,
                    FirstName = t1.mul_fname,
                    Lastname = t1.mul_lname,
                    FullName = Constant.MargeString(t1.mul_fname, t1.mul_lname, " "),
                    Market = (t1.mut_id == 1) ? true : false,
                    HPC = (t1.mut_id == 2) ? true : false,
                    Collection = (t1.mut_id == 3) ? true : false,
                    ContactCenter = (t1.mut_id == 4) ? true : false,
                    IsEdit = t1.mul_permit.ToString().Trim(),
                    IsActive = (t1.mut_status != null && t1.mut_status == 'A') ? true : false,
                    Status = "O"
                }).ToList();
                //if (strsearch != null)
                //{
                //    _UserList = _UserList.Where(x => x.Userlogin.ToLower().Contains(strsearch)
                //                || x.FirstName.ToLower().Contains(strsearch)
                //                || x.Lastname.ToLower().Contains(strsearch)
                //                || x.FullName.ToLower().Contains(strsearch)).ToList();
                //}
                showGridUser();
            }
            lbmsgAlert.Text    = "";
            lbmsgAlertAdd.Text = "";
        }
Ejemplo n.º 19
0
        public static void addListSiteToControl(DropDownList dropDown)
        {
            InhToDoListDataContext tdc = new InhToDoListDataContext();
            var dataobj = (from s in tdc.mst_checkup_locations.ToList()
                           where s.mcl_status == 'A'
                           select new DropdowData
            {
                code = s.mcl_id,
                name = MargeString(s.mcl_tname, s.mcl_ename)
            }).ToList();
            DropdowData newitem = new DropdowData();

            newitem.code = 0;
            newitem.name = String.Empty;
            dataobj.Insert(0, newitem);
            dropDown.DataSource     = dataobj;
            dropDown.DataValueField = "code";
            dropDown.DataTextField  = "name";
            dropDown.DataBind();
        }
Ejemplo n.º 20
0
        public static void addListDocCateToControl(DropDownList dropDown)
        {
            InhToDoListDataContext tdc = new InhToDoListDataContext();
            var dataobj = (from s in tdc.mst_doctor_cats.ToList()
                           where s.mdc_status == 'A'
                           select new DropdowData
            {
                code = s.mdc_id,
                name = s.mdc_ename
            }).ToList();

            DropdowData newitem = new DropdowData();

            newitem.code = 0;
            newitem.name = String.Empty;
            dataobj.Insert(0, newitem);
            dropDown.DataSource     = dataobj;
            dropDown.DataValueField = "code";
            dropDown.DataTextField  = "name";
            dropDown.DataBind();
        }
Ejemplo n.º 21
0
        private bool Login1(string strUsername, string strPassword)
        {
            Service.WS_TrakcareCls ws = new Service.WS_TrakcareCls();
            DataTable dt = ws.LogonTrakcare(strUsername, strPassword);

            if (dt.Rows.Count > 0)
            {
                using (InhToDoListDataContext dbc = new InhToDoListDataContext())
                {
                    var objcurrentuser = (from t1 in dbc.mst_user_logins
                                          where t1.mul_user_login == strUsername
                                          select t1).FirstOrDefault();
                    if (objcurrentuser != null && (objcurrentuser.mul_user_login == "Admin" && strPassword == "nimd@"))
                    {
                        Constant.CurrentUserLogin = strUsername;
                        return(true);
                    }
                    else
                    {
                        Constant.CurrentUserLogin = "";
                        return(false);
                    }
                }
            }
            else
            {
                if (strUsername == "Admin" && strPassword == "nimd@")
                {
                    Constant.CurrentUserLogin = strUsername;
                    return(true);
                }
                else
                {
                    Constant.CurrentUserLogin = "";
                    return(false);
                }
            }
        }
Ejemplo n.º 22
0
        public List <CompResult> GetListComp(DateTime dateArrived)
        {
            using (InhToDoListDataContext tdc = new InhToDoListDataContext())
            {
                var clist = tdc.GetCompByArrived(dateArrived)
                            .Select(x => new CompResult
                {
                    tcd_id  = x.tcd_id,
                    doc_no  = x.tcd_document_no,
                    comName = x.tcd_tname
                }).ToList();

                //var clist = tdc.test_document_nos
                //               .Where(x => x.tcd_date_from.Value.Date <= dateArrived.Date &&
                //                           x.tcd_date_to.Value.Date >= dateArrived.Date)
                //               .Select(x => new CompResult
                //               {
                //                   doc_no = x.tcd_document_no,
                //                   comName = x.tcd_tname
                //               }).OrderBy(x => x.comName).ToList();
                return(clist);
            }
        }
Ejemplo n.º 23
0
        protected void btnsubmit_Click(object sender, ImageClickEventArgs e)
        {
            if (txtUser.Text == "" || txtpass.Text == "")
            {
                lbalertmsg.Text = "input UserName & Password try again";
                txtUser.Focus();
                return;
            }
            if (Login1(txtUser.Text.Trim(), txtpass.Text.Trim()))
            {
                //Defualt Page Current
                using (InhToDoListDataContext dbc = new InhToDoListDataContext())
                {
                    var objpolicy = (from t1 in dbc.mst_user_logins
                                     where t1.mul_user_login == Constant.CurrentUserLogin
                                     select t1).FirstOrDefault();
                    if (objpolicy != null)
                    {
                        Constant.CurrentPageLogin = objpolicy.mul_user_login;
                    }
                }

                switch (Constant.CurrentPageLogin)
                {
                case "Admin":
                    Response.Redirect(this.Page.ResolveClientUrl("~/BackOffice/AdminControlPage.aspx"));
                    break;
                }
            }
            else
            {
                lbalertmsg.Text = "UserName & Password incorrect. Please try again";
                txtUser.Text    = "";
                txtpass.Text    = "";
                txtUser.Focus();
            }
        }
Ejemplo n.º 24
0
        public static List <fileclass> GetObjAttachFile(int tcd_id, string site)
        {
            using (InhToDoListDataContext dbc = new InhToDoListDataContext())
            {
                //List<fileclass> objattachfile = (from file in dbc.trn_attach_files
                //                                 where file.mst_user_type.mut_code == site
                //                                 && file.mst_path_file.tcd_id == tcd_id
                //                                 select new fileclass
                //                                 {
                //                                     file_name = file.mst_path_file.mpf_file_name,
                //                                     file_path = Constant.HttpUrl + file.mst_path_file.mpf_path_name
                //                                 }).ToList();

                List <fileclass> objattachfile = (from t1 in dbc.mst_path_files
                                                  where t1.tcd_id == tcd_id && t1.trn_attach_files.Where(x => x.mst_user_type.mut_code == site).Count() > 0
                                                  select new fileclass
                {
                    file_name = t1.mpf_file_name,
                    file_path = Constant.HttpUrl + t1.mpf_path_name,
                }).ToList();

                return(objattachfile);
            }
        }
Ejemplo n.º 25
0
 private void IsLoginBackOffice()
 {
     if (Constant.CurrentUserLogin != "")
     {//ถ้ายังไม่ได้ login ให้ ไปหน้า login
         using (InhToDoListDataContext dbc = new InhToDoListDataContext())
         {
             var objpolicy = (from t1 in dbc.mst_user_logins
                              where t1.mul_user_login == Constant.CurrentUserLogin
                              select t1).Count();
             if (objpolicy == 1 && Constant.CurrentUserLogin == "Admin")
             {
                 return;
             }
             else
             {
                 HttpContext.Current.Response.Redirect("BOLogin.aspx");
             }
         }
     }
     else
     {
         HttpContext.Current.Response.Redirect("BOLogin.aspx");
     }
 }
Ejemplo n.º 26
0
        public static List <string> GetMasterCompanyList(string cname)
        {
            try
            {
                string strSearch = cname.Trim().ToLower();
                if (strSearch.Length >= 2)
                {
                    using (InhToDoListDataContext dbc = new InhToDoListDataContext())
                    {
                        List <string> result = dbc.mst_companies
                                               .Where(x => x.mco_tname.ToLower().Contains(strSearch) ||
                                                      x.mco_ename.ToLower().Contains(strSearch))
                                               .Select(x => x.mco_tname).Distinct().ToList();
                        //List<string> result = new List<string>();
                        //var objcomp = (from comp in dbc.mst_companies
                        //               where comp.mco_tname.ToLower().Contains(cname.ToLower()) ||
                        //                  comp.mco_ename.ToLower().Contains(cname.ToLower())
                        //               select new { cname = comp.mco_tname }).ToList();

                        //foreach (var data in objcomp)
                        //{
                        //    result.Add(data.cname.ToString());
                        //}
                        return(result);
                    }
                }
                else
                {
                    return(new List <string>());
                }
            }
            catch
            {
                return(new List <string>());
            }
        }
Ejemplo n.º 27
0
        private void _book_cover_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "tpbc_patient_type")
            {
                if (_book_cover != null)
                {
                    if (_book_cover.tpbc_patient_type == "G")
                    {
                        _book_cover.tpbc_emp_id        = "";
                        _book_cover.tcd_document_no    = "";
                        _book_cover.tpbc_position      = "";
                        _book_cover.tpbc_department    = "";
                        autoCompleteComName.DataSource = null;
                        autoCompleteComName.ReadOnly   = true;
                        txtEmpID.ReadOnly    = true;
                        txtPosition.ReadOnly = true;
                        txtDepart.ReadOnly   = true;
                    }
                    else if (_book_cover.tpbc_patient_type == "C")
                    {
                        using (InhToDoListDataContext tdc = new InhToDoListDataContext())
                        {
                            DateTime dateArrived = _book_cover.trn_patient_regi.trn_patient_regis_detail.tpr_real_arrived_date.Value;

                            var clist = new Class.CompanyCls().GetListComp(dateArrived);
                            autoCompleteComName.DataSource    = clist;
                            autoCompleteComName.DisplayMember = "comName";
                            autoCompleteComName.ValueMember   = "doc_no";

                            if (string.IsNullOrEmpty(_book_cover.tcd_document_no))
                            {
                                var list_tcd = clist.Select(x => x.doc_no).ToList();
                                var res      = new Class.CompanyCls().MappingPatient(_book_cover.tpr_id, list_tcd);
                                _book_cover.tcd_document_no = res.document_no;
                                if (string.IsNullOrEmpty(_book_cover.tpbc_emp_id))
                                {
                                    _book_cover.tpbc_emp_id = res.emp_id;
                                }
                                if (string.IsNullOrEmpty(_book_cover.tpbc_position))
                                {
                                    _book_cover.tpbc_position = res.position;
                                }
                                if (string.IsNullOrEmpty(_book_cover.tpbc_department))
                                {
                                    _book_cover.tpbc_department = res.department;
                                }
                                //var list_tcd = clist.Select(x => x.tcd_id).ToList();
                                //var pers_id = _book_cover.trn_patient_regi.trn_patient.tpt_id_card;
                                //string doc_no = null;
                                //string emp_id = null;
                                //if (!string.IsNullOrEmpty(pers_id) && !string.IsNullOrEmpty(pers_id.Trim()))
                                //{
                                //    var person = tdc.trn_name_checks
                                //                    .Where(x => list_tcd.Contains(x.tcd_id) &&
                                //                                x.tnc_personal_id == pers_id)
                                //                    .Select(x => new
                                //                    {
                                //                        doc_no = x.trn_company_detail.tcd_document_no,
                                //                        emp_id = x.tnc_emp_id
                                //                    }).FirstOrDefault();
                                //    if (person != null)
                                //    {
                                //        doc_no = person.doc_no;
                                //        emp_id = person.emp_id;
                                //    }
                                //}

                                //if (doc_no == null)
                                //{
                                //    var fname = _book_cover.trn_patient_regi.trn_patient.tpt_first_name;
                                //    var lname = _book_cover.trn_patient_regi.trn_patient.tpt_last_name;
                                //    var person = tdc.trn_name_checks
                                //                .Where(x => list_tcd.Contains(x.tcd_id) &&
                                //                            x.tnc_fname == fname &&
                                //                            x.tnc_lname == lname)
                                //                .Select(x => new
                                //                {
                                //                    doc_no = x.trn_company_detail.tcd_document_no,
                                //                    emp_id = x.tnc_emp_id
                                //                }).FirstOrDefault();
                                //    if (person != null)
                                //    {
                                //        doc_no = person.doc_no;
                                //        emp_id = person.emp_id;
                                //    }
                                //}

                                //if (doc_no != null)
                                //{
                                //    _book_cover.tcd_document_no = doc_no;
                                //    _book_cover.tpbc_emp_id = emp_id;
                                //}
                            }
                        }
                        autoCompleteComName.ReadOnly = false;
                        txtEmpID.ReadOnly            = false;
                        txtPosition.ReadOnly         = false;
                        txtDepart.ReadOnly           = false;
                    }
                }
            }
            else if (e.PropertyName == "tpbc_cover_lang")
            {
                if (_book_cover != null)
                {
                    if (_book_cover.tpbc_cover_lang == "TH")
                    {
                        _book_cover.tpbc_patient_name = Address.nameTH;
                    }
                    else if (_book_cover.tpbc_cover_lang == "EN")
                    {
                        _book_cover.tpbc_patient_name = Address.nameEN;
                    }
                }
            }
            else if (e.PropertyName == "tpbc_address")
            {
                if (_book_cover != null)
                {
                    if (_book_cover.tpbc_address == "H")
                    {
                        txtAddress.ReadOnly = true;
                        var addHome = Address.listAddress.Where(x => x.type == "H").FirstOrDefault();
                        _book_cover.tpbc_patient_address = addHome.address;
                    }
                    else if (_book_cover.tpbc_address == "C")
                    {
                        txtAddress.ReadOnly = true;
                        var addCom = Address.listAddress.Where(x => x.type == "C").FirstOrDefault();
                        _book_cover.tpbc_patient_address = addCom.address;
                    }
                    else if (_book_cover.tpbc_address == "O")
                    {
                        txtAddress.ReadOnly = false;
                    }
                }
            }
            else if (e.PropertyName == "tcd_document_no")
            {
                if (_book_cover != null)
                {
                    if (string.IsNullOrEmpty(_book_cover.tcd_document_no))
                    {
                        _book_cover.tcd_document_no = "";
                        //_book_cover.tpbc_emp_id = ""; //--  Still  Staff id


                        var addCom = Address.listAddress.Where(x => x.type == "C").FirstOrDefault();

                        addCom.contactPerson = "";
                        addCom.address       = "";
                        addCom.phone         = "";
                        addCom.fax           = "";
                    }
                    else
                    {
                        using (InhToDoListDataContext tdc = new InhToDoListDataContext())
                        {
                            var com = tdc.trn_company_details
                                      .Where(x => x.tcd_document_no == _book_cover.tcd_document_no)
                                      .OrderByDescending(x => x.tcd_create_date)
                                      .Select(x => new
                            {
                                tcd_id      = x.tcd_id,
                                contacts    = x.trn_contact_persons,
                                adress      = x.tcd_address == null ? "" : x.tcd_address.Trim(),
                                subArea     = x.tcd_tambon == null ? "" : x.tcd_tambon.Trim(),
                                area        = x.tcd_district == null ? "" : x.tcd_district.Trim(),
                                province    = x.tcd_province == null ? "" : x.tcd_province.Trim(),
                                postal      = x.tcd_postcode == null ? "" : x.tcd_postcode.Trim(),
                                phone       = x.tcd_tel == null ? "" : x.tcd_tel.Trim(),
                                fax         = x.tcd_fax == null ? "" : x.tcd_fax.Trim(),
                                sendRptMst  = x.tcd_send_rep_real == "Y" ? "E" : x.tcd_send_rep_flag,
                                sendRptCopy = x.tcd_send_rep_copy,
                                legel       = x.tcd_legal
                            }).FirstOrDefault();
                            var addCom = Address.listAddress.Where(x => x.type == "C").FirstOrDefault();
                            addCom.contactPerson = com.contacts.Select(x => x.tcp_name).FirstOrDefault();
                            addCom.address       = CheckAddress(new Models.AddressModels {
                                address = com.adress, subArea = com.subArea, area = com.area, province = com.province, postal = com.postal
                            });
                            addCom.phone = com.phone;
                            addCom.fax   = com.fax;
                            addCom.legel = com.legel;

                            Medical.Clear();
                            ClearMed();
                            Medical.rptMst  = com.sendRptMst;
                            Medical.rptCopy = com.sendRptCopy;
                            var rpt = tdc.trn_medical_reports
                                      .Where(x => x.tcd_id == com.tcd_id)
                                      .Select(x => new { x.mmr_id, x.tmr_rep_remark })
                                      .ToList();

                            foreach (var r in rpt)
                            {
                                switch (r.mmr_id)
                                {
                                case 1:
                                    checkBoxBinding1.Checked = true;
                                    break;

                                case 2:
                                    checkBoxBinding2.Checked = true;
                                    break;

                                case 3:
                                    checkBoxBinding3.Checked = true;
                                    break;

                                case 4:
                                    checkBoxBinding4.Checked = true;
                                    break;

                                case 5:
                                    checkBoxBinding6.Checked = true;
                                    break;

                                case 6:
                                    checkBoxBinding7.Checked = true;
                                    break;

                                case 7:
                                    checkBoxBinding5.Checked = true;
                                    Medical.remarkOther      = r.tmr_rep_remark;
                                    break;
                                }
                            }
                        }
                    }
                    AddressComBS.ResetCurrentItem();
                    MedReportBS.ResetCurrentItem();
                    _book_cover_PropertyChanged(_book_cover, new PropertyChangedEventArgs("tpbc_address"));
                }
            }
        }
Ejemplo n.º 28
0
        private void LoadCompany()
        {
            //var objcomp = (from comp in dbc.sp_search_company()
            //               where ChSearch.Checked == true ? (funcCls.GetServerDateTime().Date >= comp.tcd_date_from.Value.Date && funcCls.GetServerDateTime().Date <= comp.tcd_date_to.Value.Date) : (comp.tcd_date_from.Value.Date > funcCls.GetServerDateTime().Date && comp.tcd_date_to.Value.Date > funcCls.GetServerDateTime().Date) || (comp.tcd_date_to.Value.Date < funcCls.GetServerDateTime().Date)
            //               select comp).ToList();

            //if (Convert.ToInt16(DDLocation.SelectedIndex) != 0)
            //{
            //    //objcomp = objcomp.Where(c => c.tcd_id == LoadLocationId(Convert.ToInt16(DDLocation.SelectedValue))).ToList();
            //    List<int> tcdid = LoadLocationId(Convert.ToInt32(DDLocation.SelectedValue));
            //    objcomp = (from data in objcomp where tcdid.Contains(data.tcd_id) select data).ToList();
            //}

            //if (Convert.ToInt16(ddltypeofcomp.SelectedIndex) != 0)
            //{
            //    string typecode = ddltypeofcomp.Text;
            //    objcomp = (from data in objcomp where data.tcd_type.ToLower().Contains(typecode.ToLower()) select data).ToList();
            //    //objmstcomp.Where(c => c.tcd_type.ToLower() == typecode.ToLower()).ToList();
            //}


            //if (txtlegal.Text != String.Empty)
            //{
            //    objcomp = objcomp.Where(c => c.tcd_legal == txtlegal.Text).ToList();
            //}

            //if (txtsearch.Text != String.Empty)
            //{
            //    objcomp = objcomp.Where(c => c.tcd_tname.Contains(txtsearch.Text)).ToList();
            //}

            //if (Convert.ToInt16(DDType.SelectedIndex) != 0)
            //{
            //    using (InhToDoListDataContext tdc = new InhToDoListDataContext())
            //    {
            //        List<int?> new_tcd_id = (from tpm in tdc.trn_payments
            //                                 where tpm.mst_id == Convert.ToInt32(DDType.SelectedValue)
            //                                 select tpm.tcd_id).ToList();
            //        objcomp = objcomp.Where(x => new_tcd_id.Contains(x.tcd_id)).ToList();
            //    }
            //    //objcomp = objcomp.Where(c => c.mst_id == Convert.ToInt16(DDType.SelectedValue)).ToList();
            //}

            //if (txtstart.Text != String.Empty && txtEndDate.Text != String.Empty)
            //{
            //    objcomp = objcomp.Where(c => (c.tcd_date_from >= Constant.ConvertStringToDate(txtstart.Text)) && c.tcd_date_to <= Constant.ConvertStringToDate(txtEndDate.Text)).ToList();
            //}

            //var result = (from comp in objcomp
            //              select new
            //              {
            //                  tcd_id = comp.tcd_id,
            //                  tcd_tname = comp.tcd_tname,
            //                  tcd_document_no = comp.tcd_document_no,
            //                  tcd_date_from = comp.tcd_date_from,
            //                  tcd_date_to = comp.tcd_date_to,
            //                  status = LoadCheckCompanyMaster(comp.tcd_code),
            //                  mul_user_login = comp.mul_user_login
            //              });

            //RepeaterCompany.DataSource = result;
            //RepeaterCompany.DataBind();

            try
            {
                string   strSearch   = (string.IsNullOrEmpty(txtsearch.Text) ? "" : txtsearch.Text).Trim().ToLower();
                bool?    active      = ChSearch.Checked == true ? true : false;
                int      mcl_id      = Convert.ToInt32(DDLocation.SelectedValue);
                int      mst_id      = Convert.ToInt32(DDType.SelectedValue);
                DateTime?fromDate    = string.IsNullOrEmpty(txtstart.Text) ? (DateTime?)null : Constant.ConvertStringToDate(txtstart.Text);
                DateTime?endDate     = string.IsNullOrEmpty(txtEndDate.Text) ? (DateTime?)null : Constant.ConvertStringToDate(txtEndDate.Text);
                string   strTypeComp = ddltypeofcomp.Text;
                string   strLegal    = txtlegal.Text;

                using (InhToDoListDataContext context = new InhToDoListDataContext())
                {
                    var result = context.sp_search_company2(strSearch, active, mcl_id, mst_id, fromDate, endDate, strTypeComp, strLegal)
                                 .Select(x => new
                    {
                        tcd_id          = x.tcd_id,
                        tcd_tname       = x.tcd_tname,
                        tcd_document_no = x.tcd_document_no,
                        tcd_date_from   = x.tcd_date_from,
                        tcd_date_to     = x.tcd_date_to,
                        status          = LoadCheckCompanyMaster(x.tcd_code),
                        mul_user_login  = x.mul_user_login
                    }).ToList();

                    RepeaterCompany.DataSource = result;
                    RepeaterCompany.DataBind();
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 29
0
        //save final
        protected void btnSave_Click(object sender, EventArgs e)
        {
            lbmsgAlertAdd.Text = "";
            DateTime dtnow = funcCls.GetServerDateTime();

            for (int i = _UserList.Count - 1; i >= 0; i--)
            {
                if (_UserList[i].Status == "N")
                {
                    using (InhToDoListDataContext dbc = new InhToDoListDataContext())
                    {
                        mst_user_login newitem = new mst_user_login();
                        newitem.mul_user_login = _UserList[i].Userlogin;
                        newitem.mul_fname      = _UserList[i].FirstName;
                        newitem.mul_lname      = _UserList[i].Lastname;
                        if (_UserList[i].Market == true)
                        {
                            newitem.mut_id = 1;
                        }

                        if (_UserList[i].HPC == true)
                        {
                            newitem.mut_id = 2;
                        }

                        if (_UserList[i].Collection == true)
                        {
                            newitem.mut_id = 3;
                        }

                        if (_UserList[i].ContactCenter == true)
                        {
                            newitem.mut_id = 4;
                        }

                        newitem.mul_permit            = Convert1.ToChar(_UserList[i].IsEdit);
                        newitem.mut_status            = (_UserList[i].IsActive == true) ? 'A' : 'I';
                        newitem.mul_create_by         = Constant.CurrentUserLogin;
                        newitem.mul_create_date       = dtnow;
                        newitem.mul_user_login_update = Constant.CurrentUserLogin;
                        newitem.mul_update_date       = dtnow;
                        dbc.mst_user_logins.InsertOnSubmit(newitem);
                        dbc.SubmitChanges();
                        _UserList[i].Status = "O";
                    }
                }
                else if (_UserList[i].Status == "D")
                {
                    using (InhToDoListDataContext dbc = new InhToDoListDataContext())
                    {
                        var currentUser = (from t1 in dbc.mst_user_logins
                                           where t1.mul_user_login == _UserList[i].Userlogin
                                           select t1).FirstOrDefault();
                        if (currentUser != null)
                        {
                            dbc.mst_user_logins.DeleteOnSubmit(currentUser);
                        }
                        dbc.SubmitChanges();
                    }
                }
                else
                {
                    using (InhToDoListDataContext dbc = new InhToDoListDataContext())
                    {
                        var currentUser = (from t1 in dbc.mst_user_logins
                                           where t1.mul_user_login == _UserList[i].Userlogin
                                           select t1).FirstOrDefault();
                        if (currentUser != null)
                        {
                            currentUser.mul_permit     = Convert1.ToChar(_UserList[i].IsEdit);
                            currentUser.mul_user_login = _UserList[i].Userlogin;
                            currentUser.mul_fname      = _UserList[i].FirstName;
                            currentUser.mul_lname      = _UserList[i].Lastname;
                            if (_UserList[i].Market == true)
                            {
                                currentUser.mut_id = 1;
                            }

                            if (_UserList[i].HPC == true)
                            {
                                currentUser.mut_id = 2;
                            }

                            if (_UserList[i].Collection == true)
                            {
                                currentUser.mut_id = 3;
                            }

                            if (_UserList[i].ContactCenter == true)
                            {
                                currentUser.mut_id = 4;
                            }

                            currentUser.mut_status            = (_UserList[i].IsActive == true) ? 'A' : 'I';
                            currentUser.mul_user_login_update = Constant.CurrentUserLogin;
                            currentUser.mul_update_date       = dtnow;
                            dbc.SubmitChanges();
                        }
                    }
                }
            }//end for each

            lbmsgAlert.Text = "Save data completed.";
        }
Ejemplo n.º 30
0
        //Add Userlogin
        protected void btnAddnew_Click(object sender, EventArgs e)
        {
            lbmsgAlertAdd.Text = "";
            if (txtUserLogin.Text == "" || txtFirstName.Text == "" || txtLastName.Text == "")
            {
                lbmsgAlertAdd.Text = "Please input Username, FirstName or LastName.";
                return;
            }

            string userlo = txtUserLogin.Text.Trim();
            string fname  = txtFirstName.Text.Trim();
            string lname  = txtLastName.Text.Trim();

            if (btnAddnew.Text == "Add")
            {
                //Check UserLogin ซ้ำในtemp
                using (InhToDoListDataContext dbc = new InhToDoListDataContext())
                {
                    var objuser = (from t1 in dbc.mst_user_logins
                                   where t1.mul_user_login.ToLower() == userlo.ToLower()
                                   select t1).Count();
                    if (objuser > 0)
                    {
                        lbmsgAlertAdd.Text = "User login had in system. please change user login.";
                        txtUserLogin.Text  = "";
                        return;
                    }
                }

                Viewuserlogin newitem = new Viewuserlogin();
                newitem.Userlogin     = txtUserLogin.Text;
                newitem.FirstName     = txtFirstName.Text;
                newitem.Lastname      = txtLastName.Text;
                newitem.IsActive      = chActive.Checked;
                newitem.Market        = false;
                newitem.HPC           = false;
                newitem.Collection    = false;
                newitem.ContactCenter = false;
                newitem.Status        = "N";
                if (RDDepartment.SelectedValue != null)
                {
                    var departmentvalue = RDDepartment.SelectedValue;
                    if (departmentvalue == "1")
                    {
                        newitem.Market = true;
                    }

                    if (departmentvalue == "2")
                    {
                        newitem.HPC = true;
                    }

                    if (departmentvalue == "3")
                    {
                        newitem.Collection = true;
                    }

                    if (departmentvalue == "4")
                    {
                        newitem.ContactCenter = true;
                    }
                }
                newitem.IsEdit = RDPolicyEdit.SelectedValue;
                _UserList.Add(newitem);
            }

            else if (btnAddnew.Text == "SAVE")
            {
                var objcurrent = (from t1 in _UserList
                                  where t1.Userlogin.ToLower() == txtUserLogin.Text.ToLower()
                                  select t1).FirstOrDefault();

                if (objcurrent != null)
                {
                    objcurrent.FirstName     = txtFirstName.Text;
                    objcurrent.Lastname      = txtLastName.Text;
                    objcurrent.IsActive      = chActive.Checked;
                    objcurrent.Market        = false;
                    objcurrent.HPC           = false;
                    objcurrent.Collection    = false;
                    objcurrent.ContactCenter = false;
                    objcurrent.IsEdit        = RDPolicyEdit.SelectedValue;
                    string st = objcurrent.Status;
                    if (st == "N")
                    { //แก้รายการที่เพิ่ง insert ไป แต่ ยังไม่ได้ Save
                        objcurrent.Status = "N";
                    }
                    else
                    {
                        objcurrent.Status = "E";
                    }
                    if (RDDepartment.SelectedValue != null)
                    {
                        var departmentvalue = RDDepartment.SelectedValue;
                        if (departmentvalue == "1")
                        {
                            objcurrent.Market = true;
                        }

                        if (departmentvalue == "2")
                        {
                            objcurrent.HPC = true;
                        }

                        if (departmentvalue == "3")
                        {
                            objcurrent.Collection = true;
                        }

                        if (departmentvalue == "4")
                        {
                            objcurrent.ContactCenter = true;
                        }
                    }
                    txtUserLogin.Enabled = true;
                    btnAddnew.Text       = "Add";
                }
            }
            showGridUser();

            //clear text
            txtFirstName.Text = "";
            txtLastName.Text  = "";
            txtUserLogin.Text = "";
            RDDepartment.ClearSelection();
            RDPolicyEdit.ClearSelection();
            chActive.Checked = false;
        }