Exemple #1
0
    public void update_vehicles(Vehicle_Info info)
    {
        con.Open();

        SqlCommand cmd = new SqlCommand("Update_Vehicles", con);

        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter p = new SqlParameter();

        p       = cmd.Parameters.Add("@bus_id", SqlDbType.Int);
        p.Value = info.Bus_Id;


        p       = cmd.Parameters.Add("@bus_name", SqlDbType.Int);
        p.Value = info.BusName;

        p       = cmd.Parameters.Add("@bus_reg_no", SqlDbType.Int);
        p.Value = info.Bus_Reg_No;


        p       = cmd.Parameters.Add("@no", SqlDbType.Int);
        p.Value = info.Own_No;

        p       = cmd.Parameters.Add("@model_no", SqlDbType.Int);
        p.Value = info.Model_No;


        cmd.ExecuteNonQuery();

        con.Close();
    }
Exemple #2
0
    public Vehicle_Info ViewVehicle(int bus_id_ref)
    {
        con.Open();


        SqlCommand cmd = new SqlCommand("View_Vehicle", con);

        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter p = new SqlParameter();

        p       = cmd.Parameters.Add("@bus_id", SqlDbType.Int);
        p.Value = bus_id_ref;

        SqlDataReader read = cmd.ExecuteReader();


        Vehicle_Info v_info = new Vehicle_Info();

        read.Read();
        if (read.HasRows)
        {
            v_info.Bus_Reg_No = read["bus_reg_no"].ToString();
            v_info.BusName    = read["bus_name"].ToString();
            v_info.Model_No   = read["model_no"].ToString();
            v_info.Own_No     = int.Parse(read["no"].ToString());
        }
        else
        {
            v_info.Bus_Reg_No = "1000";// to represent database is null or no such entry.
        }

        read.Close();
        con.Close();
        return(v_info);
    }
Exemple #3
0
    public Vehicle_Info ViewVehicleThroughBusRegNo(string busregno)
    {
        con.Open();


        SqlCommand cmd = new SqlCommand("ViewVehicleThroughBusRegNo", con);

        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter p = new SqlParameter();

        p       = cmd.Parameters.Add("@bus_reg_no", SqlDbType.VarChar);
        p.Value = busregno;

        SqlDataReader read = cmd.ExecuteReader();


        Vehicle_Info v_info = new Vehicle_Info();

        read.Read();
        if (read.HasRows)
        {
            v_info.Bus_Id   = int.Parse(read["bus_id"].ToString());
            v_info.BusName  = read["bus_name"].ToString();
            v_info.Model_No = read["model_no"].ToString();
            v_info.Own_No   = int.Parse(read["no"].ToString());
        }
        else
        {
            v_info.BusName = "Not exists such a regno";// to represent database is null or no such entry.
        }

        read.Close();
        con.Close();
        return(v_info);
    }
Exemple #4
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        Vehicle_Info v_inf = new Vehicle_Info();
        Vehicle_Sp   v_sp  = new Vehicle_Sp();
        Memb_Info    info  = new Memb_Info();
        Memb_Sp      sp    = new Memb_Sp();

        v_inf.Bus_Reg_No = txtvehicle.Text.ToLower();
        if (v_sp.CompareBusRegNo(v_inf.Bus_Reg_No) != 0)
        {
            Vehicle_Info nv_inf = new Vehicle_Info();
            nv_inf = v_sp.ViewVehicleThroughBusRegNo(v_inf.Bus_Reg_No);
            int       sds   = nv_inf.Own_No;
            Memb_Info ninfo = new Memb_Info();
            ninfo        = sp.ViewMember(sds);
            lbname.Text  = ninfo.MemberName;
            lbage.Text   = ninfo.Age.ToString();
            lbadd.Text   = ninfo.Address;
            lbemail.Text = ninfo.E_Mail;
            lbphno.Text  = ninfo.Mobile;
            lbnob.Text   = ninfo.Nob.ToString();
            String path = Server.MapPath("~/Photos/Owners/");
            Image1.ImageUrl = path + ninfo.Phot;
            MultiView1.SetActiveView(View2);
        }
        else
        {
            Label14.Visible = true;
        }
    }
