private void materialButton_save_Click(object sender, EventArgs e)
 {
     if (betterTextBox_amount.decVal == 0)
     {
         CustomControls.Alert.show("Amount ", "enter paid amount", 2000);
         return;
     }
     if (betterTextBox_paidby.Text.Trim() == "")
     {
         CustomControls.Alert.show("name ", "enter paid by", 2000);
         return;
     }
     var edit = db.paidadvances.Find(id);
     var loaddata = db.staffs.Find(staff_id);
     loaddata.advance = (loaddata.advance - edit.paidamount) + betterTextBox_amount.decVal;
     db.Entry(loaddata).State = System.Data.Entity.EntityState.Modified;
     edit.paidamount = betterTextBox_amount.decVal;
     edit.paidby = betterTextBox_paidby.Text;
     edit.staff_id = staff_id;
     edit.paid_date = nepaliCalender_paiddate.Datestamp;
     edit.updated_at = DateTime.Now;
     edit.created_at = DateTime.Now;
     db.Entry(edit).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
     editdata?.Invoke(edit);
     this.Close();
 }
        private void materialButton_save_Click(object sender, EventArgs e)
        {
            if (betterTextBox_amount.decVal == 0)
            {
                CustomControls.Alert.show("Amount ", "enter paid amount", 2000);
                return;
            }
            if (betterTextBox_paidby.Text.Trim() == "")
            {
                CustomControls.Alert.show("name ", "enter paid by", 2000);
                return;
            }
            var edit = db.paidsalarys.Find(id);

            //var loadadv = db.staffs.Find(staff_id);
            // loadadv.advance = (loadadv.advance + edit.usedadvence) + betterTextBox_advance.decVal;
            // db.Entry(loadadv).State = System.Data.Entity.EntityState.Modified;
            edit.staff_id        = staff_id;
            edit.paidby          = betterTextBox_paidby.Text;
            edit.paidamount      = betterTextBox_amount.decVal;
            edit.paid_date       = nepaliCalender_paiddate.Datestamp;
            edit.paid_form       = nepaliCalender_paidfrom.Datestamp;
            edit.paid_to         = nepaliCalender_paidto.Datestamp;
            db.Entry(edit).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            editdata?.Invoke(edit);
            this.Close();
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
        private void materialButton_save_Click(object sender, EventArgs e)
        {
            if (betterTextBox_vehiclenumber.Text.Trim() == "")
            {
                CustomControls.Alert.show("Number", "Please Enter Vehicle Number", 2000);
                return;
            }
            if (betterTextBox_type.Text.Trim() == "")
            {
                CustomControls.Alert.show("Type", "Please Enter Vehicle Type", 2000);
                return;
            }
            if (betterTextBox_modelnumber.Text.Trim() == "")
            {
                CustomControls.Alert.show("Model Number", "Please Enter Model Number", 2000);
                return;
            }
            if (betterTextBox_Chassisnumber.Text.Trim() == "")
            {
                CustomControls.Alert.show("Chassis Number", "Please Enter Chassis Number", 2000);
                return;
            }
            if (betterTextBox_carringcapacity.Text.Trim() == "")
            {
                CustomControls.Alert.show("Carring Capacity", "Please Enter Carring Capacity", 2000);
                return;
            }
            if (betterTextBox_ownername.Text.Trim() == "")
            {
                CustomControls.Alert.show("Name", "Please Enter owner Name", 2000);
                return;
            }

            if (comboBox_staffname.SelectedItem == null)
            {
                CustomControls.Alert.show("Select Name", "Please Select staff name", 2000);
                comboBox_staffname.Focus();
                return;
            }
            var load = db.vehicles.Find(id);

            load.vehicle_no      = betterTextBox_vehiclenumber.Text;
            load.vehicle_type    = betterTextBox_type.Text;
            load.modelnumber     = betterTextBox_modelnumber.Text;
            load.carringcapacity = betterTextBox_carringcapacity.Text;
            load.chassisnumber   = betterTextBox_Chassisnumber.Text;
            load.onwername       = betterTextBox_ownername.Text;
            load.date            = nepaliCalender_startdate.Datestamp;
            load.enginenumber    = betterTextBox_Enginenumber.Text;
            load.staff_id        = (comboBox_staffname.SelectedItem as Model.staff).id;
            db.Entry(load).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            edit?.Invoke(load);
            this.Close();
        }
Ejemplo n.º 5
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Do you wnt to delete?", "Delete record", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                CustomControls.Alert.show("Finance", "data deleted", 1500);

                var i = db.finances.Where(o => o.id == this.id).First();
                db.Entry(i).State = System.Data.Entity.EntityState.Deleted;
                db.SaveChanges();
                this.Parent.Controls.Remove(this);
            }
        }
