Xamarin forms: How to add tapped event on XamForms.Controls.Calendar specialdate? - xamarin.forms

I am using XamForms.Controls.Calendar package for showing calendar in my project. I am marking events on the calendar using the below code.
private void AddSpecialDateWithList(List<events> list)
{
List<SpecialDate> newList = new List<SpecialDate>();
foreach (events model in list)
{
string startDate = model.start;
int startIndex = startDate.IndexOf('T');
if (startIndex > 0)
{
startDate = startDate.Substring(0, startIndex);
}
string endDate = model.end;
int endIndex = endDate.IndexOf('T');
if (endIndex > 0)
{
endDate = endDate.Substring(0, endIndex);
}
List<DateTime> dates = GetDatesBetween(DateTime.Parse(startDate), DateTime.Parse(endDate));
for(int i=0;i< dates.Count; i++)
{
var newDate = AddDate(dates[i], model);
newList.Add(newDate);
}
}
calendar.SpecialDates = newList;
}
private SpecialDate AddDate(DateTime dateTime, events model)
{
SpecialDate newDate = new SpecialDate(dateTime)
{
Selectable = true,
BackgroundPattern = new BackgroundPattern(1)
{
Pattern = new List<Pattern>
{
new Pattern { WidthPercent = 1f, HightPercent = 0.7f, Color = Color.White },
new Pattern{ WidthPercent = 1f, HightPercent = 0.3f, Color = Color.Yellow, Text = model.title, TextColor=Color.Black, TextSize=10, TextAlign=TextAlign.LeftCenter},
}
}
};
return newDate;
}
Screenshot:
When I tap a day having event(31 Jan having maths homework), I need to get the event id and all the other details associated with that event. How can I do this feature? Also is it possible to show month, week and day view in XamForms.Controls.Calendar?

You could get the index of SpecialDate in your list in the event DateClicked
private void calendar_DateClicked(object sender, DateTimeEventArgs e)
{
int num = 0;
var specialList = calendar.SpecialDates;
var date = e.DateTime;
foreach(SpecialDate specialDate in specialList)
{
if(specialDate.Date.Year==date.Year&& specialDate.Date.Month == date.Month&&specialDate.Date.Day == date.Day)
{
events model = list[num];
// do something you want
}
else
{
num++;
}
}
}

Related

customize the height and width of ESRI map callout

