protected void gridCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Allotte") { long id; string aan = string.Empty; string quarterNumber = string.Empty; Int64.TryParse(e.CommandArgument.ToString(), out id); //AllotementApplications.UpdateApplicationStaus(id, ApplicationStatus.Allotted); tblAllottee _Allottee = null; //if (id > 0) //{ // _Allottee = Allottee.GetAllottee(id); //} //else //{ var gridRow = ((LinkButton)e.CommandSource).NamingContainer as GridViewRow; var hidAAN = gridRow.FindControl("hidAAN") as HiddenField; aan = hidAAN.Value; tblAllottee a = Allottee.GetAllotteeByAAN(aan); if (a != null) { //lblMessage.Text = "User has already allotted quarter!"; //lblMessage.Visible = true; //return; _Allottee = a; } else { _Allottee = new tblAllottee(); } Label lblQuarterNumber = gridRow.FindControl("lblQuarterNumber") as Label; quarterNumber = lblQuarterNumber.Text; tblQuarter quarter = Quarters.GetQuarter(quarterNumber); if (quarter == null) { lblMessage.Text = "Quarter number selected is not valid"; lblMessage.Visible = true; return; } else if (quarter.Status.HasValue && quarter.Status != (int)QuarterStatus.Vacant) { lblMessage.Text = "Quarter is not vacant!"; lblMessage.Visible = true; return; } quarter.DateOfAllottement = DateTime.Now; quarter.Status = (int)QuarterStatus.Alloted; Quarters.Save(quarter); //_Allottee = new tblAllottee(); //} _Allottee.QuarterNumber = quarterNumber; _Allottee.AAN = aan; _Allottee.ApplicationId = id; _Allottee.Status = (int)AllotementStatus.Allotted; _Allottee.DateOfAllotement = DateTime.Now; //_Allottee.OfficeId = Convert.ToInt32(drpOffice.SelectedValue); //_Allottee.Designation =Convert.ToInt32( drpDesignation.SelectedValue); //_Allottee.DateOfJoining = Convert.ToDateTime(txtDoj.Text); //_Allottee.DateOfRetirement = Convert.ToDateTime(txtDor.Text); //_Allottee.Name = txtAllotteeName.Text; tbluserhistory _userhistory = new tbluserhistory(); _userhistory.Action = "Allotement"; _userhistory.description = _user.Username + " has allotted quarter " + _Allottee.QuarterNumber + " to user " + _Allottee.AAN; _userhistory.time = DateTime.Now; _userhistory.useraan = _user.AAN; userHistory.Save(_userhistory); Allottee.Save(_Allottee); if (id > 0) { AllotementApplications.UpdateApplicationStaus(id, ApplicationStatus.Allotted); try { //SEND SMS new IntegratedMessageSender().SendMessage("QUARTER_ALLOTTED", _Allottee.QuarterNumber, AllotementApplications.GetApplicationByAAN(aan).ContactNumber); } catch (Exception) { throw; } } BindData(); ///Response.Redirect("~/admin/Allottee.aspx?Applicationid="+id+"&returnurl=admin/Prioritizeapplications.aspx"); } else if (e.CommandName == "Withdraw") { long id; Int64.TryParse(e.CommandArgument.ToString(), out id); AllotementApplications.UpdateApplicationStaus(id, ApplicationStatus.withdraw); BindData(); // AllotementApplications.UpdateApplicationStaus(id, ApplicationStatus.Pos); } else if (e.CommandName == "Allotte") { long id; Int64.TryParse(e.CommandArgument.ToString(), out id); //AllotementApplications.UpdateApplicationStaus(id, ApplicationStatus.withdraw); Response.Redirect("~/admin/Allottee.aspx?Applicationid=" + id + "&returnurl=admin/Prioritizeapplications.aspx"); } else if (e.CommandName == "AllotteManual") { //Manual allocation long id; Int64.TryParse(e.CommandArgument.ToString(), out id); //AllotementApplications.UpdateApplicationStaus(id, ApplicationStatus.withdraw); Response.Redirect("~/admin/Allottee.aspx?Applicationid=" + id + "&returnurl=admin/Prioritizeapplications.aspx?selectedCategory=" + drpQuarterCatergory.SelectedValue); } //DataNavigateUrlFormatString="~/admin/Allottee.aspx?Applicationid={0}&returnurl=admin/Prioritizeapplications.aspx" }
protected void btnadd_Click(object sender, EventArgs e) { tblAllottee _Allottee = null; if (id > 0) { _Allottee = Allottee.GetAllottee(id); } else { tblAllottee a = Allottee.GetAllotteeByAAN(txtAllotteeName.Text); if (a != null) { _Allottee = a; //lblmessage.Text = "User has already allotted quarter!"; //lblmessage.Visible = true; //return; } if (a == null) { _Allottee = new tblAllottee(); } tblQuarter quarter = Quarters.GetQuarter(drpQuarter.SelectedValue); if (quarter == null) { lblmessage.Text = "Please enter valid number"; lblmessage.Visible = true; return; } else if (quarter.Status.HasValue && quarter.Status != (int)QuarterStatus.Vacant) { lblmessage.Text = "Quarter is not vacant!"; lblmessage.Visible = true; return; } quarter.DateOfAllottement = DateTime.Now; quarter.Status = (int)QuarterStatus.Alloted; Quarters.Save(quarter); //_Allottee = new tblAllottee(); } _Allottee.QuarterNumber = drpQuarter.SelectedValue; _Allottee.AAN = txtAllotteeName.Text; _Allottee.ApplicationId = applicationid; _Allottee.Status = btnAddUpdate.Text == "Add Change Request" ? (int)AllotementStatus.ChangeRequested : (int)AllotementStatus.Possessed; _Allottee.DateOfAllotement = DateTime.Now; //_Allottee.OfficeId = Convert.ToInt32(drpOffice.SelectedValue); //_Allottee.Designation =Convert.ToInt32( drpDesignation.SelectedValue); //_Allottee.DateOfJoining = Convert.ToDateTime(txtDoj.Text); //_Allottee.DateOfRetirement = Convert.ToDateTime(txtDor.Text); //_Allottee.Name = txtAllotteeName.Text; tbluserhistory _userhistory = new tbluserhistory(); _userhistory.Action = "Allotement"; _userhistory.description = _user.Username + " has allotted quarter " + _Allottee.QuarterNumber + " to user " + _Allottee.AAN; _userhistory.time = DateTime.Now; _userhistory.useraan = _user.AAN; userHistory.Save(_userhistory); Allottee.Save(_Allottee); if (applicationid > 0) { AllotementApplications.UpdateApplicationStaus(applicationid, btnAddUpdate.Text == "Add Change Request" ? ApplicationStatus.ChangeRequested : ApplicationStatus.Allotted); } if (!string.IsNullOrEmpty(Request["returnurl"])) { Response.Redirect("~/" + Request["returnurl"]); } else { Response.Redirect("~/admin/Allottees.aspx"); } }