我使用 Devexpress 和 Ado.net 连接模式与数据库制作了 WPF 应用程序。我使用其他语言工作,现在转向 C#,我是 WPF 新手。我编写了这段代码来编辑单个和分组的行:
void EditRow(int focRowHand, nrcsaEntities a)
{
Name nametext = grid.GetRow(focRowHand) as Name;
try
{
if (nametext.Name1 != string.Empty)
{
update_id = nametext.PK_ID;
txtName2.Text = update_text = nametext.Name1;
if (Panel3.Visibility == System.Windows.Visibility.Visible)
{
Panel1.Visibility = System.Windows.Visibility.Visible;
Panel3.Visibility = System.Windows.Visibility.Collapsed;
}
else
{
Panel1.Visibility = System.Windows.Visibility.Collapsed;
Panel3.Visibility = System.Windows.Visibility.Visible;
}
}
}
catch (Exception err)
{
DXMessageBox.Show(err.StackTrace);
}
}
private void ToggleButton1_Copy_Click(object sender, RoutedEventArgs e)
{
if (view.FocusedRowHandle == -1)
{
DXMessageBox.Show("Please Select any Item From Grid List");
}
else
{
try
{
int FocRowHand = view.FocusedRowHandle;
nrcsaEntities a = new nrcsaEntities();
if (grid.IsGroupRowHandle(FocRowHand))
{
int childCount = grid.GetChildRowCount(FocRowHand);
for (int i = 0; i < childCount; i++)
{
int childHandle = grid.GetChildRowHandle(FocRowHand, i);
EditRow(childHandle, a);
}
}
else
{
EditRow(FocRowHand, a);
}
}
catch (Exception ee)
{
DXMessageBox.Show(ee.StackTrace);
}
}
由于我的客户要求生成高质量的代码。可能会有超过 1000 名用户使用此应用程序,并且可以保存超过 5000 个用户数据,我的问题是:因为我有更少的时间将我的应用程序提交给我的客户。如果我想将此代码转换为 MVVM,如何执行此操作,因为转换对我来说有点复杂。其次,您如何看待这种代码质量。我对此很困惑。我期待着您的回复。