here is the formatted String which i am binding to callout but i am able to see only some contents of my string in callout
private async void WebMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
{
try
{
WebMapView.DismissCallout();
MapPoint mapLocation = null;
var layers = await WebMapView.IdentifyLayersAsync(e.Position, 20, false);
if (layers.Count > 0)
{
foreach (var idResults in layers)
{
FeatureLayer idLayer = idResults.LayerContent as FeatureLayer;
await idLayer.LoadAsync();
var result = layers.First();
var feature = result.GeoElements.First() as ArcGISFeature;
await feature.LoadAsync(); // Load feature to get all attributes
Feature idFeature = result.GeoElements.First() as Feature;
featureAttrs = idFeature.Attributes;
var stateExtent = idFeature.Geometry;
Graphicoverlay = new GraphicsOverlay();
Graphic graphicLine = null;
graphicLine = new Graphic(stateExtent, AppConstant.HighLight1);
Graphicoverlay.Graphics.Add(graphicLine);
EnvelopeBuilder myEnvelopeBuilder = new EnvelopeBuilder(SpatialReferences.WebMercator);
//Geometry abd = oneGraphic.Geometry;
myEnvelopeBuilder.UnionOf(graphicLine.Geometry.Extent);
myEnvelopeBuilder.Expand(1.3);
mapLocation = myEnvelopeBuilder.Center;
Geometry myGeometry = GeometryEngine.Project(mapLocation, SpatialReferences.WebMercator);
MapPoint projectedLocation = (MapPoint)myGeometry;
string formattedString = "";
if (featureAttrs.Count > 0)
{
foreach (var attributes in featureAttrs)
{
string recordOneAttribute = $"{attributes.Key} {attributes.Value}";
formattedString = $"{formattedString}\n{ recordOneAttribute}";
}
}
CalloutDefinition calloutDef = new CalloutDefinition("Feature:",formattedString);
WebMapView.ShowCalloutAt(mapLocation, calloutDef);
}
}

How to populate data related to an item from the location which is same for all items in Xamarin.forms

I am developing an xamarin.forms app ,I have various fields like Item Name ,Item Number and location ,here Location of all the items are same ,by entering names or number of the items the values are generated automatically because name and number are unique but since the location number is common is for all the items I am not able to populate correct data related to a particular field ,I am using sqlite database in my project can anyone please suggest me on what basis can I generate related values ?
Here is the code
public async void OnSearch_Location(object o, EventArgs args)
{
if (location.Text == string.Empty || location.Text == null)
{
await Navigation.PushAsync(new ListValuePage("Location", filePath,
pos, list));
}
else
{
for (int p = 0; p < list.Count; p++)
{
if (list.ElementAt(p).Aisle + "." + list.ElementAt(p).Bin +
"." + list.ElementAt(p).Level == location.Text)
{
line.Text =
Convert.ToString(list.ElementAt(p).Line_Number);
location.Text = list.ElementAt(p).Aisle + "." +
list.ElementAt(p).Bin + "." + list.ElementAt(p).Level;
item.Text = list.ElementAt(p).Item_Number;
name.Text = list.ElementAt(p).Name;
if (list.ElementAt(p).Order_Qty == 0)
{
order_uom.Text = "";
}
else
{
order_qty.Text =
Convert.ToString(list.ElementAt(p).Order_Qty);
}
order_uom.Text = list.ElementAt(p).Order_UOM;
if (list.ElementAt(p).Consumption_UOM == string.Empty ||
list.ElementAt(p).Consumption_UOM == null)
{
consume_lbl.IsVisible = false;
consume_qty.IsVisible = false;
consume_uom.IsVisible = false;
}
else
{
consume_lbl.IsVisible = true;
consume_qty.IsVisible = true;
consume_uom.IsVisible = true;
if (list.ElementAt(p).Consumption_Qty == 0)
{
consume_qty.Text = "";
}
else
{
consume_qty.Text =
Convert.ToString(list.ElementAt(p).Consumption_Qty);
}
consume_uom.Text = list.ElementAt(p).Consumption_UOM;
}
}
}
}
}

Index out of bound at xmlworkerhelper in c#

PaymentService.PaymentServiceClient client = new
PaymentService.PaymentServiceClient();
PaymentTransactionDto model = new PaymentTransactionDto();
OrderInvoiceDto invoiceData;
List<ProductRepoDto> products;
List<OrderTaxDto> taxes;
// Check payment status
int chkProduct = 0;
int chkCourse = 0;
int chkProductCourse = 0;
#region Get order details for invoice
var order_details = client.GetOrderDetailsForInvoice(Convert.ToInt32(Oid.Rows[0]["OrderId"]));
invoiceData = new OrderInvoiceDto();
if (order_details != null)
{
invoiceData = AutoMapConverter<PaymentService.OrderInvoiceDto, OrderInvoiceDto>.GetMappedData(order_details);
}
#endregion
#region Get Products list in order
var productList = client.GetOrderItemsByOrderId(Convert.ToInt32(Oid.Rows[0]["OrderId"]));
products = new List<ProductRepoDto>();
if (productList != null && productList.Count() > 0)
{
products = AutoMapConverter<PaymentService.ProductRepoDto, ProductRepoDto>.GetMappedList(productList.ToList());
}
#endregion
#region ADD Taxes
#region check product type
decimal Amount = 0;
foreach (var item in products)
{
if (item.TypeId == 1)
chkCourse = 1;
if (item.TypeId == 2)
chkProduct = 1;
if (chkCourse == 1 && chkProduct == 1)
chkProductCourse = 1;
Amount = Amount + (item.Amount * item.Quantity);
Amount = Amount - item.Discount;
}
#endregion
// Apply taxes
client.AddOrderTaxMappingDetails(Convert.ToInt64(orderid), Amount);
#endregion
#region Get Applied Tax details
var taxesApplied = client.GetOrderAppliedTaxes(Convert.ToInt64(orderid));
taxes = new List<OrderTaxDto>();
if (taxesApplied != null && taxesApplied.Count() > 0)
{
taxes = AutoMapConverter<PaymentService.OrderTaxDto, OrderTaxDto>.GetMappedList(taxesApplied.ToList());
}
#endregion
string pdfbody = System.IO.File.ReadAllText(Server.MapPath("~/Views/Payment/InvoiceView.cshtml"));
Document document = new Document();
string fileName = string.Format("{0}.pdf", invoiceData.OrderNumber);
var fpath = HttpContext.Current.Server.MapPath("~/Document/Payment/Invoice/");
if (!Directory.Exists(fpath))
{
Directory.CreateDirectory(fpath);
}
pdfbody = pdfbody.Replace("$name$", string.Format("{0} {1}", invoiceData.Billing_FirstName, invoiceData.Billing_LastName));
pdfbody = pdfbody.Replace("$address$", invoiceData.Billing_Address);
pdfbody = pdfbody.Replace("$billingCity$", invoiceData.Billing_City);
pdfbody = pdfbody.Replace("$billingPinCode$", invoiceData.Billing_PinCode.ToString());
pdfbody = pdfbody.Replace("$billingState$", invoiceData.Billing_State);
pdfbody = pdfbody.Replace("$billingCountry$", invoiceData.Billing_Country);
//pdfbody = pdfbody.Replace("$netAmt$", invoiceData.NetAmt.ToString());
//pdfbody = pdfbody.Replace("$grossAmt$", invoiceData.GrossAmt.ToString());
//pdfbody = pdfbody.Replace("$discountAmt$", invoiceData.DiscountAmt.ToString());
pdfbody = pdfbody.Replace("$orderNumber$", invoiceData.OrderNumber.Remove(0, 2));
pdfbody = pdfbody.Replace("$orderDate$", CommonFunctions.EpochToIstDate(Convert.ToDouble(invoiceData.OrderDate)));
StringBuilder b = new StringBuilder();
decimal totalAmount = 0;
foreach (var item in products)
{
if (!string.IsNullOrEmpty(item.ActivationKey))
item.ActivationKey = string.Format("Activation Key:{0}", item.ActivationKey);
b.AppendFormat("<tr><td width='60%'>{0}<br/>{1}</td>", item.ProductName, item.ActivationKey);
b.AppendFormat("<td width='10%' align='left'>{0}</td>", item.Quantity);
b.AppendFormat("<td width='30%' align='right'>{0}</td></tr>", (item.Amount * item.Quantity) - item.Discount);
totalAmount = totalAmount + (item.Amount * item.Quantity);
totalAmount = totalAmount - item.Discount;
}
pdfbody = pdfbody.Replace("$OrderDetailsList$", Convert.ToString(b));
if (taxes != null && taxes.Count > 0)
{
b = new StringBuilder();
foreach (var item in taxes)
{
b.AppendFormat("<tr><td width='80%' colspan='2'>{0} ({1}%)</td>", item.TaxName, item.Percentage);
b.AppendFormat("<td width='20%' align='right'>{0}</td></tr>", item.Amount);
}
pdfbody = pdfbody.Replace("$OrderTaxDetailsList$", Convert.ToString(b));
}
else
{
pdfbody = pdfbody.Replace("$OrderTaxDetailsList$", "");
}
pdfbody = pdfbody.Replace("$netAmt$", totalAmount.ToString());
pdfbody = pdfbody.Replace("$rupees$", CommonFunctions.ConvertNumbertoWords(Convert.ToInt32((int)Math.Ceiling(totalAmount))));
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fpath + fileName, FileMode.Create));
document.Open();
StringReader sr = new StringReader(pdfbody);
XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, sr);
document.Close();
I want to generate pdf invoice.so i am using itextsharp.
but i am getting Index out of bound array at XMLWorkerHelper.
I am using itextsharp.xmlworker.dll, v5.4.5.0
when i try to update itextsharp.xmlworker.dll, v5.4.5.9
this code works fine..but all other modules of my project which use iTextsharp starts getting error.
if this is version problem, then how i add two different dll in bin folder and use it
or it is code related error?

