private void txtDeptID_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (Char)13) { if (this.txtDeptID.Text == "") { string tempStr = deptMgr.GetMaxDeptID(); if (tempStr != null && tempStr != "") { this.txtDeptID.Text = tempStr.PadLeft(4, '0'); } else { return; } } this.txtDeptName.Focus(); } }