//Update:VehicleClassification
 private void UpdateVC()
 {
     if (Request.QueryString["Id"] != null)
     {
         int id = Convert.ToInt32(Request.QueryString["Id"].ToString());
         VehicleClassification _tran = repo.Get_VehicleClassification_List().Where(x => x.Id != id && x.ClassificationCode == txtcode.Text.Trim()).SingleOrDefault();
         if (_tran != null)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('Same Vehicle Classification code exist! Please try again');", true);
         }
         else
         {
             VehicleClassification _vc = db.VehicleClassifications.Where(x => x.Id == id && x.IsDeleted == false).SingleOrDefault();
             _vc.BodyType           = txtBodyType.Text.ToString();
             _vc.ClassificationCode = txtcode.Text.ToString();
             _vc.GrossWeight        = Convert.ToDecimal(txtGrossWt.Text);
             _vc.KerbWt             = Convert.ToDecimal(txtkerbWt.Text);
             _vc.Make            = txtMake.Text.ToString();
             _vc.ManufactureYear = Convert.ToInt32(txtYearManufacture.Text.ToString());
             _vc.Model           = txtModel.Text.ToString();
             _vc.NoOfAxies       = Convert.ToDecimal(txtNoOfAxles.Text.ToString());
             _vc.UOMWeight       = ddluom.SelectedValue.ToString();
             db.SubmitChanges();
             ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.success('Record Update Successfully')", true);
             HtmlMeta meta = new HtmlMeta();
             meta.HttpEquiv = "Refresh";
             meta.Content   = "1;url=Add.aspx?id=" + id;
             this.Page.Controls.Add(meta);
         }
     }
 }
 //Add:New VehicleClassification record
 private void AddVC()
 {
     if (Request.QueryString["Id"] == null)
     {
         VehicleClassification _tran = repo.Get_VehicleClassificationByCode(txtcode.Text.Trim());
         if (_tran != null)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('Same Vehicle Classification code exist! Please try again');", true);
         }
         else
         {
             VehicleClassification _vc = new VehicleClassification();
             _vc.BodyType           = txtBodyType.Text.ToString();
             _vc.ClassificationCode = txtcode.Text.ToString();
             _vc.GrossWeight        = Convert.ToDecimal(txtGrossWt.Text);
             _vc.KerbWt             = Convert.ToDecimal(txtkerbWt.Text);
             _vc.Make            = txtMake.Text.ToString();
             _vc.ManufactureYear = Convert.ToInt32(txtYearManufacture.Text.ToString());
             _vc.Model           = txtModel.Text.ToString();
             _vc.NoOfAxies       = Convert.ToDecimal(txtNoOfAxles.Text.ToString());
             _vc.UOMWeight       = ddluom.SelectedValue.ToString();
             _vc.IsDeleted       = false;
             if (repo.Add_vc(_vc))
             {
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.success('Saved Successfully')", true);
                 HtmlMeta meta = new HtmlMeta();
                 meta.HttpEquiv = "Refresh";
                 meta.Content   = "1;url=Add.aspx";
                 this.Page.Controls.Add(meta);
             }
         }
     }
 }
Пример #3
0
        public VehicleClassification GetTruckVehicleClassification(string TruckNo)
        {
            VehicleClassification VC = (from a in db.TruckMasters
                                        join b in db.VehicleClassifications on a.ClassificationCode equals b.Id.ToString()
                                        where a.TruckRegNo == TruckNo
                                        select b).SingleOrDefault();

            return(VC);
        }
Пример #4
0
 // Our constructor with all properties given
 public Vehicle(string VIN, double wholesaleCost, double retailPrice, int modelYear, string make, string model, string color, VehicleClassification vehicleClass)
 {
     this.VIN           = VIN;
     this.wholesaleCost = wholesaleCost;
     this.retailPrice   = retailPrice;
     this.modelYear     = modelYear;
     this.make          = make;
     this.model         = model;
     this.color         = color;
     this.vehicleClass  = vehicleClass;
 }
Пример #5
0
        //Add:New Vehicleclassification record
        public bool Add_vc(VehicleClassification vc)
        {
            bool status = false;

            if (vc != null)
            {
                db.VehicleClassifications.InsertOnSubmit(vc);
                db.SubmitChanges();
                status = true;
            }
            return(status);
        }
