本文整理汇总了C#中System.Data.DataRow.Count方法的典型用法代码示例。如果您正苦于以下问题:C# DataRow.Count方法的具体用法?C# DataRow.Count怎么用?C# DataRow.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataRow
的用法示例。
在下文中一共展示了DataRow.Count方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SPC_SetQueryRunUpdate
string SPC_SetQueryRunUpdate(DataRow[] _rows, string _emplPwtime0)
{
string ret = string.Empty;
DateTime lineDate = new DateTime(1901, 1, 1);
StringBuilder sb = new StringBuilder();
if (_rows.Count() > 0)
{
sb.AppendFormat(@"{0} ", "UPDATE PWTIME2 SET");
for (var rowIdx = 0; rowIdx < _rows.Count(); rowIdx++)
{
lineDate = _rows[rowIdx].Field<DateTime>("SHIFTDATE").Date;
if (rowIdx == 0)
sb.AppendFormat(@"{0} = N'{1}'", this.SPC_SetFieldNameByDay(lineDate.Day), _rows[rowIdx].Field<string>("TOSHIFTID").Trim());
else
sb.AppendFormat(@", {0} = N'{1}'", this.SPC_SetFieldNameByDay(lineDate.Day), _rows[rowIdx].Field<string>("TOSHIFTID").Trim());
}
sb.AppendFormat(@" WHERE PWTIME0 = N'{0}' AND PWYEAR = {1} AND PWMONTH = {2};", _emplPwtime0, lineDate.Year, lineDate.Month);
}
ret = sb.ToString();
return ret;
}
示例2: setSingleProperty
private void setSingleProperty(PropertyInfo prop, ColumnBindingAttribute attribute, DataRow[] rows, int index)
{
object value = null;
if (rows != null && rows.Count() > 0)
{
string colName = attribute.ColNames.First();
//May Throw Error
DataRow dr = rows[index];
if (dr[colName] != null && dr[colName].ToString() != "")
{
value = getConvertValue(attribute, dr[colName], prop.PropertyType);
}
}
setValue(prop, value, attribute);
}
示例3: RefreshMenu
void RefreshMenu(DataRow[] rows)
{
tileControl1.Groups.Clear();
TileGroup g = new TileGroup();
if (rows != null && rows.Count()!=0)
{
tileControl1.Groups.Add(g);
foreach (DataRow i in rows)
{
TileItem ti = new TileItem { Name = i["MenuID"].ToString(), Text = i["Name"].ToString() };
ti.ItemClick += ti_ItemClick;
ti.Tag = i;
g.Items.Add(ti);
}
tileControl1.SelectedItem = g.Items[0];
g.Items[0].AppearanceItem.Selected.BackColor = Color.Red;
g.Items[0].AppearanceItem.Selected.BackColor2 = Color.Orange;
g.Items[0].AppearanceItem.Selected.BorderColor = Color.White;
}
}
示例4: GetData
public DataTable GetData()
{
IEnumerable<DataRow> rows = new DataRow[] { };
DataTable dtResult = null;
DataTable dt = GetDataView();
if (dt != null)
{
int iRowCount = dt.Rows.Count;
if (iRowCount > 0)
{
rows = dt.Rows.Cast<DataRow>();
// handle paging
if (this.Pager != null && this.Pager.PageSize > 0)
{
if (this.Pager.PageCurrent > 0)
{
var skipN = this.Pager.PageCurrent * this.Pager.PageSize;
if (skipN > rows.Count())
skipN = rows.Count();
rows = rows.Skip(skipN);
}
if (this.Pager.PageSize < rows.Count())
rows = rows.Take(this.Pager.PageSize);
}
// handle SkipN
if (this.SkipN > 0 && this.SkipN < rows.Count())
rows = rows.Skip(this.SkipN);
// handle TopN
if (this.TopN > 0 && this.TopN < rows.Count())
rows = rows.Take(this.TopN);
// handle RandomN
if (this.RandomN > 0 && this.RandomN < rows.Count())
rows = rows.Random(this.RandomN);
// handle EveryNth
if (this.EveryNth > 0 && this.EveryNth < rows.Count())
rows = rows.Where((dr, index) => index % this.EveryNth == 0);
}
dtResult = dt.Clone();
foreach (DataRow dr in rows)
dtResult.ImportRow(dr);
// Set the assign special field values
AssignSpecialFieldValues(dtResult);
}
return dtResult;
}
示例5: usuario_pedido_parse
public static List<PedidoUsuario> usuario_pedido_parse(DataRow[] rowCollection)
{
List<PedidoUsuario> pedidos = new List<PedidoUsuario>();
PedidoUsuario pedido;
ProductoPedido producto;
int i = 0;
DataRow row;
int nextPedido;
while (i < rowCollection.Count())
{
row = rowCollection[i];
pedido = new PedidoUsuario();
pedido.IdPedido = Int32.Parse(row["idPedido"].ToString());
pedido.MontoCobrar = Int32.Parse(row["total"].ToString());
pedido.MontoPagar = Int32.Parse(row["cuantoPaga"].ToString());
pedido.MontoVuelto = Int32.Parse(row["vuelto"].ToString());
pedido.Productos = new List<ProductoPedido>();
do
{
producto = new ProductoPedido();
producto.Nombre = row["nombre"].ToString();
producto.Precio = Int32.Parse(row["precioUnitario"].ToString());
producto.Cantidad = Int32.Parse(row["cantidad"].ToString());
pedido.Productos.Add(producto);
i++;
if (i < rowCollection.Count())
{
row = rowCollection[i];
nextPedido = Int32.Parse(row["idPedido"].ToString());
}
else
break;
}
while (nextPedido == pedido.IdPedido);
pedidos.Add(pedido);
}
return pedidos;
}
示例6: GetDeliverDetailsPDF
/// <summary>
/// 出貨明細
/// </summary>
public void GetDeliverDetailsPDF()
{
string deliver_id = Request.Params["deliver_id"];
_DeliverDetailMgr = new DeliverDetailMgr(mySqlConnectionString);
DataTable deliverdetail = _DeliverDetailMgr.GetOrderDelivers(deliver_id, 1);
BaseFont bfChinese = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bfChinese, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED);
iTextSharp.text.Font font = new iTextSharp.text.Font(bfChinese, 12, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑
string filename = "deliver_details_D" + deliver_id.PadLeft(8, '0') + ".pdf";
Document document = new Document(PageSize.A4, (float)5, (float)5, (float)20, (float)0.5);
string newPDFName = Server.MapPath(excelPath) + filename;
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create));
document.Open();
PdfContentByte cb = writer.DirectContent;
cb.BeginText();
DataRow[] singleproduct = new DataRow[] { };//單一商品
DataRow[] fatherproduct = new DataRow[] { };//組合商品中的父商品
DataRow[] sonproduct = new DataRow[] { };//組合商品中的子商品
//DataRow[] normal;
//DataRow[] low;
//DataRow[] lowstore;
//List<DataRow> deliverdetails = new List<DataRow>();
ArrayList combine = new ArrayList();
singleproduct = deliverdetail.Select(" combined_mode<=1 and ddeliver_id=" + deliver_id, "item_id asc");//單一商品
fatherproduct = deliverdetail.Select(" combined_mode>1 and item_mode=1 and ddeliver_id=" + deliver_id, "item_id asc");//組合商品中父商品是否存在
foreach (var item in fatherproduct)
{
combine.Add(item);
sonproduct = deliverdetail.Select(" combined_mode>1 and item_mode<>1 and parent_id=" + item["parent_id"] + " and pack_id=" + item["pack_id"], "item_id asc");//對應組合商品中的子商品
foreach (var son in sonproduct)
{
son["buy_num"] = (int.Parse(son["buy_num"].ToString()) * int.Parse(son["parent_num"].ToString())).ToString();
combine.Add(son);
}
}
List<DataRow[]> deliverdetails = new List<DataRow[]>();
//normal = deliverdetail.Select("product_freight_set in(1,3) and ddeliver_id=" + deliver_id, "item_id asc");//常溫
//low = deliverdetail.Select("product_freight_set in(2,4) and ddeliver_id=" + deliver_id, "item_id asc");//冷凍
//lowstore = deliverdetail.Select("product_freight_set in(5,6) and ddeliver_id=" + deliver_id, "item_id asc");//冷藏
if (singleproduct.Count() > 0)
{
deliverdetails.Add(singleproduct);
}
if (combine.Count > 0)
{
deliverdetails.Add((DataRow[])combine.ToArray(typeof(DataRow)));
}
if (deliverdetail.Rows.Count > 0)
{
cb.SetFontAndSize(bfChinese, 20);
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "吉甲地台灣好市集出貨明細", 30, 750, 0);
string freight_set = string.Empty;
switch (deliverdetail.Rows[0]["freight_set"].ToString().Trim())
{
case "1":
freight_set = "常溫";
break;
case "2":
freight_set = "冷凍";
break;
case "5":
freight_set = "冷藏";
break;
}
cb.SetFontAndSize(bfChinese, 12);
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, freight_set, 350, 780, 0);
if (deliverdetail.Rows[0]["estimated_arrival_period"].ToString() != "0")
{
string estimated_arrival_period = string.Empty;
switch (deliverdetail.Rows[0]["estimated_arrival_period"].ToString().Trim())
{
case "0":
estimated_arrival_period = "不限時";
break;
case "1":
estimated_arrival_period = "12:00以前";
break;
case "2":
estimated_arrival_period = "12:00-17:00";
break;
case "3":
estimated_arrival_period = "17:00-20:00";
break;
}
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, estimated_arrival_period, 350, 765, 0);
}
Phrase ph = new Phrase();
BarCode.Code128 _Code = new BarCode.Code128();
_Code.ValueFont = new System.Drawing.Font("宋体", 20);
System.Drawing.Bitmap imgTemp1 = _Code.GetCodeImage("D" + deliverdetail.Rows[0]["deliver_id"].ToString().PadLeft(8, '0'), BarCode.Code128.Encode.Code128A);
imgTemp1.Save(System.AppDomain.CurrentDomain.BaseDirectory + "\\ImportUserIOExcel\\" + "Code.gif", System.Drawing.Imaging.ImageFormat.Gif);
//.........这里部分代码省略.........
示例7: GetOrderDetailsPDF
/// <summary>
/// 订单出货明细
/// </summary>
public void GetOrderDetailsPDF()
{
string deliver_id = Request.Params["deliver_id"];
_DeliverDetailMgr = new DeliverDetailMgr(mySqlConnectionString);
DataTable orderdeliver = _DeliverDetailMgr.GetOrderDelivers(deliver_id);
Dictionary<string, string> dicproduct_freight_set = new Dictionary<string, string> { { "1", "1" }, { "2", "2" }, { "3", "1" }, { "4", "2" }, { "5", "5" }, { "6", "5" } };
BaseFont bfChinese = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
iTextSharp.text.Font font = new iTextSharp.text.Font(bfChinese, 12, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑
string filename = "order_details_D" + deliver_id.PadLeft(8, '0') + ".pdf";
Document document = new Document(PageSize.A4, (float)5, (float)5, (float)20, (float)0.5);
string newPDFName = Server.MapPath(excelPath) + filename;
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create));
document.Open();
PdfContentByte cb = writer.DirectContent;
if (orderdeliver.Rows.Count > 0)
{
#region 生成條形碼
BarCode.Code128 _Code = new BarCode.Code128();
_Code.ValueFont = new System.Drawing.Font("宋体", 20);
System.Drawing.Bitmap imgTemp = _Code.GetCodeImage("D" + orderdeliver.Rows[0]["deliver_id"].ToString().PadLeft(8, '0'), BarCode.Code128.Encode.Code128A);
imgTemp.Save(System.AppDomain.CurrentDomain.BaseDirectory + "\\ImportUserIOExcel\\" + "Code.gif", System.Drawing.Imaging.ImageFormat.Gif);
iTextSharp.text.Image IMG = iTextSharp.text.Image.GetInstance(Server.MapPath("../ImportUserIOExcel/Code.gif"));
IMG.ScaleToFit(200, 30);
IMG.SetAbsolutePosition(345, 740);
#endregion
cb.BeginText();
cb.SetFontAndSize(bfChinese, 20);
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "吉甲地市集出貨明細", 30, 750, 0);
//首購
if (orderdeliver.Rows[0]["priority"].ToString() == "1")
{
PdfPTable ot = new PdfPTable(1);
ot.SetTotalWidth(new float[] { 190 });
PdfPCell c = new PdfPCell(new Phrase("", font));
c.FixedHeight = 30;
c.BorderWidthBottom = 0.5f;
c.BorderWidthLeft = 0.5f;
c.BorderWidthRight = 0.5f;
c.BorderWidthTop = 0.5f;
ot.AddCell(c);
ot.WriteSelectedRows(0, -1, 29, 770, cb);
}
cb.AddImage(IMG);
if (orderdeliver.Rows[0]["channel"].ToString() != "1")
{
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["channel_name_simple"].ToString(), 80, 700, 0);
}
if (orderdeliver.Rows[0]["retrieve_mode"].ToString() == "1")
{
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "7-11取貨", 200, 700, 0);
}
cb.SetFontAndSize(bfChinese, 10);
string freight_set = string.Empty;
switch (orderdeliver.Rows[0]["freight_set"].ToString().Trim())
{
case "1":
freight_set = "常溫";
break;
case "2":
freight_set = "冷凍";
break;
case "5":
freight_set = "冷藏";
break;
}
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, freight_set, 345, 785, 0);
string estimated_arrival_period = string.Empty;
if (orderdeliver.Rows[0]["estimated_arrival_period"].ToString() != "0")
{
switch (orderdeliver.Rows[0]["estimated_arrival_period"].ToString().Trim())
{
case "0":
estimated_arrival_period = "不限時";
break;
case "1":
estimated_arrival_period = "12:00以前";
break;
case "2":
estimated_arrival_period = "12:00-17:00";
break;
case "3":
estimated_arrival_period = "17:00-20:00";
break;
}
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, estimated_arrival_period, 345, 773, 0);
}
}
cb.SetFontAndSize(bfChinese, 10);
//cb.SetTextMatrix(150,20);
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "訂購人:", 10, 680, 0);
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "收件人:", 200, 680, 0);
//.........这里部分代码省略.........
示例8: ConvertToSqlStr
/// <summary>
/// 根据时间段转化为相应的时间查找条件
/// </summary>
/// <param name="rows"></param>
/// <param name="date"></param>
/// <returns></returns>
private string ConvertToSqlStr(DataRow[] rows, string date, string workingTeam="")
{
StringBuilder timeBuilder = new StringBuilder();
int n = rows.Count();
//SqlParameter paramater = new SqlParameter("variableName", variableName);
foreach (DataRow dr in rows)
{
string endTime;
string startTime;
if ("24:00" == dr["EndTime"].ToString().Trim())
{
DateTime time= DateTime.Parse(date + " 00:00:00");
endTime= time.AddDays(1).ToString();
//endTime = "23:59:59";
}
else
{
endTime =date+" "+ dr["EndTime"].ToString().Trim() + ":00";
}
startTime = date + " " + dr["StartTime"].ToString().Trim() + ":00";
if (workingTeam == "甲班" && DateTime.Parse(startTime)>DateTime.Parse(endTime))
{
startTime = DateTime.Parse(startTime).AddDays(-1).ToString();
}
if (workingTeam == "丙班" && DateTime.Parse(startTime) > DateTime.Parse(endTime))
{
endTime = DateTime.Parse(endTime).AddDays(1).ToString();
}
timeBuilder.Append("vDate>=");
//timeBuilder.Append("#");
timeBuilder.Append("'");
timeBuilder.Append(startTime);
//timeBuilder.Append(dr["StartTime"].ToString().Trim() + ":00");
//timeBuilder.Append("#");
timeBuilder.Append("'");
timeBuilder.Append(" AND ");
timeBuilder.Append("vDate<");
//timeBuilder.Append("#");
timeBuilder.Append("'");
//timeBuilder.Append(date + " ");
timeBuilder.Append(endTime);
//timeBuilder.Append("#");
timeBuilder.Append("'");
timeBuilder.Append(" OR ");
}
int m_long = timeBuilder.ToString().Length;
string timeCriterion = timeBuilder.ToString().Substring(0, m_long - 4);
return timeCriterion;
}
示例9: AddDoTask
/// <summary>
/// 新增待办
/// </summary>
/// <param name="entity"></param>
/// <param name="dr1"></param>
/// <param name="SourceValueDT"></param>
/// <param name="strAPPFIELDVALUE"></param>
public void AddDoTask(T_WF_DOTASK entity, DataRow[] drs, DataTable SourceValueDT, string strAPPFIELDVALUE, string submitUserName, string ModeName, string applicationUrl)
{
CloseDoTaskStatus(entity.SYSTEMCODE, entity.ORDERID, null);
try
{
string[] strListUser;
if (entity.RECEIVEUSERID.IndexOf('|') != -1)
{
strListUser = entity.RECEIVEUSERID.ToString().Split('|');
}
else
{
strListUser = new string[1];
strListUser[0] = entity.RECEIVEUSERID.ToString();
}
//
foreach (string User in strListUser)
{
string insSql = @"INSERT INTO T_WF_DOTASK (DOTASKID,COMPANYID,ORDERID,ORDERUSERID,ORDERUSERNAME,ORDERSTATUS,MESSAGEBODY,
APPLICATIONURL,RECEIVEUSERID,BEFOREPROCESSDATE,DOTASKTYPE,DOTASKSTATUS,MAILSTATUS,
RTXSTATUS,APPFIELDVALUE,FLOWXML,APPXML,SYSTEMCODE,MODELCODE,MODELNAME,REMARK)
VALUES (@DOTASKID,@COMPANYID,@ORDERID,@ORDERUSERID,@ORDERUSERNAME,@ORDERSTATUS,@MESSAGEBODY,@APPLICATIONURL,
@RECEIVEUSERID,@BEFOREPROCESSDATE,@DOTASKTYPE,@DOTASKSTATUS,@MAILSTATUS,@RTXSTATUS,
@APPFIELDVALUE,@FLOWXML,@APPXML,@SYSTEMCODE,@MODELCODE,@MODELNAME,@REMARK)";
Parameter[] pageparm =
{
new Parameter("@DOTASKID",null),
new Parameter("@COMPANYID",null),
new Parameter("@ORDERID",null),
new Parameter("@ORDERUSERID",null),
new Parameter("@ORDERUSERNAME",null),
new Parameter("@ORDERSTATUS",null),
new Parameter("@MESSAGEBODY",null),
new Parameter("@APPLICATIONURL",null),
new Parameter("@RECEIVEUSERID",null),
new Parameter("@BEFOREPROCESSDATE",null),
new Parameter("@DOTASKTYPE",null),
new Parameter("@DOTASKSTATUS",null),
new Parameter("@MAILSTATUS",null),
new Parameter("@RTXSTATUS",null),
new Parameter("@APPFIELDVALUE",null),
new Parameter("@FLOWXML",null),
new Parameter("@APPXML",null),
new Parameter("@SYSTEMCODE",null),
new Parameter("@MODELCODE",null),
new Parameter("@MODELNAME",null),
new Parameter("@REMARK",null)
};
pageparm[0].ParameterValue = GetValue(Guid.NewGuid().ToString());//待办任务ID
pageparm[1].ParameterValue = GetValue(entity.COMPANYID);//公司ID
pageparm[2].ParameterValue = GetValue(entity.ORDERID);//单据ID
pageparm[3].ParameterValue = GetValue(entity.ORDERUSERID);//单据所属人ID
pageparm[4].ParameterValue = GetValue(entity.ORDERUSERNAME);//单据所属人名称
pageparm[5].ParameterValue = GetValue(entity.ORDERSTATUS);//单据状态
if (SourceValueDT != null)
{
foreach (DataRow dr in SourceValueDT.Rows)
{
if (!string.IsNullOrEmpty(dr["ColumnValue"].ToString().Trim()))
{
if (dr["ColumnName"].ToString().ToLower() == "appusername")
{
string AppUserName = dr["ColumnValue"].ToString();
pageparm[20].ParameterValue = AppUserName;//接收员工名,使用remark字段
}
}
}
}
#region 消息体
string XmlTemplete = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "\r\n" +
"<System>" + "\r\n" +
"{0}" +
"</System>";
string strMsgBody = string.Empty;
string strMsgUrl = applicationUrl;
if (drs.Count() == 0)//如果没有设置消息,则构造默认消息:请审核xxx提交的"xxxx",
{
strMsgBody = "请审核[" + submitUserName + @"]提交的[" + ModeName + "]";
pageparm[6].ParameterValue = strMsgBody;//消息体
pageparm[7].ParameterValue = ReplaceLowerValue(strMsgUrl, SourceValueDT);//应用URL
}
else
{
DataRow dr1 = drs[0];
if (dr1["MESSAGEBODY"].ToString() == "")//默认消息为空
{
if (dr1 != null)
{
ModelMsgDefine(dr1["SYSTEMCODE"].ToString(), dr1["MODELCODE"].ToString(), entity.COMPANYID, ref strMsgBody, ref strMsgUrl);
}
if (string.IsNullOrEmpty(strMsgBody))
//.........这里部分代码省略.........