Telerik Load on demand RadOrgChart not loading nodes after 3 levels

In Telerik Load on demand RadOrgChart, I'm Loading data through server.
It will take up to 2 levels of data on every time click of each node. but data is coming properly from server,but problem is nodes not generated for those data. what should I do to get it properly?
private void CreateTeams() {
teams = new DataTable();
teams.Columns.Add("UniqueID");
teams.Columns.Add("ReportsTo");
teams.Columns.Add("Collapsed");
var myList = (List < NodeViewModel > ) Session["items"];
foreach(var nodeitem in myList) {
if (nodeitem.IsManager == true && nodeitem.level == 0) {
teams.Rows.Add(new string[] {
nodeitem.EmployeeBadge, null, "0"
});
} else {
teams.Rows.Add(new string[] {
nodeitem.EmployeeBadge, nodeitem.ManagerBadge, "1"
});
}
}
}
protected void Page_Load(object sender, EventArgs e) {
if (Request.Cookies["badgeName"] != null) {
var value = Request.Cookies["badgeName"].Value;
EmployeeRepository obj = new EmployeeRepository();
var myList = (List < NodeViewModel > ) Session["items"];
try {
obj.CreateLevel(new NodeViewModel() {
EmployeeBadge = value
}, myList);
logger.Info("OrgChart:Page_Load()::success");
} catch (Exception ex) {
logger.Error(string.Concat("OrgChart:Page_Load()::", ex.Message));
logger.Error(string.Concat("OrgChart:Page_Load()::", ex.StackTrace));
}
Response.Cookies["badgeName"].Expires = DateTime.Now.AddDays(-1);
}
CreateTeams();
CreateEmployees();
RadOrgChart1.GroupEnabledBinding.NodeBindingSettings.DataFieldID = "UniqueID";
RadOrgChart1.GroupEnabledBinding.NodeBindingSettings.DataFieldParentID = "ReportsTo";
RadOrgChart1.GroupEnabledBinding.NodeBindingSettings.DataCollapsedField = "Collapsed";
RadOrgChart1.GroupEnabledBinding.NodeBindingSettings.DataGroupCollapsedField = "Collapsed";
//RadOrgChart1.RenderedFields.NodeFields.Add(new Telerik.Web.UI.OrgChartRenderedField() { DataField = "Team" });
RadOrgChart1.GroupEnabledBinding.NodeBindingSettings.DataSource = teams;
RadOrgChart1.GroupEnabledBinding.GroupItemBindingSettings.DataFieldID = "EmployeeID";
RadOrgChart1.GroupEnabledBinding.GroupItemBindingSettings.DataFieldNodeID = "UniqueID";
RadOrgChart1.GroupEnabledBinding.GroupItemBindingSettings.DataTextField = "Name";
RadOrgChart1.GroupEnabledBinding.GroupItemBindingSettings.DataImageUrlField = "ImageUrl";
RadOrgChart1.GroupEnabledBinding.GroupItemBindingSettings.DataSource = employees;
RadOrgChart1.DataBind();
}

