public Resistor(ComponentDirection direction, double resistance, double voltage, double current) : base(direction, resistance, voltage, current) { ImageUp = Resources.Resistor; ImageUp.RotateFlip(RotateFlipType.Rotate90FlipNone); ImageRight = Resources.Resistor; ImageDown = Resources.Resistor; ImageDown.RotateFlip(RotateFlipType.Rotate90FlipNone); ImageLeft = Resources.Resistor; ComponentType = ComponentType.Resistor; Direction = direction; }
public Cell(ComponentDirection direction, double resistance, double voltage, double current) : base(direction, resistance, voltage, current) { ImageUp = Resources.Power_Supply; ImageUp.RotateFlip(RotateFlipType.Rotate90FlipY); ImageRight = Resources.Power_Supply; ImageDown = Resources.Power_Supply; ImageDown.RotateFlip(RotateFlipType.Rotate90FlipNone); ImageLeft = Resources.Power_Supply; ImageLeft.RotateFlip(RotateFlipType.RotateNoneFlipX); ComponentType = ComponentType.Cell; Direction = direction; }
public WireThreeWay(ComponentDirection direction, double resistance, double voltage, double current) : base(direction, resistance, voltage, current) { //Direction is where the most anti clockwise wire is facing. //E.g. For up right, the most anti clockwise wire is facing to the right. ImageUp = Resources._3_Way_Up; ImageUp.RotateFlip(RotateFlipType.Rotate90FlipNone); ImageRight = Resources._3_Way_Up; ImageDown = Resources._3_Way_Down; ImageDown.RotateFlip(RotateFlipType.Rotate90FlipNone); ImageLeft = Resources._3_Way_Down; ComponentType = ComponentType.WireThreeWay; Direction = direction; }
//添加新闻 protected void Button1_Click(object sender, EventArgs e) { //表示编辑功能 if (Request.QueryString["type"] != null) { //修改新闻 int id = Convert.ToInt32(Request.QueryString["id"].ToString()); //编号 var news = Entity.News.FirstOrDefault(a => a.Id == id); //获取对象 news.Title = Title.Text; news.Type = Type.Text; news.Content = Request["editor"]; //获取图片 if (Request.Files.Count > 0) { string ImagePath = ImageUp.SaveImage(Request.Files["ImagePath"], Server.MapPath("~/File/")); news.Image = ImagePath; } //保存数据 Entity.Entry(news).State = EntityState.Modified; Entity.SaveChanges(); Message("Manage.aspx", "保存成功"); } else { //添加新闻 News news = new News(); news.Title = Title.Text; news.Type = Type.Text; news.Content = Request["editor"]; news.ClickNum = 0; news.OperTime = DateTime.Now; //获取图片 if (Request.Files.Count > 0) { string ImagePath = ImageUp.SaveImage(Request.Files["ImagePath"], Server.MapPath("~/File/")); news.Image = ImagePath; } //插入数据 Entity.News.Add(news); Entity.SaveChanges(); Message("保存成功"); } }
protected void UpLoad_Click(object sender, EventArgs e) { string savepath = @"~/Image/"; string filetype = string.Empty; if (!Directory.Exists(savepath)) { Directory.CreateDirectory(savepath); } if (ImageUp.HasFile) { string TempSql = "select count(*) from goods"; string ConStr = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; SqlConnection con = new SqlConnection(ConStr); SqlCommand cmd = new SqlCommand(TempSql, con); string id = "0"; using (con) { con.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { id = dr[0].ToString(); } dr.Close(); con.Close(); } string filename = ImageUp.FileName; filetype = Path.GetExtension(filename).ToLower(); if (filetype == ".jpg") { savepath += id; savepath += ".jpg"; ImageUp.SaveAs(savepath); GoodImage.ImageUrl = @"~/Image/" + id + ".jpg"; } else { ImageMsg.Text = "只允许上传.jpg类型的图片。"; } } }