Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void MultipleUpdate(object sender, DirectEventArgs e)
        {
            var ids = hdfIds.Text.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var id in ids)
            {
                var reportColumn = ReportColumnController.GetById(int.Parse(id));
                if (reportColumn == null)
                {
                    continue;
                }

                // set new props for model
                if (!string.IsNullOrEmpty(hdfTextAlign2.Text))
                {
                    reportColumn.TextAlign = (ReportTextAlign)Convert.ToInt32(hdfTextAlign2.Text);
                }
                if (!string.IsNullOrEmpty(txtFontSize2.Text))
                {
                    reportColumn.FontSize = Convert.ToInt32(txtFontSize2.Text);
                }
                if (!string.IsNullOrEmpty(txtFormat2.Text))
                {
                    reportColumn.Format = txtFormat2.Text;
                }
                if (!string.IsNullOrEmpty(txtWidth2.Text))
                {
                    reportColumn.Width = Convert.ToInt32(txtWidth2.Text);
                }
                if (!string.IsNullOrEmpty(txtHeight2.Text))
                {
                    reportColumn.Height = Convert.ToInt32(txtHeight2.Text);
                }
                if (!string.IsNullOrEmpty(hdfDataType2.Text))
                {
                    reportColumn.DataType = (ReportColumnDataType)Convert.ToInt32(hdfDataType2.Text);
                }
                if (!string.IsNullOrEmpty(hdfIsGroup2.Text))
                {
                    reportColumn.IsGroup = Convert.ToBoolean(hdfIsGroup2.Text);
                }
                if (!string.IsNullOrEmpty(hdfSummaryFunction2.Text))
                {
                    reportColumn.SummaryRunning = (ReportSummaryRunning)Convert.ToInt32(hdfSummaryRunning2.Text);
                }
                if (!string.IsNullOrEmpty(hdfSummaryFunction2.Text))
                {
                    reportColumn.SummaryFunction = (ReportSummaryFunction)Convert.ToInt32(hdfSummaryFunction2.Text);
                }

                // update model
                ReportColumnController.Update(reportColumn);
            }

            // hide window
            wdMultipleSetting.Hide();

            // reload data
            gpReportColumn.Reload();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Init setting window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void InitWindow(object sender, DirectEventArgs e)
        {
            try
            {
                // init id
                var param = e.ExtraParams["Id"];

                // parse id
                if (int.TryParse(param, out var id))
                {
                    // init window props
                    if (id > 0)
                    {
                        // edit
                        wdSetting.Title = @"Sửa";
                        wdSetting.Icon  = Icon.Pencil;
                    }
                    else
                    {
                        // insert
                        wdSetting.Title = @"Thêm mới";
                        wdSetting.Icon  = Icon.Add;
                    }

                    // init id
                    hdfId.Text = id.ToString();

                    // init object
                    var model = new ReportColumnModel();

                    // check id
                    if (id > 0)
                    {
                        var result = ReportColumnController.GetById(id);
                        if (result != null)
                        {
                            model = result;
                        }
                    }

                    // set props
                    txtName.Text            = model.Name;
                    hdfFieldName.Text       = model.FieldName;
                    cboFieldName.Text       = model.FieldName;
                    hdfTextAlign.Text       = ((int)model.TextAlign).ToString();
                    cboTextAlign.Text       = model.TextAlignName;
                    txtFontSize.Text        = model.FontSize.ToString();
                    txtFormat.Text          = model.Format;
                    hdfParentId.Text        = model.ParentId.ToString();
                    cboParent.Text          = model.ParentName;
                    txtWidth.Text           = model.Width.ToString();
                    txtHeight.Text          = model.Height.ToString();
                    txtOrder.Text           = model.Order.ToString();
                    hdfIsGroup.Text         = model.IsGroup.ToString();
                    cboGroup.Text           = model.GroupName;
                    hdfDataType.Text        = ((int)model.DataType).ToString();
                    cboDataType.Text        = model.DataTypeName;
                    hdfStatus.Text          = ((int)model.Status).ToString();
                    cboStatus.Text          = model.StatusName;
                    hdfType.Text            = ((int)model.Type).ToString();
                    cboType.Text            = model.TypeName;
                    hdfSummaryRunning.Text  = ((int)model.SummaryRunning).ToString();
                    cboSummaryRunning.Text  = model.SummaryRunningName;
                    hdfSummaryFunction.Text = ((int)model.SummaryFunction).ToString();
                    cboSummaryFunction.Text = model.SummaryFunctionName;
                    txtValue.Text           = model.SummaryValue;

                    // show window
                    wdSetting.Show();
                }
            }
            catch (Exception exception)
            {
                Dialog.ShowError(exception);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Insert or Update
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void InsertOrUpdate(object sender, DirectEventArgs e)
        {
            try
            {
                // init entity
                var model = new ReportColumnModel();
                ReportColumnModel resultModel;

                // check id
                if (!string.IsNullOrEmpty(hdfId.Text) && Convert.ToInt32(hdfId.Text) > 0)
                {
                    var result = ReportColumnController.GetById(Convert.ToInt32(hdfId.Text));
                    if (result != null)
                    {
                        model = result;
                    }
                }

                // set new props for entity
                model.ReportId  = Convert.ToInt32(hdfReportId.Text);
                model.Name      = txtName.Text;
                model.FieldName = hdfFieldName.Text;
                model.TextAlign = (ReportTextAlign)Convert.ToInt32(hdfTextAlign.Text);
                model.FontSize  = !string.IsNullOrEmpty(txtFontSize.Text)
                    ? Convert.ToInt32(txtFontSize.Text) : ReportHelper.DefaultFontSize;
                model.Format   = txtFormat.Text;
                model.ParentId = !string.IsNullOrEmpty(hdfParentId.Text)
                    ? Convert.ToInt32(hdfParentId.Text) : 0;
                model.Width = !string.IsNullOrEmpty(txtWidth.Text)
                    ? Convert.ToInt32(txtWidth.Text) : ReportHelper.DefaultCellHeight;
                model.Height = !string.IsNullOrEmpty(txtHeight.Text)
                    ? Convert.ToInt32(txtHeight.Text) : 0;
                model.Order = !string.IsNullOrEmpty(txtOrder.Text)
                    ? Convert.ToInt32(txtOrder.Text) : 0;
                model.IsGroup         = Convert.ToBoolean(hdfIsGroup.Text);
                model.DataType        = (ReportColumnDataType)Convert.ToInt32(hdfDataType.Text);
                model.Status          = (ReportColumnStatus)Convert.ToInt32(hdfStatus.Text);
                model.Type            = (ReportColumnType)Convert.ToInt32(hdfType.Text);
                model.SummaryRunning  = (ReportSummaryRunning)Convert.ToInt32(hdfSummaryRunning.Text);
                model.SummaryFunction = (ReportSummaryFunction)Convert.ToInt32(hdfSummaryFunction.Text);
                model.SummaryValue    = txtValue.Text;

                // check entity id
                if (model.Id > 0)
                {
                    // update
                    resultModel = ReportColumnController.Update(model);
                }
                else
                {
                    // insert
                    resultModel = ReportColumnController.Create(model);
                }

                // check result
                if (resultModel != null)
                {
                    Dialog.ShowNotification("Lưu thành công");
                    // hide window
                    wdSetting.Hide();
                    // reload data
                    gpReportColumn.Reload();
                }
                else
                {
                    Dialog.ShowNotification("Độ rộng của cột không hợp lệ");
                }
            }
            catch (Exception exception)
            {
                Dialog.ShowError(exception);
            }
        }