Exemplo n.º 1
0
 private void btnSaveDrv_Click(object sender, RoutedEventArgs e)
 {
     if (tBoxDrvName.Text.ToString().Trim() == "" || tBoxDrvAddress.Text.ToString().Trim() == "" || tBoxPhone.Text.ToString().Trim() == "" || tBoxDsShortName.Text.ToString().Trim() == "" || tBoxContact.Text.ToString().Trim() == "")
     {
         System.Windows.Forms.MessageBox.Show("请检查是否有信息为空.");
         return;
     }
     else
     {
         TrainingControl.DrvSchool drvSh = new TrainingControl.DrvSchool();
         if (dsrsrc.IsRegEx("^(-?[0-9]*[.]*[0-9]{0,3})$", this.tboxdrvid.Text.ToString().Trim()))
         {
             drvSh.DrvId = Convert.ToInt32(this.tboxdrvid.Text.ToString().Trim());
         }
         else
         {
             System.Windows.Forms.MessageBox.Show("驾校ID必须为数字,请重新输入");
             return;
         }
         drvSh.drvname      = tBoxDrvName.Text.ToString().Trim();
         drvSh.drvaddress   = tBoxDrvAddress.Text.ToString().Trim();
         drvSh.drvphoneno   = tBoxPhone.Text.ToString().Trim();
         drvSh.drvshortname = tBoxDsShortName.Text.ToString().Trim();
         drvSh.drvcontact   = tBoxContact.Text.ToString().Trim();
         DataRow[] drow = dsrsrc.trainMangeDataSet.DrvSchoolDataTable.Select("DRIVING_SCHOOL_ID = '" + Convert.ToInt32(this.tboxdrvid.Text.ToString().Trim()) + "'");
         if (drow.Length > 0)
         {
             if (System.Windows.MessageBox.Show("已经存在相同ID的驾校信息,确认更新ID为" + this.tboxdrvid.Text.ToString().Trim() + "的驾校信息吗?", "提示:", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
             {
                 dsrsrc.AddDrvSchool("Y");
                 dsrsrc.MainBarText = "更新名称为:" + drvSh.drvname + "的驾校信息到本地数据库成功";
             }
             else
             {
                 return;
             }
         }
         else
         {
             dsrsrc.AddDrvSchool("");
             dsrsrc.MainBarText = "新增名称为:" + drvSh.drvname + "的驾校信息到本地数据库成功";
         }
     }
     PopuDrvPage();
 }