//保存洗唛图片 protected void BtnSave_Click(object sender, DirectEventArgs e) { Y_CareLabel _Y_CareLabel = new Y_CareLabel(); string filename = UpFile.PostedFile.FileName; if (Hid.Text.Length > 0) { _Y_CareLabel = WMSFactory.Y_CareLabel.FindById(Hid.Text); } else { if (string.IsNullOrEmpty(filename)) { X.Msg.Alert("失败", "请选择图片文件!").Show(); return; } } if (!string.IsNullOrEmpty(filename)) { string ext = Path.GetExtension(filename).ToLower(); if (ext != ".png" && ext != ".jpg") { X.Msg.Notify("失败", "<font color='red'>文件格式不正确,仅支持png,jpg格式文件!</font>").Show(); return; } filename = DateTime.Now.ToString("yyyyMMddHHmmss") + ext; UpFile.PostedFile.SaveAs(Server.MapPath("XMimg/" + filename)); if (File.Exists(Server.MapPath("XMimg/" + _Y_CareLabel.LbUrl))) { File.Delete(Server.MapPath("XMimg/" + _Y_CareLabel.LbUrl)); } _Y_CareLabel.LbUrl = filename; //图标地址 } _Y_CareLabel.LbName = TxtLbName.Text; //图标名称 bool isok = false; if (Hid.Text.Length > 0) { isok = WMSFactory.Y_CareLabel.Update(_Y_CareLabel); } else { isok = WMSFactory.Y_CareLabel.Add(_Y_CareLabel); } if (isok) { CL_WinEdit.Hide(); CL_Grid.Reload(); MsgBox.NotifiShow("恭喜您,操作成功!", "OK"); } else { MsgBox.MessageShow("操作失败,请您重试!", "ERROR"); } }
protected void BtnClearImg_Click(object sender, DirectEventArgs e) { try { if (Hid.Text.Length > 0) { IList <Y_StylePicture> list = WMSFactory.Y_StylePicture.FindByCondition("StyleId+ColorId='" + Hid.Text.Trim() + "'"); Y_StylePicture _Y_StylePicture = new Y_StylePicture(); if (list != null && list.Count == 1) { _Y_StylePicture = list[0]; if (File.Exists(Server.MapPath("StylePicture/" + _Y_StylePicture.Picture))) { File.Delete(Server.MapPath("StylePicture/" + _Y_StylePicture.Picture)); } _Y_StylePicture.Picture = ""; //图标地址 if (WMSFactory.Y_StylePicture.Update(_Y_StylePicture)) { CL_WinEdit.Hide(); Y_Grid.Reload(); MsgBox.NotifiShow("恭喜您,图片清除成功!", "OK"); } else { MsgBox.MessageShow("操作失败,请您重试!", "ERROR"); } } else { CL_WinEdit.Hide(); MsgBox.NotifiShow("恭喜您,图片清除成功!", "OK"); } } else { X.Msg.Alert("失败", "请重新选择要操作的行!").Show(); return; } } catch (Exception error) { X.Msg.Alert("失败", "异常:" + error.Message).Show(); return; } }
//保存已经选择的图片 protected void BtnSaveSelected_Click(object sender, DirectEventArgs e) { if (StyleIDHidden.Text == "") { MsgBox.MessageShow("请先输入款式编号,然后单击查询按钮!", "ERROR"); return; } RowSelectionModel sm = CL_Grid.SelectionModel.Primary as RowSelectionModel; foreach (SelectedRow row in sm.SelectedRows) { Y_StyleCareLabel _Y_CareLabel = new Y_StyleCareLabel(); _Y_CareLabel.LbId = int.Parse(row.RecordID); _Y_CareLabel.StyleId = StyleIDHidden.Text; WMSFactory.Y_StyleCareLabel.Add(_Y_CareLabel); } CL_Win.Hide(); CL_WinEdit.Hide(); Y_CareLabel_Grid.Reload(); }
protected void BtnSave_Click(object sender, DirectEventArgs e) { try { Y_StylePicture _Y_StylePicture = new Y_StylePicture(); string filename = UpFile.PostedFile.FileName; if (string.IsNullOrEmpty(filename)) { X.Msg.Alert("失败", "请先选择要上传的图片!").Show(); return; } if (Hid.Text.Length > 0) { string ext = Path.GetExtension(filename).ToLower(); if (ext != ".png" && ext != ".jpg") { X.Msg.Notify("失败", "<font color='red'>文件格式不正确,仅支持png,jpg格式文件!</font>").Show(); return; } filename = DateTime.Now.ToString("yyyyMMddHHmmss") + ext; UpFile.PostedFile.SaveAs(Server.MapPath("StylePicture/" + filename)); IList <Y_StylePicture> list = WMSFactory.Y_StylePicture.FindByCondition("StyleId+ColorId='" + Hid.Text.Trim() + "'"); bool isok = false; if (list != null && list.Count == 1) { _Y_StylePicture = list[0]; if (File.Exists(Server.MapPath("StylePicture/" + _Y_StylePicture.Picture))) { File.Delete(Server.MapPath("StylePicture/" + _Y_StylePicture.Picture)); } _Y_StylePicture.Picture = filename; //图标地址 isok = WMSFactory.Y_StylePicture.Update(_Y_StylePicture); } else { _Y_StylePicture.StyleId = Hid.Text.Trim().Substring(0, Hid.Text.Trim().Length - 1); _Y_StylePicture.ColorId = Hid.Text.Trim().Replace(_Y_StylePicture.StyleId, ""); _Y_StylePicture.Picture = filename; isok = WMSFactory.Y_StylePicture.Add(_Y_StylePicture); } if (isok) { CL_WinEdit.Hide(); Y_Grid.Reload(); MsgBox.NotifiShow("恭喜您,操作成功!", "OK"); } else { MsgBox.MessageShow("操作失败,请您重试!", "ERROR"); } } else { X.Msg.Alert("失败", "请重新选择要修改的行!").Show(); return; } } catch (Exception error) { X.Msg.Alert("失败", "异常:" + error.Message).Show(); return; } }