private PatientMedicineSale GetSelectedProcedure(DataGridView dgv)
        {
            PatientMedicineSale obj = null;

            if (dgv != null && dgv.CurrentRow != null)
            {
                obj = dgv.CurrentRow.Tag as PatientMedicineSale;
            }
            return(obj);
        }
 public PatientMedicineSaleForm(PatientBill obj)
     : base(obj, false)
 {
     this.mPatientBill = obj;
     this.mPatientMedicineSaleCollections = new PatientMedicineSaleCollection(obj.ObjectGuid);
     this.mEntry = new PatientMedicineSale();
     counter     = 0;
     this.InitializeComponent();
     this.UserInitialize();
 }
        protected override void OnSaveComplete()
        {
            base.OnSaveComplete();
            this.mEntry = new PatientMedicineSale();

            PatientMedicineSale obj = this.GetSelectedProcedure(this.dgvData);

            //PatientMedicineSaleForm.ShowForm(mPatientBill);
            this.LoadPatientAllMedicine(obj);
            this.cmbCategory.Focus();
            ClearAllControls();
        }
        private void OnDeletePatientMedicineClick(object sender, EventArgs e)
        {
            PatientMedicineSale obj = this.GetSelectedProcedure(this.dgvData);

            if (obj != null && MessageBox.Show(this, "Are you sure to delete selected patient medicine?", "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                this.mEntry = obj;
                this.mEntry.MarkToDelete();
                this.mEntry.UpdateChanges();
                ClearAllControls();
                this.mEntry = new PatientMedicineSale();
                this.cmbCategory.Focus();
            }
            LoadPatientAllMedicine(GetSelectedProcedure(this.dgvData));
        }
        private void OnOpenClick(object sender, EventArgs e)
        {
            PatientMedicineSale obj = this.GetSelectedProcedure(this.dgvData);

            if (obj != null)
            {
                obj.RefershData();
            }
            isPatientMedicineSaleEdit = true;
            if (obj != null)
            {
                this.mEntry = obj;
                this.cmbCategory.SelectedItem = obj.Category;
                this.cmbCompany.SelectedItem  = obj.Company;
                this.cmbItem.SelectedItem     = obj.Item;
                this.nupQuantity.Value        = obj.Quantity;
                this.nupAmount.Value          = obj.Amount;
                this.txtNotes.Text            = obj.Note;
            }
        }
        private void LoadPatientAllMedicine(PatientMedicineSale selected)
        {
            int     count            = 0;
            decimal totalAmount      = 0;
            decimal balanceToCollect = 0;

            this.LoadEntityList <PatientMedicineSale>(this.dgvData, clmSrNo.Index, new PatientMedicineSaleCollection(this.mPatientBill.ObjectGuid), selected, false, false,
                                                      delegate(DataGridViewRow row, PatientMedicineSale obj)
            {
                count++;
                row.Cells[this.clmSrNo.Index].Value     = obj.SrNo;
                row.Cells[this.clmMedicine.Index].Value = obj.CategoryName + " " + obj.CompanyName + " " + obj.ItemName;
                row.Cells[this.clmQuantity.Index].Value = obj.Quantity;
                row.Cells[this.clmAmount.Index].Value   = obj.Amount;
                row.Cells[this.clmNotes.Index].Value    = obj.Note;
                totalAmount = totalAmount + obj.Amount;
            }
                                                      );
            balanceToCollect              = totalAmount;
            lblTotalAmountValue.Text      = totalAmount.ToString();
            lblBalanceToCollectValue.Text = balanceToCollect.ToString();
        }