Exemplo n.º 1
0
        /// <summary>
        /// 得到周计划的项目明细
        /// </summary>
        /// <param name="f1"></param>
        /// <param name="saveFileName"></param>
        /// <returns></returns>
        public List <Tb_PlanDetailDD> GetWeekPlanDetailListByExcel(System.Web.UI.WebControls.FileUpload f1,
                                                                   ref String saveFileName)
        {
            List <Tb_PlanDetailDD> list1 = new List <Tb_PlanDetailDD>();

            try
            {
                if (f1.HasFile)
                {
                    System.Web.HttpServerUtility server = System.Web.HttpContext.Current.Server;
                    saveFileName = "/Attachment/Plan/" + WebFrame.Util.JString.GetUnique32ID()
                                   + System.IO.Path.GetExtension(f1.FileName);

                    String fname = server.MapPath(saveFileName);
                    UExcel u1    = new UExcel(XlsFormat.Xls2003);
                    f1.SaveAs(fname);
                    DataSet   ds1 = u1.XlsToDataSet(fname);
                    DataTable dt1 = ds1.Tables[0];

                    /*
                     * 分类/编号/计划内容/计划开始时间/计划结束时间/工作量预估(人天)/责任人/交付物/备注
                     */
                    for (int i = 2; i < dt1.Rows.Count; i++)
                    {
                        if (String.IsNullOrEmpty(dt1.Rows[i][1].ToString()) == false &&
                            String.IsNullOrEmpty(dt1.Rows[i][2].ToString()) == false)
                        {
                            Tb_PlanDetailDD dd1 = new Tb_PlanDetailDD();
                            dd1.PlanKind  = dt1.Rows[i][0].ToString();
                            dd1.PlanNum   = dt1.Rows[i][1].ToString();
                            dd1.PlanTitel = dt1.Rows[i][2].ToString();
                            dd1.BegTime   = DateTime.Parse(dt1.Rows[i][3].ToString());
                            dd1.EndTime   = DateTime.Parse(dt1.Rows[i][4].ToString());
                            dd1.Workload  = double.Parse(dt1.Rows[i][5].ToString());

                            //设置责任人
                            String zren1  = dt1.Rows[i][6].ToString();
                            String zrenid = KORWeb.BUL.JUserBU.GetUserIDByUserName(zren1);
                            dd1.ExecuteManID   = zrenid;
                            dd1.ExecuteManName = zren1;

                            dd1.PayMemo = dt1.Rows[i][7].ToString();
                            dd1.Remark  = dt1.Rows[i][8].ToString();

                            dd1.ParentNum     = dd1.PlanNum.Substring(0, 3);    //取前3位
                            dd1.MaonthPlanNum = dd1.PlanNum.Substring(0, 5);    //取前5位

                            list1.Add(dd1);
                        }
                    }
                }
            }
            catch (Exception err)
            {
                list1.Clear();
            }
            return(list1);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据计划文件Excel得到计划明细的数据
        /// </summary>
        /// <param name="f1"></param>
        /// <returns></returns>
        public List <Tb_PlanDetailDD> GetPlanDetailListByExcel(System.Web.UI.WebControls.FileUpload f1, ref String saveFileName)
        {
            List <Tb_PlanDetailDD> list1 = new List <Tb_PlanDetailDD>();

            try
            {
                if (f1.HasFile)
                {
                    System.Web.HttpServerUtility server = System.Web.HttpContext.Current.Server;
                    saveFileName = "/Attachment/Plan/" + WebFrame.Util.JString.GetUnique32ID()
                                   + System.IO.Path.GetExtension(f1.FileName);

                    String fname = server.MapPath(saveFileName);
                    UExcel u1    = new UExcel(XlsFormat.Xls2003);
                    f1.SaveAs(fname);
                    DataSet   ds1 = u1.XlsToDataSet(fname);
                    DataTable dt1 = ds1.Tables[0];

                    /*
                     * 分类/编号/计划内容/计划开始时间/计划结束时间/工作量预估(人天)/关键节点/交付物/备注
                     */
                    for (int i = 2; i < dt1.Rows.Count; i++)
                    {
                        if (String.IsNullOrEmpty(dt1.Rows[i][1].ToString()) == false &&
                            String.IsNullOrEmpty(dt1.Rows[i][2].ToString()) == false)
                        {
                            Tb_PlanDetailDD dd1 = new Tb_PlanDetailDD();
                            dd1.PlanKind  = dt1.Rows[i][0].ToString();
                            dd1.PlanNum   = dt1.Rows[i][1].ToString();
                            dd1.PlanTitel = dt1.Rows[i][2].ToString();
                            dd1.BegTime   = DateTime.Parse(dt1.Rows[i][3].ToString());
                            dd1.EndTime   = DateTime.Parse(dt1.Rows[i][4].ToString());
                            dd1.Workload  = double.Parse(dt1.Rows[i][5].ToString());
                            dd1.KeyPlan   = false;
                            if (dt1.Rows[i][6].ToString() != String.Empty)
                            {
                                if (dt1.Rows[i][6].ToString() == "是" || dt1.Rows[i][6].ToString() == "1" ||
                                    dt1.Rows[i][6].ToString().ToLower() == "yes" || dt1.Rows[i][6].ToString().ToLower() == "true")
                                {
                                    dd1.KeyPlan = true;
                                }
                            }
                            dd1.PayMemo = dt1.Rows[i][7].ToString();
                            dd1.Remark  = dt1.Rows[i][8].ToString();

                            list1.Add(dd1);
                        }
                    }
                }
            }
            catch (Exception err)
            {
                list1.Clear();
            }
            return(list1);
        }