Пример #6
0
        //Delete:VehicleClassification by id
        public bool Delete_vc(int id)
        {
            bool status = false;
            VehicleClassification vc = db.VehicleClassifications.FirstOrDefault(x => x.Id == id && x.IsDeleted == false);

            if (vc != null)
            {
                vc.IsDeleted = true;
                db.SubmitChanges();
                status = true;
            }
            return(status);
        }
        //Get:Previous record
        protected void Previous_Record_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request.QueryString["Id"].ToString());
            VehicleClassification next = null;

            try
            {
                next = repo.Get_VehicleClassification_List().Where(x => x.Id < id && x.IsDeleted == false).OrderByDescending(i => i.Id).FirstOrDefault();
            }
            catch
            {
            }
            if (next != null)
            {
                Response.Redirect("Add.aspx?id=" + next.Id.ToString());
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.success('No more records founds.')", true);
            }
        }
 //Get:Vehicle classification record for update
 private void GetVCForUpdate()
 {
     if (!string.IsNullOrEmpty(Request.QueryString["Id"]))
     {
         divoptions.Style.Add("display", "block");
         txtcode.Enabled = false;
         int id = Convert.ToInt32(Request.QueryString["Id"].ToString());
         VehicleClassification _vc = repo.Get_vcById(id);
         if (_vc != null)
         {
             txtBodyType.Text        = _vc.BodyType.ToString();
             txtcode.Text            = _vc.ClassificationCode.ToString();
             txtGrossWt.Text         = _vc.GrossWeight.ToString();
             txtkerbWt.Text          = _vc.KerbWt.ToString();
             txtMake.Text            = _vc.Make.ToString();
             txtYearManufacture.Text = _vc.ManufactureYear.ToString();
             txtModel.Text           = _vc.Model.ToString();
             txtNoOfAxles.Text       = _vc.NoOfAxies.ToString();
             ddluom.SelectedValue    = _vc.UOMWeight.Trim().ToString();
         }
     }
 }
Пример #9
0
 // Simple Truck constructor inheriting all of the methods and properties of
 // Vehicle
 public Truck(string VIN, double wholesaleCost, double retailPrice, int modelYear, string make, string model, string color, VehicleClassification vehicleClass) : base(VIN, wholesaleCost, retailPrice, modelYear, make, model, color, vehicleClass)
 {
 }
Пример #10
0
 public HybridCar(string VIN, double wholesaleCost, double retailPrice, int modelYear, string make, string model, string color, int batteryLife, int MPG, string chargerType, VehicleClassification vehicleClass) : base(VIN, wholesaleCost, retailPrice, modelYear, make, model, color, vehicleClass)
 {
     this.batteryLife = batteryLife;
     this.MPG         = MPG;
     this.chargerType = chargerType;
 }
Пример #11
0
    // Constructor with both inherited properties and new properites
    public LightTruck(string VIN, double wholesaleCost, double retailPrice, int modelYear, string make, string model, string color, long towingCapacity, long truckWeight, bool is4wd, VehicleClassification vehicleClass) : base(VIN, wholesaleCost, retailPrice, modelYear, make, model, color, vehicleClass)
    {
        this.towingCapacity      = towingCapacity;
        this.truckWeight         = truckWeight;
        this.is4wd               = is4wd;
        this.grossCombinedWeight = this.towingCapacity + this.truckWeight;

        if (this.is4wd == true)
        {
            // Create new TransferCase object if LightTruck is 4WD
            // and store object in variable xferCase
            this.xferCase = new TransferCase(this);
        }
    }
        //:Save excel data to database
        internal string SaveDataToServer(DataSet ds)
        {
            string result = string.Empty;

            using (DataClasses1DataContext db = new DataClasses1DataContext())
            {
                string    connection = ConfigurationManager.ConnectionStrings["AveryDBConnectionString"].ConnectionString;
                DataTable dt         = ds.Tables[0];
                int       _failed    = 0;
                int       _success   = 0;
                int       _update    = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    try
                    {
                        string                _TruckRegNo              = dr["Truck Reg No"].ToString();
                        string                _ClassificationCode      = dr["Classification Code"].ToString();
                        string                _StoreTareWeight         = dr["Store Tare Weight"].ToString();
                        string                _TareValidityDate        = dr["Tare Validity Date"].ToString();
                        string                _AveraTareScheme         = dr["Average Tare Scheme"].ToString();
                        string                _CurrentAverageTareValue = dr["Current Average Tare Value"].ToString();
                        string                _UOMWeight   = dr["UOM Weight"].ToString();
                        TruckMaster           _TruckMaster = db.TruckMasters.Where(x => x.TruckRegNo == _TruckRegNo && x.IsDeleted == false).FirstOrDefault();
                        VehicleClassification _vc          = db.VehicleClassifications.FirstOrDefault(x => x.ClassificationCode == _ClassificationCode && x.IsDeleted == false);
                        if (_TruckMaster != null)
                        {
                            if (string.IsNullOrEmpty(_ClassificationCode))
                            {
                                _failed++;
                            }
                            else
                            {
                                _TruckMaster.ClassificationCode      = _ClassificationCode;
                                _TruckMaster.StoredTareWeight        = _StoreTareWeight;
                                _TruckMaster.TareValidityDate        = _TareValidityDate;
                                _TruckMaster.AverageTareScheme       = _AveraTareScheme;
                                _TruckMaster.CurrentAverageTareValue = _CurrentAverageTareValue;
                                _TruckMaster.UOMWeight = _UOMWeight;
                                db.SubmitChanges();
                                _update++;
                            }
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(_TruckRegNo) && !string.IsNullOrEmpty(_ClassificationCode))
                            {
                                if (_vc == null)
                                {
                                    _failed++;
                                }
                                else
                                {
                                    TruckMaster t = new TruckMaster();
                                    t.TruckRegNo              = _TruckRegNo;
                                    t.ClassificationCode      = _ClassificationCode;
                                    t.AverageTareScheme       = _AveraTareScheme;
                                    t.CurrentAverageTareValue = _CurrentAverageTareValue;
                                    t.StoredTareWeight        = _StoreTareWeight;
                                    t.TareValidityDate        = _TareValidityDate;
                                    t.UOMWeight = _UOMWeight;
                                    t.IsDeleted = false;
                                    db.TruckMasters.InsertOnSubmit(t);
                                    db.SubmitChanges();
                                    _success++;
                                }
                            }
                            else
                            {
                                _failed++;
                            }
                        }
                    }
                    catch { _failed++; }
                }
                result = "New Added: " + _success + "  Updated:  " + _update + "  Failed:  " + _failed + "";
            }
            return(result);
        }
