Exemplo n.º 1
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtDeviceNumber.Text.Trim() == string.Empty)
         {
             MessageBox.Show("设备编号不能为空");
             return;
         }
         if (Encoding.Default.GetBytes(txtDeviceNumber.Text.Trim()).Length > 10)
         {
             MessageBox.Show("设备编号不能超过10");
             return;
         }
         if (txtDeviceName.Text.Trim() == string.Empty)
         {
             MessageBox.Show("设备名称不能为空");
             return;
         }
         if (Encoding.Default.GetBytes(txtDeviceName.Text.Trim()).Length > 50)
         {
             MessageBox.Show("设备名称不能超过50");
             return;
         }
         Model_PDAInfo pda = new Model_PDAInfo();
         pda.Numberk__BackingField   = txtDeviceNumber.Text.Trim();
         pda.Namek__BackingField     = txtDeviceName.Text.Trim();
         pda.CreateAtk__BackingField = DateTime.Now;
         if (rdbEnabled.Checked == true)
         {
             pda.Activedk__BackingField = Enum_Active.Enabled;
         }
         else
         {
             pda.Activedk__BackingField = Enum_Active.Disable;
         }
         ResultModelOfModel_PDAInfod4FqxSXX pdalist = cs.EditPDA(pda);
         if (pdalist.Code != 0)
         {
             MessageBox.Show(pdalist.Message);
         }
         else
         {
             MessageBox.Show("操作成功");
             getClear();
             DeviceLoad();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }