internal static DataTable ObjectArrayToDataTable1(ClsTreatmentConditionCollection obj, Type type, DataColumn[] extra) { try { DataTable dt = new DataTable(); foreach (PropertyInfo pi in type.GetProperties()) { if (pi.PropertyType.IsPrimitive || pi.PropertyType == typeof(string) || pi.PropertyType == typeof(DateTime)) { dt.Columns.Add(pi.Name, pi.PropertyType); } } if (extra != null) { foreach (DataColumn c in extra) { if (dt.Columns.Contains(c.ColumnName)) { dt.Columns.Remove(c.ColumnName); } dt.Columns.Add(c); } } foreach (object k in obj) { DataRow dr = dt.NewRow(); foreach (PropertyInfo pi in type.GetProperties()) { if (pi.PropertyType.IsPrimitive || pi.PropertyType == typeof(string) || pi.PropertyType == typeof(DateTime)) { dr[pi.Name] = pi.GetValue(k, null); } } dt.Rows.Add(dr); } return(dt); } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "ObjectArrayToDataTable1()", "CtlTratment.xaml.cs"); return(null); } }
internal static DataTable ObjectArrayToDataTable1(ClsTreatmentConditionCollection obj, Type type, DataColumn[] extra) { try { DataTable dt = new DataTable(); foreach (PropertyInfo pi in type.GetProperties()) { if (pi.PropertyType.IsPrimitive || pi.PropertyType == typeof(string) || pi.PropertyType == typeof(DateTime)) { dt.Columns.Add(pi.Name, pi.PropertyType); } } if (extra != null) { foreach (DataColumn c in extra) { if (dt.Columns.Contains(c.ColumnName)) dt.Columns.Remove(c.ColumnName); dt.Columns.Add(c); } } foreach (object k in obj) { DataRow dr = dt.NewRow(); foreach (PropertyInfo pi in type.GetProperties()) { if (pi.PropertyType.IsPrimitive || pi.PropertyType == typeof(string) || pi.PropertyType == typeof(DateTime)) { dr[pi.Name] = pi.GetValue(k, null); } } dt.Rows.Add(dr); } return dt; } catch(Exception ex) { VMuktiHelper.ExceptionHandler(ex, "ObjectArrayToDataTable1()", "CtlTratment.xaml.cs"); return null; } }
internal static DataTable ObjectArrayToDataTable1(ClsTreatmentConditionCollection obj, Type type) { return ObjectArrayToDataTable1(obj, type, null); }
private void CtlGrid_btnEditClicked(int rowID) { try { CtlGrid.IsEnabled = false; VarState = 1; varID = Convert.ToInt32(objTreatmentCollection[rowID].ID); txtName.Text = objTreatmentCollection[rowID].TreatmentName.ToString(); txtDescription.Text = objTreatmentCollection[rowID].Description.ToString(); strTreatmentType = objTreatmentCollection[rowID].Type.ToString(); cmbValues.Items.Clear(); objTreatmentConditionCollection = ClsTreatmentConditionCollection.GetAll(varID); DataTable dt = ObjectArrayToDataTable1(ClsTreatmentConditionCollection.GetAll(varID), typeof(ClsTreatmentCondition)); if (dt.Rows.Count != 0) { if (strTreatmentType == "Filter") { rdFilter.IsChecked = true; rdFilter.IsEnabled = false; rdDisposition.IsEnabled = false; rdFieldValue.IsEnabled = false; } else { rdFieldValue.IsChecked = true; rdFieldValue.IsEnabled = false; rdDisposition.IsEnabled = false; rdFilter.IsEnabled = false; } } for (int i = 0; i < dt.Rows.Count; i++) { cmbLeadFormat.Text = objTreatmentConditionCollection[i].LeadFormatName.ToString(); string str = "(" + objTreatmentConditionCollection[i].FieldName.ToString() + " " + objTreatmentConditionCollection[i].Operator.ToString() + " " + objTreatmentConditionCollection[i].FieldValues.ToString() + " )"; ListBoxItem newItem = new ListBoxItem(); newItem.Content = str; if (strTreatmentType == "Filter") { newItem.Tag = objTreatmentConditionCollection[i].FieldName.ToString() + "~" + objTreatmentConditionCollection[i].Operator.ToString() + "~" + objTreatmentConditionCollection[i].FieldValues.ToString().Replace("~",","); } else { newItem.Tag = objTreatmentConditionCollection[i].FieldName.ToString() + "~" + objTreatmentConditionCollection[i].Operator.ToString() + "~" + objTreatmentConditionCollection[i].FieldValues.ToString(); } lstConditionsCreated.Items.Add(newItem); } Treatment.DataAccess.ClsTreatmentConditionDataService obj = new Treatment.DataAccess.ClsTreatmentConditionDataService(); DataSet ds = obj.TreatmentDisposition_GetByTreatmentID(varID); DataTable dt1 = ds.Tables[0]; if (dt1.Rows.Count != 0) { rdDisposition.IsChecked = true; rdDisposition.IsEnabled = false; rdFieldValue.IsEnabled = false; } for (int i = 0; i < dt1.Rows.Count; i++) { //cmbLeadFormat.Text = objTreatmentConditionCollection[i].LeadFormatName.ToString(); string str = "(Call After" + " " + dt1.Rows[i]["Duration"] + " on " + dt1.Rows[i]["Disposition"] + " )"; ListBoxItem newItem = new ListBoxItem(); newItem.Content = str; newItem.Tag = "Call After ~" + dt1.Rows[i]["Duration"] + "~" + dt1.Rows[i]["Disposition"]; lstConditionsCreated.Items.Add(newItem); } //if (strTreatmentType == "Filter") //{ // if (lstConditionsCreated.Items.Count > 0) // { // btnAdd.IsEnabled = false; // } //} } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "CtlGrid_btnEditClicked()", "CtlTratment.xaml.cs"); } }
internal static DataTable ObjectArrayToDataTable1(ClsTreatmentConditionCollection obj, Type type) { return(ObjectArrayToDataTable1(obj, type, null)); }
private void CtlGrid_btnEditClicked(int rowID) { try { CtlGrid.IsEnabled = false; VarState = 1; varID = Convert.ToInt32(objTreatmentCollection[rowID].ID); txtName.Text = objTreatmentCollection[rowID].TreatmentName.ToString(); txtDescription.Text = objTreatmentCollection[rowID].Description.ToString(); strTreatmentType = objTreatmentCollection[rowID].Type.ToString(); cmbValues.Items.Clear(); objTreatmentConditionCollection = ClsTreatmentConditionCollection.GetAll(varID); DataTable dt = ObjectArrayToDataTable1(ClsTreatmentConditionCollection.GetAll(varID), typeof(ClsTreatmentCondition)); if (dt.Rows.Count != 0) { if (strTreatmentType == "Filter") { rdFilter.IsChecked = true; rdFilter.IsEnabled = false; rdDisposition.IsEnabled = false; rdFieldValue.IsEnabled = false; } else { rdFieldValue.IsChecked = true; rdFieldValue.IsEnabled = false; rdDisposition.IsEnabled = false; rdFilter.IsEnabled = false; } } for (int i = 0; i < dt.Rows.Count; i++) { cmbLeadFormat.Text = objTreatmentConditionCollection[i].LeadFormatName.ToString(); string str = "(" + objTreatmentConditionCollection[i].FieldName.ToString() + " " + objTreatmentConditionCollection[i].Operator.ToString() + " " + objTreatmentConditionCollection[i].FieldValues.ToString() + " )"; ListBoxItem newItem = new ListBoxItem(); newItem.Content = str; if (strTreatmentType == "Filter") { newItem.Tag = objTreatmentConditionCollection[i].FieldName.ToString() + "~" + objTreatmentConditionCollection[i].Operator.ToString() + "~" + objTreatmentConditionCollection[i].FieldValues.ToString().Replace("~", ","); } else { newItem.Tag = objTreatmentConditionCollection[i].FieldName.ToString() + "~" + objTreatmentConditionCollection[i].Operator.ToString() + "~" + objTreatmentConditionCollection[i].FieldValues.ToString(); } lstConditionsCreated.Items.Add(newItem); } Treatment.DataAccess.ClsTreatmentConditionDataService obj = new Treatment.DataAccess.ClsTreatmentConditionDataService(); DataSet ds = obj.TreatmentDisposition_GetByTreatmentID(varID); DataTable dt1 = ds.Tables[0]; if (dt1.Rows.Count != 0) { rdDisposition.IsChecked = true; rdDisposition.IsEnabled = false; rdFieldValue.IsEnabled = false; } for (int i = 0; i < dt1.Rows.Count; i++) { //cmbLeadFormat.Text = objTreatmentConditionCollection[i].LeadFormatName.ToString(); string str = "(Call After" + " " + dt1.Rows[i]["Duration"] + " on " + dt1.Rows[i]["Disposition"] + " )"; ListBoxItem newItem = new ListBoxItem(); newItem.Content = str; newItem.Tag = "Call After ~" + dt1.Rows[i]["Duration"] + "~" + dt1.Rows[i]["Disposition"]; lstConditionsCreated.Items.Add(newItem); } //if (strTreatmentType == "Filter") //{ // if (lstConditionsCreated.Items.Count > 0) // { // btnAdd.IsEnabled = false; // } //} } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "CtlGrid_btnEditClicked()", "CtlTratment.xaml.cs"); } }