Пример #1
0
        void barAction_ItemClick(object sender, ItemClickEventArgs e)
        {
            referhComment = false;
            DataRow dr = e.Item.Tag as DataRow;

            if (this._data.DbData.HasErrors)
            {
                this._data.DbData.HasErrors = false;
            }
            string Confirm = "";

            if (Config.GetValue("Language").ToString() == "1")
            {
                Confirm = "Are you sure " + e.Item.Caption + "?";
            }
            else
            {
                Confirm = "Bạn có chắc thực hiện " + e.Item.Caption + "?";
            }
            if (dr.Table.Columns.Contains("Confirm") && dr["Confirm"] != DBNull.Value && dr["Confirm"].ToString() != string.Empty)
            {
                Confirm = dr["Confirm"].ToString();
            }
            if (XtraMessageBox.Show(Confirm, "Xác nhận", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                Config.NewKeyValue("Operation", "Edit");
                _frmDesigner.formAction = FormAction.Approve;
                if (frmMtDtCt == null)
                {
                    frmMtDtCt = new FrmMasterDetailDt(_frmDesigner);
                }
                frmMtDtCt.ShowDialog();
                frmMtDtCt.SetCurrentData();
                if (!_data.DataChanged)
                {
                    //frmMtDtCt.UpdateData();

                    if (!(this._data as DataMasterDetail).doAction(dr))
                    {
                        if (dr.Table.Columns.Contains("Message") && dr["Message"] != DBNull.Value && dr["Message"].ToString() != string.Empty)
                        {
                            MessageBox.Show(dr["Message"].ToString());
                        }
                    }
                }
            }

            _data.GetData();
            _frmDesigner.RefreshDataForLookup();
            DisplayData();
            gvDetail.ClearColumnsFilter();


            referhComment = true;
        }
Пример #2
0
        private void simpleButtonDetail_Click(object sender, EventArgs e)
        {
            string linkField = _data.DrTable["LinkField"].ToString().ToUpper();

            if (linkField == string.Empty)
            {
                return;
            }
            if (gridViewReport.SelectedRowsCount == 0)
            {
                return;
            }
            string  linkItem = gridViewReport.GetFocusedRowCellValue(linkField).ToString().Trim();
            DataRow dr       = gridViewReport.GetDataRow(gridViewReport.FocusedRowHandle);

            foreach (DataColumn col in dr.Table.Columns)
            {
                Config.NewKeyValue("@" + col.ColumnName, dr[col]);
            }
            if (linkItem == string.Empty)
            {
                return;
            }

            string linkString = linkField + " = '" + linkItem + "'";

            DataReport data = (_data as DataReport).GetDataForDetailReport(linkField, linkItem) as DataReport;

            if (data != null)
            {
                data.PsString = (_data as DataReport).PsString;
                ReportPreview rptPre = new ReportPreview(data);
                data.SaveVariables();
                // rptPre.MdiParent = this.MdiParent;
                rptPre.Show();
                rptPre.Disposed += new EventHandler(rptPre_Disposed);
                //load lại dữ liệu trong trường hợp sửa lại voucher
                //if (rptPre.DataChanged)
                //{
                //    (_data as DataReport).GetDataForReport();
                //    gridControlReport.DataSource = (_data as DataReport).DtReportData;
                //    this.DataChanged = true;
                //}
            }
            else
            {
                string maCT;//= gridViewReport.GetFocusedRowCellValue("MACT").ToString();
                maCT = dr["MaCT"].ToString();
                CDTData data1 = (_data as DataReport).GetDataForVoucher(maCT, linkItem);
                _bindingSource                 = new BindingSource();
                _bindingSource.DataSource      = data1.DsData;
                this._bindingSource.DataMember = data1.DsData.Tables[0].TableName;
                this._frmDesigner              = new FormDesigner(data1, _bindingSource);
                _frmDesigner.formAction        = FormAction.Edit;
                FrmMasterDetailDt frmMtDtCt = new FrmMasterDetailDt(_frmDesigner);
                if (frmMtDtCt.ShowDialog() == DialogResult.OK)
                {
                    (_data as DataReport).GetDataForReport();
                    gridControlReport.DataSource = (_data as DataReport).DtReportData;
                    DataChanged = true;
                }
            }
        }