public void cargarBarrio() { ASPxPageControl tabs = (ASPxPageControl)ASPxGridView1.FindEditFormTemplateControl("pageControl"); ASPxFormLayout form = (ASPxFormLayout)tabs.FindControl("formLayoutUbicacion"); /* PROVINCIA */ ASPxComboBox comboProvincia = (ASPxComboBox)form.FindControl("cmbProvincia"); /* CANTON */ ASPxComboBox comboCanton = (ASPxComboBox)form.FindControl("cmbCanton"); /* DISTRITO */ ASPxComboBox comboDistrito = (ASPxComboBox)form.FindControl("cmbDistrito"); /* BARRIO */ ASPxComboBox comboBarrio = (ASPxComboBox)form.FindControl("cmbBarrio"); comboBarrio.Items.Clear(); if (comboProvincia.Value != null && comboCanton.Value != null && comboDistrito.Value != null) { using (var conexion = new DataModelFE()) { foreach (var item in conexion.Ubicacion. Where(x => x.codProvincia == comboProvincia.Value.ToString()). Where(x => x.codCanton == comboCanton.Value.ToString()). Where(x => x.codDistrito == comboDistrito.Value.ToString()). Select(x => new { x.codBarrio, x.nombreBarrio }).Distinct()) { comboBarrio.Items.Add(item.nombreBarrio, item.codBarrio); } comboBarrio.IncrementalFilteringMode = IncrementalFilteringMode.Contains; comboBarrio.SelectedIndex = 0; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { formLayout = (ASPxFormLayout)LAdministratorGridview.FindEditFormTemplateControl("formLayout"); } }
protected void grd_DSRole_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { Utils.notifierListClearGrid(grd_DSRole, Constant.NOTIFY_CLEAR); List <Error_Obj> lstError = new List <Error_Obj>(); ASPxFormLayout pnLayData = grd_DSRole.FindEditFormTemplateControl("LayOutThemSua") as ASPxFormLayout; ASPxTextBox txtName = pnLayData.FindControl("txtName") as ASPxTextBox; if (String.IsNullOrEmpty(txtName.Text)) { lstError.Add(new Error_Obj { error = "[Tên role] không được để trống." }); } Role role = ctlRole.getRolesByName(txtName.Text.Trim()); if (role != null && grd_DSRole.IsNewRowEditing) { lstError.Add(new Error_Obj { error = "[Tên role] đã tồn tại." }); } if (lstError.Count > 0) { e.Errors[grd_DSRole.Columns[0]] = "error"; Utils.notifierListErrorGrid(grd_DSRole, Constant.NOTIFY_FAILURE, lstError); } }
public void Effect_Inserting(object sender, ASPxDataInsertingEventArgs e) { ASPxGridView detailGridView = (ASPxGridView)sender; ASPxGridView editform_gv = (ASPxGridView)detailGridView.FindEditFormTemplateControl("cnr").FindControl("gv1"); ASPxFormLayout fl = (ASPxFormLayout)detailGridView.FindEditFormTemplateControl("cnr").FindControl("Effect_Layout_Form"); for (int i = 0; i < editform_gv.Selection.Count; i++) { SqlCommand cmd; string effect_obid = editform_gv.GetSelectedFieldValues("OBID")[i].ToString(); string detector_obid = detailGridView.GetMasterRowKeyValue().ToString(); string load_qry = "insert into TB_DE_LINK(OBID, LEFTREL, RIGHTREL, N1CREATIONDATE, N1CREATIONSESID) "; load_qry = load_qry + "VALUES (NEWID(), '" + detector_obid + "', '" + effect_obid + "', "; load_qry = load_qry + "REPLACE(REPLACE(CONVERT(varchar(23), GETDATE(), 121), '-','/'),' ', '-') , '" + SessionInfo.UserName + "') "; cmd = new SqlCommand(load_qry, fgm_moduler.func_Class.conn); cmd.ExecuteNonQuery(); } e.Cancel = true; Detector_Grid.CancelEdit(); //makeDetectorGridView(); //makeEffectGridView(); //Session["Dataset"] = DetectorVoting; //Detector_Grid.DataSource = DetectorVoting; //Detector_Grid.DataBind(); }
protected void ASPxFormLayout1_DataBinding(object sender, EventArgs e) { ASPxFormLayout fl = sender as ASPxFormLayout; DataViewItemTemplateContainer container = fl.NamingContainer as DataViewItemTemplateContainer; fl.DataSource = container.DataItem; }
private void PrepareFormLayout(ASPxFormLayout formLayout, bool isOptionFormLayout, ControlOptionsSettings?settings = null) { if (settings != null) { var optionsValue = settings.Value; if (optionsValue.ColumnMinWidth != 0) { LayoutBreakpoints breakpoints = formLayout.SettingsAdaptivity.GridSettings.Breakpoints; if (optionsValue.ColumnCountMode == RecalculateColumnCountMode.RootGroup && breakpoints.IsEmpty) { for (int i = 0; i < 10; i++) { breakpoints.Add(new LayoutBreakpoint(i.ToString(), ((i + 2) * optionsValue.ColumnMinWidth), i + 1)); } } formLayout.SettingsAdaptivity.GridSettings.StretchLastItem = DefaultBoolean.True; } if (optionsValue.RightBlockWidth != 0) { ControlOptionsRightBlockWidth = Unit.Pixel(optionsValue.RightBlockWidth); } } formLayout.ForRootChildGroups(group => PrepareFLGroup(group, isOptionFormLayout, settings)); AppyCssClassesForFormLayout(formLayout); ApplySettingsForFormLayout(formLayout); if (isOptionFormLayout) { formLayout.Theme = Theme; } formLayout.ForEach(itemBase => PrepareFLItem(itemBase, isOptionFormLayout)); }
public static ASPxFormLayout ApplyDataSource <T>(this ASPxFormLayout source, T dataSource) where T : class { source.DataSource = dataSource; source.DataBind(); return(source); }
private void AppyCssClassesForFormLayout(ASPxFormLayout formLayout) { formLayout.CssClass = " form-layout"; formLayout.Styles.LayoutGroupBox.CssClass += " group-box"; formLayout.Styles.LayoutGroupBox.Caption.CssClass += " group-box-caption"; formLayout.Styles.LayoutGroup.CssClass += " group"; formLayout.Styles.LayoutGroup.Cell.CssClass += " cell"; formLayout.Styles.LayoutItem.Caption.CssClass += " item-caption"; }
protected void Page_Load(object sender, EventArgs e) { gridview_tangpham.DataSource = new[] { new { stt = "01", MaQuaTang = "N/A", TenQuaTang = "Phiếu Giảm Giá", DonViTinh = "N/A", PhanLoai = "Tặng phẩm", GiaTri = "15.000", lotid = "SL0001", duedate = "01/01/2015", SoLuong = "2", ThanhTien = "0", MoTa = "NAAN Solution" }, new { stt = "02", MaQuaTang = "N/A", TenQuaTang = "Gốm Minh Long", DonViTinh = "N/A", PhanLoai = "Tặng phẩm", GiaTri = "15.000", lotid = "SL0001", duedate = "01/01/2015", SoLuong = "3", ThanhTien = "0", MoTa = "NAAN Solution" }, new { stt = "03", MaQuaTang = "SP00001", TenQuaTang = "Hàng hóa 1", DonViTinh = "Hộp", PhanLoai = "Hàng hóa", GiaTri = "15.000", lotid = "SL0001", duedate = "01/01/2015", SoLuong = "1", ThanhTien = "0", MoTa = "" }, new { stt = "04", MaQuaTang = "SP00002", TenQuaTang = "Hàng hóa 2", DonViTinh = "Hộp", PhanLoai = "Hàng hóa", GiaTri = "15.000", lotid = "SL0001", duedate = "01/01/2015", SoLuong = "1", ThanhTien = "0", MoTa = "" }, new { stt = "05", MaQuaTang = "SP00003", TenQuaTang = "Hàng hóa 3", DonViTinh = "Thùng", PhanLoai = "Hàng hóa", GiaTri = "15.000", lotid = "SL0001", duedate = "01/01/2015", SoLuong = "1", ThanhTien = "0", MoTa = "" }, }; gridview_tangpham.DataBind(); /* Setting for tab 1 */ ASPxFormLayout form_infoquyenloi = navbar_info.Groups[1].FindControl("form_infoquyenloi") as ASPxFormLayout; ASPxGridView gridview_hanghoatang = form_infoquyenloi.FindControl("gridview_hanghoatang") as ASPxGridView; gridview_hanghoatang.DataSource = new[] { new{ productid = "SP00001", productname = "Hàng hóa 1", productunitid = "Hộp", lotid = "L00001", duedate = "01/01/2015", condition_buy = "5", condition_give = "1" }, new{ productid = "SP00002", productname = "Hàng hóa 2", productunitid = "Hộp", lotid = "L00002", duedate = "01/01/2015", condition_buy = "10", condition_give = "1" }, new{ productid = "SP00003", productname = "Hàng hóa 3", productunitid = "Thùng", lotid = "L00003", duedate = "01/01/2015", condition_buy = "100", condition_give = "1" }, }; gridview_hanghoatang.DataBind(); gridview_hanghoatang.Visible = true; ASPxLabel lbl_title_khuyenmai2 = form_infoquyenloi.FindControl("lbl_title_khuyenmai2") as ASPxLabel; lbl_title_khuyenmai2.Visible = true; ASPxGridView gridview_hanghoabonus = form_infoquyenloi.FindControl("gridview_hanghoabonus") as ASPxGridView; gridview_hanghoabonus.DataSource = new[] { new { TenQuaTang = "Phiếu Giảm Giá", GiaTri = "15.000", SoLuong = "2", ThanhTien = "30.000", MoTa = "NAAN Solution" }, new { TenQuaTang = "Gấu Bông", GiaTri = "15.000", SoLuong = "3", ThanhTien = "45.000", MoTa = "NAAN Solution" }, }; gridview_hanghoabonus.DataBind(); gridview_hanghoabonus.Visible = false; ASPxLabel lbl_title_khuyenmai3 = form_infoquyenloi.FindControl("lbl_title_khuyenmai3") as ASPxLabel; ASPxRoundPanel round_chietkhau = form_infoquyenloi.FindControl("round_chietkhau") as ASPxRoundPanel; round_chietkhau.Visible = false; lbl_title_khuyenmai3.Visible = false; }
private ASPxEdit GetNestedEditor(ASPxFormLayout formLayout, string itemName) { LayoutItem item = formLayout.FindItemOrGroupByName(itemName) as LayoutItem; if (item != null) { return(item.GetNestedControl() as ASPxEdit); } return(null); }
public static void ForRootChildGroups(this ASPxFormLayout formLayout, Action <LayoutGroup> callback) { foreach (LayoutItemBase item in formLayout.Items) { var group = item as LayoutGroup; if (group != null) { callback(group); } } }
public static void ForEachNestedControl(this ASPxFormLayout formLayout, Action <Control> callback) { formLayout.ForEach(itemBase => { var item = itemBase as LayoutItem; if (item != null) { foreach (Control nestedControl in item.LayoutItemNestedControlCollection[0].Controls) { callback(nestedControl); } } }); }
public FormLayoutNewValues(ASPxFormLayout form) { foreach (var item in form.Items) { if (item is LayoutGroupBase) { (item as LayoutGroupBase).ForEach(ProcessNestedControls); } else { AddValues(item as LayoutItem); } } }
protected void ASPxGridView1_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { ASPxPageControl tabs = (ASPxPageControl)ASPxGridView1.FindEditFormTemplateControl("pageControl"); if (tabs != null) { ASPxFormLayout form = (ASPxFormLayout)tabs.FindControl("formLayoutUbicacion"); /* PROVINCIA */ ASPxComboBox comboProvincia = (ASPxComboBox)form.FindControl("cmbProvincia"); /* CANTON */ ASPxComboBox comboCanton = (ASPxComboBox)form.FindControl("cmbCanton"); /* DISTRITO */ ASPxComboBox comboDistrito = (ASPxComboBox)form.FindControl("cmbDistrito"); /* BARRIO */ ASPxComboBox comboBarrio = (ASPxComboBox)form.FindControl("cmbBarrio"); ASPxMemo otraSena = (ASPxMemo)form.FindControl("txtOtraSenas"); ASPxComboBox combPlan = (ASPxComboBox)form.FindControl("cmbPlan"); if (comboProvincia.Value == null || comboCanton.Value == null || comboDistrito.Value == null || comboBarrio.Value == null || string.IsNullOrWhiteSpace(otraSena.Text)) { e.RowError = "La ubicación es obligatoria (provincia, cantón, distrito, barrio y otras señas"; } if (string.IsNullOrWhiteSpace(combPlan.Text)) { e.RowError = "Debe seleccionar un plan"; } } if (e.NewValues["correoElectronico"] != null) { Regex validator = new Regex(@"\s*\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\s*"); string[] correos = e.NewValues["correoElectronico"].ToString().Split(','); foreach (var correo in correos) { if (!validator.IsMatch(correo)) { AddError(e.Errors, this.ASPxGridView1.Columns["correoElectronico"], string.Format("Verificar formato: {0}", correo)); } } if (correos.Length > 5) { e.RowError = "Solo puede agregar un máximo de 5 correos"; } } }
protected void btnSaveAction_Click(object sender, EventArgs e) { try { ASPxButton btn = (ASPxButton)sender; var user = HttpContext.Current.Session["user"] as User; ASPxFormLayout frm = (ASPxFormLayout)btn.NamingContainer; int FaultAuditRecordsId = Session["FaultAuditRecordsId"].ToInt32(0); string ContainmentAction = frm.GetNestedControlValueByFieldName("ContainmentAction").ToString(""); string RootCauseAnalysis = frm.GetNestedControlValueByFieldName("RootCauseAnalysis").ToString(""); string CorrectiveAction = frm.GetNestedControlValueByFieldName("CorrectiveAction").ToString(""); string MonitoringEffectiveness = frm.GetNestedControlValueByFieldName("MonitoringEffectiveness").ToString(""); QmRepository.UpdateAction(FaultAuditRecordsId, ContainmentAction, RootCauseAnalysis, CorrectiveAction, MonitoringEffectiveness, "", user.UserName); var AttachFileModelList = (List <FaultAuditRecordAttachment>)Session["Attachment"]; var AttachFileModelListRC = (List <FaultAuditRecordAttachment>)Session["AttachmentRC"]; var AttachFileModelListCA = (List <FaultAuditRecordAttachment>)Session["AttachmentCA"]; var AttachFileModelListME = (List <FaultAuditRecordAttachment>)Session["AttachmentME"]; for (int x = 0; x < AttachFileModelList.Count(); x++) { QmRepository.InsertAttachMent(AttachFileModelList[x].FileName, AttachFileModelList[x].FileLocation, 1, FaultAuditRecordsId, user.UserName); } for (int x = 0; x < AttachFileModelListRC.Count(); x++) { QmRepository.InsertAttachMent(AttachFileModelListRC[x].FileName, AttachFileModelListRC[x].FileLocation, 2, FaultAuditRecordsId, user.UserName); } for (int x = 0; x < AttachFileModelListCA.Count(); x++) { QmRepository.InsertAttachMent(AttachFileModelListCA[x].FileName, AttachFileModelListCA[x].FileLocation, 3, FaultAuditRecordsId, user.UserName); } for (int x = 0; x < AttachFileModelListME.Count(); x++) { QmRepository.InsertAttachMent(AttachFileModelListME[x].FileName, AttachFileModelListME[x].FileLocation, 4, FaultAuditRecordsId, user.UserName); } } catch (Exception ex) { //errorMessageLabel.Text = ex.Message; //errorMessageLabel.Visible = true; } }
protected void grd_DSRole_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { try { e.Cancel = true; ASPxFormLayout pnLayData = grd_DSRole.FindEditFormTemplateControl("LayOutThemSua") as ASPxFormLayout; ASPxMemo txtNote = pnLayData.FindControl("txtNote") as ASPxMemo; ASPxTextBox txtName = pnLayData.FindControl("txtName") as ASPxTextBox; ctlRole.insertRoles(txtName.Text, txtNote.Text); BindataThemNhanh(); Utils.notifierGrid(grd_DSRole, Constant.NOTIFY_SUCCESS, "Bạn đã thêm thành công Role có [" + txtName.Text + "]"); } catch (Exception ex) { Utils.notifierGrid(grd_DSRole, Constant.NOTIFY_FAILURE, ex.Message + " " + ex.StackTrace); } }
public ASPxFormLayout CreateFormLayout() { var formLayout = new ASPxFormLayout(); formLayout.ID = "formLayout"; if (tableMeta.Columns.Count > 20) { formLayout.ColCount = 3; } else if (tableMeta.Columns.Count > 5) { formLayout.ColCount = 2; } foreach (var column in tableMeta.Columns.OrderBy(c => c.OrderNo)) { if (!column.DisplayInGrid) { continue; } var layoutItem = new LayoutItem(column.Caption); layoutItem.FieldName = column.Name; ASPxWebControl editor = null; if (column.IsPrimaryKey || readOnly) { editor = new ASPxLabel(); } else { editor = new ASPxTextBox(); } editor.ID = column.Name.RemoveSpaces(); layoutItem.Controls.Add(editor); formLayout.Items.Add(layoutItem); } var dataSource = GetFormLayoutDataSource(tableMeta, connectionString); dataSource.Selected += dataSource_Selected; formLayout.DataSource = dataSource; return(formLayout); }
private void cargaPlanes() { /* PLAN */ ASPxPageControl tabs = (ASPxPageControl)ASPxGridView1.FindEditFormTemplateControl("pageControl"); ASPxFormLayout form = (ASPxFormLayout)tabs.FindControl("formLayoutUbicacion"); ASPxComboBox comboPlan = (ASPxComboBox)form.FindControl("cmbPlan"); comboPlan.Items.Clear(); using (var conexion = new DataModelFE()) { foreach (var item in conexion.TipoPlan.Where(x => x.estado == Estado.ACTIVO.ToString()).ToList()) { comboPlan.Items.Add(item.descripcion, item.codigo); } } }
protected void grd_DSRole_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { try { e.Cancel = true; Int32 idRoles = Convert.ToInt32(e.Keys[grd_DSRole.KeyFieldName]); ASPxFormLayout pnLayData = grd_DSRole.FindEditFormTemplateControl("LayOutThemSua") as ASPxFormLayout; ASPxMemo txtNote = pnLayData.FindControl("txtNote") as ASPxMemo; ASPxTextBox txtName = pnLayData.FindControl("txtName") as ASPxTextBox; ctlRole.updateRoles(idRoles, txtName.Text, txtNote.Text); BindataThemNhanh(); Utils.notifierGrid(grd_DSRole, Constant.NOTIFY_SUCCESS, "Bạn đã cập nhập thành công cho Role có ID [" + idRoles.ToString() + "]"); } catch (Exception ex) { Utils.notifierGrid(grd_DSRole, Constant.NOTIFY_FAILURE, ex.Message + " " + ex.StackTrace); } }
protected void grd_DSUsers_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { try { e.Cancel = true; Int32 idUser = Convert.ToInt32(e.Keys[grd_DSUsers.KeyFieldName]); ASPxFormLayout pnLayData = grd_DSUsers.FindEditFormTemplateControl("LayOutThemSua") as ASPxFormLayout; User user = new User(); Utils.setView2ObjectLayout <User>(user, pnLayData); ctlUser.updateUsers(idUser, user); Bindata(); Utils.notifierGrid(grd_DSUsers, Constant.NOTIFY_SUCCESS, "Bạn đã cập nhập thành công tài khoản [" + user.Id_Login + "]"); } catch (Exception ex) { Utils.notifierGrid(grd_DSUsers, Constant.NOTIFY_FAILURE, ex.Message + " " + ex.StackTrace); } }
protected void grd_DSUsers_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { Utils.notifierListClearGrid(grd_DSUsers, Constant.NOTIFY_CLEAR); List <Error_Obj> lstError = new List <Error_Obj>(); ASPxFormLayout LayOutThemSua = grd_DSUsers.FindEditFormTemplateControl("LayOutThemSua") as ASPxFormLayout; ASPxTextBox txtId_Login = LayOutThemSua.FindControl("Id_Login") as ASPxTextBox; ASPxTextBox txtPassword = LayOutThemSua.FindControl("Password") as ASPxTextBox; ASPxTextBox txtPasswordConfirm = LayOutThemSua.FindControl("PasswordConfirm") as ASPxTextBox; if (String.IsNullOrEmpty(txtId_Login.Text)) { lstError.Add(new Error_Obj { error = "[Tên đăng nhập] không được để trống." }); } User user = ctlUser.getUsersByIDLogin(txtId_Login.Text.Trim()); if (user != null && grd_DSUsers.IsNewRowEditing) { lstError.Add(new Error_Obj { error = "Tên đăng nhập đã tồn tại." }); } if (String.IsNullOrEmpty(txtPassword.Text) && grd_DSUsers.IsNewRowEditing) { lstError.Add(new Error_Obj { error = "[Mật khẩu] không được để trống." }); } if (!txtPassword.Text.Equals(txtPasswordConfirm.Text)) { lstError.Add(new Error_Obj { error = "[Xác nhận mật khẩu] không chính xác." }); } if (lstError.Count > 0) { e.Errors[grd_DSUsers.Columns[0]] = "error"; Utils.notifierListErrorGrid(grd_DSUsers, Constant.NOTIFY_FAILURE, lstError); } }
protected void grd_DSUsers_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { try { e.Cancel = true; ASPxFormLayout pnLayData = grd_DSUsers.FindEditFormTemplateControl("LayOutThemSua") as ASPxFormLayout; User user = new User(); Utils.setView2ObjectLayout <User>(user, pnLayData); user.LockoutEnabled = false; user.Password = Utils.Encrypt(user.Password); getFirstLastName(user); ctlUser.insertUsers(user); Bindata(); Utils.notifierGrid(grd_DSUsers, Constant.NOTIFY_SUCCESS, "Bạn đã thêm thành công tài khoản [" + user.Id_Login + "]"); } catch (Exception ex) { Utils.notifierGrid(grd_DSUsers, Constant.NOTIFY_FAILURE, ex.Message + " " + ex.StackTrace); } }
ASPxFormLayout GetFormLayout(object dataItem) { var formLayout = new ASPxFormLayout(); var layoutGroup = formLayout.Items.Add(new LayoutGroup("Item Info")) as LayoutGroup; var layoutItemName = new LayoutItem("Name"); layoutItemName.Controls.Add(new ASPxLabel() { Text = GetData(dataItem, "Name") }); var layoutItemDecsription = new LayoutItem("Description"); layoutItemDecsription.Controls.Add(new ASPxLabel() { Text = GetData(dataItem, "Description") }); layoutGroup.Items.Add(layoutItemName); layoutGroup.Items.Add(layoutItemDecsription); return(formLayout); }
public void cargarProvincias() { ASPxPageControl tabs = (ASPxPageControl)ASPxGridView1.FindEditFormTemplateControl("pageControl"); ASPxFormLayout form = (ASPxFormLayout)tabs.FindControl("formLayoutUbicacion"); /* PROVINCIA */ ASPxComboBox comboProvincia = (ASPxComboBox)form.FindControl("cmbProvincia"); comboProvincia.Items.Clear(); using (var conexion = new DataModelFE()) { foreach (var item in conexion.Ubicacion. Select(x => new { x.codProvincia, x.nombreProvincia }).Distinct()) { comboProvincia.Items.Add(item.nombreProvincia, item.codProvincia); } comboProvincia.IncrementalFilteringMode = IncrementalFilteringMode.Contains; } }
public static T setView2ObjectLayout <T>(T obj, ASPxFormLayout layout) { Type type = obj.GetType(); foreach (var item in type.GetProperties()) { var control = layout.FindControl(item.Name); if (control == null) { continue; } Type type1 = control.GetType(); if (type1 == typeof(ASPxTextBox)) { item.SetValue(obj, (control as ASPxTextBox).Text); } } return(obj); }
public static OrderedDictionary GetControlValues <T>(this ASPxFormLayout source, Func <T, object> valueSelector) where T : Control { var result = new OrderedDictionary(); source .GetItems <LayoutItem>() .Where(x => x.FieldName.IsNotEmpty()) .Each(x => { var nestedControl = x.GetNestedControl() as T; if (nestedControl != null) { result.Add(x.FieldName, valueSelector(nestedControl)); } } ); return(result); }
protected void ASPxButton1_Click(object sender, EventArgs e) { ASPxButton b = sender as ASPxButton; DataViewItemTemplateContainer container = b.NamingContainer as DataViewItemTemplateContainer; ASPxFormLayout fl = container.FindControl("ASPxFormLayout1") as ASPxFormLayout; foreach (Parameter par in SqlDataSource1.UpdateParameters) { LayoutItem item = fl.FindItemByFieldName(par.Name) as LayoutItem; foreach (Control control in item.Controls) { ASPxEdit editor = control as ASPxEdit; if (editor != null && editor.Value != null) { par.DefaultValue = editor.Value.ToString(); } } } //SqlDataSource1.Update(); //editing not allowed in the examples running online. please uncomment this line in your real application }
/// <summary> /// Page Init event; creates all required controls in a page. /// </summary> /// <param name="sender">The page sending the event.</param> /// <param name="e"></param> protected void Page_Init(object sender, EventArgs e) { var tableName = RouteData.Values["module"] == null ? "" : RouteData.Values["module"].ToString(); var schemaInfo = Application["SchemaInfo"] as SchemaInfo; tableMeta = schemaInfo.Tables.Where(s => s.Name.Equals(tableName, StringComparison.InvariantCultureIgnoreCase)).SingleOrDefault(); if (tableMeta == null) { Response.Redirect("~/404.aspx"); } var routeValues = RouteData.Values["values"] == null ? "" : RouteData.Values["values"].ToString(); var idValues = routeValues.Split(new char[] { ',' }); var formLayoutCreator = new FormLayoutCreator(tableMeta, connectionString, idValues, (RouteData.Route as Route).Url.Contains("view")); formLayoutCreator.EmptyData += formLayoutCreator_EmptyData; formLayout = formLayoutCreator.CreateFormLayout(); var masterPage = this.Controls[0] as IMainMaster; if (masterPage == null) { Response.Write("<p>Your master page must implement IMainMaster interface.</p>"); } else { var panel = new System.Web.UI.WebControls.Panel(); panel.CssClass = "mainContent"; panel.Controls.Add(new LiteralControl(string.Format("<h2>{0}</h2>", tableMeta.Caption))); panel.Controls.Add(formLayout); masterPage.MainContent.Controls.Add(panel); masterPage.PageTitle.Controls.Add(new LiteralControl(tableMeta.Caption)); } }
protected void ASPxFormLayout1_E8_SelectedIndexChanged(object sender, EventArgs e) { NpgsqlConnection myConn1 = new NpgsqlConnection(connString); ASPxFormLayout fl_1 = (ASPxFormLayout)ASPxNavBar1.Groups[1].FindControl("ASPxFormLayout1"); ASPxComboBox combox_sdz = (ASPxComboBox)fl_1.FindControl("ASPxFormLayout1_E8"); ASPxTextBox max_pot = (ASPxTextBox)fl_1.FindControl("ASPxFormLayout1_E3"); ASPxTextBox min_pot = (ASPxTextBox)fl_1.FindControl("ASPxFormLayout1_E1"); ASPxTextBox avg_pot = (ASPxTextBox)fl_1.FindControl("ASPxFormLayout1_E2"); ASPxTextBox max_pot_rz = (ASPxTextBox)fl_1.FindControl("ASPxFormLayout1_E6"); ASPxTextBox min_pot_rz = (ASPxTextBox)fl_1.FindControl("ASPxFormLayout1_E4"); ASPxTextBox avg_pot_rz = (ASPxTextBox)fl_1.FindControl("ASPxFormLayout1_E5"); try { NpgsqlCommand cmd_get_subjectdata_max = new NpgsqlCommand(String.Format("select s.subject_name as subject, max(m.pot_tz) as sum from \"Monitoring_SDZ\" as m LEFT JOIN \"Subject\" as s on m.subject_id=s.subject_id where s.subject_name = '{0}' GROUP BY subject", combox_sdz.SelectedItem.ToString()), myConn1); myConn1.Open(); NpgsqlDataReader dataReaderGetSubject = cmd_get_subjectdata_max.ExecuteReader(); while (dataReaderGetSubject.Read()) { max_pot.Text = dataReaderGetSubject.GetValue(dataReaderGetSubject.GetOrdinal("sum")).ToString(); } myConn1.Close(); NpgsqlCommand cmd_get_subjectdata_min = new NpgsqlCommand(String.Format("select s.subject_name as subject, min(m.pot_tz) as sum from \"Monitoring_SDZ\" as m LEFT JOIN \"Subject\" as s on m.subject_id=s.subject_id where s.subject_name = '{0}' GROUP BY subject", combox_sdz.SelectedItem.ToString()), myConn1); myConn1.Open(); NpgsqlDataReader dataReaderGetSubject2 = cmd_get_subjectdata_min.ExecuteReader(); while (dataReaderGetSubject2.Read()) { min_pot.Text = dataReaderGetSubject2.GetValue(dataReaderGetSubject2.GetOrdinal("sum")).ToString(); } myConn1.Close(); NpgsqlCommand cmd_get_subjectdata_avg = new NpgsqlCommand(String.Format("select s.subject_name as subject, avg(m.pot_tz) as sum from \"Monitoring_SDZ\" as m LEFT JOIN \"Subject\" as s on m.subject_id=s.subject_id where s.subject_name = '{0}' GROUP BY subject", combox_sdz.SelectedItem.ToString()), myConn1); myConn1.Open(); NpgsqlDataReader dataReaderGetSubject3 = cmd_get_subjectdata_avg.ExecuteReader(); while (dataReaderGetSubject3.Read()) { avg_pot.Text = dataReaderGetSubject3.GetValue(dataReaderGetSubject3.GetOrdinal("sum")).ToString(); } myConn1.Close(); NpgsqlCommand cmd_get_subjectdata_avg_rz = new NpgsqlCommand(String.Format("select s.subject_name as subject, avg(m.pot_rz) as sum from \"Monitoring_SDZ\" as m LEFT JOIN \"Subject\" as s on m.subject_id=s.subject_id where s.subject_name = '{0}' GROUP BY subject", combox_sdz.SelectedItem.ToString()), myConn1); myConn1.Open(); NpgsqlDataReader dataReaderGetSubject4 = cmd_get_subjectdata_avg_rz.ExecuteReader(); while (dataReaderGetSubject4.Read()) { avg_pot_rz.Text = dataReaderGetSubject4.GetValue(dataReaderGetSubject4.GetOrdinal("sum")).ToString(); } myConn1.Close(); NpgsqlCommand cmd_get_subjectdata_min_rz = new NpgsqlCommand(String.Format("select s.subject_name as subject, min(m.pot_rz) as sum from \"Monitoring_SDZ\" as m LEFT JOIN \"Subject\" as s on m.subject_id=s.subject_id where s.subject_name = '{0}' GROUP BY subject", combox_sdz.SelectedItem.ToString()), myConn1); myConn1.Open(); NpgsqlDataReader dataReaderGetSubject5 = cmd_get_subjectdata_min_rz.ExecuteReader(); while (dataReaderGetSubject5.Read()) { min_pot_rz.Text = dataReaderGetSubject5.GetValue(dataReaderGetSubject5.GetOrdinal("sum")).ToString(); } myConn1.Close(); NpgsqlCommand cmd_get_subjectdata_max_rz = new NpgsqlCommand(String.Format("select s.subject_name as subject, max(m.pot_rz) as sum from \"Monitoring_SDZ\" as m LEFT JOIN \"Subject\" as s on m.subject_id=s.subject_id where s.subject_name = '{0}' GROUP BY subject", combox_sdz.SelectedItem.ToString()), myConn1); myConn1.Open(); NpgsqlDataReader dataReaderGetSubject6 = cmd_get_subjectdata_max_rz.ExecuteReader(); while (dataReaderGetSubject6.Read()) { max_pot_rz.Text = dataReaderGetSubject6.GetValue(dataReaderGetSubject6.GetOrdinal("sum")).ToString(); } myConn1.Close(); } catch (NpgsqlException ex) { } finally { myConn1.Close(); } }
public void InstantiateIn(Control container) { Control control = new Control(); control.ID = "GroupDetectorEditForm"; container.Controls.Add(control); DataTable dt = datafield; string db_name = ""; string desc_name = ""; string auth = ""; string cell_type = ""; ASPxFormLayout editform_GroupDetector = new ASPxFormLayout(); editform_GroupDetector.ID = "editform_GroupDetector"; //editform_GroupDetector.Border.BorderWidth = Unit.Pixel(1); //editform_GroupDetector.SettingsItems.VerticalAlign = FormLayoutVerticalAlign.Middle; //editform_GroupDetector.SettingsItems.HorizontalAlign = FormLayoutHorizontalAlign.Center; editform_GroupDetector.Paddings.Padding = Unit.Pixel(8); foreach (DataRow dr in dt.Select("AUTH <> 'System'", "VIEW_SEQ")) { db_name = dr["DB_NAME"].ToString(); desc_name = dr["DESC_NAME"].ToString(); auth = dr["AUTH"].ToString(); cell_type = dr["SEL_TYPE"].ToString(); LayoutItem li = new LayoutItem(desc_name); li.FieldName = db_name; editform_GroupDetector.Items.Add(li); LayoutItemNestedControlContainer li_container = li.LayoutItemNestedControlContainer; if (auth == "Manager") { li.CaptionStyle.Font.Bold = true; li.CaptionStyle.ForeColor = Color.Red; } if (cell_type == "DropDown List") { ASPxDropDownEdit dropdownEdit = new ASPxDropDownEdit(); dropdownEdit.ID = db_name; ASPxComboBox comboBox = new ASPxComboBox(); comboBox.DataSource = Srch_DropDownItem(db_name); comboBox.TextField = "LOOKUPDETDESC"; comboBox.DataBind(); comboBox.IncrementalFilteringMode = IncrementalFilteringMode.StartsWith; comboBox.DropDownStyle = DropDownStyle.DropDown; comboBox.EnableSynchronization = DevExpress.Utils.DefaultBoolean.False; li_container.Controls.Add(comboBox); } else if (cell_type == "Note") { ASPxMemo textMemo = new ASPxMemo(); textMemo.ID = db_name; textMemo.Width = Unit.Percentage(91); li_container.Controls.Add(textMemo); } else { ASPxTextBox textBox = new ASPxTextBox(); textBox.ID = db_name; li_container.Controls.Add(textBox); //Suffix 증가 유무 체크 (15.10.16) if (db_name == "CNT") { li = new LayoutItem("Suffix"); li.FieldName = "DETECTOR_SUFFIX"; editform_GroupDetector.Items.Add(li); li_container = li.LayoutItemNestedControlContainer; ASPxCheckBox chkBox = new ASPxCheckBox(); chkBox.ID = "DETECTOR_SUFFIX"; li_container.Controls.Add(chkBox); } } } container.Controls.Add(editform_GroupDetector); //container.Controls.Add(editform_GroupDetector); //Button ASPxFormLayout btn_lo = new ASPxFormLayout(); btn_lo.ID = "button_GroupDetector"; btn_lo.ColCount = 1; btn_lo.Width = Unit.Percentage(90); btn_lo.SettingsItems.HorizontalAlign = FormLayoutHorizontalAlign.Right; btn_lo.Paddings.Padding = Unit.Pixel(1); LayoutItem btn_li = new LayoutItem("btn_li"); btn_li.ShowCaption = DevExpress.Utils.DefaultBoolean.False; btn_lo.Items.Add(btn_li); LayoutItemNestedControlContainer btn_li_container = btn_li.LayoutItemNestedControlContainer; ASPxGridViewTemplateReplacement btn_add = new ASPxGridViewTemplateReplacement(); btn_add.ReplacementType = GridViewTemplateReplacementType.EditFormUpdateButton; btn_add.ID = "btn_add"; btn_li_container.Controls.Add(btn_add); //LayoutItem btn_li2 = new LayoutItem("btn_li2"); //btn_li2.ShowCaption = DevExpress.Utils.DefaultBoolean.False; //btn_lo.Items.Add(btn_li2); //LayoutItemNestedControlContainer btn_li_container2 = btn_li2.LayoutItemNestedControlContainer; ASPxGridViewTemplateReplacement btn_cancel = new ASPxGridViewTemplateReplacement(); btn_cancel.ReplacementType = GridViewTemplateReplacementType.EditFormCancelButton; btn_cancel.ID = "btn_cancel"; btn_li_container.Controls.Add(btn_cancel); //btn_li.HorizontalAlign = FormLayoutHorizontalAlign.Right; container.Controls.Add(btn_lo); }
private void SetImportProfilePropertiesFromFormLayout(ASPxFormLayout formLayout, ImportProfile profile) { foreach (string fieldName in Utilities.GetPropertyNames<ImportProfile>()) { ASPxEdit control = (ASPxEdit)formLayout.FindNestedControlByFieldName(fieldName); // if control exists and part of this step's update process if (control != null && control.Value != null) { PropertyInfo propertyInfo = profile.GetType().GetProperty(fieldName); profile.SetMemberValue(fieldName, Convert.ChangeType(control.Value, propertyInfo.PropertyType)); } } }
protected void gridview_applykm_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e) { if (e.RowType == DevExpress.Web.ASPxGridView.GridViewRowType.Detail) { ASPxGridView mastergrid = sender as ASPxGridView; ASPxPageControl tabs = mastergrid.FindDetailRowTemplateControl(e.VisibleIndex, "tab_stepkhuyenmai") as ASPxPageControl; /* Setting for tab 1 */ ASPxNavBar navbar_info = tabs.TabPages[0].FindControl("navbar_info") as ASPxNavBar; ASPxFormLayout form_infoquyenloi = navbar_info.Groups[1].FindControl("form_infoquyenloi") as ASPxFormLayout; ASPxGridView gridview_hanghoatang = form_infoquyenloi.FindControl("gridview_hanghoatang") as ASPxGridView; gridview_hanghoatang.DataSource = new[] { new{ sequenceno = "01", productid = "SP00001", productname = "Hàng hóa 1", productunitid = "Hộp", lotid = "L00001", condition_buy = "5", condition_give = "1" }, new{ sequenceno = "02", productid = "SP00002", productname = "Hàng hóa 2", productunitid = "Hộp", lotid = "L00002", condition_buy = "10", condition_give = "1" }, new{ sequenceno = "03", productid = "SP00003", productname = "Hàng hóa 3", productunitid = "Thùng", lotid = "L00003", condition_buy = "100", condition_give = "1" }, }; gridview_hanghoatang.DataBind(); gridview_hanghoatang.Visible = true; ASPxLabel lbl_title_khuyenmai2 = form_infoquyenloi.FindControl("lbl_title_khuyenmai2") as ASPxLabel; lbl_title_khuyenmai2.Visible = true; ASPxGridView gridview_hanghoabonus = form_infoquyenloi.FindControl("gridview_hanghoabonus") as ASPxGridView; gridview_hanghoabonus.DataSource = new[] { new { TenQuaTang = "Phiếu Giảm Giá", GiaTri = "15.000", SoLuong = "2", ThanhTien = "30.000", MoTa = "NAAN Solution" }, new { TenQuaTang = "Gấu Bông", GiaTri = "15.000", SoLuong = "3", ThanhTien = "45.000", MoTa = "NAAN Solution" }, }; gridview_hanghoabonus.DataBind(); gridview_hanghoabonus.Visible = false; ASPxLabel lbl_title_khuyenmai3 = form_infoquyenloi.FindControl("lbl_title_khuyenmai3") as ASPxLabel; ASPxRoundPanel round_chietkhau = form_infoquyenloi.FindControl("round_chietkhau") as ASPxRoundPanel; round_chietkhau.Visible = false; lbl_title_khuyenmai3.Visible = false; /* Setting for tab 2 */ ASPxNavBar navbar_nextinfo = tabs.TabPages[1].FindControl("navi_nextinfo") as ASPxNavBar; form_infoquyenloi = navbar_nextinfo.Groups[1].FindControl("form_infoquyenloi") as ASPxFormLayout; gridview_hanghoatang = form_infoquyenloi.FindControl("gridview_hanghoatang") as ASPxGridView; gridview_hanghoatang.DataSource = new[] { new{ sequenceno = "01", productid = "SP00001", productname = "Hàng hóa 1", productunitid = "Hộp", lotid = "L00001", condition_buy = "5", condition_give = "1" }, new{ sequenceno = "02", productid = "SP00002", productname = "Hàng hóa 2", productunitid = "Hộp", lotid = "L00002", condition_buy = "10", condition_give = "1" }, new{ sequenceno = "03", productid = "SP00003", productname = "Hàng hóa 3", productunitid = "Thùng", lotid = "L00003", condition_buy = "100", condition_give = "1" }, }; gridview_hanghoatang.DataBind(); gridview_hanghoatang.Visible = false; lbl_title_khuyenmai2 = form_infoquyenloi.FindControl("lbl_title_khuyenmai2") as ASPxLabel; lbl_title_khuyenmai2.Visible = false; gridview_hanghoabonus = form_infoquyenloi.FindControl("gridview_hanghoabonus") as ASPxGridView; gridview_hanghoabonus.DataSource = new[] { new { TenQuaTang = "Phiếu Giảm Giá", GiaTri = "15.000", SoLuong = "2", ThanhTien = "30.000", MoTa = "NAAN Solution" }, new { TenQuaTang = "Gấu Bông", GiaTri = "15.000", SoLuong = "3", ThanhTien = "45.000", MoTa = "NAAN Solution" }, }; gridview_hanghoabonus.DataBind(); gridview_hanghoabonus.Visible = true; round_chietkhau = form_infoquyenloi.FindControl("round_chietkhau") as ASPxRoundPanel; round_chietkhau.Visible = true; } }