private void btn清零操作_Click(object sender, EventArgs e) { if (tbRand2.Text != "" && tbEsamNo.Text != "") { if (tbEndTime.Text.Length != 12) { MessageBox.Show("命令有效截止长度不足!"); return; } Esam645Service.EsamOptionClient ESAMproxy = new Esam645Service.EsamOptionClient();//要操作时才new try { Protocol645 p645 = new Protocol645(); //电量清零 if (rbEnergyClr.Checked) { string putData = "1A00" + tbEndTime.Text; string enData = ESAMproxy.Meter_Formal_DataClear1(0, tbRand2.Text, tbDiv.Text, putData); if (p645.MeterClr(enData)) { MessageBox.Show("电量清零成功!"); } else { MessageBox.Show("电量清零失败"); } } //事件清零 if (rbEvenClr.Checked) { if (tbEvenClrID.Text.Length != 8) { MessageBox.Show("请输入8位清零ID!"); return; } string putData = "1B00" + tbEndTime.Text + tbEvenClrID.Text; string enData = ESAMproxy.Meter_Formal_DataClear2(0, tbRand2.Text, tbDiv.Text, putData); if (p645.EventClear98(enData)) { MessageBox.Show("事件清零成功!"); } else { MessageBox.Show("事件清零失败"); } } //需量清零 if (rbDemandClr.Checked) { string putData = "1900" + tbEndTime.Text; string enData = ESAMproxy.Meter_Formal_DataClear2(0, tbRand2.Text, tbDiv.Text, putData); if (p645.MaxDemandClear98(enData)) { MessageBox.Show("需量清零成功!"); } else { MessageBox.Show("需量清零失败"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { ESAMproxy.Close(); } } else { MessageBox.Show("请先身份认证!"); } }
private void btnMeterClr_Click(object sender, EventArgs e)//电表清零 { Protocol645 p645 = new Protocol645(); p645.MeterClr(); }