Example #1
0
        public decimal totalcostindescimal(transportation a)
        {
            decimal result = 0;

            result = Convert.ToDecimal(a.totalcost);



            return(result);
        }
Example #2
0
 public transportation Insert_transportation_select(int ID)
 {
     transportation = transportation.Select(ID);
     Insert_location_from_txt.Text    = Convert.ToString(transportation.location_from);
     Insert_location_to_txt.Text      = Convert.ToString(transportation.location_to);
     Insert_no_of_passangers_txt.Text = Convert.ToString(transportation.no_of_passangers);
     Insert_pickup_date_txt.Text      = Convert.ToString(transportation.pickup_date);
     Insert_trans_type_txt.Text       = Convert.ToString(transportation.trans_type);
     Insert_Vehicle_id_txt.Text       = Convert.ToString(transportation.Vehicle_id);
     return(transportation);
 }
 public transportation Insert_transportation_select(int ID)
 {
     transportation = transportation.Select(ID);
     Insert_location_from_txt.Text = Convert.ToString(transportation.location_from);
     Insert_location_to_txt.Text = Convert.ToString(transportation.location_to);
     Insert_no_of_passangers_txt.Text = Convert.ToString(transportation.no_of_passangers);
     Insert_pickup_date_txt.Text = Convert.ToString(transportation.pickup_date);
     Insert_trans_type_txt.Text = Convert.ToString(transportation.trans_type);
     Insert_Vehicle_id_txt.Text = Convert.ToString(transportation.Vehicle_id);
     return transportation;
 }
Example #4
0
 public transportation transportation_insert()
 {
     transportation.location_from    = Insert_location_from_txt.Text;
     transportation.location_to      = Insert_location_to_txt.Text;
     transportation.no_of_passangers = Convert.ToInt32(Insert_no_of_passangers_txt.Text);
     transportation.pickup_date      = Convert.ToDateTime(Insert_pickup_date_txt.Text);
     transportation.trans_type       = Insert_trans_type_txt.Text;
     transportation.Vehicle_id       = Convert.ToInt32(Insert_Vehicle_id_txt.Text);
     transportation = transportation.Insert(transportation);
     Insert_transportation_GridView.DataBind();
     Update_transportation_GridView.DataBind();
     Delete_transportation_GridView.DataBind();
     return(transportation);
 }
Example #5
0
 public transportation transportation_update(int ID)
 {
     transportation = transportation.Select(ID);
     transportation.transport_id     = Convert.ToInt32(Update_transport_id_txt.Text);
     transportation.location_from    = Update_location_from_txt.Text;
     transportation.location_to      = Update_location_to_txt.Text;
     transportation.no_of_passangers = Convert.ToInt32(Update_no_of_passangers_txt.Text);
     transportation.pickup_date      = Convert.ToDateTime(Update_pickup_date_txt.Text);
     transportation.trans_type       = Update_trans_type_txt.Text;
     transportation.Vehicle_id       = Convert.ToInt32(Update_Vehicle_id_txt.Text);
     transportation.Update(transportation);
     Insert_transportation_GridView.DataBind();
     Update_transportation_GridView.DataBind();
     Delete_transportation_GridView.DataBind();
     return(transportation);
 }
