Example #1
0
        private void materialButton_saveandprint_Click(object sender, EventArgs e)
        {
            if (comboBox_vehicle.SelectedItem == null)
            {
                CustomControls.Alert.show("Select", "please Select Vechicle ", 2000);
                return;
            }

            int date;
            var newbills = new Model.trip()
            {
                vechicle_id = (comboBox_vehicle.SelectedItem as Model.vehicle).id,
                totalamount = valorSum,
                created_at  = DateTime.Now,
                updated_at  = DateTime.Now,
                admin_id    = INFO.admin_id,
                date        = nepaliCalender1.Datestamp
            };

            db.trips.Add(newbills);
            db.SaveChanges();

            foreach (var item in betterListView_orderitem.Items.Cast <Viwer>().ToList())
            {
                item.save(newbills.id, nepaliCalender1.Datestamp);
            }
            Senditems.Printing printing = new Printing();
            printing.prininte(newbills);
            foreach (ListViewItem item1 in betterListView_exp.Items)
            {
                var title  = item1.SubItems[1].Text;
                var amount = Convert.ToDecimal(item1.SubItems[2].Text);
                var exp    = new Model.expence()
                {
                    title      = title,
                    amount     = amount,
                    bill_id    = newbills.id,
                    created_at = DateTime.Now,
                    updated_at = DateTime.Now,
                    date       = nepaliCalender1.Datestamp,
                    admin_id   = INFO.admin_id,
                    vehicle_id = (comboBox_vehicle.SelectedItem as Model.vehicle).id,
                };
                db.expences.Add(exp);
                db.SaveChanges();
            }
            var deactivate_vechicle = db.vehicles.Find((comboBox_vehicle.SelectedItem as Model.vehicle).id);

            deactivate_vechicle.active          = false;
            db.Entry(deactivate_vechicle).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            betterListView_exp.Items.Clear();
            betterListView_orderitem.Items.Clear();
            betterTextBox_total.Clear();

            this.Close();
        }
Example #2
0
        public void prininte(Model.trip trip, BetterListView _bs = null)

        {
            bs   = _bs;
            Trip = trip;
            if (this.PrintObject == null)
            {
                this.PrintObject = new CustomControls.PrintObject("transport");
                this.PrintObject.PrintDocument.PrintPage += PrintDocument_PrintPage;
            }
            offset = 0;
            this.PrintObject.PrintDocument.Print();
        }