表数据:
28
2012
07
26
2012
07
winform将含有超过两列的DataTable绑定到combobox并有"请选择"或"全部"选择项
.Net winform:
#region 显示多列DataTable到combobox /// <summary> /// 显示多列DataTable到combobox /// </summary> /// <param name="dataTable">含有超过两列的DataTable</param> /// <param name="comboBox">combobox控件名</param> /// <param name="TextColumn">显示的text对应的列</param> /// <param name="ValueColumn">value值对应的列</param> /// <param name="isNeedShowEmpty">是否显示‘请选择’</param> /// <param name="isNeedShowAll">是否显示‘全部’</param> public static void ToDataTableCombobox(DataTable dataTable, ComboBox comboBox, string TextColumn, string ValueColumn, bool isNeedShowEmpty, bool isNeedShowAll) { if (dataTable == null || comboBox == null || dataTable.Columns.Count == 0) { return; } DataTable dtnew = new DataTable(); dtnew.Columns.Add("text"); dtnew.Columns.Add("value");
25
2012
07
winForm开发问题,vs的bug,Datagridview始终不能编辑!
如果更改Datagridview启用编辑为不选中
22
2012
07
c#利用反射Assembly 对类和成员属性进行操作
protected static void test() { //获取程序集 Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();//Assembly.LoadFrom("test.dll"); //获取模块 Module[] modules = assembly.GetModules(); foreach (Module module in modules) { Console.WriteLine("module name:" + module.Name); } //获取类 Type type = assembly.GetType("Reflect_test.PurchaseOrderHeadManageModel", true, true); //命名空间名称 + 类名 //创建类的实例 object obj = Activator.CreateInstance(type, true);
19
2012
07
对Remoting进行封装,方便使用
using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Runtime.Remoting.Channels.Http; using System.Runtime.Remoting.Channels; using System.Xml; using System.Runtime.Remoting; using System.Collections; namespace Tools { /// <summary> /// Remote自定义操作类,更方便使用 /// </summary> public class RemoteHelper { /// <summary> /// 服务端注册的端口信息 /// </summary> public static IDictionary ServerHttpProp = new Hashtable(); /// <summary> /// 客户端连接服务端的端口 /// </summary> public static int ClientToServerPort = 8888; /// <summary> /// 服务端的http地址 /// </summary> private string url = ""; #region 单个实例 Instance private static readonly RemoteHelper instance = new RemoteHelper(); /// <summary> /// 单个实例 Instance /// </summary> public static RemoteHelper Instance { get { return instance; } } #endregion
19
2012
07
存储过程模拟加锁解锁
-- 获取锁
ALTER procedure [dbo].[pro_get_sys_ordr_lock_info](
@ORDR_HEAD_SEQ 编号,
@ORDR_TYP_CD VARCHAR(20)
)as
begin
19
2012
07
将DataGridViewRows转换为DataTable数据
.Net WinForm代码:
/// <summary> /// 将DataGridViewRows转换为DataTable数据 /// </summary> /// <param name="Listrows">DataGridView的行集合</param> /// <param name="dtSource">源数据表</param> /// <param name="colum">映射关系</param> /// <param name="dtDestination">目的数据表</param> /// <returns>返回新的DataTable</returns> public static DataTable Getdatatable(DataGridViewRowCollection Listrows, DataTable dtSource, string[,] colum, DataTable dtDestination) { // string[,] colum = { { "id1", "id2" }, { "name1", "name2" } }; //colum是源DataGridViewRow到目标DataRow的映射关系 DataTable dtNew = dtSource.Clone();//复制表结构 foreach (DataGridViewRow dgvr in Listrows) { DataRow dataRow = (dgvr.DataBoundItem as DataRowView).Row; //转换成数据行DataRow dtNew.ImportRow(dataRow); //添加DataRow到DataTable } string[] copy = new string[colum.Length / 2]; for (int i = 0; i < colum.Length / 2; i++) { copy[i] = colum[i, 0]; //获取源数据要的列 } DataTable dtNew2 = dtNew.DefaultView.ToTable(false, copy);//复制源表结构和数据,并只保留copy数据中的列 if (dtDestination != null) { for (int j = 0; j < dtNew2.Rows.Count; j++) { DataRow row = dtDestination.NewRow(); for (int f = 0; f < colum.Length / 2; f++) { row[colum[f, 1]] = dtNew2.Rows[j][colum[f, 0]]; //将源表中每行的各列数据复制到对应的目的表的行中 } dtDestination.Rows.Add(row); //添加到目的表 } } return dtDestination; }
18
2012
07
存储过程用例--新增、修改、删除数据
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
/*****************************************************
** PROCEDURE : pro_set_so_cust_info
** DECRIPTION: 维护客户资料信息
18
2012
07
存储过程样例--获取数据
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
/*****************************************************
** PROCEDURE : pro_get_so_cust_list
** DECRIPTION: 获取客户列表
18
2012
07
mssql存储过程样例--判断是否存在
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
/*****************************************************
** PROCEDURE : pro_is_so_cust_nam_show_repeat
** DECRIPTION: 判断客户用户和或显示名称是否重复