Example #1
0
        // Insert bill detail after insert bill
        private void insertBillDetail()
        {
            switch (BillDetail.BillTypeID)
            {
            case Bill.MEDICINEBILL:

                MedicineBillDetail newMedicineBillDetail = new MedicineBillDetail();

                foreach (DataRow record in ((DataTable)dataViewBillDetail.DataSource).Rows)
                {
                    newMedicineBillDetail.BillID     = BillDetail.BillID;
                    newMedicineBillDetail.MedicineID = Convert.ToInt32(record["MEDICINEID"]);
                    newMedicineBillDetail.Quantity   = Convert.ToInt32(record["Số lượng"]);
                    newMedicineBillDetail.Price      = Convert.ToDecimal(record["Giá"]);

                    MedicineBillDetail.InsertMedicineBillDetail(newMedicineBillDetail);
                }
                break;

            case Bill.SERVICEBILL:

                ServiceBillDetail newServiceBillDetail = new ServiceBillDetail();

                foreach (DataRow record in ((DataTable)dataViewBillDetail.DataSource).Rows)
                {
                    newServiceBillDetail.BillID    = BillDetail.BillID;
                    newServiceBillDetail.ServiceID = Convert.ToInt32(record["SERVICEID"]);
                    newServiceBillDetail.Quantity  = Convert.ToInt32(record["Số lượng"]);
                    newServiceBillDetail.Price     = Convert.ToDecimal(record["Giá"]);

                    ServiceBillDetail.InsertServiceBillDetail(newServiceBillDetail);
                }
                break;

            case Bill.MATERIALBILL:

                RentMaterialBillDetail newRentMaterialBillDetail = new RentMaterialBillDetail();

                foreach (DataRow record in ((DataTable)dataViewBillDetail.DataSource).Rows)
                {
                    newRentMaterialBillDetail.BillID     = BillDetail.BillID;
                    newRentMaterialBillDetail.MaterialID = Convert.ToInt32(record["MATERIALID"]);
                    newRentMaterialBillDetail.Quantity   = Convert.ToInt32(record["Số lượng"]);
                    newRentMaterialBillDetail.Price      = Convert.ToDecimal(record["Giá"]);

                    RentMaterialBillDetail.InsertRentMaterialBillDetail(newRentMaterialBillDetail);
                }
                break;
            }
        }