此方法用于两个不同类型Entity Framework 对象相同名称属性之间的拷贝

public class EntityHelper

{

/// <summary>

///","号分隔忽略属性

/// </summary>

/// <param name="source">源对象</param>

/// <param name="target">目标对象</param>

/// <param name="ignorePoperties"></param>

/// <returns></returns>

public static TTarget EntityCopy<TSource, TTarget>(TSource source, TTarget target, string ignorePoperties)

{

 

List<string> ignoreP = new List<string>();

if (!string.IsNullOrEmpty(ignorePoperties))

{

ignoreP = ignorePoperties.ToLower().Split(',').ToList();

}

 

ignoreP.Add("entitykey");

ignoreP.Add("entitystate");

var tFields = target.GetType().GetProperties();

var sFields = source.GetType().GetProperties();

 

foreach (var item in tFields)

{

if (!ignoreP.Contains(item.Name.ToLower()))

{

foreach (var si in sFields)

{

if (si.Name == item.Name)

{

object svalue = si.GetValue(source, null);

object tvalue = item.GetValue(target, null);

if (svalue != null && !svalue.Equals(tvalue))

{

item.SetValue(target, svalue, null);

}

}

}

}

}

return target;

 

}

 

/// <summary>

///","号分隔忽略属性

/// </summary>

/// <param name="source">源对象</param>

/// <param name="target">目标对象</param>

/// <returns></returns>

public static TTarget EntityCopy<TSource, TTarget>(TSource source, TTarget target)

{

return EntityCopy(source, target, "");

 

}

 

 

调用:

/// <summary>

///新上下级关系

/// </summary>

public int GetChagedPositionRelations()

{

var query = from pr in EISEEntities.View_Interface_PositionReport

join p in EISEEntities.View_Interface_Position on pr.PositionId equals p.PositionId

join dic in EISEEntities.View_Interface_Dictionary on p.DivisionID equals dic.DictionaryId

where DivtionFilt.IndexOf(dic.Code) != -1

&& pr.LastModifiedOn > StartTime

&& pr.LastModifiedOn < EndTime

select new { pr, p.PositionCode };

var list = query.ToList();

 

foreach (var item in list)

{

ocm_map_PositionRelation_Approval model = new ocm_map_PositionRelation_Approval();

 

//

EntityHelper.EntityCopy(item.pr, model);

model.HRPositionCode = item.PositionCode;

if (item.pr.ParentPositionId != null)

{

model.ParentPositionCode = (from pp in EISEEntities.View_Interface_Position

where pp.PositionId == item.pr.ParentPositionId

select pp.PositionCode).FirstOrDefault();

 

}

model.PositionRelationApprovalId = Guid.NewGuid();

model.ApprovalStatus = (int)EISSyncApprovalStatus.Stored;

SDMEntities.ocm_map_PositionRelation_Approval.AddObject(model);

}

SDMEntities.SaveChanges(SaveOptions.AcceptAllChangesAfterSave);

return list.Count;

}

 

表结构:

posted @ 2012-05-15 10:32 丘比特 阅读(20) 评论(0) 编辑

 

 

 1     internal class Node
 2     {
 3         protected Node m_next;
 4         public Node(Node next)
 5         {
 6             m_next = next;
 7         }
 8 
 9     }
10     internal class TypedNode<T> : Node
11     {
12         public T m_data;
13         public TypedNode(T data)
14             : this(data, null)
15         {
16 
17         }
18         public TypedNode(T data, Node next)
19             : base(next)
20         {
21             m_data = data;
22         }
23         public override string ToString()
24         {
25             return m_data.ToString() + ((m_next == null ? null : m_next.ToString()));
26         }
27     }

 

测试代码:

            Node head = new TypedNode<Char>('.');
            head = new TypedNode<DateTime>(DateTime.Now, head);
            head = new TypedNode<string>(" Today is ", head);
            Console.WriteLine(head.ToString());

 

Codes from <CLR via C# 3>

posted @ 2012-05-10 23:51 丘比特 阅读(5) 评论(0) 编辑

一个经典的创建职位申请/审批流程

虽然只是对现有系统的扩充,但是总觉得这样写的代码不够美....但又不知道更好该怎么设计

