привет, пожалуйста, подтвердите мой код Правильный способ передать необязательный параметр методу. Если что-то не так, пожалуйста, предложите мне, если есть какое-нибудь лучшее решение.asp.net code quality проверить это
protected void Ok_Click(object sender, EventArgs e)
{
try
{
if (Page.IsValid)
{
int course_id = Convert.ToInt32(course.SelectedValue);
int passoutYear = Convert.ToInt32(passout.SelectedValue);
int currentBacklog = Convert.ToInt32(currrentBacklogDDL.SelectedValue);
int sex = Convert.ToInt32(gender.SelectedValue);
int? eGap = null;
int? firstYrPercent = null;
int? secondYrPercent = null;
int? thirdYrPercent = null;
int? finalYearpercent = null;
int? currentDegeePercentage = null;
int? highSchoolPercentge = null;
int? higherSchoolPercentage = null;
int? grauationPercentage = null;
int? diplomaPercentage = null;
int? noOfAtkt = null;
string dateOfBirth = DOB.Text.Trim();
DateTime birthDate = DateTime.ParseExact(dateOfBirth, "dd/mm/yyyy", System.Globalization.CultureInfo.InvariantCulture);
string outPut = birthDate.ToString("mm/dd/YYYY");
DateTime date = Convert.ToDateTime(outPut);
if (!String.IsNullOrEmpty(educationGap.Text))
{
eGap = Convert.ToInt32(educationGap.Text.Trim());
}
if (!string.IsNullOrEmpty(firstYear.Text))
{
firstYrPercent = Convert.ToInt32(firstYear.Text.Trim());
}
if (!string.IsNullOrEmpty(secondYear.Text))
{
secondYrPercent = Convert.ToInt32(secondYear.Text.Trim());
}
if (!string.IsNullOrEmpty(thirdYear.Text))
{
thirdYrPercent = Convert.ToInt32(thirdYear.Text.Trim());
}
if (!string.IsNullOrEmpty(finalyear.Text))
{
finalYearpercent = Convert.ToInt32(finalyear.Text.Trim());
}
if (!string.IsNullOrEmpty(currentDegree.Text))
{
currentDegeePercentage = Convert.ToInt32(currentDegree);
}
if (!string.IsNullOrEmpty(higherSchool.Text.Trim()))
{
higherSchoolPercentage = Convert.ToInt32(higherSchool.Text.Trim());
}
if (!string.IsNullOrEmpty(highSchool.Text))
{
highSchoolPercentge = Convert.ToInt32(highSchool.Text.Trim());
}
if (!string.IsNullOrEmpty(graduation.Text))
{
grauationPercentage = Convert.ToInt32(graduation.Text.Trim());
}
if (!string.IsNullOrEmpty(diploma.Text))
{
diplomaPercentage = Convert.ToInt32(diploma.Text.Trim());
}
if (!string.IsNullOrEmpty(atkt.Text))
{
noOfAtkt = Convert.ToInt32(atkt.Text.Trim());
}
Dictionary<string, object> paramList = new Dictionary<string, object>();
paramList.Add("@courseId", course_id);
paramList.Add("@passoutYear", passoutYear);
paramList.Add("@currentBacklog", currentBacklog);
paramList.Add("@sex", sex);
paramList.Add("@eGap", eGap);
paramList.Add("@firstYrPercent", firstYrPercent);
paramList.Add("@secondYrPercent", secondYrPercent);
paramList.Add("@thirdYrPercent", thirdYrPercent);
paramList.Add("@finalYearpercent", finalYearpercent);
paramList.Add("@currentDegeePercentage", currentDegeePercentage);
paramList.Add("@highSchoolPercentge", highSchoolPercentge);
paramList.Add("@higherSchoolPercentage", higherSchoolPercentage);
paramList.Add("@grauationPercentage", grauationPercentage);
paramList.Add("@diplomaPercentage", diplomaPercentage);
paramList.Add("@noOfAtkt", noOfAtkt);
StringBuilder branchId= new StringBuilder();
foreach (ListItem li in branch.Items)
{
if (li.Selected)
{
branchId.Append(Convert.ToInt32(li.Value));
}
}
DataTable dt = searchManager.GetEligibleStudent(paramList, branchId);
}
}
catch (Exception ex)
{
COMMON.logger.Error("Error On Button click Ok", ex);
}
}
Я appologise сэр, но я не получаю вас, Я передаю это параметрам метода, чтобы вызвать mehod класса бизнес-логики, где я получу данные, написав соответствующий запрос, чтобы получить таблицу данных как здесь – NoviceToDotNet
общественного DataTable GetEligibleStudent (Dictionary <строка, объект> paramList, StringBuilder branchId) { попробовать { строка CMD = ""; // string cmd = "SELECT * FROM [tbl_branch] WHERE course_id IN (" + sb + ")"; if (dbManager.OpenConnection()) { dt = dbManager.GetDataTable (cmd, paramList); return dt; } else { dt = null; return dt; } } } – NoviceToDotNet
Как я могу отредактировать приведенный выше код, он ограничивает меня помещением символов, и я не знаю, как отредактировать его, пожалуйста, дайте мне знать – NoviceToDotNet