コード例 #1
0
        private void Insert_Button_Click(object sender, EventArgs e)
        {
            VoucherCover selected = VoucherCover_LookupEdit.GetSelectedDataRow().CastTo <VoucherCover>();

            if (selected == null)
            {
                MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000032);
                return;
            }

            VoucherCoverDetail detailSelected = Detail_GridView.GetFocusedRow().CastTo <VoucherCoverDetail>();

            if (detailSelected == null)
            {
                MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000032);
                return;
            }

            int index = VoucherCoverDetailData.FindIndex(o => o.VoucherCoverID == selected.VoucherCoverID && o.SEQ == detailSelected.SEQ);

            if (index < 0)
            {
                index = 0;
            }

            VoucherCoverDetailData.Insert(index, new VoucherCoverDetail
            {
                VoucherCoverID = selected.VoucherCoverID,
                Status         = ModifyMode.Insert
            });

            SetSEQ();
            Detail_GridView.RefreshData();
            Detail_GridView.FocusedRowHandle = index;
        }
コード例 #2
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            VoucherCover selected = VoucherCover_LookupEdit.GetSelectedDataRow().CastTo <VoucherCover>();

            if (selected == null)
            {
                MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000032);
            }

            List <VoucherCoverDetail> saveData = this.VoucherCoverDetailData
                                                 .Where(o => (o.SEQ ?? 0) > 0 && (o.Status == ModifyMode.Insert || o.Status == ModifyMode.Update)).ToList();

            if (VoucherCoverDetailDeleteData != null && VoucherCoverDetailDeleteData.Count > 0)
            {
                saveData?.InsertRange(0, VoucherCoverDetailDeleteData);
            }

            if (saveData?.Count > 0)
            {
                using (VoucherCoverController controller = new VoucherCoverController())
                {
                    if (controller.SaveVoucherCoverDetail(saveData))
                    {
                        MessageBoxHelper.ShowInfoMessage(BSMessage.BSM000001);
                        VoucherCoverDetailDeleteData = new List <VoucherCoverDetail>();
                        this.LoadGridData();
                    }
                    else
                    {
                        MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000002);
                    }
                }
            }
        }
コード例 #3
0
        private void UpdateVoucherCover()
        {
            VoucherCover selected = VoucherCover_LookupEdit.GetSelectedDataRow().CastTo <VoucherCover>();

            if (selected == null)
            {
                MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000032);
                return;
            }

            var frm = new InputBox()
            {
                Text    = "Sửa tiêu đề",
                Content = selected.VoucherCoverName
            };

            if (frm.ShowDialog() == DialogResult.OK)
            {
                selected.VoucherCoverName = frm.Content;
                selected.Status           = ModifyMode.Update;

                if (SaveVoucherCover(selected))
                {
                    MessageBoxHelper.ShowInfoMessage(BSMessage.BSM000001);
                    InitComboBox();
                }
                else
                {
                    MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000002);
                }
            }
        }
コード例 #4
0
 private void InitComboBox()
 {
     using (var controller = new VoucherCoverController())
     {
         VoucherCoverData = controller.GetVoucherCovers();
         VoucherCover_LookupEdit.SetupLookUpEdit("VoucherCoverID", "VoucherCoverName", VoucherCoverData);
         VoucherCover_LookupEdit.ItemIndex = 0;
     }
 }
コード例 #5
0
        private void Delete_Button_Click(object sender, EventArgs e)
        {
            VoucherCover selected = VoucherCover_LookupEdit.GetSelectedDataRow().CastTo <VoucherCover>();

            if (selected == null)
            {
                MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000032);
                return;
            }

            Detail_GridView.DeleteSelectedRows();
            SetSEQ();
        }
コード例 #6
0
 private void SetSEQ()
 {
     if (STTAuto_CheckEdit.Checked)
     {
         int          seq      = 0;
         VoucherCover selected = VoucherCover_LookupEdit.GetSelectedDataRow().CastTo <VoucherCover>();
         for (int i = 0; i < VoucherCoverDetailData.Count; i++)
         {
             if (VoucherCoverDetailData[i].VoucherCoverID == selected.VoucherCoverID)
             {
                 seq++;
                 VoucherCoverDetailData[i].SEQ = seq;
             }
         }
     }
 }
コード例 #7
0
        private void DeleteVoucherCover()
        {
            VoucherCover selected = VoucherCover_LookupEdit.GetSelectedDataRow().CastTo <VoucherCover>();

            selected.Status = ModifyMode.Delete;

            if (SaveVoucherCover(selected))
            {
                MessageBoxHelper.ShowInfoMessage(BSMessage.BSM000001);
                InitComboBox();
            }
            else
            {
                MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000002);
            }
        }
コード例 #8
0
        private List <VoucherCoverDetail> GetSelectedDetailData()
        {
            VoucherCover selected = VoucherCover_LookupEdit.GetSelectedDataRow().CastTo <VoucherCover>();

            if (selected == null || VoucherCoverDetailData == null)
            {
                return(null);
            }

            List <VoucherCoverDetail> result = VoucherCoverDetailData
                                               .Where(o => o.VoucherCoverID == selected.VoucherCoverID).ToList();

            result.ForEach(o => o.VoucherCoverName = selected.VoucherCoverName);

            return(result);
        }
コード例 #9
0
        private void SetFilterDetail()
        {
            this.Detail_GridView.ClearColumnsFilter();
            VoucherCover selected = VoucherCover_LookupEdit.GetSelectedDataRow().CastTo <VoucherCover>();

            if (selected == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(selected.VoucherCoverID))
            {
                //Set new filter
                string filter = string.Empty;
                filter += $"[VoucherCoverID] = '{selected.VoucherCoverID}'";
                this.Detail_GridView.ActiveFilterString = filter;
            }
        }
コード例 #10
0
        private void Add_Button_Click(object sender, EventArgs e)
        {
            VoucherCover selected = VoucherCover_LookupEdit.GetSelectedDataRow().CastTo <VoucherCover>();

            if (selected == null)
            {
                MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000032);
                return;
            }

            VoucherCoverDetailData.Add(new VoucherCoverDetail
            {
                VoucherCoverID = selected.VoucherCoverID,
                Status         = ModifyMode.Insert
            });

            SetSEQ();
            Detail_GridView.RefreshData();
            Detail_GridView.FocusedRowHandle = Detail_GridView.RowCount - 1;
        }