Пример #1
0
        /// <summary>
        /// 删除预测项目
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelPrj_ItemClick(object sender, ItemClickEventArgs e)
        {
            string    msg      = string.Empty;
            CafcUtils cafcUtil = new CafcUtils();

            try
            {
                this.gvForePrj.PostEditor();
                CafcService.ForecastPrj[] prjObjArr       = (CafcService.ForecastPrj[]) this.gvForePrj.DataSource;
                List <string>             selectPrjIdList = new List <string>();
                if (prjObjArr != null)
                {
                    foreach (CafcService.ForecastPrj prjObj in (CafcService.ForecastPrj[]) this.gvForePrj.DataSource)
                    {
                        if (prjObj.Check)
                        {
                            selectPrjIdList.Add(prjObj.Prj_Id.Trim());
                        }
                    }
                }

                if (selectPrjIdList.Count > 0)
                {
                    bool flag = cafcService.DelForecastPrj(Utils.userId, Utils.password, selectPrjIdList.ToArray());

                    if (flag)
                    {
                        this.SearchForecastPrj();
                        this.ResetForecastParam();
                        msg = "项目删除成功!";
                    }
                    else
                    {
                        msg = "项目删除失败";
                    }
                }
                else
                {
                    msg = "请选择要删除的项目";
                }
            }
            catch (Exception ex)
            {
                msg += "项目保存失败:" + ex.Message;
            }
            MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Пример #2
0
        //private bool DelForecastParam(string[] paramIdArr)
        //{
        //    string msg = string.Empty;
        //    try
        //    {
        //        bool result = cafcService.DelForecastParam(Utils.userId, Utils.password, paramIdArr);
        //    }
        //    catch (Exception ex)
        //    {
        //        msg += string.Format("查询出错:{0}\r\n", ex.Message);
        //    }

        //    return msg;
        //}

        /// <summary>
        /// 获取需要修改的预测项目信息
        /// </summary>
        /// <returns></returns>
        private CafcService.ForecastPrj GetEidtForecastPrjObj()
        {
            try
            {
                CafcUtils cafcUtil = new CafcUtils();

                this.gvForePrj.PostEditor();
                CafcService.ForecastPrj[]      prjObjArr        = (CafcService.ForecastPrj[]) this.gvForePrj.DataSource;
                List <CafcService.ForecastPrj> selectPrjObjList = new List <CafcService.ForecastPrj>();
                if (prjObjArr != null)
                {
                    foreach (CafcService.ForecastPrj prjObj in (CafcService.ForecastPrj[]) this.gvForePrj.DataSource)
                    {
                        if (prjObj.Check)
                        {
                            selectPrjObjList.Add(prjObj);
                        }
                    }
                }

                if (selectPrjObjList != null)
                {
                    if (selectPrjObjList.Count > 1)
                    {
                        MessageBox.Show("只能选择一个项目", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return(null);
                    }
                    else if (selectPrjObjList.Count < 1)
                    {
                        MessageBox.Show("请选择一个项目", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return(null);
                    }
                    else
                    {
                        return(selectPrjObjList[0]);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            return(null);
        }