- 博客(1)
- 资源 (2)
- 收藏
- 关注
原创 QQ 新浪微博 淘宝账号 第三方登陆 (C#)
QQ登陆 首先导入QQ脚本 data-redirecturi 接受返回数据页,appid就是获取的appkey 页面写入 QC.Login({ btnId: "qqLoginBtn" //插入按钮的节点id }); 接受数据处理
2014-03-26 10:42:55 1904
数据库实体生成器(完全开源)
private void btnCreateEntity_Click(object sender, EventArgs e)
{
HeaderOfEntity HeaderOfEntity = new HeaderOfEntity();
DataTable dt = new DataTable();
#region 实例化一个实体,并为这个实体类赋值
//实体类名不能为空
if (txtClassName.Text == "")
{
MessageBox.Show("类名不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
else
{
HeaderOfEntity.ClassName = txtClassName.Text.Trim();
}
//实体类的说明
if (txtClassExplain.Text != "")
{
HeaderOfEntity.ClassExplain = txtClassExplain.Text.Trim();
}
else
{
HeaderOfEntity.ClassExplain = "";
}
//实体类的作者
if (txtAuthor.Text != "")
{
HeaderOfEntity.ClassAuthor = txtAuthor.Text.Trim();
}
else
{
HeaderOfEntity.ClassAuthor = "";
}
//类的命名空间
if (txtNamespace.Text != "")
{
HeaderOfEntity.NameSpace = txtNamespace.Text.Trim();
}
else
{
HeaderOfEntity.NameSpace = "";
}
#endregion
#region 将dataGridView中的数据复制出来,复制到DataTable中,做为参数
//添加列
for (int i = 0; i < dgvAttribute.Columns.Count; i++)
{
dt.Columns.Add(dgvAttribute.Columns[i].Name);
}
//添加行
for (int j = 0; j < dgvAttribute.Rows.Count; j++)
{
DataRow dr = dt.NewRow();
for (int k = 0; k < dgvAttribute.Columns.Count; k++)
{
dr[k] = dgvAttribute.Rows[j].Cells[k].Value;
}
dt.Rows.Add(dr);
}
#endregion
string strFileName = "\\" + txtClassName.Text + ".cs";
//实例化一个接口对象
IWriteEntity writeEntity = new WriteEntity();
string strPath = "../../CreateClass";
FileStream fs;
if (!File.Exists(strPath + strFileName))
{
fs = new FileStream(strPath + strFileName, FileMode.Create,FileAccess.Write);
}
else
{
fs = new FileStream(strPath + strFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
}
if (writeEntity.Write(fs, dt, HeaderOfEntity) == true)
{
MessageBox.Show("写入文件成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("写入文件失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
2014-03-26
RSA加密解密(C#)实现
RSA加密解密C#实现调用实例
public string RSAEncrypt(string xmlPublicKey, string m_strEncryptString)
{
try
{
byte[] PlainTextBArray;
byte[] CypherTextBArray;
string Result;
System.Security.Cryptography.RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(xmlPublicKey);
PlainTextBArray = (new UnicodeEncoding()).GetBytes(m_strEncryptString);
CypherTextBArray = rsa.Encrypt(PlainTextBArray, false);
Result = Convert.ToBase64String(CypherTextBArray);
return Result;
}
catch (Exception ex)
{
throw ex;
}
}
//RSA的加密函数
public string RSAEncrypt(string xmlPublicKey, byte[] EncryptString)
{
try
{
byte[] CypherTextBArray;
string Result;
System.Security.Cryptography.RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(xmlPublicKey);
CypherTextBArray = rsa.Encrypt(EncryptString, false);
Result = Convert.ToBase64String(CypherTextBArray);
return Result;
}
catch (Exception ex)
{
throw ex;
}
}
2009-02-04
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人