protected void Save_Click(object sender, EventArgs e)
        {
            TrafficDepartment TrafficDepartment = TrafficDepartmentModel();

            if (TrafficDepartment.Id == 0)
            {
                try
                {
                    db.TrafficDepartment.Add(TrafficDepartment);
                    db.SaveChanges();
                }
                catch (Exception except)
                {
                }
            }
            else
            {
                try
                {
                    db.TrafficDepartment.AddOrUpdate(TrafficDepartment);
                    db.SaveChanges();
                }
                catch (Exception except)
                {
                }
            }
            ClearSearchModel();
            Page.Response.Redirect(Page.Request.Url.ToString(), true);
        }
        protected void edit_Btn_Command(object sender, CommandEventArgs e)
        {
            int index = Convert.ToInt32(e.CommandArgument);
            List <TrafficDepartment> gvr = (List <TrafficDepartment>)GridView1.DataSource;
            TrafficDepartment        TrafficDepartmentEdit = gvr[index];

            TrafficDepartmentIdHid.Value = TrafficDepartmentEdit.Id.ToString();
            TrafficDepartment_Name.Text  = TrafficDepartmentEdit.Name;
        }
        protected TrafficDepartment TrafficDepartmentModel()
        {
            TrafficDepartment TrafficDepartment = new TrafficDepartment();

            if (TrafficDepartmentIdHid.Value != "0")
            {
                TrafficDepartment.Id = Convert.ToInt32(TrafficDepartmentIdHid.Value);
            }
            if (TrafficDepartment_Name.Text != "")
            {
                TrafficDepartment.Name = TrafficDepartment_Name.Text;
            }
            TrafficDepartment.LoginID = ExtendedMethod.LoginedUser.Id;
            return(TrafficDepartment);
        }