private void AddAmmeter_Click(object sender, EventArgs e)
        {
            string lineNo = "";
            if (this.LineNoList_Add.SelectedIndex == -1)
            {
                MessageBox.Show("请选择线路!");
                return;
            }
            lineNo = this.LineNoList_Add.SelectedItem.ToString().Trim().Split(' ')[0];

            if (this.AmmeterNo_Add.Text.ToString().Trim() == "")
            {
                MessageBox.Show("请填写电表编号!");
                return;
            }
            string ammeterNo = this.AmmeterNo_Add.Text.ToString().Trim();
            bool state = false;
            if (Constant.ERROR == this.lineAmmeterAction.checkLANo(lineNo, ammeterNo, ref state))
            {
                return;
            }

            if (!state)
            {
                MessageBox.Show("该电表编号已经存在!");
                return;
            }

            LineAmmeterInfo laInfo = new LineAmmeterInfo();
            laInfo.LineNum = lineNo;
            laInfo.AmmeterNo = ammeterNo;

            if ("" == this.AmmeterName_Add.Text.ToString().Trim())
            {
                MessageBox.Show("请填写电表名称!");
                return;
            }

            laInfo.AmmeterName = this.AmmeterName_Add.Text.ToString().Trim();

            if ("" == this.AmmeterMulti_Add.Text.ToString().Trim())
            {
                MessageBox.Show("请填写电表倍率!");
                return;

            }
            laInfo.LineAmmeterMulti = this.AmmeterMulti_Add.Text.ToString().Trim();

            if (Constant.OK == this.lineAmmeterAction.addLineAmmeter(ref laInfo))
            {
                MessageBox.Show("添加成功!");
                return;
            }
            else
            {
                MessageBox.Show("添加失败!");
                return;
            }
        }
 /**
  * 添加线路电表信息
  * @param       ref LineAmmeterInfo lineAmmeterInfo:线路电表信息
  * @return      int 值为Constant.OK:执行成功,值为Constant.ERROR为执行失败
  * @author      Rick
  **/
 public int addLineAmmeter(ref LineAmmeterInfo lineAmmeterInfo)
 {
     string strAdd = "insert into LineAmmeterInfo values (" + lineAmmeterInfo.LineNum + "," + lineAmmeterInfo.AmmeterNo + ", '" + lineAmmeterInfo.AmmeterName + "', " + lineAmmeterInfo.LineAmmeterMulti +", getdate())";
     try
     {
         SQLUtl.ExecuteSql(strAdd);
         return Constant.OK;
     }
     catch (Exception)
     {
         return Constant.ERROR;
     }
 }
        private void UpdateAmmeter_Click(object sender, EventArgs e)
        {
            string lineNo = "";
            string ammeterNo = "";

            if (-1 == this.LineNoList.SelectedIndex)
            {
                MessageBox.Show("请选择线路号!");
                return;
            }

            if (-1 == this.AmmeterList.SelectedIndex)
            {
                MessageBox.Show("请选择电表!");
                return;
            }

            lineNo = this.LineNoList.SelectedItem.ToString().Trim().Split(' ')[0];
            ammeterNo = this.AmmeterList.SelectedItem.ToString().Trim().Split(' ')[0];

            if (this.AmmeterName.Text.ToString().Trim() == "")
            {
                MessageBox.Show("电表名称不能为空!");
                return;
            }

            if (this.AmmeterMulti.Text.ToString().Trim() == "")
            {
                MessageBox.Show("电表倍率不能为空值!");
                return;
            }

            LineAmmeterInfo laInfo = new LineAmmeterInfo();

            laInfo.LineNum = lineNo;
            laInfo.AmmeterNo = ammeterNo;
            laInfo.AmmeterName = this.AmmeterName.Text.ToString().Trim();
            laInfo.LineAmmeterMulti = this.AmmeterMulti.Text.ToString().Trim();

            if (Constant.OK == this.lineAmmeterAction.updateLineAmmeter(lineNo, ammeterNo, ref laInfo))
            {
                MessageBox.Show("电表信息更新成功!");
                return;
            }
            else
            {
                MessageBox.Show("电表信息更新失败!");
                return;
            }
        }
        private void AmmeterList_SelectedIndexChanged(object sender, EventArgs e)
        {
            string lineNo = "";
            string ammeterNo = "";

            if (-1 == this.LineNoList.SelectedIndex)
            {
                MessageBox.Show("请选择线路号!");
                return;
            }

            if (-1 == this.AmmeterList.SelectedIndex)
            {
                MessageBox.Show("请选择电表!");
                return;
            }

            lineNo = this.LineNoList.SelectedItem.ToString().Trim().Split(' ')[0];
            ammeterNo = this.AmmeterList.SelectedItem.ToString().Trim().Split(' ')[0];

            LineAmmeterInfo laInfo = new LineAmmeterInfo();
            if (Constant.OK == this.lineAmmeterAction.getLineAmmeterById(lineNo, ammeterNo, ref laInfo))
            {
                //MessageBox.Show("")
                this.AmmeterNo.Text = laInfo.AmmeterNo;
                this.AmmeterName.Text = laInfo.AmmeterName;
                this.AmmeterMulti.Text = laInfo.LineAmmeterMulti;
            }
        }
        /**
         * 查询线路电表信息
         * @param       string lineNo:线路号
         * @param       string l_a_no:线路电表编号
         * @param       ref LineAmmeterInfo lineAmmeterInfo:线路电表信息
         * @return      int 值为Constant.OK:执行成功,值为Constant.ERROR为执行失败
         * @author      Rick
         **/
        public int getLineAmmeterById(string lineNo, string l_a_no, ref LineAmmeterInfo lineAmmeterInfo)
        {
            string strSelect = "select * from LineAmmeterInfo where  LineNum = " + lineNo + " and AmmeterNo = " + l_a_no;

            try
            {
                DataSet ds = SQLUtl.Query(strSelect);
                DataTable dt = ds.Tables[0];
                if (null != dt.Rows[0].ItemArray[0])
                {
                    lineAmmeterInfo.LineNum = dt.Rows[0].ItemArray[0].ToString().Trim();
                }
                else
                {
                    lineAmmeterInfo.LineNum = "";
                }

                if (null != dt.Rows[0].ItemArray[1])
                {
                    lineAmmeterInfo.AmmeterNo = dt.Rows[0].ItemArray[1].ToString().Trim();
                }
                else
                {
                    lineAmmeterInfo.AmmeterNo = "";
                }

                if (null != dt.Rows[0].ItemArray[2])
                {
                    lineAmmeterInfo.AmmeterName = dt.Rows[0].ItemArray[2].ToString().Trim();
                }
                else
                {
                    lineAmmeterInfo.AmmeterName = "";
                }

                if (null != dt.Rows[0].ItemArray[3])
                {
                    lineAmmeterInfo.LineAmmeterMulti = dt.Rows[0].ItemArray[3].ToString().Trim();
                }
                else
                {
                    lineAmmeterInfo.LineAmmeterMulti = "";
                }

                if (null != dt.Rows[0].ItemArray[4])
                {
                    lineAmmeterInfo.LineAmmeterDate = dt.Rows[0].ItemArray[4].ToString().Trim();
                }
                else
                {
                    lineAmmeterInfo.LineAmmeterDate = "";
                }

                return Constant.OK;
            }
            catch (Exception)
            {
                return Constant.ERROR;
            }
        }
 /**
 * 更新线路电表信息
 * @param       ref LineAmmeterInfo lineAmmeterInfo:电表信息
  * @param      string l_a_no:电表号
 * @return      int 值为Constant.OK:执行成功,值为Constant.ERROR为执行失败
 * @author      Rick
 **/
 public int updateLineAmmeter(string lineNo, string l_a_no,  ref LineAmmeterInfo lineAmmeterInfo)
 {
     string strUpdate = "update LineAmmeterInfo set AmmeterName = '" + lineAmmeterInfo.AmmeterName + "', LineAmmeterMulti = " + lineAmmeterInfo.LineAmmeterMulti + ", LineAmmeterDate = getdate()" + " where LineNum = " + lineNo + "and AmmeterNo = " + l_a_no;
     try
     {
         SQLUtl.ExecuteSql(strUpdate);
         return Constant.OK;
     }
     catch (Exception)
     {
         return Constant.ERROR;
     }
 }