/// <summary>
 /// ��������б�
 /// </summary>
 public List<WebProject.Model.BaseData.ZT_COM_CompanyInfo> DataTableToList(DataTable dt)
 {
     List<WebProject.Model.BaseData.ZT_COM_CompanyInfo> modelList = new List<WebProject.Model.BaseData.ZT_COM_CompanyInfo>();
     int rowsCount = dt.Rows.Count;
     if (rowsCount > 0)
     {
         WebProject.Model.BaseData.ZT_COM_CompanyInfo model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new WebProject.Model.BaseData.ZT_COM_CompanyInfo();
             if(dt.Rows[n]["InfoID"].ToString()!="")
             {
                 model.InfoID=int.Parse(dt.Rows[n]["InfoID"].ToString());
             }
             if(dt.Rows[n]["InfoOrder"].ToString()!="")
             {
                 model.InfoOrder=int.Parse(dt.Rows[n]["InfoOrder"].ToString());
             }
             model.Title=dt.Rows[n]["Title"].ToString();
             model.ImgUrl=dt.Rows[n]["ImgUrl"].ToString();
             model.Body=dt.Rows[n]["Body"].ToString();
             model.CreateBy=dt.Rows[n]["CreateBy"].ToString();
             if(dt.Rows[n]["CreateDate"].ToString()!="")
             {
                 model.CreateDate=DateTime.Parse(dt.Rows[n]["CreateDate"].ToString());
             }
             model.LastUpdateBy=dt.Rows[n]["LastUpdateBy"].ToString();
             if(dt.Rows[n]["LastUpdateDate"].ToString()!="")
             {
                 model.LastUpdateDate=DateTime.Parse(dt.Rows[n]["LastUpdateDate"].ToString());
             }
             model.Remark=dt.Rows[n]["Remark"].ToString();
             modelList.Add(model);
         }
     }
     return modelList;
 }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (Session["ZT_ADMIN"] == null)
        {
            Response.Redirect("Login.aspx");
        }
        else
        {
            if (this.txtTitle.Text.Trim() == "")
            {
                MessageBox.Show(this, "请输入信息名称!");
                return;
            }
            int InfoOrder;
            if (this.txtInfoOrder.Text.Trim() == "")
            {
                InfoOrder = 1000;
            }
            else
            {
                double u;
                if (!double.TryParse(this.txtInfoOrder.Text.Trim(), out u))
                {
                    MessageBox.Show(this, "排序必须为数字!");
                    return;
                }
                else
                {
                    InfoOrder = Convert.ToInt32(this.txtInfoOrder.Text.Trim());
                }
            }
            if (this.txtBody.Text.Trim() == "")
            {
                MessageBox.Show(this, "请输入信息内容!");
                return;
            }

            Boolean fileTypeOK = false;
            String path = Server.MapPath("~/SysManage/IMG/");
            if (txtImgUrl.HasFile == false)
            {
                WebProject.Model.BaseData.ZT_COM_CompanyInfo model_CompanyInfo = new WebProject.Model.BaseData.ZT_COM_CompanyInfo();
                model_CompanyInfo.Body = this.txtBody.Text.Trim();
                model_CompanyInfo.CreateBy = SessionUtil.GetAdminSession().AdminNo;
                model_CompanyInfo.CreateDate = DateTime.Now;
                model_CompanyInfo.ImgUrl = "onlinenone.jpg";
                model_CompanyInfo.InfoOrder = Int32.Parse(this.txtInfoOrder.Text.Trim());
                model_CompanyInfo.Title = this.txtTitle.Text.Trim();
                WebProject.BLL.BaseData.ZT_COM_CompanyInfo bll_CompanyInfo = new WebProject.BLL.BaseData.ZT_COM_CompanyInfo();
                bll_CompanyInfo.Add(model_CompanyInfo);
                LogManage.WriteLog(Request.UserHostAddress, "公司信息管理", "添加公司信息", "成功", "信息标题:" + model_CompanyInfo.Title + ", 创建人:" + SessionUtil.GetAdminSession().AdminNo);
                MessageBox.ShowAndRedirect(this, "添加信息成功!", "CompanyInfoList.aspx");
            }
            if (txtImgUrl.HasFile == true)
            {
                String fileExtension = System.IO.Path.GetExtension(txtImgUrl.FileName).ToLower();
                String[] allowedExtensions = { ".bmp", ".jpg", ".jpeg", ".png", ".gif" };
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtension == allowedExtensions[i])
                    {
                        fileTypeOK = true;
                        break;
                    }
                }
                if (fileTypeOK == false)
                {
                    MessageBox.Show(this, "你要上传的文件类型不符合要求!");
                    return;
                }
                if (fileTypeOK == true)
                {
                    if (txtImgUrl.PostedFile.ContentLength > 10240000)
                    {
                        MessageBox.Show(this, "你选择上传的文件不能大于10M,请重新选择!");
                        return;
                    }
                    if (txtImgUrl.PostedFile.ContentLength <= 10240000)
                    {
                        try
                        {
                            string SaveFileName = DateTime.Now.ToString().Replace("-", "").Replace(" ", "").Replace(":", "") + fileExtension;
                            txtImgUrl.PostedFile.SaveAs(path + SaveFileName);
                            WebProject.Model.BaseData.ZT_COM_CompanyInfo model_CompanyInfo = new WebProject.Model.BaseData.ZT_COM_CompanyInfo();
                            model_CompanyInfo.Body = this.txtBody.Text.Trim();
                            model_CompanyInfo.CreateBy = SessionUtil.GetAdminSession().AdminNo;
                            model_CompanyInfo.CreateDate = DateTime.Now;
                            model_CompanyInfo.ImgUrl = SaveFileName;
                            model_CompanyInfo.InfoOrder = Int32.Parse(this.txtInfoOrder.Text.Trim());
                            model_CompanyInfo.Title = this.txtTitle.Text.Trim();
                            WebProject.BLL.BaseData.ZT_COM_CompanyInfo bll_CompanyInfo = new WebProject.BLL.BaseData.ZT_COM_CompanyInfo();
                            bll_CompanyInfo.Add(model_CompanyInfo);
                            LogManage.WriteLog(Request.UserHostAddress, "公司信息管理", "添加公司信息", "成功", "信息标题:" + model_CompanyInfo.Title + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo);
                            MessageBox.ShowAndRedirect(this, "添加信息成功!", "CompanyInfoList.aspx");
                        }
                        catch (Exception)
                        {
                            MessageBox.Show(this, "文件上传失败!");
                            return;
                        }
                    }
                }
            }
        }
    }