Exemple #5
0
        public ActionResult CreateNewCustomerPolicy()
        {
            int cusId = (int)Session["id"];
            CustomerinfoDAORequest customerRequest = new CustomerinfoDAORequest();
            Customer_Info          customerInfo    = customerRequest.searchCustomerById(cusId);

            int policyID = int.Parse(Request.Params["idPolicyHidden"]);
            PolicyDAORequest policyRequest = new PolicyDAORequest();
            Policy           policyInfo    = policyRequest.searchPolicyById(policyID);

            int             modelId = int.Parse(Request.Params["cbVehicleModel"]);
            ModelDAORequest dao     = new ModelDAORequest();
            Model           model1  = dao.searchModelByModel(modelId);
            ModelViewModel  model   = dao.GetModelById(modelId);

            int vehicleCondition = int.Parse(Request.Params["condition"]);

            Vehicle_Info newVehicle = new Vehicle_Info()
            {
                brand_id          = int.Parse(Request.Form["cbVehicleBrand"]),
                model_id          = int.Parse(Request.Form["cbVehicleModel"]),
                address           = Request.Form["address"].ToString(),
                owner_name        = Request.Form["ownerName"].ToString(),
                version           = Request.Params["version"],
                frame_number      = Request.Params["frameNumber"],
                engine_number     = Request.Params["engineNumber"],
                vehicle_number    = Request.Params["vehicleNumber"],
                vehicle_condition = vehicleCondition,
                rate_by_condition = (vehicleCondition * model.rate) / 100,
                Model             = model1
            };

            Customer_Policy newCustomerPolicy = new Customer_Policy()
            {
                customer_id        = cusId,
                policy_id          = policyID,
                Vehicle_Info       = newVehicle,
                vehicle_id         = newVehicle.id,
                policy_start_date  = DateTime.Parse(Request.Params["startDate"]),
                policy_end_date    = DateTime.Parse(Request.Params["endDate"]),
                create_date        = DateTime.Parse(Request.Params["createDate"]),
                customer_add_prove = "Proved",
                total_payment      = decimal.Parse(Request.Params["totalPayment"]),
                active             = true,
                Policy             = policyInfo,
                Customer_Info      = customerInfo
            };

            CheckoutInfo checkout = new CheckoutInfo()
            {
                CustomerPolicy = newCustomerPolicy,
                Vehicle        = newVehicle
            };

            Session["checkoutInfo"] = checkout;
            return(RedirectToAction("CheckOutPage"));
        }
        public void AddCustomerPolicy()
        {
            CheckoutInfo checkout = (CheckoutInfo)Session["checkoutInfo"];

            Vehicle_Info    vehicleInfo    = checkout.Vehicle;
            Customer_Policy customerPolicy = checkout.CustomerPolicy;

            VehicleinfoViewModel vehicle = new VehicleinfoViewModel()
            {
                address          = vehicleInfo.address,
                brandid          = vehicleInfo.brand_id,
                eginenumber      = vehicleInfo.engine_number,
                framenumber      = vehicleInfo.frame_number,
                modelid          = vehicleInfo.model_id,
                ownername        = vehicleInfo.owner_name,
                ratebycondition  = vehicleInfo.rate_by_condition,
                vehiclecondition = vehicleInfo.vehicle_condition,
                vehiclenumber    = vehicleInfo.vehicle_number,
                version          = vehicleInfo.version
            };

            VehicleinfoDAORequest request1 = new VehicleinfoDAORequest();

            request1.Add(vehicle);

            VehicleinfoViewModel vehicle2 = request1.GetByAllNumber(vehicle.framenumber, vehicle.eginenumber, vehicle.vehiclenumber);

            CustomerpolicyViewModel cPolicy = new CustomerpolicyViewModel()
            {
                active           = customerPolicy.active,
                createdate       = customerPolicy.create_date,
                customeraddprove = customerPolicy.customer_add_prove,
                customerid       = (int)customerPolicy.customer_id,
                policyenddate    = customerPolicy.policy_end_date,
                policyid         = (int)customerPolicy.policy_id,
                policystartdate  = customerPolicy.policy_start_date,
                TotalPayment     = customerPolicy.total_payment,
                vehicleid        = vehicle2.id
            };

            CustomerpolicyDAORequest request2 = new CustomerpolicyDAORequest();

            request2.Add(cPolicy);
        }
Exemple #7
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        Vehicle_Info v_info = new Vehicle_Info();
        Vehicle_Sp   v_sp   = new Vehicle_Sp();
        Memb_Sp      m_sp   = new Memb_Sp();



        string uname_recieved = Session["username"].ToString();
        int    no_of_bus      = m_sp.return_nob(uname_recieved) - i;

        v_info.Bus_Reg_No = Txtbrno.Text;
        if (v_sp.CompareBusRegNo(v_info.Bus_Reg_No) == 0)
        {
            v_info.BusName  = Txtbname.Text;
            v_info.Model_No = Txtmno.Text;

            int own_id;
            own_id = (m_sp.GetMaxCode() - 1);

            v_info.Own_No = own_id;
            v_sp.Add_Vehicles(v_info);

            i++;

            if (no_of_bus <= 1)
            {
                i = 0;

                Response.Redirect("admin_regn.aspx");
            }
            else
            {
                Response.Redirect("admin_vehicle_info.aspx");
            }
            Txtbname.Text = "";
            Txtbrno.Text  = "";
            Txtmno.Text   = "";
        }
        else
        {
            lbexists.Text = "This Regno already exists, To see more about it!!//add link btn to vehicle view grid";
        }
    }
        public int Add(VehicleinfoViewModel newItem)
        {
            Vehicle_Info vehicle = new Vehicle_Info()
            {
                address           = newItem.address,
                owner_name        = newItem.ownername,
                version           = newItem.version,
                frame_number      = newItem.framenumber,
                engine_number     = newItem.eginenumber,
                vehicle_number    = newItem.vehiclenumber,
                brand_id          = newItem.brandid,
                model_id          = newItem.modelid,
                vehicle_condition = newItem.vehiclecondition,
                rate_by_condition = newItem.ratebycondition,
            };

            context.Vehicle_Info.Add(vehicle);
            context.SaveChanges();
            return(1);
        }