小编Rob*_*ert的帖子

DataView行过滤

我有两个DataView我想要排序,在dgtest1我试图为包含a Typeid != 25和dgtest2 的数据的例外我试图只显示数据在哪里Typeid == 25.

当我单步执行代码时,我会说错误

"无法解释令牌'!' 在第6位".

有人能告诉我如何正确使用字符串行过滤器吗?

参数是(数据表表,字符串RowFilter,字符串排序,DataViewRowState)

dgtest1.ItemsSource = new DataView(dttest1, "Typeid!= 25", "", DataViewRowState.CurrentRows);
dgtest2.ItemsSource = new DataView(dttest1, "Typeid == 25", "", DataViewRowState.CurrentRows);
Run Code Online (Sandbox Code Playgroud)

c# wpf c#-4.0

5
推荐指数
1
解决办法
1252
查看次数

XAML中的WPF日期字符串格式

我试图在DatePicker选择日期后格式化字符串.我得到的格式是"9/5/2013 12:00:00 AM",我想要的是"9/5/2013"​​.有人能告诉我我的字符串格式错了吗?

<DataGridTemplateColumn Header="Start">
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Start, StringFormat=d}" FontFamily="Verdana" />
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
    <DataGridTemplateColumn.CellEditingTemplate>
        <DataTemplate>
            <DatePicker SelectedDate="{Binding Start}" FontFamily="Verdana"  >
                <DatePicker.CalendarStyle>
                    <Style TargetType="Calendar">
                          <Setter Property="DisplayMode" Value="Month"/>
                    </Style>
                </DatePicker.CalendarStyle>
            </DatePicker>
        </DataTemplate>
    </DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
Run Code Online (Sandbox Code Playgroud)

wpf xaml wpf-controls wpfdatagrid c#-4.0

5
推荐指数
1
解决办法
2万
查看次数

使用WPF的日期转换器

public class DateTimeConverter : IValueConverter
{
    #region IValueConverter Members

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (values != null)
        {
            DateTime test = (DateTime) value ;
            string date = test.ToString("d/M/yyyy");
            return (date);
        }
        return string.Empty;
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }

    #endregion
}
Run Code Online (Sandbox Code Playgroud)

从DatePicker中选择日期后,我将此转换器设置为获取当前时间.在字符串日期我得到从DatePicker中选择的值,但我似乎只能得到日期.进入Value属性的格式是9/24/2013 12:00:00,但我希望它是9/24/2013.我已经在datetime转换器WPF上问了一个类似的问题,但没有一个提供的答案有效.我得到了同样的错误:指定的强制转换无效.

c# wpf wpf-controls wpfdatagrid

4
推荐指数
1
解决办法
1万
查看次数

只有赋值,调用,递增,递减,等待和新对象表达式才能用作语句

我有这个foreach部分,我试图在我的"result = string.Format"之后添加一行但是我得到以下错误"只有赋值,调用,递增,递减,等待和新对象表达式可以用作语句"有人能告诉我我做错了什么.

foreach (DataRow record in table.Rows)
{
    string key = record["Code"] + "_" + record["Description"];
    int row = (int)rownum[key];

    string date = formatDate(record["ApptDate"].ToString(), "_");

    string result = string.Empty;
    if (record["Dosage"].ToString() != string.Empty)
        result = string.Format("{0}/{1}", test.SharedLib.Application.RemoveTrailingZeroes(record["Dosage"].ToString()), 
                                          test.SharedLib.Application.RemoveTrailingZeroes(record["Units"].ToString()));
    if (record["Dosage"].ToString() != string.Empty)
        result.StartsWith("/") && result.EndsWith("/") ? result.Replace("/", string.Empty) : result;
    else if (record["Units"].ToString() != string.Empty)
        result = record["Units"].ToString();

    dataTable.Rows[row]["ApptDate" + date] = result;
}
Run Code Online (Sandbox Code Playgroud)

c# c#-4.0

2
推荐指数
2
解决办法
3万
查看次数

SQL Server更新声明

这是我在SQL Server中更新表的存储过程,但我似乎无法解决该语句的错误.

Update pc.PatientCopayId, pc.amount, pc.patientid, pc.apptid ,p.PaymentId,p.PaymentDate,p.PayorType,p.PaymentMethod,
      p.RefNumber,p.PaymentAmount,p.PayorId,pt.LastFirstName As PatientName,
      ISNULL((SELECT note FROM dbo.PatientNote WHERE NoteTypeId = 28 AND KeyValue = pc.PatientCopayId),'') AS Note
from [dbo].[PatientCopay] pc, dbo.pymt_Payment p, dbo.Patient pt
where ApptId =  @ApptId
  and p.PaymentId = pc.Paymentid
  And pt.PatientId = p.PayorId
Run Code Online (Sandbox Code Playgroud)

价值观和意义

pc.amount, = @PaymentAmount
pc.patientid, = @PatientId
pc.apptid , = @ApptId
p.PaymentId, = @PaymentId
p.PaymentDate, = @PaymentDate
p.PayorType, = @PayorType
p.PaymentMethod, = @PaymentMethod
p.RefNumber, = @RefNumber
p.PaymentAmount, = @PaymentAmount
p.PayorId, = @PayorId
Run Code Online (Sandbox Code Playgroud)

sql t-sql sql-server stored-procedures

1
推荐指数
1
解决办法
645
查看次数