protected void btnSave_Click(object sender, EventArgs e)
        {
            if (ddlVehType.SelectedIndex <= 0)
            {
                Show("Please Select vehicle type");
                return;
            }

            //if(us2lat.Text == "" || us2lon.Text == "" )
            //{
            //    Show("Please Select Latitude or Longitude");
            //    return;
            //}

            vehallobj.OffRoadVehcileId = Convert.ToInt32(ddlVehicleNumber.SelectedItem.Value);
            vehallobj.OffRoadVehicleNo = ddlVehicleNumber.SelectedItem.Text;
            vehallobj.DistrictId       = Convert.ToInt32(ddlDistrict.SelectedItem.Value);
            vehallobj.District         = ddlDistrict.SelectedItem.Text;

            string manids = "";

            //if (ddlSegments.Visible)
            //{
            //    vehallobj.SegmentId = Convert.ToInt32(ddlSegments.SelectedItem.Value);
            //    vehallobj.Segment = ddlSegments.SelectedItem.Text;
            //    //vehallobj.NewSegFlag = "Old";
            //    //vehallobj.NewSegMandalIds = "";
            //    vehallobj.NewSegFlag = "New";
            //    for (int i = 1; i < ddlMandal.Items.Count; i++)
            //        manids = manids + ddlMandal.Items[i].Value.ToString() + ",";
            //    vehallobj.NewSegMandalIds = manids;
            //}
            //else
            //{
            //    //string manids = "";
            //    vehallobj.SegmentId = 0;
            //    // vehallobj.Segment = txtNewSegment.Text;
            //    vehallobj.NewSegFlag = "New";
            //    for (int i = 1; i < ddlMandal.Items.Count; i++)
            //        manids = manids + ddlMandal.Items[i].Value.ToString() + ",";
            //    vehallobj.NewSegMandalIds = manids;
            //}
            vehallobj.MandalId = Convert.ToInt32(ddlMandal.SelectedItem.Value);
            vehallobj.Mandal   = ddlMandal.SelectedItem.Text;
            vehallobj.CityId   = Convert.ToInt32(ddlCity.SelectedItem.Value);
            vehallobj.City     = ddlCity.SelectedItem.Text;
            if (ddlBaseLocation.Visible)
            {
                vehallobj.BaseLocationId = Convert.ToInt32(ddlBaseLocation.SelectedItem.Value);
                vehallobj.BaseLocation   = ddlBaseLocation.SelectedItem.Text;
                vehallobj.Flag           = "Old";
                vehallobj.Latitude       = "0.00";
                vehallobj.Longitude      = "0.00";


                // Bind Lat Longs
            }
            else
            {
                vehallobj.BaseLocationId = 0;
                vehallobj.BaseLocation   = txtBaseLocation.Text;
                vehallobj.Flag           = "New";
                vehallobj.Latitude       = txtLatitude.Text;
                vehallobj.Longitude      = txtLongitude.Text;
            }


            vehallobj.SegmentId  = 0;
            vehallobj.Segment    = "";
            vehallobj.NewSegFlag = "New";
            for (int i = 1; i < ddlMandal.Items.Count; i++)
            {
                manids = manids + ddlMandal.Items[i].Value.ToString() + ",";
            }
            vehallobj.NewSegMandalIds = manids;

            vehallobj.SegmentId = 0;
            // vehallobj.BaseLocationId = 0;
            //   vehallobj.BaseLocation = "";
            // vehallobj.Flag = "New";
            vehallobj.Latitude      = txtLatitude.Text;
            vehallobj.Longitude     = txtLongitude.Text;
            vehallobj.ContactNumber = txtContactNumber.Text;
            vehallobj.VehType       = ddlVehType.SelectedItem.Value.ToString();
            DataTable  dtGetVehData = new DataTable();
            ClsGeneral clsGen       = new ClsGeneral();


            dtGetVehData = clsGen.getVehicleData(ddlVehicleNumber.SelectedItem.Text.ToString());
            if (dtGetVehData.Rows.Count > 0)
            {
                Show("Vehicle Number Already Exists!!");
                ClearAll();
                return;
            }
            int insres = vehallobj.InsNewVehAllocation_new();

            if (insres != 0)
            {
                if (ddlBaseLocation.Visible)
                {
                    clsGen.InsertVehicle(ddlVehicleNumber.SelectedItem.Value, ddlVehicleNumber.SelectedItem.Text, "1", txtContactNumber.Text, txtLatitude.Text, txtLongitude.Text, ddlVehType.SelectedItem.Text.ToString(), ddlDistrict.SelectedItem.Value, ddlMandal.SelectedItem.Value, ddlBaseLocation.SelectedItem.Text);
                }
                else
                {
                    clsGen.InsertVehicle(ddlVehicleNumber.SelectedItem.Value, ddlVehicleNumber.SelectedItem.Text, "1", txtContactNumber.Text, txtLatitude.Text, txtLongitude.Text, ddlVehType.SelectedItem.Text.ToString(), ddlDistrict.SelectedItem.Value, ddlMandal.SelectedItem.Value, txtBaseLocation.Text);
                }
                Show("Record Inserted Successfully!!");
            }
            else
            {
                Show("Error!!");
            }

            ClearAll();

            //if (!ddlSegments.Visible)
            //{
            //    if (vehallobj.ChkExistingSegment().Tables[0].Rows.Count > 0)
            //    {
            //        Show("Segment Already Exist!!");
            //    }
            //    else
            //    {
            //        int insres = vehallobj.InsNewVehAllocation();
            //        if (insres != 0)
            //            Show("Record Inserted Successfully!!");
            //        else
            //            Show("Error!!");

            //        ClearAll();
            //    }
            //}
            //else
            //{
            //    int insres = vehallobj.InsNewVehAllocation();
            //    if (insres != 0)
            //        Show("Record Inserted Successfully!!");
            //    else
            //        Show("Error!!");

            //    ClearAll();
            //}
        }
Beispiel #2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (ddlVehType.SelectedIndex <= 0)
            {
                Show("Please Select vehicle type");
            }
            else
            {
                _vehallobj.OffRoadVehcileId = Convert.ToInt32(ddlVehicleNumber.SelectedItem.Value);
                _vehallobj.OffRoadVehicleNo = ddlVehicleNumber.SelectedItem.Text;
                _vehallobj.DistrictId       = Convert.ToInt32(ddlDistrict.SelectedItem.Value);
                _vehallobj.District         = ddlDistrict.SelectedItem.Text;
                var manids = "";
                _vehallobj.MandalId = Convert.ToInt32(ddlMandal.SelectedItem.Value);
                _vehallobj.Mandal   = ddlMandal.SelectedItem.Text;
                _vehallobj.CityId   = Convert.ToInt32(ddlCity.SelectedItem.Value);
                _vehallobj.City     = ddlCity.SelectedItem.Text;
                if (ddlBaseLocation.Visible)
                {
                    _vehallobj.BaseLocationId = Convert.ToInt32(ddlBaseLocation.SelectedItem.Value);
                    _vehallobj.BaseLocation   = ddlBaseLocation.SelectedItem.Text;
                    _vehallobj.Flag           = "Old";
                    _vehallobj.Latitude       = "0.00";
                    _vehallobj.Longitude      = "0.00";
                    // Bind Lat Longs
                }
                else
                {
                    _vehallobj.BaseLocationId = 0;
                    _vehallobj.BaseLocation   = txtBaseLocation.Text;
                    _vehallobj.Flag           = "New";
                    _vehallobj.Latitude       = txtLatitude.Text;
                    _vehallobj.Longitude      = txtLongitude.Text;
                }

                _vehallobj.SegmentId  = 0;
                _vehallobj.Segment    = "";
                _vehallobj.NewSegFlag = "New";
                for (var i = 1; i < ddlMandal.Items.Count; i++)
                {
                    manids = manids + ddlMandal.Items[i].Value + ",";
                }
                _vehallobj.NewSegMandalIds = manids;
                _vehallobj.SegmentId       = 0;
                _vehallobj.Latitude        = txtLatitude.Text;
                _vehallobj.Longitude       = txtLongitude.Text;
                _vehallobj.ContactNumber   = txtContactNumber.Text;
                _vehallobj.VehType         = ddlVehType.SelectedItem.Value;
                var clsGen       = new ClsGeneral();
                var dtGetVehData = clsGen.getVehicleData(ddlVehicleNumber.SelectedItem.Text);
                var insres       = _vehallobj.InsNewVehAllocation_new();
                switch (insres)
                {
                case 0:
                    Show("Error!!");
                    break;

                default:
                    clsGen.InsertVehicle(ddlVehicleNumber.SelectedItem.Value, ddlVehicleNumber.SelectedItem.Text, "1", txtContactNumber.Text, txtLatitude.Text, txtLongitude.Text, ddlVehType.SelectedItem.Text, ddlDistrict.SelectedItem.Value, ddlMandal.SelectedItem.Value, ddlBaseLocation.Visible ? ddlBaseLocation.SelectedItem.Text : txtBaseLocation.Text);
                    if (dtGetVehData.Rows.Count > 0)
                    {
                        UpdateData(ddlVehicleNumber, txtContactNumber.Text, txtLatitude.Text, txtLongitude.Text, ddlDistrict.SelectedItem.Value, ddlMandal.SelectedItem.Value, ddlBaseLocation.SelectedItem.Text);
                    }
                    Show("Record Inserted Successfully!!");
                    break;
                }

                ClearAll();
            }
        }
        catch (Exception ex)
        {
            _helper.ErrorsEntry(ex);
        }
    }