/admins/Config.aspx.cs

http://github.com/gmhawash/SSR · C# · 91 lines · 78 code · 13 blank · 0 comment · 7 complexity · 7791aae6730934d44bb5bb3fc57aaf3c MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data;
  8. using System.Web.UI.WebControls.WebParts;
  9. using System.Web.UI.HtmlControls;
  10. using System.Data.SqlClient;
  11. using System.Data.Common;
  12. public partial class admins_Default2 : ZaytonaClasses.ZPage
  13. {
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16. }
  17. protected void NoDataInsert_Click(object sender, EventArgs e)
  18. {
  19. TextBox tbCode = DeptGridView.Controls[0].Controls[0].FindControl("NoDataCode") as TextBox;
  20. TextBox tbDescription = DeptGridView.Controls[0].Controls[0].FindControl("NoDataDescription") as TextBox;
  21. DeptsBLL deptBll = new DeptsBLL();
  22. deptBll.AddDept(tbCode.Text, tbDescription.Text);
  23. DeptGridView.DataBind();
  24. }
  25. protected void InsertNew_Click(object sender, EventArgs e)
  26. {
  27. TextBox tbCode = DeptGridView.FooterRow.FindControl("InsertCode") as TextBox;
  28. TextBox tbDescription = DeptGridView.FooterRow.FindControl("InsertDescription") as TextBox;
  29. DeptsBLL deptBll = new DeptsBLL();
  30. deptBll.AddDept(tbCode.Text, tbDescription.Text);
  31. DeptGridView.DataBind();
  32. }
  33. protected void GroupInsert(TextBox tb1, TextBox tb2, DropDownList dd)
  34. {
  35. try
  36. {
  37. GroupsBLL groupBll = new GroupsBLL();
  38. groupBll.AddGroup(tb1.Text, tb2.Text, new Guid(dd.SelectedItem.Value));
  39. GroupGridView.DataBind();
  40. }
  41. catch (Exception e)
  42. {
  43. Flash.Text = e.Message;
  44. Flash.Visible = true;
  45. }
  46. }
  47. protected void GroupInsert_Click(object sender, EventArgs e)
  48. {
  49. if (((LinkButton)sender).ID == "InsertFirst")
  50. {
  51. TextBox tb1 = GroupGridView.Controls[0].Controls[0].FindControl("GroupFirstCode") as TextBox;
  52. TextBox tb2 = GroupGridView.Controls[0].Controls[0].FindControl("GroupFirstName") as TextBox;
  53. DropDownList dd = GroupGridView.Controls[0].Controls[0].FindControl("GroupFirstDeptId") as DropDownList;
  54. GroupInsert(tb1, tb2, dd);
  55. }
  56. else if (((LinkButton)sender).ID == "InsertNew")
  57. {
  58. TextBox tb1 = GroupGridView.FooterRow.FindControl("GroupCode") as TextBox;
  59. TextBox tb2 = GroupGridView.FooterRow.FindControl("GroupName") as TextBox;
  60. DropDownList dd = GroupGridView.FooterRow.FindControl("GroupDeptId") as DropDownList;
  61. GroupInsert(tb1, tb2, dd);
  62. }
  63. }
  64. protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
  65. {
  66. TextBox tb1 = GroupGridView.FooterRow.FindControl("GroupCode") as TextBox;
  67. }
  68. protected void GroupGridView_RowUpdated(object sender, GridViewUpdatedEventArgs e)
  69. {
  70. if (e.Exception != null)
  71. {
  72. Flash.Visible = true;
  73. Flash.Text = e.Exception.Message;
  74. e.ExceptionHandled = true;
  75. e.KeepInEditMode = true;
  76. }
  77. }
  78. }