protected void btnSave_Click(object sender, EventArgs e)
{
double a, b, c, d;
a = Convert.ToDouble(lblpurchasequantity.Text.ToString());
b = Convert.ToDouble(lblreceivedqty.Text.ToString());
c = Convert.ToDouble(txtreceivedquantity.Text.ToString());
d = b + c;
if (a >= d)
{
int? insertgrnorecords;
IFormatProvider provider = new System.Globalization.CultureInfo("en-CA", true);
String datetime = txtgoodsreceiveddate.Text.ToString();
DateTime dt = DateTime.Parse(datetime, provider, System.Globalization.DateTimeStyles.NoCurrentDateDefault);
objsupplyPL.goodsreceiveddate = dt;
objsupplyPL.productid1 = Hidden1.Value.ToString();
objsupplyPL.purchaseid = Hid_Sno1.Value.ToString();
objsupplyPL.vehicleno = (txtvehicleno.Text.Trim().ToString() == "" ? null : txtvehicleno.Text.Trim());
objsupplyPL.grno = txtgrno.Text.Trim().ToString();
objsupplyPL.dcno = txtdcno.Text.Trim().ToString();
objsupplyPL.username = Session["username"].ToString();
objsupplyPL.quantity = Convert.ToDouble(lblpurchasequantity.Text.ToString());
objsupplyPL.receivedquantity = Convert.ToDouble(txtreceivedquantity.Text.ToString());
objsupplyPL.totalreceived = Convert.ToDouble(lblreceivedqty.Text.ToString());
objsupplyPL.branch = Hid_Sno.Value;
insertgrnorecords = objsupplyBAL.insertgrnotorecords(objsupplyPL);
buildBranches();
clear();
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "UpdateDetails", "alert('Save Successful');", true);
}
}
actuvally,this code for pop up window fields insertion,if i click save button,then it shows save succefully message..then it goes to general aspx page..In that GRNO button is having..then i click on GRNO two times,first time GRNO button is not fired,second time it will be fired
Related
When I pass the string value to the dropdown, it is not getting selected. I am not sure why?
I've tried passing the value eg:ddlInitialIncidentType.Items.FindByValue("1").Selected = true; directly which works fine.
protected void btnIncTypeSave_Click(object sender, EventArgs e) {
string value;
if (rbIncTypeY.Checked == true) {
//getting the value number from the Label
value = label.Text;
ddlInitialIncidentType.ClearSelection();
//here I want to select the dropdown with the value number
ddlInitialIncidentType.Items.FindByValue(value).Selected = true;
}
}
Note: I am assigning the value to the label in the below method
function prioritySelection(sender) {
var e = document.getElementById(sender.id);
e = e.value;
if (e == 2 || e == 4 || e == 1 || e == 3)
{
$('#<%=lblInitialIncidentTypeCurrent.ClientID%>').html(e); $find("ContentPlaceHolder1_ContentPlaceHolder2_ModalPopupIncidentTypeChange").show();
}
protected void btnIncTypeSave_Click(object sender,EventArgs e)
{ string value; if (rbIncTypeY.Checked==true) {
value=label.Text; // did you check here that value gets value or not?} }
In your javascript code you have used the ID of the Label control as lblInitialIncidentTypeCurrent where as in your server side code your are using some other Label control.
Replace this
value = label.Text;
with
value = lblInitialIncidentTypeCurrent.Text;
There was some problem by using the Label to store the value.
But by using HiddenField it is solved.
Thanks all for the answers provided.
below is the code for it,
//aspx.cs
<asp:HiddenField ID="hdtest" runat="server" />
protected void btnIncTypeSave_Click(object sender, EventArgs e)
{
string value;
if (rbIncTypeY.Checked ==true)
{
value = hdnIncType.Value;
ddlInitialIncidentType.ClearSelection();
ddlInitialIncidentType.Items.FindByValue(value).Selected = true;
ModalPopupIncidentTypeChange.Hide();
rbIncTypeY.Checked = false;
}
}
//aspx
function prioritySelection(sender) {
var e = document.getElementById(sender.id);
e = e.value;
if (e == 2 || e == 4 || e == 1 || e == 3) {
$('#<%=hdtest.ClientID%>').val(e);
$find("ContentPlaceHolder1_ContentPlaceHolder2_ModalPopupIncidentTypeChange").show();
}
}
I want to view another page using
Response.redirect
but considering a customerID along with it. here is my button code:
protected void btnPlaceOrder_Click(object sender, EventArgs e)
{
string productids = string.Empty;
DataTable dt;
if (Session["MyCart"] != null)
{
dt = (DataTable)Session["MyCart"];
decimal totalPrice, totalProducts;
bool totalPriceConversionResult = decimal.TryParse(txtTotalPrice.Text, out totalPrice), totalProductsConversionResult = decimal.TryParse(txtTotalProducts.Text, out totalProducts);
ShoppingCart k = new ShoppingCart()
{
CustomerName = txtCustomerName.Text,
CustomerEmailID = txtCustomerEmailID.Text,
CustomerAddress = txtCustomerAddress.Text,
CustomerPhoneNo = txtCustomerPhoneNo.Text,
TotalProducts = totalProductsConversionResult ? Convert.ToInt32(totalProducts) : 0,
TotalPrice = totalPriceConversionResult ? Convert.ToInt32(totalPrice) : 0,
ProductList = productids,
PaymentMethod = rblPaymentMethod.SelectedItem.Text
};
DataTable dtResult = k.SaveCustomerDetails();
for (int i = 0; i < dt.Rows.Count; i++) // loop on how many products are added by the user
{
ShoppingCart SaveProducts = new ShoppingCart()
{
CustomerID = Convert.ToInt32(dtResult.Rows[0][0]),
ProductID = Convert.ToInt32(dt.Rows[i]["ProductID"]),
TotalProducts = Convert.ToInt32(dt.Rows[i]["ProductQuantity"]),
};
SaveProducts.SaveCustomerProducts();
}
Response.Redirect("Admin/OrderDetails.aspx?Id={0}");
What it does is that it gets all the user input then in the end, i want to show to the user his/her order summary. As you can see, i am trying to use Response.Redirect.
The problem is i want to use the current customerID when i use the
Response.Redirect("Admin/OrderDetails.aspx?Id={0}");
any tricks on this?
You have CustomerID already. Substitute {0} before redirecting with that value
var customerId = Convert.ToInt32(dtResult.Rows[0][0]);
Response.Redirect(String.Format("Admin/OrderDetails.aspx?Id={0}", customerId.ToString()));
How to count the no of records in Gridview which have some particular data in a column
name result
======== ======
krishna pass
sanjay pass
ajay fail
out put needed in grid view - above Gridview already present,according to that grid i have to make another grid to count results
result no
====== =====
pass 2
fail 1
in data row bound , i calculated
protected void GVKeywordReport_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRow pr = ((DataRowView)e.Row.DataItem).Row;
int oldPos = Convert.ToInt32(pr["oldposition"]);
int newPos = Convert.ToInt32(pr["newposition"]);
GVKeywordReport.HeaderRow.Cells[3].Text = txtfrmdate.Text;
GVKeywordReport.HeaderRow.Cells[4].Text = txtEndDate.Text;
GVKeywordReport.HeaderRow.BackColor = ColorTranslator.FromHtml("#B3B300");
e.Row.Cells[0].BackColor = ColorTranslator.FromHtml("#B3B300");
e.Row.Cells[5].BackColor = ColorTranslator.FromHtml("#FFFFFF");
if (oldPos == newPos)
{
e.Row.BackColor = ColorTranslator.FromHtml("#FF950E");
e.Row.Cells[6].Text = "No Change";
nc= nc+1;
}
else if (oldPos > newPos)
{
e.Row.BackColor = ColorTranslator.FromHtml("#FFFFCC");
e.Row.Cells[6].Text = "Improved";
imprv= imprv+1;
}
else
{
e.Row.BackColor = ColorTranslator.FromHtml("#FF0000");
e.Row.Cells[6].Text = "Decreased";
decrs=decrs+1;
}
// e.Row.Cells[0].BackColor = ColorTranslator.FromHtml("#7DA647");
}
txt_TargetReached.Text = "0";
txtDecreased.Text =Convert.ToString(decrs);
I set my report‘s data source in the backstage of the page that display the report.The code is below:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string acceptedStatus = QuoteStatusEnum.Accepted.ToString();
string rejectedStatus = QuoteStatusEnum.Rejected.ToString();
string canceledStatus = QuoteStatusEnum.Canceled.ToString();
IList<QuoteRequest> list = ServiceFactory.QuoteRequestService.QueryItems(p => (p.QuoteRequestStatus.QuoteRequestStatusName == acceptedStatus) ||
(p.QuoteRequestStatus.QuoteRequestStatusName == rejectedStatus) ||
(p.QuoteRequestStatus.QuoteRequestStatusName == canceledStatus)).OrderBy(p => p.CreatedBy).ToList();
var data = from d in list
select new
{
ClientName = d.Client.CompanyName,
Client = d.Client.ClientID,
CompanyName = d.Client.CompanyName,
QuoteNumber = d.QuoteNumber,
PropertyAddress = d.Property.PropertyAddressLine1 + (string.IsNullOrEmpty(d.Property.PropertyAddressLine2) ? "" : " ," + d.Property.PropertyAddressLine2),
QuotePrice = d.QuotePrice.HasValue ? d.QuotePrice.Value : 0,
ClientContact = ServiceFactory.ContactService.Read(p => p.ContactID == d.ClientContactID).FirstName + " " + ServiceFactory.ContactService.Read(p => p.ContactID == d.ClientContactID).LastName,
IsConverted = d.QuoteRequestStatus.QuoteRequestStatusName == "Accepted" ? "Yes" : "No",
ModifiedDate = d.ModifiedDate ?? DateTime.Now.AddYears(-10)
};
int pastDueCount = list.Count(p => p.ClientDueDate < DateTime.Today);
var instanceReporSouce = new InstanceReportSource();
instanceReporSouce.ReportDocument = new CompletedQuotesReport();
instanceReporSouce.ReportDocument.Reports.First().DataSource = data;
ReportViewer1.ReportSource = instanceReporSouce;
}
}
Now, I want to add some filter to the report.just like the effect that add filter in the design view by using "Fields.XX=parameter.value" expression,For there is no data source in the report now,so it can't be use 'Fields.XX......' expressions.How can i achieve my goal by programs in the backstage. BTW,I try to add parameter by code:
instanceReporSouce.ReportDocument.Reports.First().ReportParameters.Add(new ReportParameter("TotalAccepted", ReportParameterType.String, "TotalAccepted:" + list.Count(p => p.QuoteRequestStatus.QuoteRequestStatusName == acceptedStatus)));
I can get the parameters. but still can't filter data. How can i solve this problem?
Any suggestion is appreciated,
Best regards,
Tang.
private void RegisterByDept_NeedDataSource(object sender, EventArgs e)
{
string groupBy = string.Empty;
string sortBy = string.Empty;
Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;
var payoutUID = report.Parameters["payoutUID"].Value.ToString();
// some code here...
}
I have created a function which displays a bus seat layout, dynamically. Now after adding all this dynamically created table and cells into a tag, I want to know which imagebutton was clicked.I have also mentioned proper ID to each imagebutton in cell.
public void DisplaySeatLayout(ListBus _listBus) {
//fetching data from database
SeatBUS _seatBUS = new SeatBUS();
DataTable dt = _seatBUS.GetAllSeatByBusRouter(_listBus);
//Layout generation code
ImageButton img ;
HtmlTable table = new HtmlTable();
table.Attributes.Add("runat", "server");
table.Attributes.Add("id", "LayoutTable");
HtmlTableRow [] tr = new HtmlTableRow[] { new HtmlTableRow(), new HtmlTableRow(), new HtmlTableRow(),new HtmlTableRow(),new HtmlTableRow()};
HtmlTableCell tc = null;
int SeatNo=0;
//Getting Total no of seats.
int MaxSeatNo = dt.Rows.Count;
//Iterating datatable
//Displaying labels for displaying column names in the table
for (int columnCounter = 0; columnCounter < 8; columnCounter++){
for (int rowCounter = 0; rowCounter < 5; rowCounter++){
if (SeatNo < MaxSeatNo){
if (rowCounter == 2 && columnCounter < 7){
tc = new HtmlTableCell();
Label lbl = new Label();
lbl.Text = "";
lbl.ID = "lbl " + rowCounter.ToString() + columnCounter.ToString();
tc.Controls.Add(lbl);
tr[rowCounter].Controls.Add(tc);
//reducing seat number for sake of sequence.
}
else{
//adding label in each cell.
tc = new HtmlTableCell();
Label lbl = new Label();
lbl.Text = dt.Rows[SeatNo]["NumberSeat"].ToString();
lbl.ID = "lbl " + rowCounter.ToString() + columnCounter.ToString();
tc.Controls.Add(lbl);
//adding imagebutton in each cell .
img = new ImageButton();
img.Attributes.Add("type", "image");
img.Attributes.Add("id", rowCounter.ToString());
img.CssClass = "seatRightMostRow1";
img.ImageUrl = "../Images/available_seat_img.png";
img.ID = dt.Rows[SeatNo]["NumberSeat"].ToString();
img.Click += new ImageClickEventHandler(Imagebutton_Click);
tc.Controls.Add(img);
tr[rowCounter].Controls.Add(tc);
SeatNo++;
}
}//SeatNo < MaxSeatNo
table.Controls.Add(tr[rowCounter]);
}
seatArranngement.Controls.Add(table);
}
}
this is complete code after suggestion.
function that is displaying dynamic table is inside Page_load
protected void Page_Load(object sender, EventArgs e)
{
_listBusBUS = new ListBusBUS();
_routerBUS = new RouterBUS();
_listBus = new ListBus();
_promoteBUS = new PromoteBUS();
if (!Page.IsPostBack)
{
LoadData();
}
DisplaySeatLayout();
}
Also here i have copied code in prerender
protected override void OnPreRender(EventArgs e)
{
if (MultiView1.ActiveViewIndex == 1)
{
int listBusID = int.Parse(hdlListBusID.Value.ToString());
_listBus = _listBusBUS.GetAllListBusById(listBusID);
litListBusID.Text = _listBus.ListBusID.ToString();
litRouterID.Text = _listBus.RouterID.ToString();
litArrival.Text = _listBus.Arrival.ToString();
litDeparture.Text = _listBus.Departure.ToString();
litPrice.Text = _listBus.Price.ToString();
}
else if (MultiView1.ActiveViewIndex == 2)
{
//original code starts from here
litListBusIDS.Text = litListBusIDS.Text;
litRouterIDS.Text = litRouterID.Text;
litArrivalS.Text = litArrival.Text;
litDepartureS.Text = litDeparture.Text;
litSeat.Text = hdlSeat.Value;// chkSeat.SelectedItem.Text;
litPrices.Text = litPrice.Text;
//hdlSeat.Value = chkSeat.SelectedItem.Text.ToString();
}
else if (MultiView1.ActiveViewIndex == 3)
{
litCustomerNameStep4.Text = txtcustomername.Text;
litSeatStep4.Text = litSeat.Text;
litPriceStep4.Text = litPrices.Text;
}
base.PreRender(e);
}
Also, layout is getting created twice if i click on any imagebutton.
All you have to do is get the value that you already placed inside the "id" attribute.
You can do this inside the Imagebutton_Click even you created:
protected void Imagebutton_Click(object sender, EventArgs e)
{
ImageButton b = sender as ImageButton;
string id = b.Attributes["id"]; // Returns the id
}