private void fixWebButton_Click(object sender, RoutedEventArgs e) { string boxStr = this.TextDemo.Text; boxStr = tencentServer.fixFomulashtml(boxStr); WebDemo.NavigateToString(boxStr); }
protected void btnSave_Click(object sender, EventArgs e) { try { WebDemo obj = new WebDemo(); int ParentID = obj.GetRootID(Globals.AgentCatID); string Name = txtCategoryName.Value.Trim(); string Order = txtCategoryOrder.Value.Trim(); string Action = Globals.GetStringFromQueryString("Action"); int kq = -1; if (Action == "Edit") //Cập nhật { int ID = Globals.GetIntFromQueryString("ID"); kq = obj.UpdateWebDemoGroup(ID, Globals.AgentCatID, Name, ParentID, Order); ShowMessage(kq, "cập nhật"); } else //Thêm mới { kq = obj.InsertWebDemoGroup(Globals.AgentCatID, Name, ParentID, Order); ShowMessage(kq, "thêm mới"); } LoadTreeViewCategory(TreeViewCategory); } catch (FormatException) { MessageBox.Show("Vui lòng nhập thứ tự là Số Nguyên!"); txtCategoryOrder.Focus(); } }
private void LoadWebDemoGroup() { WebDemo obj = new WebDemo(); int RootID = obj.GetRootID(Globals.AgentCatID); DataSet ds = obj.GetWebDemoGroupByParentID("WebDemoGroup", Globals.AgentCatID, RootID); DropDownListHelper ddlHelp = new DropDownListHelper(); ddlHelp.FillData(ddlCategory, ds, "Name", "ID", "---Chọn chuyên mục WebDemo---"); }
private void fixWebButton_Click(object sender, RoutedEventArgs e) { progresring.Visibility = Visibility.Visible; string boxStr = this.TextDemo.Text; boxStr = tencentServer.fixFomulashtml(boxStr); WebDemo.NavigateToString(boxStr); progresring.Visibility = Visibility.Collapsed; }
private void LoadGridViewDemoList() { try { WebDemo obj = new WebDemo(); DataSet ds = obj.GetAllWebDemo("WebDemo", Globals.AgentCatID); GridViewHelper gvHelper = new GridViewHelper(); gvHelper.FillData(gridViewDemoList, ds); } catch { } }
private void LoadDataEdit() { try { WebDemo obj = new WebDemo(); int ID = Globals.GetIntFromQueryString("ID"); DataSet ds = obj.GetWebDemoGroupByID("WebDemoGroup", Globals.AgentCatID, ID); txtCategoryName.Value = Convert.ToString(ds.Tables[0].Rows[0]["Name"]); txtCategoryOrder.Value = Convert.ToString(ds.Tables[0].Rows[0]["Order"]); } catch { } }
protected void btnDelete_Click(object sender, EventArgs e) { try { int ID = Globals.GetIntFromQueryString("ID"); WebDemo obj = new WebDemo(); int kq = -1; kq = obj.DeleteWebDemoGroup(ID); LoadTreeViewCategory(TreeViewCategory); ShowMessage(kq, "xóa"); } catch { } }
protected void btnDelete_Click(object sender, EventArgs e) { try { int ID = Globals.GetIntFromQueryString("ID"); WebDemo obj = new WebDemo(); DataSet ds = obj.GetWebDemoByID("WebDemo", Globals.AgentCatID, ID); Globals.DeleteFile(Convert.ToString(ds.Tables[0].Rows[0]["SmallImage"]), "ImageFiles/WebDemos"); Globals.DeleteFile(Convert.ToString(ds.Tables[0].Rows[0]["LargeImage"]), "ImageFiles/WebDemos"); obj.DeleteWebDemo(ID); Response.Redirect("DemoList.aspx"); } catch { } }
protected void gridViewDemoList_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { GridViewRow row = gridViewDemoList.Rows[e.RowIndex]; Int32 ID = Convert.ToInt32(((Label)row.Cells[0].FindControl("lblID")).Text); WebDemo obj = new WebDemo(); DataSet ds = obj.GetWebDemoByID("WebDemo", Globals.AgentCatID, ID); Globals.DeleteFile(Convert.ToString(ds.Tables[0].Rows[0]["SmallImage"]), "ImageFiles/WebDemos"); Globals.DeleteFile(Convert.ToString(ds.Tables[0].Rows[0]["LargeImage"]), "ImageFiles/WebDemos"); obj.DeleteWebDemo(ID); LoadGridViewDemoList(); } catch { } }
private void Save() { try { WebDemo obj = new WebDemo(); int GroupID = Convert.ToInt32(ddlCategory.SelectedValue); string Link = txtLink.Value.Trim(); if (Action == "Edit") { int ID = Globals.GetIntFromQueryString("ID"); obj.UpdateWebDemo(ID, Globals.AgentCatID, GroupID, Convert.ToString(Session["SmallImageName"]), Convert.ToString(Session["LargeImageName"]), "", "", Link); } else { obj.InsertWebDemo(Globals.AgentCatID, GroupID, Convert.ToString(Session["SmallImageName"]), Convert.ToString(Session["LargeImageName"]), "", "", Link); } } catch { } }
/// <summary> /// Load các danh mục chủng loại WebDemo vào TreeViewCategory /// </summary> /// <param name="TreeViewCategory"></param> /// <param name="Lang"></param> public void LoadTreeViewCategory(TreeView TreeViewCategory) { try { TreeViewCategory.Nodes.Clear(); WebDemo obj = new WebDemo(); int RootID = obj.GetRootID(Globals.AgentCatID); DataSet dsParent = obj.GetWebDemoGroupByParentID("WebDemoGroup", Globals.AgentCatID, RootID); for (int i = 0; i < dsParent.Tables[0].Rows.Count; i++) { TreeNode newNode = new TreeNode(Convert.ToString(dsParent.Tables[0].Rows[i]["Name"]), Convert.ToString(dsParent.Tables[0].Rows[i]["ID"])); newNode.ToolTip = Convert.ToString(dsParent.Tables[0].Rows[i]["Name"]); newNode.NavigateUrl = "Catalog.aspx?Action=Edit&ID=" + Convert.ToString(dsParent.Tables[0].Rows[i]["ID"]); newNode.ExpandAll(); //RootNode.ChildNodes.Add(newNode); TreeViewCategory.Nodes.Add(newNode); } } catch { } }
private async System.Threading.Tasks.Task chooseImageAndDeSerAsync() { FileOpenPicker picker = new FileOpenPicker(); picker.FileTypeFilter.Add(".png"); picker.FileTypeFilter.Add(".jpg"); picker.FileTypeFilter.Add(".jpeg"); var file = await picker.PickSingleFileAsync(); if (file != null) { file = await file.CopyAsync(ApplicationData.Current.LocalFolder, file.GetHashCode() + file.Name); try { BitmapImage bmp = new BitmapImage(); await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read)); ImageControl.Source = bmp; List <String> data; if (this.recognizeWordsCheck.IsChecked == true) { data = await TencentPaperData.getPaperStringArrayAsync(file); } else { data = await TencentData.getLatexStringArrayAsync(file); } if (data == null) { throw new Exception("Json didn't deserialize anything"); } HtmlResult htmlResult; try { tencentServer.init(); htmlResult = tencentServer.getServerHtmls(data); } catch (Exception e) { htmlResult = tencentServer.WebServerErrorHandles(e); } if (recognizeWordsCheck.IsChecked == true) { foreach (var i in data) { TextDemo.Text += i + "\n"; } WebDemo.NavigateToString(htmlResult.result_w); } else if (recognizeWordsCheck.IsChecked == false) { foreach (var i in data) { TextDemo.Text += i + "\n"; } WebDemo.NavigateToString(htmlResult.result_f); } else { WebDemo.NavigateToString(tencentServer.WebServerErrorHandle(new Exception("wrong option"))); } HistoryData.addHistory(new recognizedData(bmp, TextDemo.Text, htmlResult, file)); await HistoryData.storeAsync(); } catch (WebException ex) { try { var res = (HttpWebResponse)ex.Response; StreamReader streamReader = new StreamReader(res.GetResponseStream()); MainPage.Current.toNavigate(typeof(ErrorPage)); ErrorPage.errorPage.showError(ex.Message + streamReader.ReadToEnd()); initalizeProgressringAndImage(); } catch (Exception e) { MainPage.Current.toNavigate(typeof(ErrorPage)); ErrorPage.errorPage.showError(e.Message + "(Probably network problem)"); initalizeProgressringAndImage(); } } catch (Exception ex) { MainPage.Current.toNavigate(typeof(ErrorPage)); ErrorPage.errorPage.showError(ex.Message); initalizeProgressringAndImage(); } } else { DisplayNoFileDialog(); initalizeProgressringAndImage(); } saveStringTorefresh = TextDemo.Text; }
private async System.Threading.Tasks.Task <HtmlResult> pasteImageAndDeSerAsync(RandomAccessStreamReference imageStream) { if (imageStream != null) { try { BitmapImage bmp = new BitmapImage(); await bmp.SetSourceAsync(await imageStream.OpenReadAsync()); ImageControl.Source = bmp; List <string> data; if (this.recognizeWordsCheck.IsChecked == true) { data = await TencentPaperData.getPaperStringArrayAsync(imageStream); } else { data = await TencentData.getLatexStringArrayAsync(imageStream); } if (data == null) { throw new Exception("Json didn't deserialize anything"); } HtmlResult htmlResult; try { tencentServer.init(); htmlResult = tencentServer.getServerHtmls(data); } catch (Exception e) { htmlResult = tencentServer.WebServerErrorHandles(e); } if (recognizeWordsCheck.IsChecked == true) { foreach (var i in data) { TextDemo.Text += i + "\n"; } WebDemo.NavigateToString(htmlResult.result_w); } else if (recognizeWordsCheck.IsChecked == false) { foreach (var i in data) { TextDemo.Text += i + "\n"; } WebDemo.NavigateToString(htmlResult.result_f); } else { WebDemo.NavigateToString(tencentServer.WebServerErrorHandle(new Exception("wrong option"))); } return(htmlResult); } catch (WebException ex) { try { var res = (HttpWebResponse)ex.Response; StreamReader streamReader = new StreamReader(res.GetResponseStream()); MainPage.Current.toNavigate(typeof(ErrorPage)); ErrorPage.errorPage.showError(ex.Message + streamReader.ReadToEnd()); } catch (Exception e) { MainPage.Current.toNavigate(typeof(ErrorPage)); ErrorPage.errorPage.showError(e.Message + "(Probably network problem)"); initalizeProgressringAndImage(); } } catch (Exception ex) { MainPage.Current.toNavigate(typeof(ErrorPage)); ErrorPage.errorPage.showError(ex.Message); initalizeProgressringAndImage(); } } else { MainPage.Current.toNavigate(typeof(ErrorPage)); ErrorPage.errorPage.showError("读取剪切板图片失败!检查剪切板内容"); initalizeProgressringAndImage(); } saveStringTorefresh = TextDemo.Text; return(new HtmlResult("", "")); }