当前位置:编程学习 > C#/ASP.NET >>

Wpf+cs写一个修改密码的窗口..出现问题(怎么写?)

wpf:
<Window x:Class="NetworkMonitor.UI.Changepassword.ChangePassword"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="修改密码窗口" Height="280" Width="480" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
    <Grid  x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="30*"/>
            <RowDefinition Height="30"/>
        </Grid.RowDefinitions>
        <Grid Margin="20,30">
        <Grid.RowDefinitions>
            <RowDefinition Height="30"/>
            <RowDefinition Height="30"/>
            <RowDefinition Height="30"/>
            <RowDefinition Height="30"/>
            <RowDefinition Height="30"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="120" />
            <ColumnDefinition Width="150*" />
            </Grid.ColumnDefinitions>
        <Label Grid.Row="0" Grid.Column="0"  Content="登陆名:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox  Grid.Row="0" Grid.Column="1" Name="loginname"  Height="25" Width="200" HorizontalAlignment="Left"/>
        <Label Grid.Row="1" Grid.Column="0"  Content="用户名:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox  Grid.Row="1" Grid.Column="1" Name="uesrname"  Height="25" Width="200" HorizontalAlignment="Left"/>
        <Label Grid.Row="2" Grid.Column="0"  Content="旧密码:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox  Grid.Row="2" Grid.Column="1" Name="opassword"  Height="25" Width="200" HorizontalAlignment="Left"/>
        <Label Grid.Row="3" Grid.Column="0"  Content="新密码:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox  Grid.Row="3" Grid.Column="1" Name="newpassword"  Height="25" Width="200" HorizontalAlignment="Left"/>
        <Label Grid.Row="4" Grid.Column="0"  Content="确认新密码:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox  Grid.Row="4" Grid.Column="1" Name="affirmpassword"  Height="25" Width="200" HorizontalAlignment="Left"/>
       
    </Grid>
        <WrapPanel Grid.Row="1"  HorizontalAlignment="Right" Margin="0,0,20,0">
            <Button Width="75" Height="25" Content="保存" Name="btnSubmit" Click="btnSubmit_Click" />
            <Button Width="75" Height="25" Content="重置" Name="btnreset" Margin="5,0,0,0" Click="btnreset_Click" />
            <Button Width="75" Height="25" Content="取消" Name="btnClose" Margin="5,0,0,0" Click="btnClose_Click" />
        </WrapPanel>
    </Grid>


</Window>


CS:namespace NetworkMonitor.UI.Changepassword
{
    /// <summary>
    /// ChangePassword.xaml 的交互逻辑
    /// </summary>
    public partial class ChangePassword : Window
    {
        public TbUser entity { set; get; }
        public ChangePassword()
        {
            InitializeComponent();
            entity = new TbUser();
        }

        #region 关闭按钮
        /// <summary>
        /// 关闭按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
        #endregion


        #region 绑定数据
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void BindData()
        {
           
            
        }
        #endregion

        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            entity = this.LayoutRoot.DataContext as TbUser;
            entity.IsDel = false;
            entity.CreateId = SessionContext.CurrentContext.UserID;
            entity.Creator = SessionContext.CurrentContext.UserName;
            entity.Createdate = DateTime.Now;
            
            if (string.IsNullOrWhiteSpace(newpassword.Text) || string.IsNullOrWhiteSpace(affirmpassword.Text))
            {
                MessageBox.Show("修改的密码不能为空,请重新输入!", "系统提示");
                return;
            }

            if((newpassword.Text)!=(affirmpassword.Text))
            {
                MessageBox.Show("两次密码输入不一致,请重新输入!","系统提示");
                return;
            }
            
           
            
        }

        #region 重置按钮
        /// <summary>
        /// 重置按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnreset_Click(object sender, RoutedEventArgs e)
        {
            opassword.Clear();
            newpassword.Clear();
            affirmpassword.Clear();
            opassword.Focus();
        }
        #endregion

    }
}

改怎么修改?? --------------------编程问答-------------------- 出现什么问题?报什么错? --------------------编程问答-------------------- 问题是怎么在btnSubmit_Click里把数据库里的密码修改掉
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,