コード例 #1
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();
                        }
                    }
                }
            }
        }
コード例 #2
0
 private void InsertPayor()
 {
     try
     {
         DataTable newtable = new DataTable();
         newtable = ListPayor();
         string message = string.Empty;
         if (newtable.Rows.Count > 0)
         {
             for (int i = 0; i <= newtable.Rows.Count - 1; i++)
             {
                 int countItem = (from t in dbc.mst_payors where t.msp_code.ToString() == newtable.Rows[i]["Code"].ToString() select t.msp_code).Count();
                 message = "Code :" + newtable.Rows[i]["Code"].ToString() + " :" + " Name :" + newtable.Rows[i]["Name"].ToString();
                 if (countItem == 0)
                 {
                     mst_payor objpayor = new mst_payor
                     {
                         msp_code        = newtable.Rows[i]["Code"].ToString(),
                         msp_name        = newtable.Rows[i]["Name"].ToString(),
                         msp_create_by   = "System",
                         msp_create_date = funcCls.GetServerDateTime(),
                         mul_user_login  = "******",
                         msp_update_date = funcCls.GetServerDateTime()
                     };
                     dbc.mst_payors.InsertOnSubmit(objpayor);
                     dbc.SubmitChanges();
                     isSuccess = true;
                 }
                 if (isSuccess == true)
                 {
                     WriteToLog(message + ":::" + "Completed >>> Insert to mst_payor");
                 }
                 else
                 {
                     WriteToLog(message + ":::" + "Failed >>> Duplicate Data");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         // throw new Exception(ex.Message);
         WriteToLog(ex.Message);
     }
 }
コード例 #3
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.";
        }
コード例 #4
0
        private void saveType(char strType)
        {
            if (txtcompany_code.Text == String.Empty)
            {
                lblStatus.Text    = "กรุณากรอกรหัสบริษัท.";
                lblStatus.Visible = true;
                lblStatus.Focus();
                return;
            }

            if (txtname_th.Text == String.Empty || txtname_en.Text == String.Empty)
            {
                lblStatus.Text    = "กรุณากรอกชื่อบริษัท(th/en).";
                lblStatus.Visible = true;
                lblStatus.Focus();
                return;
            }

            if (txtaddress.Text.Length > 199)
            {
                lblStatus.Text    = "Address เกิน 200 ตัวอักษร.";
                lblStatus.Visible = true;
                lblStatus.Focus();
                return;
            }

            var objcomp = (from comp in dbc.mst_companies where comp.mco_id == Convert.ToInt16(HiddenField_mcoid.Value) select comp).FirstOrDefault();

            if (HiddenFieldStatus.Value == "Add")
            {
                var objcheck = (from comp in dbc.mst_companies select comp).ToList();

                if (objcheck != null)
                {
                    int count_comp = objcheck.Where(x => x.mco_tname == txtname_th.Text || x.mco_ename == txtname_en.Text).Count();
                    if (count_comp > 0)
                    {
                        lblStatus.Focus();
                        lblStatus.Text    = "ชื่อนี้มีการใช้งานแล้ว.";
                        lblStatus.Visible = true;
                        return;
                    }

                    int count_code = objcheck.Where(x => x.mco_code == txtcompany_code.Text).Count();
                    if (count_code > 0)
                    {
                        lblStatus.Focus();
                        lblStatus.Text    = "รหัสนี้มีการใช้งานแล้ว.";
                        lblStatus.Visible = true;
                        return;
                    }
                }
            }
            if (objcomp != null)
            {
                objcomp.mco_code        = txtcompany_code.Text;
                objcomp.mco_tname       = txtname_th.Text;
                objcomp.mco_ename       = txtname_en.Text;
                objcomp.mco_legal       = txtlegal.Text;
                objcomp.mco_type        = rdona.Checked == true ? rdona.Text : rdojms.Text;
                objcomp.mco_address     = txtaddress.Text;
                objcomp.mco_district    = txtdistrict.Text;
                objcomp.mco_tambon      = txtsubdistrict.Text;
                objcomp.mco_province    = txtprovince.Text;
                objcomp.mco_postcode    = txtpostcode.Text;
                objcomp.mco_tel         = txttelephone.Text;
                objcomp.mco_fax         = txtfax.Text;
                objcomp.mco_email       = txtemail.Text;
                objcomp.mco_update_date = funcCls.GetServerDateTime();
                objcomp.mco_status      = rdoactive.Checked == true ? 'A' : 'I';
                isSuccess = true;
            }
            else
            {
                //Add New Transaction
                mst_company objinscomp = new mst_company {
                    mco_code        = txtcompany_code.Text,
                    mco_tname       = txtname_th.Text,
                    mco_ename       = txtname_en.Text,
                    mco_legal       = txtlegal.Text,
                    mco_type        = rdona.Checked == true ? rdona.Text : rdojms.Text,
                    mco_address     = txtaddress.Text,
                    mco_district    = txtdistrict.Text,
                    mco_tambon      = txtsubdistrict.Text,
                    mco_province    = txtprovince.Text,
                    mco_postcode    = txtpostcode.Text,
                    mco_tel         = txttelephone.Text,
                    mco_fax         = txtfax.Text,
                    mco_email       = txtemail.Text,
                    mco_create_by   = Constant.CurrentUserLogin,
                    mco_create_date = funcCls.GetServerDateTime(),
                    mco_status      = rdoactive.Checked == true ? 'A' : 'I'
                };
                dbc.mst_companies.InsertOnSubmit(objinscomp);
                objcomp   = objinscomp;
                isSuccess = true;
            }

            if (isSuccess == true)
            {
                //Save Company Success give Select tcd_id

                foreach (var deldata in _objdelcontact)
                {
                    var objdelmcp = (from data in dbc.mst_contact_persons where data.mco_id.Equals(HiddenField_mcoid.Value) && data.mcp_id.Equals(deldata.contact_id) select data).FirstOrDefault();
                    if (objdelmcp != null)
                    {
                        dbc.mst_contact_persons.DeleteOnSubmit(objdelmcp);
                    }
                }

                foreach (var objdata in _objaddcontact)
                {
                    var objmcp = (from data in dbc.mst_contact_persons where data.mco_id.Equals(HiddenField_mcoid.Value) && data.mcp_id.Equals(objdata.contact_id) select data).FirstOrDefault();

                    if (objmcp != null)
                    {
                        objmcp.mco_id          = objcomp.mco_id;
                        objmcp.mco_code        = txtcompany_code.Text;
                        objmcp.mcp_name        = objdata.contact_name;
                        objmcp.mcp_tel         = objdata.contact_tel;
                        objmcp.mcp_fax         = objdata.contact_fax;
                        objmcp.mcp_email       = objdata.contact_email;
                        objmcp.mct_id          = objdata.contact_type_id;
                        objmcp.mst_id          = objdata.type_id;
                        objmcp.mcp_status      = 'A';
                        objmcp.mcp_update_date = funcCls.GetServerDateTime();
                        objmcp.mul_user_login  = Constant.CurrentUserLogin;
                    }
                    else
                    {
                        mst_contact_person objins = new mst_contact_person
                        {
                            mco_id          = objcomp.mco_id,
                            mco_code        = txtcompany_code.Text,
                            mcp_name        = objdata.contact_name,
                            mcp_tel         = objdata.contact_tel,
                            mcp_fax         = objdata.contact_fax,
                            mcp_email       = objdata.contact_email,
                            mct_id          = objdata.contact_type_id,
                            mst_id          = objdata.type_id,
                            mcp_status      = 'A',
                            mcp_create_by   = Constant.CurrentUserLogin,
                            mcp_create_date = funcCls.GetServerDateTime(),
                            mcp_update_date = funcCls.GetServerDateTime(),
                            mul_user_login  = Constant.CurrentUserLogin
                        };
                        objcomp.mst_contact_persons.Add(objins);
                    }
                }

                dbc.SubmitChanges();
                lblStatus.Visible = true;
                lblStatus.Focus();
                lblStatus.Text = "Save Complete. Please wait ....";
                lblStatus.Focus();
                if (strType == 'S')
                {
                    this.ClearContent();
                }
                else if (strType == 'D')
                {
                    var tcd_id = (from t1 in dbc.trn_company_details where t1.tcd_code.Equals(txtcompany_code.Text) select t1.tcd_id).FirstOrDefault();
                    Response.Redirect("frmmktNew.aspx?id=" + tcd_id + "&code=" + txtcompany_code.Text);
                }

                TimerProgressWait.Enabled = true;
            }
        }