Ejemplo n.º 6
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            if (txt_name.Text.Trim() == "")
            {
                CustomControls.Alert.show("name", "Enter Name", 1500);
                return;
            }
            if (txt_address.Text.Trim() == "")
            {
                CustomControls.Alert.show("address", "Enter Address", 1500);
                return;
            }
            if (txt_phone.Text.Trim() == "")
            {
                CustomControls.Alert.show("phone", "Enter phone", 1500);
                return;
            }
            if (txt_salary.Text.Trim() == "")
            {
                CustomControls.Alert.show("salary", "Enter Salary", 1500);
                return;
            }
            if (txt_post.Text.Trim() == "")
            {
                CustomControls.Alert.show("post", "Enter post", 1500);
                return;
            }

            try
            {
                var i = db.staffs.Find(id);
                i.name    = txt_name.Text;
                i.address = txt_address.Text;
                i.phone   = txt_phone.Text;
                i.salary  = txt_salary.decVal;
                i.post    = txt_post.Text;
                //i.photo = txt_photo.Text;
                i.description     = txt_description.Text;
                i.startdate       = nepaliCalender1.Datestamp;
                i.created_at      = DateTime.Now;
                i.updated_at      = DateTime.Now;
                db.Entry(i).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                edit?.Invoke(i);
                this.Close();
            }
            catch (Exception ex)
            {
                CustomControls.Alert.show("Data", "Error Data", 1500);
            }
        }
        private void materialButton_save_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem lstItem in betterListView_orderitem.Items) // listView has ListViewItem objects
            {
                orderitem_id = Convert.ToInt32(lstItem.SubItems[15].Text);   // Columns 4

                var orderitemactive = db.orderitemlists.Where(o => o.id == orderitem_id).First();
                orderitemactive.active          = true;
                db.Entry(orderitemactive).State = System.Data.Entity.EntityState.Modified;
                var load = db.trips.Find(billid);
                load.vehicle.active = true;
                var activatedvehicle = db.vehicles.Find(load.vechicle_id);
                db.Entry(activatedvehicle).State = System.Data.Entity.EntityState.Modified;
                foreach (var item in db.tripitems.Where(o => o.item_id == orderitem_id).ToList())
                {
                    item.active          = false;
                    db.Entry(item).State = System.Data.Entity.EntityState.Modified;
                }

                db.SaveChanges();
                this.Close();
            }
        }
Ejemplo n.º 8
0
        private void materialButton_save_Click(object sender, EventArgs e)
        {
            var load          = db.trips.Find(staffandv_id);
            var savedelivered = new Model.tripondelivered()
            {
                staff_id   = load.staff_id,
                vehicle_id = load.vechicle_id,
                date       = nepaliCalender_date.Datestamp,
                updated_at = DateTime.Now,
                created_at = DateTime.Now,
                admin_id   = INFO.admin_id,
                amount     = betterTextBox_expamount.decVal,
                bill_id    = load.id,
            };

            date = nepaliCalender_date.Datestamp;
            var activatedvehicle = db.vehicles.Find(load.vechicle_id);

            activatedvehicle.active          = true;
            db.Entry(activatedvehicle).State = System.Data.Entity.EntityState.Modified;
            db.tripondelivereds.Add(savedelivered);

            db.SaveChanges();

            foreach (var item in betterListView_orderitem.Items.Cast <Viwer>().ToList())
            {
                item.save(savedelivered.id, savedelivered.date);
            }
            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    = load.id,
                    created_at = DateTime.Now,
                    updated_at = DateTime.Now,
                    date       = nepaliCalender_date.Datestamp,
                    admin_id   = INFO.admin_id,
                    vehicle_id = load.vechicle_id
                };
                db.expences.Add(exp);
                db.SaveChanges();
            }

            this.Close();
        }