shift select records in gridview asp.net

hey guys,
i have a gridview which displays 10records per page, now i want to implement shift+click option in my gridview, when user clicks on the first row and press shift key and click on the 5th row, all the rows between 1 and 5(1 and 5 inclusive) should be selected...
can anyone suggest how should i do this in javascript.
I take it back, I found a shift+click multiple select solution for a gridview. All credit goes to mdv over at the asp forums.
var _sPreviousRow = null;
function wsCheckRange(p_oGridView, p_oControl, e) {
var l_sCheckID = p_oControl.id;
var l_aCheckIDParts = l_sCheckID.split(p_oGridView.id);
var l_sCurrentRow = l_aCheckIDParts[1].split('_')[1].substring(3);
var l_oEvent = (window.event) ? event : e;
if (l_oEvent.shiftKey) {
if (_sPreviousRow != null && _sPreviousRow != l_sCurrentRow) {
var l_iFirst = 0, l_iLast = 0;
if (parseInt(_sPreviousRow,10) > parseInt(l_sCurrentRow,10)) {
l_iFirst = parseInt(l_sCurrentRow,10);
l_iLast = parseInt(_sPreviousRow,10);
}
else {
l_iFirst = parseInt(_sPreviousRow,10);
l_iLast = parseInt(l_sCurrentRow,10);
}
for (var i = l_iFirst; i < l_iLast; i++) {
var l_sLastRow = (i <= 9 ? '0' + i : i);
var l_sCtrlNew = l_sCheckID.replace('ctl' + l_sCurrentRow, 'ctl' + l_sLastRow);
var l_oCtrlNew = $get(l_sCtrlNew);
if (l_oCtrlNew) {
l_oCtrlNew.checked = p_oControl.checked;
}
}
}
_sPreviousRow = null;
}
else {
_sPreviousRow = l_sCurrentRow;
}
}

Resources