Example #1
0
        //修改或加入新数据
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string time = txtTimeBegin.Value.Trim();

            if (string.IsNullOrEmpty(time))
            {
                JScript.Alert("请选择月份!");
                return;
            }
            MonthConsumeInfo info = new MonthConsumeInfo();
            string           year = time.Substring(0, 4);

            info.year = Convert.ToInt32(year);
            string month = string.Empty;

            if (time.Length > 6)
            {
                month = time.Substring(5, 2);
            }
            else
            {
                month = time.Substring(5, 1);
            }
            info.month = Convert.ToInt32(month);

            double value;

            if (double.TryParse(txtValue.Text.Trim(), out value))
            {
                info.values = value;
                DataTable dt = bc.GetMonthConsumeByTime(year, month, out errMsg);
                if (dt.Rows.Count > 0)
                {
                    //更新
                    if (bc.UpdateMonthConsumeByTime(info, out errMsg))
                    {
                        JScript.Alert("更新成功!");
                    }
                    else
                    {
                        JScript.Alert("更新失败!");
                    }
                }
                else
                {
                    //插入
                }
            }
            else
            {
                JScript.Alert("请输入数字!");
            }
        }
Example #2
0
        /// <summary>
        /// 更新指定时间供电能耗月线信息。
        /// </summary>
        /// <returns></returns>
        public bool UpdateMonthConsumeByTime(MonthConsumeInfo info, out string errMsg)
        {
            this.init();
            errMsg = "";
            bool   flag = false;
            string sql  = "update T_INFO_MONTHCONSUME SET T_VALUE=" + info.values + " where T_YEAR='" + info.year + "' and T_MONTH='" + info.month + "'";

            if (rlDBType == "SQL")
            {
                // sql = "select ID_KEY,班次名,起始时间,结束时间 from 班次时间表 order by ID_KEY";
                //dt = DBsql.RunDataTable(sql, out errMsg);
            }
            else
            {
                flag = DBdb2.RunNonQuery(sql, out errMsg);
            }
            return(flag);
        }
Example #3
0
        /// <summary>
        /// 获取所有供电能耗月线信息。
        /// </summary>
        /// <returns></returns>
        public List <MonthConsumeInfo> GetMonthConsume(out string errMsg)
        {
            DataTable dts = dc.GetMonthConsume(out errMsg);
            List <MonthConsumeInfo> infoList = new List <MonthConsumeInfo>();

            //转化为list,筛选。
            if (dts.Rows.Count > 0)
            {
                for (int i = 0; i < dts.Rows.Count; i++)
                {
                    MonthConsumeInfo info = new MonthConsumeInfo();

                    info.year   = String.IsNullOrEmpty(dts.Rows[i]["T_YEAR"].ToString()) ? 0 : Convert.ToInt32(dts.Rows[i]["T_YEAR"].ToString());
                    info.month  = String.IsNullOrEmpty(dts.Rows[i]["T_MONTH"].ToString()) ? 0 : Convert.ToInt32(dts.Rows[i]["T_MONTH"].ToString());
                    info.values = String.IsNullOrEmpty(dts.Rows[i]["T_VALUE"].ToString()) ? 0 : Convert.ToDouble(dts.Rows[i]["T_VALUE"].ToString());

                    infoList.Add(info);
                }
            }
            return(infoList);
        }
Example #4
0
 /// <summary>
 /// 更新指定时间供电能耗月线信息。
 /// </summary>
 /// <returns></returns>
 public bool UpdateMonthConsumeByTime(MonthConsumeInfo info, out string errMsg)
 {
     return(dc.UpdateMonthConsumeByTime(info, out errMsg));
 }