private void GoToDealerSalesAndCollection()
        {
            _hPanel.Controls.Clear();
            SalesAndCollectionControl sacc = new SalesAndCollectionControl(_hPanel, _vPanel, _challanPage.Dealer);

            _hPanel.Controls.Add(sacc);
            sacc.Dock = DockStyle.Fill;
            sacc.Show();
        }
        private void BUC_SalesAndCollection_Click(object sender, EventArgs e)
        {
            _hPanel.Controls.Clear();
            SalesAndCollectionControl sacc = new SalesAndCollectionControl(_hPanel, _vPanel);

            _hPanel.Controls.Add(sacc);
            sacc.Dock = DockStyle.Fill;
            sacc.Show();
        }
        public PopupCollectionModelControl(Panel vPanel, Panel hPanel, Form popUpForm, SalesAndCollectionControl salesAndCollectionControl, string dealerCode)
        {
            _popUpForm = popUpForm;
            _vPanel    = vPanel;
            _hPanel    = hPanel;
            _salesAndCollectionControl = salesAndCollectionControl;
            _dealerList = DealerManager.GetAllDealers();

            if (string.IsNullOrEmpty(dealerCode) || dealerCode.ToLower().Equals("any"))
            {
                _dealer = null;
            }
            else
            {
                _dealer = DealerManager.FindDealer(dealerCode);
            }

            InitializeComponent();
            this.Load += new System.EventHandler(this.PopupModelControl_Load);
        }
        private void BindInterfaceDataToObject()
        {
            var selectedDealer = _dealerList.Where(x => x.Code.Equals(CB_PMC_SelectDealer.Text)).FirstOrDefault();

            _collection.DealerName = selectedDealer.DealerName;
            _collection.DealerCode = selectedDealer.Code;
            _collection.Address    = selectedDealer.Address;
            _collection.Contact    = selectedDealer.Contact;

            _collection.MR_NO            = TB_PMC_MR_No.Text;
            _collection.IC_NO            = TB_PMC_IC_No.Text;
            _collection.CollectionAmount = Convert.ToInt32(TB_PMC_CollectionAmount.Text);
            _collection.Remarks          = TB_PMC_Remark.Text;
            _collection.Date             = DTP_PMC_Date.Value.Date;

            if (_collection.CollectionAmount <= 0
                //|| _collection.MR_NO.Equals("")
                //|| _collection.IC_NO.Equals("")
                )
            {
                MessageBox.Show("Make sure Collection amount is not 0 ");
            }
            else
            {
                ConfirmChange();
            }

            void ConfirmChange()
            {
                DialogResult dialogResult = MessageBox.Show(BPMC_Add.Text + " Collection? ", "Confirm Change?", MessageBoxButtons.YesNo);

                if (dialogResult == DialogResult.Yes)
                {
                    if (_collection != null)
                    {
                        if (BPMC_Add.Text.Equals("Add"))
                        {
                            if (SalesAndCollectionManager.AddNewSale(_collection))
                            {
                                MessageBox.Show("Collection Added successfully!");

                                ReloadDealerControl();
                            }
                            else
                            {
                                MessageBox.Show("Error! Something went wrong!!");
                            }
                        }
                    }
                    else
                    {
                    }
                }
                else if (dialogResult == DialogResult.No)
                {
                    //do something else
                }

                void ReloadDealerControl()
                {
                    _hPanel.Controls.Clear();
                    _salesAndCollectionControl = new SalesAndCollectionControl(_hPanel, _vPanel);
                    _hPanel.Controls.Add(_salesAndCollectionControl);
                    _salesAndCollectionControl.Dock = DockStyle.Fill;
                    _salesAndCollectionControl.Show();
                    _popUpForm.Close();
                }
            }
        }