Click here to Skip to main content
16,018,202 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<Grid>
       <Rectangle>
           <Rectangle.Fill>
               <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" >
                   <GradientStop Color="#01a0fe" Offset="0"/>
                   <GradientStop Color="#2ec091" Offset="1"/>
               </LinearGradientBrush>
           </Rectangle.Fill>
           <Rectangle.OpacityMask>
               <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                   <GradientStop Color="#01a0fe" Offset="0"/>
                   <GradientStop Color="#2ec091" Offset="0.5"/>
               </LinearGradientBrush>
           </Rectangle.OpacityMask>
       </Rectangle>
       <Grid VerticalAlignment="Center" HorizontalAlignment="Center"  Height="650" Width="1000">
           <Rectangle HorizontalAlignment="Left" Height="52" Margin="111,40,0,0" VerticalAlignment="Top" Width="269" RadiusY="8.5" RadiusX="8.5"/>
           <Rectangle HorizontalAlignment="Left" Height="59" Margin="111,115,0,0" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Top" Width="269"/>
           <Rectangle HorizontalAlignment="Left" Height="54" Margin="120,183,0,0" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Top" Width="260"/>
           <Rectangle HorizontalAlignment="Left" Height="49" Margin="111,0,0,340" VerticalAlignment="Bottom" Width="269" RadiusY="10.5" RadiusX="10.5"/>
           <Rectangle HorizontalAlignment="Left" Height="59" Margin="111,0,0,251" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Bottom" Width="269"/>
           <Rectangle HorizontalAlignment="Left" Height="58" Margin="111,0,0,160" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Bottom" Width="269"/>
           <Rectangle HorizontalAlignment="Left" Height="25" Margin="120,57,0,0" RadiusY="8.5" RadiusX="8.5" VerticalAlignment="Top" Width="35">
               <Rectangle.Fill>
                   <ImageBrush ImageSource="user (1).png"/>
               </Rectangle.Fill>
           </Rectangle>
           <TextBox Name="txtCompanyId" materialDesign:HintAssist.Hint="Company Id" Height="45" Margin="167,46,0,0"  BorderBrush="White" TextWrapping="Wrap" VerticalAlignment="Top" Width="200" HorizontalAlignment="Left" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" FontSize="16" Background="#00000000" Foreground="White"/>
           <Rectangle HorizontalAlignment="Left" Height="25" Margin="120,122,0,0" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Top" Width="35">
               <Rectangle.Fill>
                   <ImageBrush ImageSource="user (1).png"/>
               </Rectangle.Fill>
           </Rectangle>
           <TextBox Name="txtCompanyName" materialDesign:HintAssist.Hint="Company Name"  BorderBrush="White" HorizontalAlignment="Left" Height="45" Margin="167,115,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="200" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" FontSize="16" Foreground="White"/>
           <Rectangle HorizontalAlignment="Left" Height="25" Margin="120,195,0,0" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Top" Width="35">
               <Rectangle.Fill>
                   <ImageBrush ImageSource="user (1).png"/>
               </Rectangle.Fill>
           </Rectangle>
           <TextBox Name="txtCaption"  materialDesign:HintAssist.Hint="Caption" BorderBrush="White" HorizontalAlignment="Left" Height="45" Margin="167,183,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="200" FontSize="16" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" Foreground="White"/>
           <Rectangle HorizontalAlignment="Left" Height="25" Margin="120,0,0,354" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Bottom" Width="35" RenderTransformOrigin="0.5,0.5">
               <Rectangle.RenderTransform>
                   <TransformGroup>
                       <ScaleTransform/>
                       <SkewTransform AngleX="0.939"/>
                       <RotateTransform/>
                       <TranslateTransform X="0.984"/>
                   </TransformGroup>
               </Rectangle.RenderTransform>
               <Rectangle.Fill>
                   <ImageBrush ImageSource="user (1).png"/>
               </Rectangle.Fill>
           </Rectangle>
           <TextBox Name="txtAddress1" materialDesign:HintAssist.Hint="Address 1" BorderBrush="White" HorizontalAlignment="Left" Height="45" Margin="167,0,0,346" TextWrapping="Wrap" VerticalAlignment="Bottom" Width="200" FontSize="16" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Foreground="White"/>
           <Rectangle HorizontalAlignment="Left" Height="25" Margin="120,0,0,269" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Bottom" Width="35">
               <Rectangle.Fill>
                   <ImageBrush ImageSource="user (1).png"/>
               </Rectangle.Fill>
           </Rectangle>
           <TextBox Name="txtAddress2"  materialDesign:HintAssist.Hint="Address 2" BorderBrush="White" HorizontalAlignment="Left" Height="45" Margin="167,0,0,260" TextWrapping="Wrap" VerticalAlignment="Bottom" Width="200" FontSize="16" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Foreground="White"/>
           <Rectangle HorizontalAlignment="Left" Height="25" Margin="120,0,0,178" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Bottom" Width="35">
               <Rectangle.Fill>
                   <ImageBrush ImageSource="user (1).png"/>
               </Rectangle.Fill>
           </Rectangle>
           <TextBox Name="txtMobile" materialDesign:HintAssist.Hint="Mobile No" BorderBrush="White" HorizontalAlignment="Left" Height="45" Margin="167,0,0,171" TextWrapping="Wrap" VerticalAlignment="Bottom" Width="200" FontSize="16" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Foreground="White"/>
           <Rectangle Height="52" Margin="452,40,321,0" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Top" RenderTransformOrigin="0.452,0.36"/>
           <Rectangle Height="25" Margin="464,57,501,0" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Top" Width="35">
               <Rectangle.Fill>
                   <ImageBrush ImageSource="user (1).png"/>
               </Rectangle.Fill>
           </Rectangle>
           <Rectangle Height="49" Margin="452,106,321,0" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Top"/>
           <Rectangle Height="25" Margin="465,122,500,0" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Top">
               <Rectangle.Fill>
                   <ImageBrush ImageSource="user (1).png"/>
               </Rectangle.Fill>
           </Rectangle>
           <Rectangle Height="54" Margin="452,183,308,0" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Top"/>
           <Rectangle Height="25" Margin="465,195,500,0" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Top">
               <Rectangle.Fill>
                   <ImageBrush ImageSource="user (1).png"/>
               </Rectangle.Fill>
           </Rectangle>
           <Rectangle Height="51" Margin="452,0,308,340" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Bottom"/>
           <Rectangle Height="50" Margin="452,0,308,260" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Bottom"/>
           <Rectangle Height="36" Margin="259,0,389,22" RadiusY="11" RadiusX="11" VerticalAlignment="Bottom"/>
           <TextBox Name="txtEmail"  materialDesign:HintAssist.Hint="Email" BorderBrush="White" HorizontalAlignment="Right" Height="46" Margin="0,46,308,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="177" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" FontSize="16" Foreground="White"/>
           <TextBox Name="txtGstin"  materialDesign:HintAssist.Hint="GSTIN" BorderBrush="White" HorizontalAlignment="Right" Height="45" Margin="0,115,308,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="177" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" FontSize="16" Foreground="White"/>
           <Rectangle Height="25" Margin="465,0,500,357" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Bottom">
               <Rectangle.Fill>
                   <ImageBrush ImageSource="user (1).png"/>
               </Rectangle.Fill>
           </Rectangle>
           <TextBox Name="txtCloudApi"  materialDesign:HintAssist.Hint="Cloud Api" BorderBrush="White" HorizontalAlignment="Right" Height="45" Margin="0,183,308,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="177" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" FontSize="16" Foreground="White"/>
           <TextBox Name="txtUsername"  materialDesign:HintAssist.Hint="User Name" BorderBrush="White" HorizontalAlignment="Right" Height="51" Margin="0,0,308,346" TextWrapping="Wrap" VerticalAlignment="Bottom" Width="177" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" FontSize="16" Foreground="White"/>
           <PasswordBox x:Name="txtPassword" materialDesign:HintAssist.Hint="Password" HorizontalAlignment="Left"  BorderBrush="White" Margin="515,345,0,0" VerticalAlignment="Top" Width="177" Height="45" Foreground="White" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" FontSize="16"/>
           <Rectangle Height="25" Margin="465,0,500,269" RadiusY="10.5" RadiusX="10.5" VerticalAlignment="Bottom" Width="35">
               <Rectangle.Fill>
                   <ImageBrush ImageSource="user (1).png"/>
               </Rectangle.Fill>
           </Rectangle>
           <ComboBox Name="txtcombox" materialDesign:HintAssist.Hint="Select User Type" BorderBrush="White" Height="56" Margin="515,0,308,171" VerticalAlignment="Bottom" FontSize="16" HorizontalContentAlignment="Center" Foreground="White" VerticalContentAlignment="Center">
               <ComboBoxItem Content="Admin" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Background="White" Foreground="Black"/>
           </ComboBox>
           <StackPanel HorizontalAlignment="Right" />
           <Rectangle HorizontalAlignment="Left" Height="40" Margin="204,526,0,0" VerticalAlignment="Top" Width="407" RadiusY="6" RadiusX="6"/>
           <TextBox Name="txtActivationKey"  materialDesign:HintAssist.Hint="Activation Key" BorderBrush="White"  HorizontalAlignment="Left" Height="40" Margin="259,526,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="352" FontSize="16" Foreground="#FFF9F9F9" VerticalContentAlignment="Center"/>
           <Image Name="picUserimage" HorizontalAlignment="Left" Height="105" Margin="770,50,0,0" VerticalAlignment="Top" Width="98" Source="Images/user.jpg"/>
           <Rectangle HorizontalAlignment="Left" Height="28" Margin="778,183,0,0" RadiusY="8.5" RadiusX="8.5" VerticalAlignment="Top" Width="110"/>
           <Button Name="btnbrowse" Content="Browse" HorizontalAlignment="Left" Margin="767,183,0,0" VerticalAlignment="Top" Width="101" Height="28" Background="White" Foreground="#DD000000" Click="btnBrowse_Click"/>
           <Button Name="btnSave" Content="Save" BorderThickness="2"  HorizontalAlignment="Left" Height="35" Margin="259,592,0,0" VerticalAlignment="Top" Width="125" Background="White" Foreground="#DD000000" Click="btnSave_Click"/>
           <Button Name="btnClear" Content="Clear" BorderThickness="2" HorizontalAlignment="Left" Margin="486,592,0,0" VerticalAlignment="Top" Width="125" Height="35" Background="White" Foreground="#DD000000" Click="btnClear_Click"/>
           <Rectangle HorizontalAlignment="Left" Height="25" Margin="214,535,0,0" VerticalAlignment="Top" Width="35" RadiusY="5" RadiusX="5">
               <Rectangle.Fill>
                   <ImageBrush ImageSource="user (1).png"/>
               </Rectangle.Fill>
           </Rectangle>
       </Grid>
   </Grid>


