⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 operatecontrol.cs

📁 入门级asp.netC#网站三层系统开发
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using DAL.Accessor;
using Common.Entities;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

//该源码下载自www.51aspx.com(51aspx.com)

namespace BLL
{
    public class OperateControl
    {
        //绑定下拉列表
        public static void BindDropDownList(DropDownList dropDownList,SqlDataReader reader,string value,string text)
        {
            while (reader.Read())
            {
                dropDownList.Items.Add(new ListItem(reader[text].ToString(), reader[value].ToString()));
            }
            reader.Dispose();
        }
        //上传文件
        public static string UpLoad(HtmlInputFile file, string saveFile)
        {
            //获取文件路径
            string fileName = file.PostedFile.FileName;
            //获取文件的后缀
            string extendName = fileName.Substring(fileName.LastIndexOf(".") + 1).ToLower();
            string newName = null;
            //过滤文件的后缀
            if (extendName == "jpg" || extendName == "bmp")
            {
                DateTime now = DateTime.Now;
                newName = now.Year.ToString() + now.Month.ToString() + now.Day.ToString() + now.Hour.ToString() + now.Minute.ToString() + now.Second.ToString();
                file.PostedFile.SaveAs(saveFile + "/" + newName + "." + extendName);
            }
            return newName + "." + extendName;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -