private static ReportParamV2 XmlNodeToParam(XmlNode node) { ReportParamV2 param; XmlAttribute d = node.Attributes["default"]; string value = null == d ? string.Empty : d.Value; XmlAttribute a; switch (node.Attributes["type"].Value) { case "bool": param = new BoolParam(value); break; case "int": param = new IntParam(value); break; case "date": param = new DateParam(value); break; case "query": var ms = node.Attributes["multiselect"]; var multiselect = null != ms && "yes" == ms.Value.ToLower(); QueryParam qp = multiselect ? new QueryParamMulti(node.InnerText) : new QueryParam(node.InnerText); a = node.Attributes["hideIfRows"]; qp.HideIfrows = null == a ? -1 : int.Parse(a.Value); param = qp; break; case "currency": a = node.Attributes["includeAll"]; bool includeAll = a != null && "yes" == a.Value; CurrencyParam cp = new CurrencyParam(includeAll); a = node.Attributes["hideIfRows"]; cp.HideIfrows = null == a ? -1 : int.Parse(a.Value); param = cp; break; case "branch": a = node.Attributes["consoTable"]; string consoTable = null == a ? string.Empty : a.Value; param = new BranchParam(consoTable); break; default: param = new StringParam(value); break; } XmlAttribute additionalAttribute = node.Attributes["additional"]; param.Additional = null != additionalAttribute && bool.Parse(additionalAttribute.Value); param.Name = node.Attributes["name"].Value; param.Label = node.Attributes["label"].Value; return(param); }
private static ReportParamV2 GenerateParameter(string name, object value) { ReportParamV2 param; if (value is bool) { param = new BoolParam(Convert.ToBoolean(value)); } else if (value is int) { param = new IntParam(Convert.ToInt32(value)); } else if (value is DateTime) { param = new DateParam(Convert.ToDateTime(value)); } else { param = new StringParam(value.ToString()); } param.Name = name; return(param); }
private void buttonPrepareExport_Click(object sender, EventArgs e) { if (cbProcNames.Items.Count > 0) { List<ReportParamV2> paramList = new List<ReportParamV2>(); Dictionary<string, string> parameters = ServicesProvider.GetInstance().GetAccountingServices().SelectExportAccountingProcParams("ExportAccounting_" + cbProcNames.Text); if (parameters != null && parameters.Count > 0) { foreach (var parameter in parameters) { ReportParamV2 reportParam; string paramName = parameter.Key.TrimStart('@'); if (paramName.Equals("branch_id", StringComparison.CurrentCultureIgnoreCase)) reportParam = new BranchParam(string.Empty); else { string paramType = parameter.Value; switch (paramType) { case "bit": reportParam = new BoolParam(false); break; case "datetime": reportParam = new DateParam(DateTime.Today); break; case "char": reportParam = new CharParam(' '); break; case "nvarchar": case "varchar": case "text": reportParam = new StringParam(string.Empty); break; case "int": reportParam = new IntParam(1); break; case "float": reportParam = new DoubleParam(1d); break; case "money": reportParam = new DecimalParam(1m); break; default: throw new NotImplementedException(string.Format("Sql type:{0} is not handled.", paramName)); } } reportParam.Label = paramName; reportParam.Name = paramName; paramList.Add(reportParam); } ReportParamsForm frm = new ReportParamsForm(paramList, cbProcNames.Text); frm.ShowDialog(); } _dataTable = ServicesProvider.GetInstance().GetAccountingServices().FindElementaryMvtsToExport( "ExportAccounting_" + cbProcNames.Text, paramList, out _idTable); _total = _dataTable.Rows.Count; _bwSelect = new BackgroundWorker {WorkerSupportsCancellation = true}; _bwSelect.DoWork += BwSelect_DoWork; ExportBookings_Load(this, null); } }