transfergoods.cs
来自「分布式数据库系统的分系统」· CS 代码 · 共 76 行
CS
76 行
using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace RemotingClass
{
/// <summary>
/// TransferGoods 的摘要说明。
/// </summary>
public class TransferGoods: MarshalByRefObject
{
public SqlConnection SqlConn;
public TransferGoods()
{
//
// TODO: 在此处添加构造函数逻辑
//
// string source="server=7B94EC184AC9445;"+"integrated security=SSPI;"+"database=branchyf";
// SqlConn=new SqlConnection(source);
}
public void SetSQL(string sqlid,string tableid)
{
string connectString="workstation id="+sqlid+";packet size=4096;integrated security=SSPI;initial catalog="+tableid+";persist security info=False";
SqlConn=new SqlConnection(connectString);
//MessageBox.Show("SetSql()!");
return;
}
public void SubGoods(float number,int commid)
{
//MessageBox.Show("SubGoods()!");
string strComm="";
string commids=commid.ToString();
string numbers=number.ToString();
DataSet dset_Goods=new DataSet();
SqlDataAdapter sqldpt_Goods=new SqlDataAdapter("select stocks from Commodity where commid='"+commids+"'",SqlConn);
sqldpt_Goods.Fill(dset_Goods);
SqlCommandBuilder cb = new SqlCommandBuilder(sqldpt_Goods);
DataTable Sgoods=dset_Goods.Tables[0];
if(Sgoods.Rows.Count >0)
{
string ystocks=Sgoods.Rows[0]["stocks"].ToString();
float nstocks=float.Parse(ystocks);
float newstocks=nstocks-number;
if(newstocks>=0)
{
string snewstocks=newstocks.ToString();
strComm="update Commodity set stocks='"+snewstocks+"' where commid='"+commids+"'";
//Sgoods.Rows[0]["stocks"]=float.Parse(snewstocks);
//cb.GetUpdateCommand();
//sqldpt_Goods.Update(Sgoods);
SqlConn.Open ();
SqlCommand SqlComm=new SqlCommand (strComm,this.SqlConn);
SqlComm.ExecuteNonQuery();
MessageBox.Show("对方仓库库存量已更新!调货成功!");
strComm="";
}
else
{
MessageBox.Show("Sorry!对方仓库库存的此产品数量已经不够!");
return;
}
}
else
MessageBox.Show("Sorry!对方仓库中没有此产品!");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?