private void txtpromoname_LostFocus(object sender, RoutedEventArgs e) { CommonResource.FullMultiplePromotion fm = ((TextBox)e.OriginalSource).DataContext as CommonResource.FullMultiplePromotion; cr.UpdateMultilpePromotionName(fm.MultiplePromotionID.ToString(), fm.PromotionName); }
private void btnSave_Click(object sender, RoutedEventArgs e) { int forregional = 0; int active = 0; decimal promotioncost = 0; decimal capevalue = 0; int multiplepromotionid; bool ok = true; string baseproduct = ""; string message = ""; Microsoft.Windows.Controls.DataGridRow row = (Microsoft.Windows.Controls.DataGridRow)(dataGrid1.ItemContainerGenerator.ContainerFromItem(dataGrid1.SelectedItem)); CommonResource.FullMultiplePromotion dv = (CommonResource.FullMultiplePromotion)row.Item; if (dv != null) { if (dv.PromotionName.Trim() == "") { message = "Please enter promotion name."; ok = false; } if (dv.BaseProduct != null) { baseproduct = dv.BaseProduct; } else { message = "Please enter base product."; ok = false; } if (dv.DisplayCodeID < 1) { message = "Please select a price display code."; ok = false; } try { promotioncost = decimal.Parse(dv.PromotionCost.ToString()); } catch (Exception ex) { message = "Please enter a valid promotion cost."; ok = false; } try { capevalue = decimal.Parse(dv.CapeVale.ToString()); } catch (Exception ex) { message = "Please enter a valid cape value."; ok = false; } multiplepromotionid = int.Parse(dv.MultiplePromotionID.ToString()); if (dv.ForRegional) { forregional = 1; } if (dv.Active) { active = 1; } if (ok) { client = new SQSAdminServiceClient(); client.Endpoint.Address = new System.ServiceModel.EndpointAddress(CommonVariables.WcfEndpoint); client.SQSAdmin_Promotion_UpdatePromotion(multiplepromotionid, baseproduct, promotioncost, capevalue, forregional, active, dv.DisplayCodeID, dv.PromotionName); client.Close(); SearchPromotion(); } else { MessageBox.Show(message); } } }
private void dataGrid1_RowEditEnding(object sender, Microsoft.Windows.Controls.DataGridRowEditEndingEventArgs e) { int forregional = 0; int active = 0; decimal promotioncost = 0; decimal capevalue = 0; int multiplepromotionid; bool ok = true; string baseproduct = ""; string message = ""; CommonResource.FullMultiplePromotion dv = (CommonResource.FullMultiplePromotion)e.Row.Item; //DataRowView dv = (DataRowView)e.Row.Item; if (dv != null) { if (dv.BaseProduct != null) { baseproduct = dv.BaseProduct; } try { promotioncost = decimal.Parse(dv.PromotionCost.ToString()); } catch (Exception ex) { message = "Please enter a valid promotion cost."; ok = false; } try { capevalue = decimal.Parse(dv.CapeVale.ToString()); } catch (Exception ex) { message = "Please enter a valid cape value."; ok = false; } multiplepromotionid = int.Parse(dv.MultiplePromotionID.ToString()); if (dv.ForRegional) { forregional = 1; } if (dv.Active) { active = 1; } if (ok) { client = new SQSAdminServiceClient(); client.Endpoint.Address = new System.ServiceModel.EndpointAddress(CommonVariables.WcfEndpoint); client.SQSAdmin_Promotion_UpdatePromotion(multiplepromotionid, baseproduct, promotioncost, capevalue, forregional, active, dv.DisplayCodeID, dv.PromotionName); client.Close(); } else { MessageBox.Show(message); } } }