What I have tried:

 public partial class MainWindow : Window
    {
        string ConnectionString = @"Data Source=DESKTOP-MEGE7J7\MSSQLSERVER02;Initial Catalog=New_Restaurant_Application;Integrated Security=True";
        OpenFileDialog openFileDialog1 = new OpenFileDialog();
        public MainWindow()
        {
            InitializeComponent();
            WindowState = WindowState.Maximized;
            WindowStyle = WindowStyle.None;
            MainWindow.EnableVisualStyles();
            MainWindow.SetCompatibleTextRenderingDefault(false);
            MainWindow.Run(new Login());
        }

        private static void Run(Login login)
        {
           // throw new NotImplementedException();
        }

        private static void SetCompatibleTextRenderingDefault(bool v)
        {
           // throw new NotImplementedException();
        }

        private static void EnableVisualStyles()
        {
          //  throw new NotImplementedException();
        }

        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if(e.LeftButton == MouseButtonState.Pressed)
            {
                  DragMove();
            }
        }
       
                
        private void btnBrowse_Click(object sender, RoutedEventArgs e)
        {
            openFileDialog1.CheckFileExists = true;
            openFileDialog1.CheckFileExists = true;

            openFileDialog1.DefaultExt = ".jpg";
            // openFileDialog1.Filter = "GIF files (*.gif)|*.gif| jpg files (*.jpg)|*.jpg| PNG files (*.png)|*.png| All files (*.*)|*.*";
            openFileDialog1.Filter = "jpg files (*.jpg)|*.jpg| PNG files (*.png)|*.png";

            openFileDialog1.FilterIndex = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == true)
            {
                //lblFileExtension.Text =  openFileDialog.FileName;
                picUserimage.Source = new BitmapImage(new Uri(openFileDialog1.FileName));
                /// textBox1.Text = openFileDialog1.FileName;
                //picItemimage.Source = openFileDialog1.FileName;
                //lblFileExtension.Text = System.IO.Path.GetExtension(openFileDialog1.FileName);
            }
        }

        public bool isValid()
        {
            //if (txtCompanyId.Text.Trim() == "")
            //{
            //    MessageBox.Show("Please Enter CompanyId", "Fill Field", MessageBoxButton.OK, MessageBoxImage.Information);
            //    txtCompanyId.Focus();
            //}

            if (txtCompanyName.Text.Trim() == "")
            {
                MessageBox.Show("Please fill CompanyName", "Fill Field", MessageBoxButton.OK, MessageBoxImage.Information);
                txtCompanyName.Focus();
            }   
            else if (txtCaption.Text.Trim() == "")
            {
                MessageBox.Show("Please fill Caption", "Fill Field", MessageBoxButton.OK, MessageBoxImage.Information);
                txtCaption.Focus();
            }
            else if (txtAddress1.Text.Trim() == "")
            {
                MessageBox.Show("Please fill Address1", "Fill Field", MessageBoxButton.OK, MessageBoxImage.Information);
                txtAddress1.Focus();
            }
            else if (txtAddress2.Text.Trim() == "")
            {
                MessageBox.Show("Please fill Address2", "Fill Field", MessageBoxButton.OK, MessageBoxImage.Information);
                txtAddress2.Focus();
            }
            else if (txtMobile.Text.Trim() == "")
            {
                MessageBox.Show("Please fill MobileNo", "Fill Field", MessageBoxButton.OK, MessageBoxImage.Information);
                txtMobile.Focus();
            }
            else if (txtEmail.Text.Trim() == "")
            {
                MessageBox.Show("Please fill Email", "Fill Field", MessageBoxButton.OK, MessageBoxImage.Information);
                txtEmail.Focus();
            }
            else if (txtGstin.Text.Trim() == "")
            {
                MessageBox.Show("Please fill Gstin", "Fill Field", MessageBoxButton.OK, MessageBoxImage.Information);
                txtGstin.Focus();
            }
            else if (txtCloudApi.Text.Trim() == "")
            {
                MessageBox.Show("Please fill CloudApi", "Fill Field", MessageBoxButton.OK, MessageBoxImage.Information);
                txtCloudApi.Focus();
            }
            else if (txtUsername.Text.Trim() == "")
            {
                MessageBox.Show("Please fill Username", "Fill Field", MessageBoxButton.OK, MessageBoxImage.Information);
                txtUsername.Focus();
            }
            else if (txtPassword.ToString() == "")
            {
                MessageBox.Show("Please fill Password", "Fill Field", MessageBoxButton.OK, MessageBoxImage.Information);
                txtPassword.Focus();
            }
            else if (txtActivationKey.Text.Trim() == "")
            {
                MessageBox.Show("Please fill ActivationKey", "Fill Field", MessageBoxButton.OK, MessageBoxImage.Information);
                txtActivationKey.Focus();
            }
            return true;
        }


        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {

                if (isValid())
                {
                    SqlConnection conn = new SqlConnection(ConnectionString);
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("add_profile_details", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@company_id", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(txtCompanyId.Text) ? DBNull.Value : (object)txtCompanyId.Text;
                    cmd.Parameters.AddWithValue("@company_name", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(txtCompanyName.Text) ? DBNull.Value : (object)txtCompanyName.Text;
                    cmd.Parameters.AddWithValue("@caption", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(txtCaption.Text) ? DBNull.Value : (object)txtCaption.Text;
                    cmd.Parameters.AddWithValue("@address1", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(txtAddress1.Text) ? DBNull.Value : (object)txtAddress1.Text;
                    cmd.Parameters.AddWithValue("@address2", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(txtAddress2.Text) ? DBNull.Value : (object)txtAddress2.Text;
                    cmd.Parameters.AddWithValue("@mobileno", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(txtMobile.Text) ? DBNull.Value : (object)txtMobile.Text;
                    cmd.Parameters.AddWithValue("@email", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(txtEmail.Text) ? DBNull.Value : (object)txtEmail.Text;
                    cmd.Parameters.AddWithValue("@gstn", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(txtGstin.Text) ? DBNull.Value : (object)txtGstin.Text;
                    cmd.Parameters.AddWithValue("@CloudApi", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(txtCloudApi.Text) ? DBNull.Value : (object)txtCloudApi.Text;
                    cmd.Parameters.AddWithValue("@username", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(txtUsername.Text) ? DBNull.Value : (object)txtUsername.Text;
                    cmd.Parameters.AddWithValue("@password", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(txtPassword.Password) ? DBNull.Value : (object)txtPassword.Password;
                    cmd.Parameters.AddWithValue("@selectusertype", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(txtcombox.Text) ? DBNull.Value : (object)txtcombox.Text;
                    cmd.Parameters.AddWithValue("@uploadlogo", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(picUserimage.Source.ToString()) ? DBNull.Value : (object)picUserimage.Source.ToString();
                    cmd.Parameters.AddWithValue("@activationkey", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(txtActivationKey.Text) ? DBNull.Value : (object)txtActivationKey.Text;
                    //conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                    MessageBox.Show("Successfully saved", "Fill Field", MessageBoxButton.OK, MessageBoxImage.Information);
                    refresh();
                    Login l = new Login();
                    l.ShowDialog();
                }

            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void refresh()
        { 
            txtCompanyId.Text = "";
            txtCompanyName.Text = "";
            txtCaption.Text = "";
            txtAddress1.Text = "";
            txtAddress2.Text = "";
            txtMobile.Text = "";
            txtEmail.Text = "";
            txtGstin.Text = "";
            txtCloudApi.Text = "";
            txtUsername.Text = "";
            txtPassword.Password = "";
            txtActivationKey.Text = "";
        }

        private void btnClear_Click(object sender, RoutedEventArgs e)
        {
            txtCompanyId.Clear();
            txtCompanyName.Clear();
            txtCaption.Clear();
            txtAddress1.Clear();
            txtAddress2.Clear();
            txtMobile.Clear();
            txtEmail.Clear();
            txtGstin.Clear();
            txtCloudApi.Clear();
            txtUsername.Clear();
            txtPassword.Clear();
            txtActivationKey.Clear();
        }
    }
}
Posted
Updated 2-Sep-22 2:28am
Comments
OriginalGriff 2-Sep-22 5:51am    
And?
What have you tried?
Where are you stuck?
What help do you need?

Use the "Improve question" widget to edit your question and provide better information.
prashanth manoj 2-Sep-22 6:28am    
register form show at only register after run a project show login form

1 solution

Here is a great YT video that shows what you want to achieve: Creating a Login Form in WPF - FULL STACK WPF (.NET CORE) MVVM #15 - YouTube[^]. Here is another: WPF Login Form Creation - A TimCo Retail Manager Video - YouTube[^]

SingletonSean does have a lot more great video tutorials that will help you: SingletonSean WPF Playlists - YouTube[^]

Tim Corey is also good: https://www.youtube.com/user/IAmTimCorey[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900