private void setdepartments()
 {
     DBFunctions db = new DBFunctions();
     Department_tbl dept = new Department_tbl { Department = "Select Department" };
     var department=db.getalldepartments();
     department.Add(dept);
     department = department.OrderBy(x => x.ID).ToList();
     DropDownDept.DataSource =department ;
     ListItem item = new ListItem();
     
     DropDownDept.DataTextField = "Department";
     DropDownDept.DataValueField = "ID";
     DropDownDept.DataBind();
 }
Exemplo n.º 2
0
    private void setdepartments()
    {
        DBFunctions    db   = new DBFunctions();
        Department_tbl dept = new Department_tbl {
            Department = "Select Department"
        };
        var department = db.getalldepartments();

        department.Add(dept);
        department = department.OrderBy(x => x.ID).ToList();
        DropDownDept.DataSource = department;
        ListItem item = new ListItem();

        DropDownDept.DataTextField  = "Department";
        DropDownDept.DataValueField = "ID";
        DropDownDept.DataBind();
    }
        protected void btn_submit_Click(object sender, EventArgs e)
        {
            string IP = GetVisitorIpAddress();
            Department_tbl tblDept = new Department_tbl();
            Tuple<Department_tbl, UniversityEntities> tuple = new Tuple<Department_tbl, UniversityEntities>(null, null);

            if (btn_submit.Text == "Submit")
            {

                try
                {
                    tblDept.CenterID = 1;
                    tblDept.DeptRoomID = Convert.ToInt32(txtbx_roomid.Text);
                    tblDept.DeptName = txtbx_deptname.Text;
                    tblDept.DeptDesc = txtbx_desc.Text;

                    tblDept.IsBitDeleted = false;
                    tblDept.CreatedBy = "Admin";
                    tblDept.CreatedDate = Convert.ToDateTime(System.DateTime.Now);
                    tblDept.CreatedIP = IP;
                    int deptid = ManageDepartmentBAL.SaveDepartment(tblDept);
                    lblmsg.Text = "Department added sucessfully!!!";
                    lblmsg.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff6230");
                    Clear();

                }
                catch
                {
                    //Exception
                }
                finally
                {
                    BindGrid(gvdept.PageSize, gvdept.PageIndex);
                }
            }
            else if (btn_submit.Text == "Update")
            {
                try
                {
                    tblDept.DeptID = Convert.ToInt32(lbldeptid.Text);
                    tblDept.DeptRoomID = Convert.ToInt32(txtbx_roomid.Text);
                    tblDept.DeptName = txtbx_deptname.Text;
                    tblDept.DeptDesc = txtbx_desc.Text;
                    tblDept.CreatedBy = lblcreator.Text;
                    tblDept.CreatedDate = Convert.ToDateTime(lblcreatedate.Text);
                    tblDept.CreatedIP = lblCreateIP.Text;
                    tblDept.ModifiedBy = "Admin";
                    tblDept.ModifiedDate = Convert.ToDateTime(System.DateTime.Now);
                    tblDept.ModifiedIP = IP;

                    int deptId = ManageDepartmentBAL.UpdateDept(tblDept);
                    lblmsg.Text = "Record Updated Sucessfully";
                    lblmsg.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff6230");
                    Clear();
                    btn_submit.Text = "Submit";
                }
                catch
                {
                    //Exception
                }
                finally
                {
                    BindGrid(gvdept.PageSize, gvdept.PageIndex);
                }
            }
        }