Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Cerficate model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into cerficate(");
            strSql.Append("ID,EMPLOYEEID,CERTIFICATENAME,FILEPATH,DESCRIPTION,ISMAIN)");
            strSql.Append(" values (");
            strSql.Append("@ID,@EMPLOYEEID,@CERTIFICATENAME,@FILEPATH,@DESCRIPTION,@ISMAIN)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ID",              MySqlDbType.VarChar,  36),
                new MySqlParameter("@EMPLOYEEID",      MySqlDbType.VarChar,  36),
                new MySqlParameter("@CERTIFICATENAME", MySqlDbType.VarChar, 100),
                new MySqlParameter("@FILEPATH",        MySqlDbType.VarChar, 255),
                new MySqlParameter("@DESCRIPTION",     MySqlDbType.VarChar, 150),
                new MySqlParameter("@ISMAIN",          MySqlDbType.Bit)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.EMPLOYEEID;
            parameters[2].Value = model.CERTIFICATENAME;
            parameters[3].Value = model.FILEPATH;
            parameters[4].Value = model.DESCRIPTION;
            parameters[5].Value = model.ISMAIN;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        protected void LoadCerficate()
        {
            Cerficate certificate = cBll.GetModelList(" employeeID = '" + EmployeeID + "' AND isMain = 1 ").FirstOrDefault();

            //if (cerficate != null)
            //{
            //    imgCerficate.Src = "/FileOperation/ImageCompression.ashx?empID=" + EmployeeID + ""; // Convert.ToString(ConfigurationManager.AppSettings["fileSavePath"]) + "/" + cerficate.FILEPATH;
            //}
            if (certificate != null)
            {
                imgCerficate.ImageUrl = Path.Combine(ConfigurationManager.AppSettings["thumbnailsPath"].ToString(), certificate.FILEPATH); // "/FileOperation/ImageCompression.ashx?empID=" + EmployeeID;
            }
        }
Пример #3
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            if (fup.HasFile)
            {
                string employeeID     = UserProfile.GetInstance().ID;
                string fileNamePrefix = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                string fileName       = string.Format("{0}_{1}", fileNamePrefix, fup.FileName);
                string cerficateName  = txtCerficateName.Text.Trim();
                string description    = txtDescription.Text.Trim();
                string rootPath       = AppDomain.CurrentDomain.BaseDirectory;
                string fileSavePath   = ConfigurationManager.AppSettings["fileSavePath"].ToString();
                string thumbnailsPath = ConfigurationManager.AppSettings["thumbnailsPath"].ToString();
                string savePath       = Path.Combine(rootPath, fileSavePath, fileName);
                try
                {
                    fup.SaveAs(savePath);
                    string fileThumbnails    = Path.Combine(rootPath, thumbnailsPath, fileName);
                    System.Drawing.Image img = new Bitmap(savePath, true);
                    //aFile.Close();
                    System.Drawing.Image imgThumbnails = new ImageHelper().GetHvtThumbnail(img, 800, 0);

                    imgThumbnails.Save(fileThumbnails, System.Drawing.Imaging.ImageFormat.Jpeg);
                }
                catch (Exception ex)
                {
                    return;
                }
                Cerficate crf = new Cerficate();
                crf.ID              = Guid.NewGuid().ToString();
                crf.EMPLOYEEID      = employeeID;
                crf.CERTIFICATENAME = cerficateName;
                crf.FILEPATH        = fileName;
                crf.DESCRIPTION     = description;
                crf.ISMAIN          = cbxIsMain.Checked;
                cBll.Add(crf);
                if (cbxIsMain.Checked)
                {
                    cBll.SetIsMainToFalseExceptID(crf.ID);
                }
                LoadCerficate();
            }
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Cerficate DataRowToModel(DataRow row)
        {
            Cerficate model = new Cerficate();

            if (row != null)
            {
                if (row["ID"] != null)
                {
                    model.ID = row["ID"].ToString();
                }
                if (row["EMPLOYEEID"] != null)
                {
                    model.EMPLOYEEID = row["EMPLOYEEID"].ToString();
                }
                if (row["CERTIFICATENAME"] != null)
                {
                    model.CERTIFICATENAME = row["CERTIFICATENAME"].ToString();
                }
                if (row["FILEPATH"] != null)
                {
                    model.FILEPATH = row["FILEPATH"].ToString();
                }
                if (row["DESCRIPTION"] != null)
                {
                    model.DESCRIPTION = row["DESCRIPTION"].ToString();
                }
                if (row["ISMAIN"] != null && row["ISMAIN"].ToString() != "")
                {
                    if ((row["ISMAIN"].ToString() == "1") || (row["ISMAIN"].ToString().ToLower() == "true"))
                    {
                        model.ISMAIN = true;
                    }
                    else
                    {
                        model.ISMAIN = false;
                    }
                }
            }
            return(model);
        }
Пример #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Cerficate model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update cerficate set ");
            strSql.Append("EMPLOYEEID=@EMPLOYEEID,");
            strSql.Append("CERTIFICATENAME=@CERTIFICATENAME,");
            strSql.Append("FILEPATH=@FILEPATH,");
            strSql.Append("DESCRIPTION=@DESCRIPTION,");
            strSql.Append("ISMAIN=@ISMAIN");
            strSql.Append(" where ID=@ID ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@EMPLOYEEID",      MySqlDbType.VarChar,  36),
                new MySqlParameter("@CERTIFICATENAME", MySqlDbType.VarChar, 100),
                new MySqlParameter("@FILEPATH",        MySqlDbType.VarChar, 255),
                new MySqlParameter("@DESCRIPTION",     MySqlDbType.VarChar, 150),
                new MySqlParameter("@ISMAIN",          MySqlDbType.Bit),
                new MySqlParameter("@ID",              MySqlDbType.VarChar, 36)
            };
            parameters[0].Value = model.EMPLOYEEID;
            parameters[1].Value = model.CERTIFICATENAME;
            parameters[2].Value = model.FILEPATH;
            parameters[3].Value = model.DESCRIPTION;
            parameters[4].Value = model.ISMAIN;
            parameters[5].Value = model.ID;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Cerficate GetModel(string ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,EMPLOYEEID,CERTIFICATENAME,FILEPATH,DESCRIPTION,ISMAIN from cerficate ");
            strSql.Append(" where ID=@ID ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ID", MySqlDbType.VarChar, 36)
            };
            parameters[0].Value = ID;

            Cerficate model = new Cerficate();
            DataSet   ds    = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Cerficate model)
 {
     return(dal.Update(model));
 }
Пример #8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Cerficate model)
 {
     return(dal.Add(model));
 }