private Panel GenerateBookIssuesTable(List <book_issue> BookIssues, int x, int y) { Control[] TableControls = new Control[5 * (BookIssues.Count + 1)]; int ControlIdx = 0; TableControls[ControlIdx++] = new Label() { Text = "No" }; TableControls[ControlIdx++] = new Label() { Text = "RecId" }; TableControls[ControlIdx++] = new Label() { Text = "Title" }; TableControls[ControlIdx++] = new Label() { Text = "Option" }; TableControls[ControlIdx++] = new Label() { Text = "GeneratedId" }; int No = 1; foreach (book_issue BS in BookIssues) { string RecId = BS.book_record.id; Button BtnRemove = new Button() { Text = "Remove" }; BtnRemove.Click += new EventHandler((s, e) => { RemoveBookIssue(RecId); }); TableControls[ControlIdx++] = new Label() { Text = No++.ToString() }; TableControls[ControlIdx++] = new TextBoxReadonly() { Text = BS.book_record.id + "(" + BS.book_record.available + ")" }; TableControls[ControlIdx++] = new TextBoxReadonly() { Text = BS.book_record.book.title }; TableControls[ControlIdx++] = BtnRemove; TableControls[ControlIdx++] = new TextBoxReadonly() { Text = BS.id }; } return(ControlUtil.GeneratePanel(5, TableControls, 5, 100, 20, Color.Cornsilk, x, y, 550, 400)); }
protected override Panel ShowDetailPanel(object Object) { issue Issue = (issue)Object; Panel DetailPanel = new Panel(); Control[] DetailsCol = new Control[7 * (Issue.book_issue.Count + 1)]; //update string[] ColumnLabels = { "No", "IssueId", "RecId", "Title", "", "Returned", Issue.type.Trim() + " item id" }; for (int i = 0; i < ColumnLabels.Length; i++) { DetailsCol[i] = new TitleLabel(11) { Text = ColumnLabels[i] }; } int ControlIndex = 7; for (int i = 0; i < Issue.book_issue.Count; i++) { book_issue BS = Issue.book_issue[i]; if (Issue.type.Trim().Equals("issue")) { Dictionary <string, object> CheckReturnResponse = Transaction.FetchObj(0, 0, Transaction.URL, "checkReturnedBook", AppUser, new Dictionary <string, object>() { { "book_issue_id", BS.id } }); if (CheckReturnResponse["result"].ToString() == "0") { BS.book_issue_id = StringUtil.JSONStringToMap(CheckReturnResponse["data"].ToString())["book_issue_id"].ToString(); } } DetailsCol[ControlIndex++] = new Label() { Text = (i + 1).ToString() }; DetailsCol[ControlIndex++] = new TextBoxReadonly() { Text = BS.id }; DetailsCol[ControlIndex++] = new TextBoxReadonly() { Text = BS.book_record_id }; DetailsCol[ControlIndex++] = new TextBoxReadonly() { Text = BS.book_record.book.title }; DetailsCol[ControlIndex++] = new BlankControl() { Reserved = ReservedFor.BEFORE_HOR }; string Type = Issue.type.ToLower().Trim(); if (Type == ("return")) { DetailsCol[ControlIndex++] = null; } else { DetailsCol[ControlIndex++] = new Label() { Text = BS.book_return == 1 ? "yes " + BS.ref_issue : "No" }; } DetailsCol[ControlIndex++] = new Label() { Text = BS.book_issue_id }; } // DetailPanel = ControlUtil.GeneratePanel(7, DetailsCol, 5, 80, 20, Color.Orange, 5, 250); student Student = UserClient.StudentById(Issue.student_id, AppUser); Panel StudentDetail = ControlUtil.GeneratePanel(1, new Control[] { new Label() { Text = Issue.type.ToUpper().Trim() + " ID" }, new TextBoxReadonly(13) { Text = Issue.id }, new Label() { Text = "Date" }, new TextBoxReadonly(13) { Text = Issue.date.ToString() }, new Label() { Text = "Student ID" }, new TextBoxReadonly(13) { Text = Student.id }, new Label() { Text = "Student Name" }, new TextBoxReadonly(13) { Text = Student.name }, new Label() { Text = "Student ClassId" }, new TextBoxReadonly(13) { Text = Student.class_id }, }, 5, 200, 17, Color.Yellow, 5, 5, 500); Panel Wrapper = new Panel(); Wrapper.Controls.Add(StudentDetail); Wrapper.Controls.Add(DetailPanel); Wrapper.SetBounds(5, 5, 500, 500); Wrapper.AutoScroll = false; Wrapper.VerticalScroll.Visible = true; Wrapper.VerticalScroll.Enabled = true; Wrapper.AutoScroll = true; return(Wrapper); }
protected Panel GeneratePanel(int Offset, int Limit) { int CustomedProp = ObjectUtil.CustomAttributesCount(Entity); Control[] TableControls = new Control[(CustomedProp + 2) * (EntityList.Count + 4)]; //HEADER// PropertyInfo[] Props = Entity.GetProperties(); int ControlIndex = 0; TableControls[ControlIndex++] = new Label() { Text = "No" }; TableControls[ControlIndex + 2 * (CustomedProp + 2)] = new Label() { Text = "==" };; for (int i = 0; i < Props.Length; i++) { PropertyInfo PropsInfo = Props[i]; object[] Attributes = PropsInfo.GetCustomAttributes(typeof(FieldAttribute), true); if (Attributes.Length > 0) { FieldAttribute Attribute = (FieldAttribute)Attributes[0]; if (Attribute.FieldType != null) { string FieldName = Attribute.FieldName != null && Attribute.FieldName != "" ? Attribute.FieldName : PropsInfo.Name; TableControls[ControlIndex++] = new Label() { Text = FieldName.ToUpper() }; TextBox FilterTxtBox = new TextBox() { Name = "FILTER_00_BY_" + PropsInfo.Name, Text = FilterParmas.ContainsKey(PropsInfo.Name) ? FilterParmas[PropsInfo.Name].ToString() : "" }; Button FilterBtn = new Button() { Text = "Search" }; Button ASCBtn = new Button() { Text = "ASC" }; Button DESCBtn = new Button() { Text = "DESC" }; string OrderBy = Entity.Name + "." + PropsInfo.Name; if (Attribute.ClassReference != null) { OrderBy = Attribute.ClassReference + "." + Attribute.ClassAttributeConverter; } FilterBtn.Click += new EventHandler((o, e) => { if (this.FilterParmas.ContainsKey(PropsInfo.Name)) { FilterParmas.Remove(PropsInfo.Name); } FilterParmas.Add(PropsInfo.Name, FilterTxtBox.Text); EntityForm.Navigate(0, 0); }); ASCBtn.Click += new EventHandler((o, e) => { if (this.FilterParmas.ContainsKey("orderby")) { FilterParmas.Remove("orderby"); } if (this.FilterParmas.ContainsKey("ordertype")) { FilterParmas.Remove("ordertype"); } FilterParmas.Add("orderby", OrderBy); FilterParmas.Add("ordertype", "asc"); EntityForm.Navigate(0, 0); }); DESCBtn.Click += new EventHandler((o, e) => { if (this.FilterParmas.ContainsKey("orderby")) { FilterParmas.Remove("orderby"); } if (this.FilterParmas.ContainsKey("ordertype")) { FilterParmas.Remove("ordertype"); } FilterParmas.Add("orderby", OrderBy); FilterParmas.Add("ordertype", "desc"); EntityForm.Navigate(0, 0); }); Panel SortPanel = ControlUtil.PopulatePanel(false, 2, new Control[] { ASCBtn, DESCBtn }, 0, 45, 17, Color.Coral); Panel FilterPanel = ControlUtil.GeneratePanel(1, new Control[] { FilterTxtBox, FilterBtn, SortPanel }, 5, 90, 18, Color.LightYellow); //FilterPanel.MinimumSize = new Size(90, 80); TableControls[ControlIndex + CustomedProp + 1] = FilterPanel; TableControls[ControlIndex + 2 * (CustomedProp) + 3] = new BlankControl() { Reserved = ReservedFor.BEFORE_VER }; } } } TableControls[ControlIndex++] = new Label() { Text = "Option" }; TableControls[ControlIndex + 2 * (CustomedProp + 2)] = new Label() { Text = "==" };; ControlIndex += 2 * (CustomedProp + 2); int No = Offset * Limit; foreach (object Object in EntityList) { No++; string NoStr = Convert.ToString(No); TableControls[ControlIndex++] = new Label() { Text = (No).ToString() }; for (int i = 0; i < Props.Length; i++) { PropertyInfo PropsInfo = Props[i]; object[] Attributes = PropsInfo.GetCustomAttributes(typeof(FieldAttribute), true); if (Attributes.Length > 0) { FieldAttribute Attribute = (FieldAttribute)Attributes[0]; if (Attribute.FieldType != null) { object PropValue = Object.GetType().GetProperty(PropsInfo.Name).GetValue(Object); string VAL = "-"; if (PropValue != null && Attribute.ClassReference != null && Attribute.ClassAttributeConverter != null) { object ClassReff = PropValue; object ClassRefConverterValue = ClassReff.GetType().GetProperty(Attribute.ClassAttributeConverter).GetValue(ClassReff); VAL = ClassRefConverterValue == null?null: ClassRefConverterValue.ToString(); } else if (PropValue != null && Attribute.DropDownItemName != null && Attribute.DropDownValues != null && PropValue != null && Attribute.DropDownItemName.Length > 0 && Attribute.DropDownValues.Length > 0) { string index = PropValue.ToString(); int intindex = 0; int.TryParse(index, out intindex); VAL = Attribute.DropDownItemName[intindex].ToString(); } else if (PropValue != null && Attribute.FieldType.Equals(AttributeConstant.TYPE_COUNT)) { VAL = ((ICollection)PropValue).Count.ToString(); } else if (PropValue != null) { VAL = PropValue.ToString(); } TableControls[ControlIndex++] = new TextBoxReadonly() { Text = VAL }; } /*if (Attribute.ClassReference != null) * { * Type refType = Type.GetType(ModelParameter.NameSpace + Attribute.ClassReference); * string refConverter = Attribute.ClassAttributeConverter; * PropertyInfo AttributeConverter = refType.GetProperty(refConverter); * * }*/ } } Panel PanelButton = new Panel(); Button BtnDetail = new Button() { Text = "Detail" }; Button BtnEdit = new Button() { Text = "Edit" }; BtnEdit.Click += (o, e) => { Panel EditPanel = ShowAddForm(Object); EntityForm.addForm = new AddForm(EditPanel, this); EntityForm.addForm.Show(); }; BtnDetail.Click += (o, e) => { SetDetailV2(Object); }; /* * foreach (MethodInfo Method in Entity.GetMethods()) * { * object[] Attributes = Method.GetCustomAttributes(typeof(ActionAttribute), true); * if (Attributes.Length > 0) * { * ActionAttribute ActionAttr = (ActionAttribute)Attributes[0]; * if (ActionAttr != null && ActionAttr.FieldType.Equals(AttributeConstant.TYPE_DETAIL_CLICK)) * { * BtnDetail.Click += (o, e) => * { * //Panel DetailPanel = (Panel)Method.Invoke(obj, null); * SetDetail(Method, obj); * }; * BtnDetail.Enabled = true; * goto next; * } * } * }*/ PanelButton = ControlUtil.GeneratePanel(2, new Control[] { BtnDetail, BtnEdit }, 1, 50, 20, Color.BlueViolet); next: TableControls[ControlIndex++] = PanelButton; } return(ControlUtil.GeneratePanel(CustomedProp + 2, TableControls, 5, 100, 30, Color.White, 5, 130, Constant.ENTITY_PANEL_WIDTH, Constant.ENTITY_PANEL_HEIGHT)); }
protected Panel StudentDetailPanel(student Student, string Type, int X, int Y, int W, int H) { List <book_issue> BookIssues = new List <book_issue>(); //fetch obj Dictionary <string, object> FilterParams = new Dictionary <string, object>(); FilterParams.Add("student_id", Student.id); FilterParams.Add("orderby", "book_issue.book_return"); FilterParams.Add("ordertype", "asc"); FilterParams.Add("issue_type", Type); List <Dictionary <string, object> > ObjectMapList = Transaction.MapList(0, 0, Transaction.URL, "bookIssueList", AppUser, FilterParams); //generate panel Panel DetailPanel = new Panel(); int ListCount = ObjectMapList == null ? 0 : ObjectMapList.Count; Control[] DetailsCol = new Control[8 * (ListCount + 2)]; //update string[] ColumnLabels = { "No", "Id", "Trx Id", "RecId", /*"Title",*/ "", "Returned", "Book Issue Ref", "" }; //generate title for (int i = 0; i < 8; i++) { if (i == 0) { DetailsCol[i] = new TitleLabel(13) { Text = ("============" + Type.ToUpper() + " LIST============") }; } else { DetailsCol[i] = new BlankControl() { Reserved = ReservedFor.BEFORE_HOR }; } } //generate column name for (int i = 8; i < ColumnLabels.Length + 8; i++) { if (ColumnLabels[i - 8] == "") { DetailsCol[i] = new BlankControl() { Reserved = ReservedFor.BEFORE_HOR }; } else { DetailsCol[i] = new Label() { Text = ColumnLabels[i - 8] } }; } int ControlIndex = 16; if (ObjectMapList == null) { goto End; } foreach (Dictionary <string, object> book_issueMap in ObjectMapList) { book_issue book_issue = (book_issue)ObjectUtil.FillObjectWithMap(new book_issue(), book_issueMap); BookIssues.Add(book_issue); } for (int i = 0; i < BookIssues.Count; i++) { book_issue BS = BookIssues[i]; if (BS == null) { continue; } if (BS.id == null) { continue; } //if (type.Trim().Equals("issue")) //{ // Dictionary<string, object> CheckReturnResponse = Transaction.FetchObj(0, 0, Transaction.URL, "checkReturnedBook", new Dictionary<string, object>() // { // {"book_issue_id",BS.id } // }); // if (CheckReturnResponse["result"].ToString() == "0") // { // BS.book_issue_id = StringUtil.JSONStringToMap(CheckReturnResponse["data"].ToString())["book_issue_id"].ToString(); // } //} bool NotReturned = Type == "issue" && BS.book_return == 0; DetailsCol[ControlIndex++] = new Label() { Text = (i + 1).ToString() + (NotReturned ? "*" : "") }; DetailsCol[ControlIndex++] = new TextBoxReadonly() { Text = BS.id }; DetailsCol[ControlIndex++] = new TextBoxReadonly() { Text = BS.issue_id }; DetailsCol[ControlIndex++] = new TextBoxReadonly() { Text = BS.book_record_id }; //DetailsCol[ControlIndex++] = new Label() { Text = BS.book_record.book.title }; DetailsCol[ControlIndex++] = new BlankControl() { Reserved = ReservedFor.BEFORE_HOR }; //string Type = this.type.ToLower().Trim(); //if (Type == ("return")) //{ // DetailsCol[ControlIndex++] = null; //} //else //{ DetailsCol[ControlIndex++] = new TextBoxReadonly() { Text = BS.book_return.ToString() }; //} DetailsCol[ControlIndex++] = new TextBoxReadonly() { Text = BS.book_issue_id }; DetailsCol[ControlIndex++] = new BlankControl() { Reserved = ReservedFor.BEFORE_HOR }; } // End: DetailPanel = ControlUtil.GeneratePanel(8, DetailsCol, 5, 70, 20, Color.Orange, X, Y, W, H); return(DetailPanel); }
protected override Panel ShowDetailPanel(object Obj) { book Book = (book)Obj; Panel DetailPanel = new Panel(); Control[] DetailsCol = new Control[5 * (Book.book_record.Count + 1)]; //update string[] ColumnLabels = { "No", "RecId", "BookCode", "BookId", "Available" }; for (int i = 0; i < ColumnLabels.Length; i++) { DetailsCol[i] = new TitleLabel(9) { Text = ColumnLabels[i] }; } int ControlIndex = 5; for (int i = 0; i < Book.book_record.Count; i++) { book_record BR = Book.book_record.ElementAt(i); DetailsCol[ControlIndex++] = new Label() { Text = (i + 1).ToString() }; DetailsCol[ControlIndex++] = new TextBoxReadonly() { Text = BR.id }; DetailsCol[ControlIndex++] = new TextBoxReadonly() { Text = BR.book_code }; DetailsCol[ControlIndex++] = new TextBoxReadonly() { Text = BR.book_id }; DetailsCol[ControlIndex++] = new TextBoxReadonly() { Text = BR.available == 1 ? "yes" : "-" }; } // DetailPanel = ControlUtil.GeneratePanel(5, DetailsCol, 5, 80, 20, Color.Orange, 5, 5, 400, 500); //picturebox string URL = "http://" + Transaction.Host + "/Assets/Image/App/bookCover.jpg"; if (Book.img != null) { URL = "http://" + Transaction.Host + "/Assets/Image/Book/" + Book.img; } PictureBox Picture = new PictureBox(); // Picture.BorderStyle = BorderStyle.Fixed3D; Picture.ImageLocation = URL; Picture.SizeMode = PictureBoxSizeMode.StretchImage; Picture.SetBounds(100, 10, 150, 200); Picture.BackColor = Color.Aqua; DetailPanel.SetBounds(10, 250, DetailPanel.Width, DetailPanel.Height); TitleLabel BookTitle = new TitleLabel(15) { Text = Book.title }; BookTitle.TextAlign = ContentAlignment.MiddleCenter; BookTitle.SetBounds(10, 200, 350, 50); Panel Wrapper = new Panel(); Wrapper.Controls.Add(Picture); Wrapper.Controls.Add(BookTitle); Wrapper.Controls.Add(DetailPanel); Wrapper.SetBounds(5, 5, 500, 1000); return(Wrapper); }