Ejemplo n.º 9
0
 private void materialButton_delete_Click(object sender, EventArgs e)
 {
     try
     {
         var delete = db.vehicles.Find(id);
         db.Entry(delete).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
         this.Parent.Controls.Remove(this);
     }
     catch (Exception ex)
     {
         CustomControls.Alert.show("not delete", "this record it's record is used in another transaction", 3000);
         return;
     }
 }
Ejemplo n.º 10
0
 public void initdelete()
 {
     try
     {
         var db = new Model.TransportManagementEntities();
         var i  = db.staffs.Find(Staff.id);
         db.Entry(i).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
         this.ListView.Items.Remove(this);
     }
     catch
     {
         CustomControls.Alert.show("this record is not delete", "this record is not deleted this record is related in another transaction", 3000);
     }
 }
Ejemplo n.º 11
0
 private void materialButton_Delete_Click(object sender, EventArgs e)
 {
     try
     {
         if (saveondatabase)
         {
             db.Entry(taxcategory).State = System.Data.Entity.EntityState.Deleted;
             db.SaveChanges();
         }
         this.Parent.Controls.Remove(this);
     }
     catch
     {
         CustomControls.Alert.show("not delete", "this is not delete", 2000);
     }
 }
Ejemplo n.º 12
0
        private void materialButton_save_Click(object sender, EventArgs e)
        {
            if (betterTextBox_amount.decVal == 0)
            {
                CustomControls.Alert.show("Amount ", "enter paid amount", 2000);
                return;
            }
            if (betterTextBox_paidby.Text.Trim() == "")
            {
                CustomControls.Alert.show("name ", "enter paid by", 2000);
                return;
            }
            var add = new Model.paidsalary()
            {
                staff_id    = staff_id,
                paidamount  = betterTextBox_amount.decVal,
                paid_form   = nepaliCalender_paidfrom.Datestamp,
                paid_to     = nepaliCalender_paidto.Datestamp,
                paid_date   = nepaliCalender_paiddate.Datestamp,
                paidby      = betterTextBox_paidby.Text,
                created_at  = DateTime.Now,
                updated_at  = DateTime.Now,
                usedadvence = betterTextBox_useadvanceamount.decVal
            };

            if (checkBox_usedadvance.Checked)
            {
                var advance = db.staffs.Find(staff_id);
                if (betterTextBox_useadvanceamount.decVal <= advance.advance)
                {
                    advance.advance -= betterTextBox_useadvanceamount.decVal;
                }
                else
                {
                    CustomControls.Alert.show("Advance amount", "your used advance amount is greter then paid advance amount please check", 4000);
                    return;
                }
                db.Entry(advance).State = System.Data.Entity.EntityState.Modified;
            }
            db.paidsalarys.Add(add);
            db.SaveChanges();
            adddata.Invoke(add);
            this.Close();
            this.Close();
        }
Ejemplo n.º 13
0
        private void materialButton_save_Click(object sender, EventArgs e)
        {
            if (comboBox_taxyear.SelectedItem == null)
            {
                CustomControls.Alert.show("Select", "Please select tax yearr", 2000);
                return;
            }
            if (comboBox_Textitle.SelectedItem == null)
            {
                CustomControls.Alert.show("Title", "Please select tax title", 2000);
                return;
            }
            if (betterTextBox_amout.decVal == 0)
            {
                CustomControls.Alert.show("Amount", "Please enter tax amount", 2000);
                return;
            }
            if (betterTextBox_paidbye.Text.Trim() == "")
            {
                CustomControls.Alert.show("Name", "Please enter Name of paidby", 2000);
                return;
            }
            if (betterTextBox_dis.Text.Trim() == "")
            {
                CustomControls.Alert.show("Discription", "Please enter discription", 2000);
                return;
            }
            var editdata = db.taxpaids.Find(id);

            editdata.taxyear_id      = ((comboBox_taxyear.SelectedItem as Model.taxcategory).id);
            editdata.tax_id          = ((comboBox_Textitle.SelectedItem as Model.tax).id);
            editdata.paidby          = betterTextBox_paidbye.Text;
            editdata.amount          = betterTextBox_amout.decVal;
            editdata.discription     = betterTextBox_dis.Text;
            editdata.date            = nepaliCalender_date.Datestamp;
            db.Entry(editdata).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            edit?.Invoke(editdata);
            this.Close();
        }
