Esempio n. 1
0
 //Add:New VehicleClassification record
 private void AddVC()
 {
     if (Request.QueryString["Id"] == null)
     {
         AverageTareSchema _tran = repo.GetTareTolerance_ByCode(ddlToleranceType.Text.Trim());
         if (_tran != null)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('Same Vehicle Classification code exist! Please try again');", true);
         }
         else
         {
             AverageTareSchema _vc = new AverageTareSchema();
             _vc.Description = ddlToleranceType.Text.ToString();
             _vc.weightvalue = Convert.ToDecimal(txtvalue.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_TareTolerance(_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);
             }
         }
     }
 }
Esempio n. 2
0
        //Update:VehicleClassification
        private void UpdateVC()
        {
            if (Request.QueryString["Id"] != null)
            {
                int id = Convert.ToInt32(Request.QueryString["Id"].ToString());
                AverageTareSchema _tran = repo.Get_TareToleranceById(id);
                if (_tran != null)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('Same Vehicle Classification code exist! Please try again');", true);
                }
                else
                {
                    AverageTareSchema _vc = db.AverageTareSchemas.Where(x => x.Id == id).SingleOrDefault();
                    _vc.Description = ddlToleranceType.Text.ToString();
                    _vc.weightvalue = Convert.ToDecimal(txtvalue.Text.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);
                }
            }
        }
 protected void ddlTareToleranceType_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(ddlTareToleranceType.Text.Trim()))
     {
         AverageTareSchema _avgtarewt = db.AverageTareSchemas.Where(x => x.Description == ddlTareToleranceType.Text.Trim()).FirstOrDefault();
         this.txtWtValue.Text = _avgtarewt.weightvalue.ToString();
     }
 }
        public string ToleranceTypeValue(string ttype)
        {
            AverageTareSchema _toltype = db.AverageTareSchemas.Where(x => x.Description == ttype).FirstOrDefault();
            //.Where(x => x.PlantCode == Session["PlantID"].ToString() && x.MachineId == Session["WBID"].ToString()).FirstOrDefault();


            string myJsonString = (new JavaScriptSerializer()).Serialize(_toltype.weightvalue.ToString());

            return(myJsonString);
        }
        //Add:New Transporter Record
        public bool Add_TareTolerance(AverageTareSchema tran)
        {
            bool status = false;

            if (tran != null)
            {
                db.AverageTareSchemas.InsertOnSubmit(tran);
                db.SubmitChanges();
                status = true;
            }
            return(status);
        }
        //Delete:Tranporter by Id
        public bool Delete_TareToleranceById(int id)
        {
            bool status            = false;
            AverageTareSchema tran = db.AverageTareSchemas.FirstOrDefault(x => x.Id == id);

            if (tran != null)
            {
                db.AverageTareSchemas.DeleteOnSubmit(tran);
                //tran.IsDeleted = true;
                db.SubmitChanges();
                status = true;
            }
            return(status);
        }
Esempio n. 7
0
 //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());
         AverageTareSchema _vc = repo.Get_TareToleranceById(id);
         if (_vc != null)
         {
             ddlToleranceType.Text = _vc.Description.ToString();
             txtvalue.Text         = _vc.weightvalue.ToString();
         }
     }
 }
        //Save:Excel data to the 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;
                foreach (DataRow dr in dt.Rows)
                {
                    try
                    {
                        string _Description = dr["Description"].ToString();
                        string _weightvalue = dr["weightvalue"].ToString();

                        var _transporter = db.AverageTareSchemas.Where(x => x.Description == _Description).FirstOrDefault();
                        if (_transporter != null)
                        {
                            if (string.IsNullOrEmpty(_Description))
                            {
                                _failed++;
                            }
                            else
                            {
                                _transporter.Description = _Description;
                                _transporter.weightvalue = Convert.ToDecimal(_weightvalue);

                                db.SubmitChanges();
                                _update++;
                            }
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(_Description) && !string.IsNullOrEmpty(_weightvalue))
                            {
                                AverageTareSchema _trans = db.AverageTareSchemas.Where(x => x.Description == _Description).FirstOrDefault();
                                if (_trans != null)
                                {
                                    _failed++;
                                }
                                else
                                {
                                    db.AverageTareSchemas.InsertOnSubmit(new AverageTareSchema
                                    {
                                        Description = _Description,
                                        weightvalue = Convert.ToDecimal(_weightvalue)
                                    });
                                    db.SubmitChanges();
                                    _success++;
                                }
                            }
                            else
                            {
                                _failed++;
                            }
                        }
                    }
                    catch { _failed++; }
                }
                result = "New Added: " + _success + "  Updated:  " + _update + "  Failed:  " + _failed + "";
            }
            return(result);
        }
        //Get:Transporter by transporter code
        public AverageTareSchema GetTareTolerance_ByCode(string code)
        {
            AverageTareSchema trans = db.AverageTareSchemas.Where(x => x.Description == code).SingleOrDefault();

            return(trans);
        }
        //Get:Transporter By Id
        public AverageTareSchema Get_TareToleranceById(int id)
        {
            AverageTareSchema tran = db.AverageTareSchemas.FirstOrDefault(x => x.Id == id);

            return(tran);
        }