     protected void SetFormView(Enumerator.ApprovalResult approvalResult)
        {

            switch (approvalResult)
            {
                case Enumerator.ApprovalResult.Pending:

                    SelectDictionaryItemsCity.Enabled = false;
                    SelectDictionaryItemsProvince.Enabled = false;
                    if (IsHR)
                    {

                        //待审核状态

                        trHRInfo.Visible = true;
                        PnAppraval.Visible = true;
                        trApprovalRemark.Visible = true;
                        txtRemark.Enabled = btnSave.Visible = PnSubmit.Visible = false;
                    }
                    else
                    {
                        //非HR
                        trHRInfo.Visible = false;
                        trApprovalRemark.Visible = false;
                        PnAppraval.Visible = txtRemark.Enabled = btnSave.Visible = PnSubmit.Visible = false;
                    }
                    break;
                case Enumerator.ApprovalResult.Reject:

                    SelectDictionaryItemsCity.Enabled = false;
                    SelectDictionaryItemsProvince.Enabled = false;
                    //已拒绝状态
                    trHRInfo.Visible = false;
                    trApprovalRemark.Visible = true;
                    txtApprovalRemark.Enabled = false;
                    PnAppraval.Visible = txtRemark.Enabled = btnSave.Visible = PnSubmit.Visible = false;
                    break;
                case Enumerator.ApprovalResult.Return:
                    //待重新提交状态 

                    if (IsHR)
                    {
                        trHRInfo.Visible = false;
                        trApprovalRemark.Visible = true;
                        txtApprovalRemark.Enabled = false;
                        PnAppraval.Visible = false;
                        txtRemark.Enabled = btnSave.Visible = PnSubmit.Visible = false;
                    }
                    else
                    {
                        trHRInfo.Visible = false;
                        trApprovalRemark.Visible = true;
                        txtApprovalRemark.Enabled = false;
                        PnAppraval.Visible = false;
                        txtRemark.Enabled = btnSave.Visible = PnSubmit.Visible = true;
                    }
                    break;
                case Enumerator.ApprovalResult.Waiting:
                    //待提交状态 
                    trHRInfo.Visible = false;
                    trApprovalRemark.Visible = false;
                    PnAppraval.Visible = false;
                    txtRemark.Enabled = btnSave.Visible = PnSubmit.Visible = true;
                    break;
                case Enumerator.ApprovalResult.Approved:
                    SelectDictionaryItemsCity.Enabled = false;
                    SelectDictionaryItemsProvince.Enabled = false;
                    //已拒绝状态
                    trHRInfo.Visible = false;
                    trApprovalRemark.Visible = true;
                    txtApprovalRemark.Enabled = false;
                    PnAppraval.Visible = txtRemark.Enabled = btnSave.Visible = PnSubmit.Visible = false;
                    break;
                default:
                    //默认状态
                    trHRInfo.Visible = false;
                    trApprovalRemark.Visible = false;
                    PnAppraval.Visible = false;
                    txtRemark.Enabled = btnSave.Visible = PnSubmit.Visible = true;
                    break;
            }
        }
   

 

 

 

 

创建职位申请

经理申请流程:

  1. 列表

    只能看到自己提交的单子

 

 

  1. 新建/保存

    保存后效果在这里看是一样的,只是打开方式和职位信息后面有(已保存)

  1. 查看已提交

  1. 查看已通过

  1. 查看已退回

  1. 查看已拒绝

HR审批流程:

  1. 列表

HR 不能删除任何单据

列表显示所有已提交状态的单据和 当前登录人已审核过的单据

  1. 创建

创建功能待定

 

  1. 审批单据

  1. 查看已通过/查看已退回/查看已拒绝

可查看 不可编辑

posted @ 2012-05-10 11:26 丘比特 阅读(4) 评论(0) 编辑
  1. 打开"开始"菜单,选择"Control Panel"。

  1. 在打开的面板中选择"Administrative Tools"。

  1. 在打开的应用列表中选择"Component Services"。

  1. 依次选择"Computers","My Computer","DCOM Config","Microsoft Excel Application"

  1. 右键单击"Microsoft Excel Application",在弹出的菜单中选择"Properties"。