Example #6
0
        public List <transportation> getbesttcost(decimal distance, decimal totalweight = 0)
        {
            decimal                cost = 0, mintotalcost = 0, number = 0, totalcost = 0;
            int                    number1 = 0;
            tbl_vehicletype        veh1    = new tbl_vehicletype();
            tbl_vehicletype        veh2    = new tbl_vehicletype();
            List <tbl_vehicletype> lstveh  = new List <tbl_vehicletype>();
            List <tbl_vehicletype> lstveh2 = new List <tbl_vehicletype>();

            decimal selectedcapacity, selectedcapacity2, capacitydif = 0, capacitydif2 = 0, remainingweight = 0;
            int     selectedveh1       = 0;
            List <transportation> tlst = new List <transportation>();

            foreach (var item in db.tbl_vehicletype)
            {
                capacitydif = totalweight - item.capacity.Value;
                if (capacitydif > 0)
                {
                    lstveh.Add(item);
                }
            }

            if (lstveh.Count() > 0)
            {
                selectedcapacity = lstveh.Max(a => a.capacity.Value);
                var vehsel1 = db.tbl_vehicletype.Where(a => a.capacity > selectedcapacity);
                if (vehsel1.Count() > 0)
                {
                    decimal selectedcapacityasl = vehsel1.Min(a => a.capacity.Value);
                    veh1 = vehsel1.Where(a => a.capacity == selectedcapacityasl).SingleOrDefault();
                }
                else
                {
                    veh1 = db.tbl_vehicletype.OrderByDescending(a => a.capacity.Value).FirstOrDefault();
                }
            }
            else
            {
                veh1 = db.tbl_vehicletype.OrderBy(a => a.capacity.Value).FirstOrDefault();
            }



            transportation t1 = new transportation();

            t1.number = Math.Floor(totalweight / veh1.capacity.Value) == 0 ? 1 : Math.Floor(totalweight / veh1.capacity.Value);
            number    = t1.number;

            cost             = (Math.Floor(veh1.factor.Value * distance) > db.tbl_vehicletype.Where(a => a.id == veh1.id).SingleOrDefault().mincost.Value) ? Math.Floor(veh1.factor.Value * distance) : db.tbl_vehicletype.Where(a => a.id == veh1.id).SingleOrDefault().mincost.Value;
            t1.cost          = cost.ToString();
            totalcost        = (t1.number * Convert.ToDecimal(cost));
            t1.totalcost     = totalcost.ToString();
            t1.vehicletype   = veh1.vehiclename;
            t1.vehicletypeid = veh1.id;
            t1.distance      = distance.ToString() + " km";
            t1.address       = "نحوه حمل پیشنهادی" + "= " + "حداقل کرایه کل";
            tlst.Add(t1);

            remainingweight = totalweight - (number * veh1.capacity.Value);
            if (remainingweight > 0)
            {
                foreach (var item2 in db.tbl_vehicletype)
                {
                    capacitydif2 = remainingweight - item2.capacity.Value;
                    if (capacitydif2 < 0)
                    {
                        lstveh2.Add(item2);
                    }
                }
                if (lstveh2.Count() > 0)
                {
                    selectedcapacity2 = lstveh2.Min(a => a.capacity.Value);
                    veh2 = lstveh.Where(a => a.capacity == selectedcapacity2).SingleOrDefault();

                    transportation t2 = new transportation();
                    t2.number        = Math.Ceiling(remainingweight / veh2.capacity.Value);
                    cost             = (Math.Floor(veh2.factor.Value * distance) > db.tbl_vehicletype.Where(a => a.id == veh2.id).SingleOrDefault().mincost.Value) ? Math.Floor(veh2.factor.Value * distance) : db.tbl_vehicletype.Where(a => a.id == veh2.id).SingleOrDefault().mincost.Value;
                    t2.cost          = cost.ToString();
                    totalcost        = (t2.number * Convert.ToDecimal(cost));
                    t2.totalcost     = totalcost.ToString();
                    t2.vehicletype   = veh2.vehiclename;
                    t2.vehicletypeid = veh2.id;
                    t2.distance      = distance.ToString() + " km";
                    t2.address       = "نحوه حمل پیشنهادی" + "= " + "حداقل کرایه کل";
                    tlst.Add(t2);
                }
                else
                {
                    transportation t2 = new transportation();
                    t2.number        = 1;
                    cost             = (Math.Floor(db.tbl_vehicletype.FirstOrDefault().factor.Value *distance) > db.tbl_vehicletype.FirstOrDefault().mincost.Value) ? Math.Floor(db.tbl_vehicletype.FirstOrDefault().factor.Value *distance) : db.tbl_vehicletype.FirstOrDefault().mincost.Value;
                    t2.cost          = cost.ToString();
                    totalcost        = (1 * Convert.ToDecimal(cost));
                    t2.totalcost     = totalcost.ToString();
                    t2.vehicletype   = db.tbl_vehicletype.FirstOrDefault().vehiclename;
                    t2.vehicletypeid = veh2.id;
                    t2.distance      = distance.ToString() + " km";
                    t2.address       = "نحوه حمل پیشنهادی" + "= " + "حداقل کرایه کل";
                    tlst.Add(t2);
                }
            }



            return(tlst);
        }
Example #7
0
 protected void INSERT(object sender, EventArgs e)
 {
     transportation = transportation_insert();
 }
Example #8
0
 protected void Insert_Select_Record(object sender, EventArgs e)
 {
     transportation = Insert_transportation_select(Convert.ToInt32(Insert_transportation_GridView.SelectedValue));
 }
Example #9
0
 protected void UPDATE(object sender, EventArgs e)
 {
     transportation = transportation_update(Convert.ToInt32(Update_transportation_GridView.SelectedValue));
 }
 public transportation transportation_update(int ID)
 {
     transportation = transportation.Select(ID);
     transportation.transport_id = Convert.ToInt32(Update_transport_id_txt.Text);
     transportation.location_from = Update_location_from_txt.Text;
     transportation.location_to = Update_location_to_txt.Text;
     transportation.no_of_passangers = Convert.ToInt32(Update_no_of_passangers_txt.Text);
     transportation.pickup_date = Convert.ToDateTime(Update_pickup_date_txt.Text);
     transportation.trans_type = Update_trans_type_txt.Text;
     transportation.Vehicle_id = Convert.ToInt32(Update_Vehicle_id_txt.Text);
     transportation.Update(transportation);
     Insert_transportation_GridView.DataBind();
     Update_transportation_GridView.DataBind();
     Delete_transportation_GridView.DataBind();
     return transportation;
 }
 public transportation transportation_insert()
 {
     transportation.location_from = Insert_location_from_txt.Text;
     transportation.location_to = Insert_location_to_txt.Text;
     transportation.no_of_passangers = Convert.ToInt32(Insert_no_of_passangers_txt.Text);
     transportation.pickup_date = Convert.ToDateTime(Insert_pickup_date_txt.Text);
     transportation.trans_type = Insert_trans_type_txt.Text;
     transportation.Vehicle_id = Convert.ToInt32(Insert_Vehicle_id_txt.Text);
     transportation = transportation.Insert(transportation);
     Insert_transportation_GridView.DataBind();
     Update_transportation_GridView.DataBind();
     Delete_transportation_GridView.DataBind();
     return transportation;
 }
 protected void Update_Select_Record(object sender, EventArgs e)
 {
     transportation = Update_transportation_select(Convert.ToInt32(Update_transportation_GridView.SelectedValue));
 }
 protected void UPDATE(object sender, EventArgs e)
 {
     transportation = transportation_update(Convert.ToInt32(Update_transportation_GridView.SelectedValue));
 }
 protected void INSERT(object sender, EventArgs e)
 {
     transportation = transportation_insert();
 }