Beispiel #1
0
 private void btnCreateuser_Click(object sender, EventArgs e)
 {
     string Output = string.Empty;
     if (Validate())
     {
         if (btnCreateuser.Text == "Save")
         {
             if (ddlLogintype.Text == "--Select--")
             {
                 MessageBox.Show("Please Select Login Type");
             }
             else
             {
                 EntAdduser objentadduser = new EntAdduser();
                 objentadduser.LoginType = ddlLogintype.SelectedItem.ToString();
                 objentadduser.LoginUserName = txtyuserId.Text;
                 objentadduser.Password = txtpassword.Text;
                 BLAdduser objbladduser = new BLAdduser();
                 Output = objbladduser.UserRegistration(objentadduser);
                 if (Output == "1")
                 {
                     MessageBox.Show("New User Added Successfully..");
                 }
                 else
                 {
                     MessageBox.Show("User Name Already Exists...");
                 }
                 txtpassword.Text = "";
                 txtyuserId.Text = "";
                 ddlLogintype.Text = "--Select--";
             }
         }
         else
         {
             SqlConnection con = new SqlConnection(ConnectionString);
             con.Open();
             SqlCommand cmd = new SqlCommand("Usp_UpdateUser", con);
             cmd.CommandType = CommandType.StoredProcedure;
             try
             {
                 cmd.Parameters.AddWithValue("@UserType", ddlLogintype.Text.ToString());
                 cmd.Parameters.AddWithValue("@UserName", txtyuserId.Text.ToString());
                 cmd.Parameters.AddWithValue("@Password", txtpassword.Text.ToString());
                 txtyuserId.Enabled = false;
                 string strMessage = Convert.ToString(cmd.ExecuteScalar());
                 MessageBox.Show("Record Updated Successfully..");
                 //loadcustomerGrid();
                 con.Close();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message.ToString());
             }
             finally
             {
                 cmd.Dispose();
                 con.Close();
                 con.Dispose();
             }
         }
     }
     else
     {
         // MessageBox.Show("Internal error occure");
     }
 }
Beispiel #2
0
        private void btnCreateuser_Click(object sender, EventArgs e)
        {
            string Output = string.Empty;
            try
            {
                EntAdduser objentadduser = new EntAdduser();
                objentadduser.LoginUserName = txtUserName.Text;
                objentadduser.Password = txtpassword.Text;
                BLAdduser objbladduser = new BLAdduser();
                DataTable dt = objbladduser.AddUser(objentadduser);
                HomeMDI objmdi = new HomeMDI();
                BLlogin objlogin = new BLlogin();
                string Expirydate = null;
                if (dt.Rows.Count > 0)
                {
                    Expirydate = dt.Rows[0]["ExpiryDate"].ToString();
                    DateTime currentdate = DateTime.Now;
                    DateTime expirydate = Convert.ToDateTime(Expirydate);
                    if (currentdate == expirydate)
                    {
                        MessageBox.Show("Your Application Is Going to Expire Today..!!! Please Contact your Support");
                        this.Visible = false;
                        objmdi.Show();
                    }
                    else if (currentdate > expirydate)
                    {
                        MessageBox.Show("Sorry...Your Application Is Expired....!!! Please Contact your Support");
                        objmdi.Close();
                    }
                    else
                    {
                        MessageBox.Show("Welcome...To Loan Application!!!!");
                        this.Visible = false;

                        HomeMDI objHomeMdi = new HomeMDI();
                        Login loginPage = new Login();
                        if (objHomeMdi.ShowDialog() == DialogResult.OK)
                        {
                            Application.Run(new HomeMDI());

                        }
                        else
                        {
                            Application.Exit();
                        }

                        InitializeComponent();
                    }
                    txtpassword.Text = "";
                    txtUserName.Text = "";
                }
                else
                {
                    MessageBox.Show("Username Or Password Not Match");
                    txtpassword.Text = "";
                    txtUserName.Text = "";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }