Exemplo n.º 1
0
        private void btnEditPrice_Click(object sender, EventArgs e)
        {
            DialogResult res = InputBox.ShowDialog("กรุณาใส่รหัสเพื่อแก้ไขราคาสินค้า:",
                                                   "Authentication",                                                        //Text message (mandatory), Title (optional)
                                                   InputBox.Icon.Exclamation,                                               //Set icon type (default info)
                                                   InputBox.Buttons.OkCancel,                                               //Set buttons (default ok)
                                                   InputBox.Type.TextBoxPassword,                                           //Set type (default nothing)
                                                   new string[] { "Item1", "Item2", "Item3" },                              //String field as ComboBox items (default null)
                                                   true,                                                                    //Set visible in taskbar (default false)
                                                   new System.Drawing.Font("Calibri", 10F, System.Drawing.FontStyle.Bold)); //Set font (default by system)

            if (res == System.Windows.Forms.DialogResult.OK || res == System.Windows.Forms.DialogResult.Yes)
            {
                using (OrderEntities db = new OrderEntities())
                {
                    string passwd = InputBox.ResultValue != "" ? HelperCS.Encrypt(InputBox.ResultValue) : ""; //InputBox.ResultValue = textbox form dialogresult
                    int    rownum = db.Login.Where(a => a.UserName == "PRICE" && a.Password == passwd).Count();
                    if (rownum > 0)
                    {
                        log.Info("OrderUC:Edit Price user:"******" customerid:" + ComboOrderCustomer.SelectedItem.ToString() + " day:" + HelperCS.daycheckbox.ToString());
                        HelperCS.editprice = true;
                        CheckTabActive();
                    }
                    else
                    {
                        log.Error("OrderUC:Edit Price Error user:"******" customerid:" + ComboOrderCustomer.SelectedItem.ToString() + " day:" + HelperCS.daycheckbox.ToString());
                        Form frm = btnEditPrice.FindForm();
                        MessageBox.Show(frm, "คุณไม่มีสิทธิ์แก้ไขข้อมูล ", "Authorization Problem", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void btnSubmitLogin_Click(object sender, EventArgs e)
        {
            using (OrderEntities db = new OrderEntities())
            {
                string passwd = txtPassword.Text != "" ? HelperCS.Encrypt(txtPassword.Text) : "";
                string usr    = txtUserName.Text != "" ? txtUserName.Text.ToUpper() : "";

                rownum = db.Login.Where(a => a.UserName == usr && a.Password == passwd).Count();
                if (rownum > 0)
                {
                    //DataInfo.UserLoginName = txtUserName.Text;
                    HelperCS.UserName = usr;
                    Form1 frm = this.FindForm() as Form1;
                    //frm.CheckUserLogin(txtUserName.Text);
                    //frm.pa
                    frm.CheckUserLogin();
                    //password anan168,ac2018
                }
                else
                {
                    lblLoginValidate.Text    = "";
                    lblLoginValidate.Text    = "** InValid Username or Password ";
                    lblLoginValidate.Visible = true;
                }
            }
        }