Ejemplo n.º 14
0
        private void materialButton_save_Click_1(object sender, EventArgs e)
        {
            if (betterTextBox_sendername.Text.Trim() == "")
            {
                CustomControls.Alert.show("Name", "Please enter sender name", 2000);
                return;
            }
            if (betterTextBox_receiverphone.Text.Trim() == "")
            {
                CustomControls.Alert.show("Name", "Please enter  receiver phone", 2000);
                return;
            }
            if (betterTextBox_receivername.Text.Trim() == "")
            {
                CustomControls.Alert.show("Name", "Please enter  receiver name", 2000);
                return;
            }
            if (betterTextBox_senderphonenumber.Text.Trim() == "")
            {
                CustomControls.Alert.show("Address", "Please enter sender phone", 2000);
                return;
            }
            if (betterTextBox_itemname.Text.Trim() == "")
            {
                CustomControls.Alert.show("Name", " please enter item name", 2000);
                return;
            }
            if (comboBox_itemtype.SelectedItem == null)
            {
                CustomControls.Alert.show("Item Type", " please select item type", 2000);
                return;
            }
            if (comboBox_locationfrom.SelectedItem == null)
            {
                CustomControls.Alert.show("From", " please select location ", 2000);
                return;
            }
            if (comboBox_locationto.SelectedItem == null)
            {
                CustomControls.Alert.show("To", "select location", 2000);
                return;
            }
            if (betterTextBox_itemweight.Text.Trim() == "")
            {
                CustomControls.Alert.show("To", "enter weight of item", 2000);
                return;
            }
            if (betterTextBox_itemqty.Text.Trim() == "")
            {
                CustomControls.Alert.show("To", "enter quantity of item", 2000);
                return;
            }
            if (betterTextBox_amount.Text.Trim() == "")
            {
                CustomControls.Alert.show("To", "enter charge amount", 2000);
                return;
            }
            if (betterTextBox_unit.Text.Trim() == "")
            {
                CustomControls.Alert.show("To", "enter unit", 2000);
                return;
            }

            if (betterTextBox_deliverplace.Text.Trim() == "")
            {
                CustomControls.Alert.show("To", "enter deliver place", 2000);
                return;
            }
            var edit = db.orderitemlists.Find(item_id);

            edit.sender_name      = betterTextBox_sendername.Text;
            edit.receiverphone    = betterTextBox_receiverphone.Text;
            edit.receivername     = betterTextBox_receivername.Text;
            edit.sender_phone     = betterTextBox_senderphonenumber.Text;
            edit.itemname         = betterTextBox_itemname.Text;
            edit.location_from    = (comboBox_locationfrom.SelectedItem as Model.location).id;
            edit.location_too     = (comboBox_locationto.SelectedItem as Model.location).id;
            edit.date             = nepaliCalender_DAte.Datestamp;
            edit.unit             = betterTextBox_unit.Text;
            edit.weight           = betterTextBox_itemweight.decVal;
            edit.quantity         = betterTextBox_itemqty.decVal;
            edit.orderitemtype_id = (comboBox_itemtype.SelectedItem as Model.orderitemtype).id;
            edit.deliveryplace    = betterTextBox_deliverplace.Text;
            edit.amount           = betterTextBox_amount.decVal;
            db.Entry(edit).State  = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            editdata?.Invoke(edit);
            this.Close();
        }