  1. 在弹出的功能面板中,选择"Security"选项卡,修改"Launch and Activation Permissions"和"Access Permissions"为"Customize",并添加用户"NETWORK SERVICE",赋予如下图示的权限:

  1. 在弹出的功能面板中,选择"Identity"选项卡,选中选项"This user",指定用户为"administrator"并输入账号密码。

  1. 权限设置完成。
posted @ 2012-05-09 14:12 丘比特 阅读(2) 评论(0) 编辑

就像这样:

<a onclick="window.open(this.href,'page title','location=0,status=0,menubar=0,scrollbars=0,toolbar=0,width=550,height=740');return false" href="javascript:void(0)" target="_blank">POP UP</a>

 

去掉Page title 中的空格 问题解决

 

 

 

posted @ 2012-05-09 14:00 丘比特 阅读(5) 评论(0) 编辑

错误解决:未能找到类型集或命名空间名称 "xxxx" (是否缺少using 指令或引用?)

 

 

 

 

1.检查是否添加引用..

2.检查生成依赖

3.检查目标框架.

  我的错误出在这里

 

 

posted @ 2012-03-05 13:54 丘比特 阅读(262) 评论(0) 编辑

cmd 进入ASP.NET 4.0安装目录 运行 aspnet_regiis -i  向IIS注册

 

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>aspnet_regiis -i
开始安装 ASP.NET (4.0.30319)。
.......................
ASP.NET (4.0.30319)安装完毕。

之后出现

 

由于 Web 服务器上的“ISAPI 和 CGI 限制”列表设置,无法提供您请求的页面。

1.选择 IIS 根节点 (就是服务器名称那里)

2.主窗体中间 "ISAPI和cgi限制"

3.允许 描述为: ASP.NET v4.0.30319 (32-bit) 的两项

 

posted @ 2012-01-06 10:22 丘比特 阅读(101) 评论(0) 编辑
摘要: 使用 sqlcmd 运行 Transact-SQL 脚本文件。打开命令提示符窗口。在命令提示符窗口中,键入 sqlcmd -S myServer\instanceName -i C:\myScript.sql -o C:\EmpAdds.txt按 Enter 键。命令提示符窗口中不会返回任何输出,而是将输出发送到 EmpAdds.txt 文件。您可以打开 EmpAdds.txt 文件来查看此输出操作。使用 sqlcmd 运行 Transact-SQL 脚本文件阅读全文
posted @ 2011-12-21 11:16 丘比特 阅读(38) 评论(0) 编辑
摘要: 无法启动服务.System.BadImageFormatException: 不是有效的 Win32 应用程序.OK 看描红位置。。。使用64位系统的童鞋应该知道怎么回事了吧?Visual Studio 64位应用程序编译Visual Studio的编译选项 build下的platform有X64、Any CPU和x86。X86表示只能在32位环境下运行,X64表示只能在64位环境下运行,Any CPU表示你的程序集可以根据环境变化适应32位还是64位,但是如果你的程序集依赖于一个x86选项编译的程序集,哪么你的程序集只能选择X86进行编译,而不能选择Any CPU编译,如果使用Any CPU阅读全文
posted @ 2011-11-04 14:22 丘比特 阅读(550) 评论(0) 编辑
摘要: 索引原理中小企业MIS系统的管理基本上由两大部份组成,一是前台的可视化操作,二是后台的数据库管理。网管对前台的管理和维护工作包括保障网络链路通畅、处理MIS终端的突发事件以及对操作员的管理、培训等,这是网管们日常做得最多、最辛苦的功课;然而MIS系统架构中同等重要的针对数据库的管理、维护和优化工作,现实中似乎并没有得到网管朋友的足够重视,看起来这都是程序员的事,事实上,一个网管如果能在MIS设计期间就数据表的规范化、表索引优化、容量设计、事务处理等诸多方面与程序员进行卓有成效的沟通和协作,那么日常的前台管理工作将会变得大为轻松,因为在某种意义上,数据库管理系统就相当于操作系统,在系统中占有同样阅读全文
posted @ 2011-06-04 23:58 丘比特 阅读(45) 评论(0) 编辑
E-Zone