private void lnkManageusers_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     User_mgt.Manage_user go = new User_mgt.Manage_user();
     go.MdiParent = this.ParentForm;
     go.Show();
     this.Close();
 }
        //// Delete user
        private void lnkDelete_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            DialogResult result = MessageBox.Show("Do you want to Delete?", "Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (result == DialogResult.Yes)
            {
                if (lblUid.Text == "-")
                {
                    // MessageBox.Show("You are Not able to Update");
                    MessageBox.Show("You are Not able to Delete", "Button3 Title", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    try
                    {
                        string sql = "delete from usermgt where   (id = '" + lblUid.Text + "' )";
                        DataAccess.ExecuteSQL(sql);

                        picUserimage.InitialImage.Dispose();
                        string path = Application.StartupPath + @"\IMAGE\";
                        System.IO.File.Delete(path + @"\" + lblimagename.Text);

                        MessageBox.Show("User has been Deleted", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        User_mgt.Manage_user go = new User_mgt.Manage_user();
                        go.MdiParent = this.ParentForm;
                        go.Show();
                        this.Close();
                        ClearForm();
                    }
                    catch (Exception exp)
                    {
                        MessageBox.Show("Sorry\r\n You have to Check the Data" + exp.Message);
                    }
                }
            }
        }
        // Save if not UID | Update if UID present
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtUserFullName.Text == "")
            {
                MessageBox.Show("Please Add User full Name", "Fill Field", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtUserFullName.Focus();
            }
            else if (txtFatherName.Text == "")
            {
                MessageBox.Show("Please fill fathers name", "Fill Field", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtFatherName.Focus();
            }
            else if (txtAddress.Text == "")
            {
                MessageBox.Show("Please Add Address", "Fill Field", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtAddress.Focus();
            }
            else if (txtContact.Text == "")
            {
                MessageBox.Show("Please Add Contact Number", "Fill Field", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtContact.Focus();
            }
            else if (txtUsername.Text == "")
            {
                MessageBox.Show("Please Add Username \n Username should be unique", "Fill Field", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtUsername.Focus();
            }
            else if (txtEmailaddress.Text == "")
            {
                MessageBox.Show("Please Add  Email address", "Fill Field", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtEmailaddress.Focus();
            }
            else if (textUserPass.Text == "")
            {
                MessageBox.Show("Please Add  Password", "Fill Field", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textUserPass.Focus();
            }
            else
            {
                try
                {
                    int flag;
                    if (rdbtnAdmin.Checked)
                    {
                        flag = 1;
                    }
                    else if (rdbtnManager.Checked)
                    {
                        flag = 2;
                    }
                    else if (rdbtnSalesMan.Checked)
                    {
                        flag = 3;
                    }
                    else if (rdbtnblock.Checked)
                    {
                        flag = 0;
                    }
                    else
                    {
                        flag = 0;
                    }
                    string posi;
                    if (rdbtnAdmin.Checked)
                    {
                        posi = "Admin";
                    }
                    else if (rdbtnManager.Checked)
                    {
                        posi = "Manager";
                    }
                    else if (rdbtnSalesMan.Checked)
                    {
                        posi = "Salesman";
                    }
                    else if (rdbtnblock.Checked)
                    {
                        posi = "Block";
                    }
                    else
                    {
                        posi = "0";
                    }

                    //New Insert / New Entry
                    if (lblUid.Text == "-")
                    {
                        //string selno = txtUid.Text;
                        string imageName = txtUid.Text + lblFileExtension.Text; //System.IO.Path.GetFileName(openFileDialog1.FileName);

                        string sql1 = "insert into usermgt (Name, Father_name, Address, Email , Contact, DOB , Username , password , usertype , position , imagename, Shopid ) " +
                                      "  values('" + txtUserFullName.Text + "', '" + txtFatherName.Text + "', '" + txtAddress.Text + "', '" + txtEmailaddress.Text + "', " +
                                      " '" + txtContact.Text + "',  '" + dtDOB.Text + "', '" + txtUsername.Text + "', '" + textUserPass.Text + "', " +
                                      " '" + flag + "', '" + posi + "' , '" + imageName + "' , '" + cmboShopid.SelectedValue + "')";
                        DataAccess.ExecuteSQL(sql1);


                        /////////////////////picture upload  /////////////////
                        string path = Application.StartupPath + @"\IMAGE\";
                        System.IO.File.Delete(path + @"\" + imageName);
                        if (!System.IO.Directory.Exists(path))
                        {
                            System.IO.Directory.CreateDirectory(Application.StartupPath + @"\IMAGE\");
                        }
                        string filename = path + @"\" + openFileDialog1.SafeFileName;
                        picUserimage.Image.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
                        System.IO.File.Move(path + @"\" + openFileDialog1.SafeFileName, path + @"\" + imageName);
                        MessageBox.Show("User hase been Created Successfully", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        lblEmailerrormsg.Visible = false;

                        User_mgt.Manage_user go = new User_mgt.Manage_user();
                        go.MdiParent = this.ParentForm;
                        go.Show();
                        this.Close();
                    }
                    else // Update info
                    {
                        string imageName;
                        if (lblFileExtension.Text == "user.png")
                        {
                            imageName = lblimagename.Text;  //Unchange pictures
                        }
                        else  //When change
                        {
                            imageName = lblUid.Text + lblFileExtension.Text;
                        }

                        string sql = "UPDATE usermgt set  Name = '" + txtUserFullName.Text + "', Father_name = '" + txtFatherName.Text + "', " +
                                     " Address = '" + txtAddress.Text + "', Email = '" + txtEmailaddress.Text + "', Contact = '" + txtContact.Text + "', " +
                                     " DOB = '" + dtDOB.Value.ToString("yyyy-MM-dd") + "' , Username= '******', password = '******',imagename = '" + imageName + "' ,    " +
                                     " usertype    = '" + flag + "', position = '" + posi + "', Shopid = '" + cmboShopid.SelectedValue + "' where (id = '" + lblUid.Text + "' )";
                        DataAccess.ExecuteSQL(sql);


                        /////////////////////////////////////////////Update image //////////////////////////////////////////////////////
                        if (lblFileExtension.Text != "user.png")
                        {
                            picUserimage.InitialImage.Dispose();
                            string path = Application.StartupPath + @"\IMAGE\";
                            System.IO.File.Delete(path + @"\" + lblimagename.Text);
                            if (!System.IO.Directory.Exists(path))
                            {
                                System.IO.Directory.CreateDirectory(Application.StartupPath + @"\IMAGE\");
                            }
                            string filename = path + @"\" + openFileDialog1.SafeFileName;
                            picUserimage.Image.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
                            System.IO.File.Move(path + @"\" + openFileDialog1.SafeFileName, path + @"\" + imageName);
                        }

                        MessageBox.Show("Successfully Data Updated!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        lblEmailerrormsg.Visible = false;
                        loadData(lblUid.Text);
                    }
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Sorry\r\n" + exp.Message);
                }
            }
        }