private void bindOrderData() { Cart c = Cart.Current; Requestor r = Requestor.Current; bool isSMTA = false; bool isRestriction = false; string SMTAIds = ""; using (SecureData sd = new SecureData(false, UserManager.GetLoginToken())) { var ds = sd.GetData("web_cartview", ":idlist=" + Toolkit.Join(c.AccessionIDs.ToArray(), ",", ""), 0, 0); var dt = ds.Tables["web_cartview"]; for (int i = 0; i < dt.Rows.Count; i++) { CartItem ci = c.FindByAccessionID(dt.Rows[i], "accession_id"); if (ci != null) { //dt.Rows[i]["quantity"] = ci.Quantity; //Laura Temp } if (dt.Rows[i]["type_code"].ToString() == "MTA-SMTA") { isSMTA = true; SMTAIds += ", <a href='accessiondetail.aspx?id=" + ci.ItemID + "'>" + dt.Rows[i]["pi_number"].ToString() + "</a>"; } if (dt.Rows[i]["type_code"].ToString().StartsWith("MTA-")) { isRestriction = true; } } gvCart.DataSource = dt; gvCart.DataBind(); int cnt = gvCart.Rows.Count; lblCnt.Text = " (" + cnt.ToString() + (cnt == 1 ? " item)" : " items)"); } pnlSMTA.Visible = isSMTA; if (isSMTA) { SMTAIds = SMTAIds.Substring(2); lblSMTAIds.Text = "(The items above flagged as SMTA are " + SMTAIds + ")"; } gvCart.Columns[7].Visible = isRestriction; lblShippingName.Text = r.Firstname + " " + r.Lastname; lblShipping1.Text = r.Addr1_s; lblShipping2.Text = r.Addr2_s; if (lblShipping2.Text.Trim() == "") { lblShipping2.Visible = false; } else { lblShipping2.Text = lblShipping2.Text + "<br />"; } lblShipping3.Text = r.Addr3_s; if (lblShipping3.Text.Trim() == "") { lblShipping3.Visible = false; } else { lblShipping3.Text = lblShipping3.Text + "<br />"; } lblShipping4.Text = r.City_s + ", " + r.State_s + " " + r.PostalIndex_s + ", " + r.Country_s; lblShippingPhone.Text = r.Phone; lblShippingAltPhone.Text = r.AltPhone; if (lblShippingAltPhone.Text.Trim() == "") { tr_altPhone.Visible = false; } lblShippingFax.Text = r.Fax; if (lblShippingFax.Text.Trim() == "") { tr_fax.Visible = false; } if (r.CarrierAcct.Trim() != "") { lblCarrier.Visible = true; lblCarrier.Text = "<br /><b>" + "Your account for expediating this order is: Carrier - " + r.Carrier + " with account number - " + r.CarrierAcct + "</b>.<br />"; } else { lblCarrier.Visible = false; } lblConfirmEmail.Text = "Confirmation of order will be sent to: " + r.Email; if (UserManager.IsAnonymousUser(UserManager.GetUserName())) { lblConfirmEmail.Visible = r.EmailOrder; } else { lblConfirmEmail.Visible = Toolkit.ToBoolean(UserManager.GetUserPref("EmailOrder"), false); } for (int i = 0; i < c.AccessionIDs.Count; i++) { _itemNotes.Add(c.AccessionIDs[i].ToString(), ""); } ViewState["item_notes"] = _itemNotes; if (!hasFootNote) { lblFootNote.Visible = false; } if (hasComments) { pnlPlaceOrder.FindControl("ShowHideButton").Visible = true; } else { pnlPlaceOrder.FindControl("ShowHideButton").Visible = false; } }
protected void gvCart_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.DataItemIndex > -1) { var accessionID = Toolkit.ToInt32(((DataRowView)e.Row.DataItem)["accession_id"], -1); var lbl = e.Row.FindControl("lblFormDistributed") as Label; var c = Cart.Current; string distributionForm = c.FindByAccessionID(accessionID).DistributionFormCode; lbl.Text = CartItem.GetMaterialDescription(distributionForm); var lblSign1 = e.Row.FindControl("lblNoteSign1") as Label; var lblSign2 = e.Row.FindControl("lblNoteSign2") as Label; var lblAvailCmt = e.Row.FindControl("lblAvailCmt") as Label; var ibtnPlus = e.Row.FindControl("btnPlus") as ImageButton; var ibtnMinus = e.Row.FindControl("btnMinus") as ImageButton; var lblFormD2 = e.Row.FindControl("lblFormD2") as Label; var ibtnPlusF = e.Row.FindControl("btnPlusF") as ImageButton; var ibtnMinusF = e.Row.FindControl("btnMinusF") as ImageButton; // display footnote //if (distributionForm == "CT") //{ // hasFootNote = true; // string note = " You will receive <i>Unrooted cuttings</i> not <i>Rooted plants</i> unless specific arrangements have been made with the curator."; // lblSign1.Visible = true; // //lblSign1.ToolTip = note.Replace("<i>", "").Replace("</i>", ""); // lblFootNote.Visible = true; // if (!isCu) // { // lblFootNote.Text += " <font color='red'><b><small>! </b></small></font>" + note + "<br />"; // isCu = true; // } //} string noteCutting = "You will receive <i>Unrooted cuttings</i> not <i>Rooted plants</i> unless specific arrangements have been made with the curator."; if (distributionForm == "CT") { hasComments = true; lblFormD2.Visible = true; e.Row.Cells[5].Width = 165; lblFormD2.Text = "<br />" + noteCutting; ibtnMinusF.Visible = true; } //string statusCode = "", statusNote = ""; //using (var sd = UserManager.GetSecureData(false)) //{ // var dtAvail = sd.GetData("web_lookup_availability", ":accessionid=" + accessionID, 0, 0).Tables["web_lookup_availability"]; // foreach (DataRow dr in dtAvail.Rows) // { // statusCode = dr["availability_status_code"].ToString(); // statusNote = dr["availability_status_note"].ToString(); // if (statusCode == "WEED") // { // hasFootNote = true; // var siteName = ((DataRowView)e.Row.DataItem)["site_code"].ToString(); // var siteID = ((DataRowView)e.Row.DataItem)["site_id"].ToString(); // string note = " <font color='red'><b>This accession is a restricted noxious weed</b></font>, contact <a href='site.aspx?id=" + siteID + "'>" + siteName + "</a> for availability."; // lblSign2.Visible = true; // lblFootNote.Visible = true; // if (!isWeed) // { // lblFootNote.Text += " <font color='red'><b><small>+ </b></small></font>" + note + "<br />"; // isWeed = true; // } // break; // } // } //} using (var sd = UserManager.GetSecureData(true)) { var dtAvilCmt = sd.GetData("web_accessiondetail_action_note", ":actionName=" + "''AVAIL_CMT', 'SMTA''" + ";:accessionid=" + accessionID, 0, 0).Tables["web_accessiondetail_action_note"]; if (dtAvilCmt.Rows.Count > 0) { hasComments = true; lblAvailCmt.Visible = true; e.Row.Cells[1].Width = 200; lblAvailCmt.Text = "<br />" + dtAvilCmt.Rows[0]["note"].ToString(); ibtnMinus.Visible = true; } } if (e.Row.Cells[7].Text == "MTA-SMTA") { e.Row.Cells[7].BackColor = System.Drawing.Color.Yellow; } } }
private void bindData() { Cart c = Cart.Current; using (SecureData sd = new SecureData(false, UserManager.GetLoginToken(true))) { var ds = sd.GetData("web_cartview", ":idlist=" + Toolkit.Join(c.AccessionIDs.ToArray(), ",", ""), 0, 0); var dt = ds.Tables["web_cartview"]; // using (DataManager dm = sd.BeginProcessing(true)) { // DataTable dt = dm.Read( //DataManager.ExpandIntegerList( //@" //select // 0 as quantity, // a.accession_id, // concat(coalesce(a.accession_number_part1,''), ' ', coalesce(convert(varchar, a.accession_number),''), ' ', coalesce(a.accession_number_part3,'')) as pi_number, // a.site_code, // (select cvl.description from code_value cv left join code_value_lang cvl on cv.code_value_id = cvl.code_value_id where cv.code_group_code = 70 and cv.value = a.initial_material_type) as distributed_type, // (select TOP 1 name from accession_name an where a.accession_id = an.accession_id and plant_name_rank = (select MIN(plant_name_rank) from accession_name an2 where a.accession_id = an2.accession_id)) as top_name, // (select top 1 i.standard_distribution_quantity from inventory i where i.accession_id = a.accession_id and i.is_distributable = 'Y') as standard_distribution_quantity, // t.taxonomy_id, // t.name as taxonomy_name //from // accession a left join taxonomy t // on a.taxonomy_id = t.taxonomy_id //where // a.accession_id in (:idlist) //", ":idlist", c.AccessionIDs)); //} // HACK: need to push in the quantity from the cart object // we can't do this as a join between accession and sys_user_cart_item // because an anonymous user won't have any records in sys_user_cart_item. for (int i = 0; i < dt.Rows.Count; i++) { CartItem ci = c.FindByAccessionID(dt.Rows[i], "accession_id"); if (ci != null) { //dt.Rows[i]["quantity"] = ci.Quantity; //Laura Temp } } gvCart.DataSource = dt; gvCart.DataBind(); if (gvCart.Rows.Count == 0) { hlCheckout.Visible = false; } else { if (UserManager.IsAnonymousUser(UserManager.GetUserName())) { hlCheckout.NavigateUrl = "~/login.aspx?action=checkout"; } else { hlCheckout.NavigateUrl = "~/userinfor.aspx?action=checkout"; } int cnt = gvCart.Rows.Count; lblCnt.Text = " (" + cnt.ToString() + (cnt == 1 ? " item)" : " items)"); } lnkPrevious.NavigateUrl = Request.Params["HTTP_REFERER"]; ViewState["previousURL"] = lnkPrevious.NavigateUrl; } }