static public DataSet DecompressDS(byte[] byt)//對數據集進行反序列化並解壓縮
{
if (byt != null)
{
DataSet DS = new DataSet();
MemoryStream ms = new MemoryStream(byt);
C1ZStreamReader CR = new C1ZStreamReader(ms);
IFormatter BF = new BinaryFormatter();
object OB = BF.Deserialize(CR);
DS = (DataSet)OB;
return DS;
}
else
return null;
}
static public byte[] SerializationDataset(DataSet dsDataSet)//對數據集進行序列化並壓縮
{
dsDataSet.RemotingFormat = SerializationFormat.Binary;
MemoryStream MS = new MemoryStream();
IFormatter BF = new BinaryFormatter();
MS.Position = 0;
C1ZStreamWriter CZ = new C1ZStreamWriter(MS);
BF.Serialize(CZ, dsDataSet);
Byte[] B = MS.ToArray();
return B;
}
//查询
private void btnSelect_Click(object sender, EventArgs e)
{
Form w = new waiting();
w.Show();
dgvVip.DataSource=null;
dsVIP.Clear();
//dsZGFY = BASEINFO.DecompressDS(zgfy.Query_ZGFY(GetWhere()));
dsVIP=BASEINFO.DecompressDS(VIP.Query_VIP(GetWhere()));
try
{
if (dsVIP.Tables[0].Rows.Count > 0)
{
BindingDgv();
bdsVIP.MoveFirst();
}
else
{
w.Hide();
BindingDgv();
MessageBox.Show("未查詢到符合條件的相關數據!");
}
}
finally
{
w.Close();
}
SetToolsBtn();
//if (!RQ1.Checked)
//{
// MessageBox.Show("起始日期不能為空", "溫馨提示");
// return;
//}
}
//保存
if (pos.Update_VIP(BASEINFO.SerializationDataset(dsFK.GetChanges()), " "))
{
dsFK.AcceptChanges();
MessageBox.Show("保存成功!", "溫馨提示");
this.Close();
}