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>
        /// Delete
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Delete(object sender, DirectEventArgs e)
        {
            try
            {
                // init id
                var param = e.ExtraParams["Id"];

                // parse id
                if (!int.TryParse(param, out var id) || id <= 0)
                {
                    // parse error, show error
                    Dialog.ShowError("Tham số không hợp lệ");
                    return;
                }

                // delete
                ReportColumnController.Delete(id);

                // reload data
                gpReportColumn.Reload();
            }
            catch (Exception exception)
            {
                Dialog.ShowError(exception);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DuplicateData(object sender, DirectEventArgs e)
        {
            try
            {
                // init model
                var reportDynamic = new ReportDynamicModel(null);
                var reportColumns = new List <ReportColumnModel>();

                // check id
                if (!string.IsNullOrEmpty(hdfId.Text) && Convert.ToInt32(hdfId.Text) > 0)
                {
                    var resultReportDynamic = ReportDynamicController.GetById(Convert.ToInt32(hdfId.Text));
                    if (resultReportDynamic != null)
                    {
                        reportDynamic = resultReportDynamic;
                        var resultReportColumn = ReportColumnController.GetAll(null, resultReportDynamic.Id, null, null, null, null, false, null, null);
                        if (resultReportColumn != null)
                        {
                            reportColumns = resultReportColumn;
                        }
                    }
                }

                // create duplicated report dynamic
                reportDynamic.Name       += " - Copy";
                reportDynamic.CreatedDate = DateTime.Now;
                reportDynamic.CreatedBy   = CurrentUser.User.UserName;
                reportDynamic.EditedDate  = DateTime.Now;
                reportDynamic.EditedBy    = CurrentUser.User.UserName;
                var newReportDynamic = ReportDynamicController.Create(reportDynamic);

                // create list id
                var ids = new Dictionary <int, int>();
                // create list old parent id
                var parentIds = new List <int>();
                // create list new report column
                var newReportColumns = new List <ReportColumnModel>();

                // create duplicated report columns
                foreach (var reportColumn in reportColumns)
                {
                    var oldParentId = reportColumn.ParentId;
                    //
                    reportColumn.ReportId    = newReportDynamic.Id;
                    reportColumn.CreatedDate = DateTime.Now;
                    reportColumn.CreatedBy   = CurrentUser.User.UserName;
                    reportColumn.EditedDate  = DateTime.Now;
                    reportColumn.EditedBy    = CurrentUser.User.UserName;
                    reportColumn.ParentId    = 0;
                    // create new column
                    var newReportColumn = ReportColumnController.Create(reportColumn);
                    // add new column to list
                    newReportColumns.Add(newReportColumn);
                    // add pair of old and new id to list
                    var oldId = reportColumn.Id;
                    var newId = newReportColumn.Id;
                    ids.Add(oldId, newId);
                    // add item to list parent id
                    parentIds.Add(oldParentId);
                }

                // update parentId
                for (var i = 0; i < newReportColumns.Count; i++)
                {
                    // set parent id
                    foreach (var id in ids)
                    {
                        if (parentIds[i] == id.Key)
                        {
                            newReportColumns[i].ParentId = id.Value;
                        }
                    }
                    // update column
                    ReportColumnController.Update(newReportColumns[i]);
                }

                gpReport.Reload();
            }
            catch (Exception ex)
            {
                Dialog.ShowError(ex);
            }
        }
Ejemplo n.º 4
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.º 5
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);
            }
        }