Пример #13
0
        //Get:VehicleClassification By Classification code
        public VehicleClassification Get_VehicleClassificationByCode(string code)
        {
            VehicleClassification vc = db.VehicleClassifications.FirstOrDefault(x => x.ClassificationCode == code && x.IsDeleted == false);

            return(vc);
        }
Пример #14
0
        //Get:Vehicleclassification by id
        public VehicleClassification Get_vcById(int id)
        {
            VehicleClassification vc = db.VehicleClassifications.FirstOrDefault(x => x.Id == id && x.IsDeleted == false);

            return(vc);
        }
Пример #15
0
        //Save Excel data to server
        public string SaveDataToServer(DataSet ds)
        {
            string result = string.Empty;

            using (DataClasses1DataContext db = new DataClasses1DataContext())
            {
                string        connection = ConfigurationManager.ConnectionStrings["AveryDBConnectionString"].ConnectionString;
                DataTable     dt         = ds.Tables[0];
                int           _failed    = 0;
                int           _success   = 0;
                int           _update    = 0;
                StringBuilder sb         = new StringBuilder();
                foreach (DataRow dr in dt.Rows)
                {
                    try
                    {
                        string  _vehicleclassificationcode = dr["ClassificationCode"].ToString();
                        string  _make            = dr["Make"].ToString();
                        string  _model           = dr["Model"].ToString();
                        decimal _noofaxies       = Convert.ToDecimal(dr["NoOfAxies"]);
                        string  _bodytype        = dr["BodyType"].ToString();
                        decimal _kerbwt          = Convert.ToDecimal(dr["KerbWt"]);
                        int     _manufactureyear = Convert.ToInt32(dr["ManufactureYear"]);
                        decimal _grossweight     = Convert.ToDecimal(dr["GrossWeight"]);
                        string  _uomweight       = dr["UOMWeight"].ToString();
                        var     _vc = db.VehicleClassifications.Where(x => x.ClassificationCode == _vehicleclassificationcode && x.IsDeleted == false).FirstOrDefault();
                        if (_vc != null)
                        {
                            try
                            {
                                _vc.Make            = _make;
                                _vc.Model           = _model;
                                _vc.BodyType        = _bodytype;
                                _vc.NoOfAxies       = _noofaxies;
                                _vc.KerbWt          = _kerbwt;
                                _vc.ManufactureYear = _manufactureyear;
                                _vc.GrossWeight     = _grossweight;
                                _vc.UOMWeight       = _uomweight;
                                db.SubmitChanges();
                                _update++;
                            }
                            catch
                            {
                                _failed++;
                            }
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(_vehicleclassificationcode))
                            {
                                VehicleClassification _vlc = db.VehicleClassifications.Where(x => x.ClassificationCode == _vehicleclassificationcode && x.IsDeleted == false).FirstOrDefault();
                                if (_vlc != null)
                                {
                                    _failed++;
                                }
                                else
                                {
                                    try
                                    {
                                        VehicleClassification _v = new VehicleClassification();
                                        _v.ClassificationCode = _vehicleclassificationcode;
                                        _v.Make            = _make;
                                        _v.Model           = _model;
                                        _v.NoOfAxies       = _noofaxies;
                                        _v.BodyType        = _bodytype;
                                        _v.KerbWt          = _kerbwt;
                                        _v.ManufactureYear = _manufactureyear;
                                        _v.GrossWeight     = _grossweight;
                                        _v.UOMWeight       = _uomweight;
                                        _v.IsDeleted       = false;
                                        db.VehicleClassifications.InsertOnSubmit(_v);
                                        db.SubmitChanges();
                                        _success++;
                                    }
                                    catch
                                    {
                                        _failed++;
                                    }
                                }
                            }
                            else
                            {
                                _failed++;
                            }
                        }
                    }
                    catch
                    {
                        _failed++;
                    }
                }
                result = "New Added: " + _success + "  Updated:  " + _update + "  Failed:  " + _failed + "";
            }
            return(result);
        }