Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string strQuery = string.Empty;
                string strCat   = txtFName.Text.Trim();

                if (USERID == 0)
                {
                    if (CheckValidation("ADD"))
                    {
                        strQuery = "INSERT INTO USERS(FNAME,LNAME,LOGINNAME,PASSWORD,USERTYPE,CREATEDATE) values ('" + strCat + "','" + txtLName.Text.Replace("'", "") + "', '" + txtLoginName.Text + "','" + AgroFUN.EncodePassword(txtPassword.Text) + "','" + cmbUserType.Text + "','" + DateTime.Now.ToString("dd-MM-yyyy") + "')";
                        USERID   = dLib.ReturnID(AgroFUN.gblConnString, strQuery, "ID");
                        USERID   = 0;
                    }
                }
                else
                {
                    if (CheckValidation("EDIT"))
                    {
                        if (txtFName.Text != strUserName)
                        {
                            if (!CheckValidation("ADD"))
                            {
                                return;
                            }
                        }
                        strQuery = "UPDATE USERS set FNAME='" + strCat + "',LNAME='" + txtLName.Text.Replace("'", "") + "',LOGINNAME='" + txtLoginName.Text + "',Password ='******',UserType='" + cmbUserType.Text + "',UpdateDate='" + DateTime.Now.ToString("dd-MM-yyyy") + "' where ID=" + USERID;
                        dLib.ExecuteNonQuery(AgroFUN.gblConnString, strQuery);
                        USERID      = 0;
                        strUserName = "";
                    }
                }
                ClearValue();
                txtFName.Focus();
                txtFName.Text = "";
                LoadGrid();
            }
            catch (Exception ex)
            {
                AgroFUN.SystemLog("Save:" + ex.Message.ToString());
            }
        }
Пример #2
0
        private void loginbtn_Click(object sender, EventArgs e)
        {
            string uname = unametxt.Text;

            string password = passtxt.Text;

            if (string.IsNullOrEmpty(uname))
            {
                MessageBox.Show("Please enter UserName");
            }

            if (string.IsNullOrEmpty(password))
            {
                MessageBox.Show("Please enter Password");
            }



            else
            {
                DataTable dt = dLib.ExecuteDatTable(AgroFUN.gblConnString, "select * from USERS where LOGINNAME='" + uname + "' and PASSWORD='******'");

                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];
                    MessageBox.Show("LogIn Successful");
                    frmMain fm = new frmMain();
                    fm.Show();
                    this.Hide();
                }

                else
                {
                    MessageBox.Show("invalid  login details");
                    cleardata();
                }
            }
        }