📄 profit.cs
字号:
this.sqlDeleteCommand1.Connection = this.sqlConnection_Compute;
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_saleid", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "saleid", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_branchid", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "branchid", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ctime", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ctime", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_gain", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(8)), ((System.Byte)(2)), "gain", System.Data.DataRowVersion.Original, null));
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO Sale(saleid, branchid, ctime, gain) VALUES (@saleid, @branchid, @ctim" +
"e, @gain); SELECT saleid, branchid, ctime, gain FROM Sale WHERE (saleid = @salei" +
"d)";
this.sqlInsertCommand1.Connection = this.sqlConnection_Compute;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@saleid", System.Data.SqlDbType.VarChar, 10, "saleid"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@branchid", System.Data.SqlDbType.VarChar, 10, "branchid"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ctime", System.Data.SqlDbType.VarChar, 10, "ctime"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@gain", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(8)), ((System.Byte)(2)), "gain", System.Data.DataRowVersion.Current, null));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT saleid, branchid, ctime, gain FROM Sale";
this.sqlSelectCommand1.Connection = this.sqlConnection_Compute;
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE Sale SET saleid = @saleid, branchid = @branchid, ctime = @ctime, gain = @gain WHERE (saleid = @Original_saleid) AND (branchid = @Original_branchid) AND (ctime = @Original_ctime) AND (gain = @Original_gain); SELECT saleid, branchid, ctime, gain FROM Sale WHERE (saleid = @saleid)";
this.sqlUpdateCommand1.Connection = this.sqlConnection_Compute;
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@saleid", System.Data.SqlDbType.VarChar, 10, "saleid"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@branchid", System.Data.SqlDbType.VarChar, 10, "branchid"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ctime", System.Data.SqlDbType.VarChar, 10, "ctime"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@gain", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(8)), ((System.Byte)(2)), "gain", System.Data.DataRowVersion.Current, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_saleid", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "saleid", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_branchid", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "branchid", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ctime", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ctime", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_gain", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(8)), ((System.Byte)(2)), "gain", System.Data.DataRowVersion.Original, null));
//
// dataSet_Vendition
//
this.dataSet_Vendition.DataSetName = "NewDataSet";
this.dataSet_Vendition.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// sqlDataAdapter_Branch
//
this.sqlDataAdapter_Branch.DeleteCommand = this.sqlDeleteCommand2;
this.sqlDataAdapter_Branch.InsertCommand = this.sqlInsertCommand2;
this.sqlDataAdapter_Branch.SelectCommand = this.sqlSelectCommand2;
this.sqlDataAdapter_Branch.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Branch", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("branchid", "branchid"),
new System.Data.Common.DataColumnMapping("sever", "sever"),
new System.Data.Common.DataColumnMapping("db", "db"),
new System.Data.Common.DataColumnMapping("ip", "ip")})});
this.sqlDataAdapter_Branch.UpdateCommand = this.sqlUpdateCommand2;
//
// sqlDeleteCommand2
//
this.sqlDeleteCommand2.CommandText = @"DELETE FROM Branch WHERE (branchid = @Original_branchid) AND (db = @Original_db OR @Original_db IS NULL AND db IS NULL) AND (ip = @Original_ip OR @Original_ip IS NULL AND ip IS NULL) AND (sever = @Original_sever OR @Original_sever IS NULL AND sever IS NULL)";
this.sqlDeleteCommand2.Connection = this.sqlConnection_Compute;
this.sqlDeleteCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_branchid", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "branchid", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_db", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "db", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ip", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ip", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_sever", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "sever", System.Data.DataRowVersion.Original, null));
//
// sqlInsertCommand2
//
this.sqlInsertCommand2.CommandText = "INSERT INTO Branch(branchid, sever, db, ip) VALUES (@branchid, @sever, @db, @ip);" +
" SELECT branchid, sever, db, ip FROM Branch WHERE (branchid = @branchid)";
this.sqlInsertCommand2.Connection = this.sqlConnection_Compute;
this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@branchid", System.Data.SqlDbType.VarChar, 10, "branchid"));
this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@sever", System.Data.SqlDbType.VarChar, 50, "sever"));
this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@db", System.Data.SqlDbType.VarChar, 50, "db"));
this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ip", System.Data.SqlDbType.VarChar, 10, "ip"));
//
// sqlSelectCommand2
//
this.sqlSelectCommand2.CommandText = "SELECT branchid, sever, db, ip FROM Branch";
this.sqlSelectCommand2.Connection = this.sqlConnection_Compute;
//
// sqlUpdateCommand2
//
this.sqlUpdateCommand2.CommandText = @"UPDATE Branch SET branchid = @branchid, sever = @sever, db = @db, ip = @ip WHERE (branchid = @Original_branchid) AND (db = @Original_db OR @Original_db IS NULL AND db IS NULL) AND (ip = @Original_ip OR @Original_ip IS NULL AND ip IS NULL) AND (sever = @Original_sever OR @Original_sever IS NULL AND sever IS NULL); SELECT branchid, sever, db, ip FROM Branch WHERE (branchid = @branchid)";
this.sqlUpdateCommand2.Connection = this.sqlConnection_Compute;
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@branchid", System.Data.SqlDbType.VarChar, 10, "branchid"));
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@sever", System.Data.SqlDbType.VarChar, 50, "sever"));
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@db", System.Data.SqlDbType.VarChar, 50, "db"));
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ip", System.Data.SqlDbType.VarChar, 10, "ip"));
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_branchid", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "branchid", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_db", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "db", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ip", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ip", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_sever", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "sever", System.Data.DataRowVersion.Original, null));
//
// Profit
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(712, 429);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupBox3);
this.ForeColor = System.Drawing.Color.Red;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Profit";
this.Text = "业绩汇总_总部";
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataSet_Vendition)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void bExit_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void bComputeOD_Click(object sender, System.EventArgs e)
{
DateTime ctime=this.dateTimePicker1.Value;
string vcommand="select * from Sale where ctime='"+ctime.Date+"'";
DataSet branch_set=new DataSet();;
sqlDataAdapter_Branch.Fill(branch_set);
DataTable branch_table=branch_set.Tables[0];
DataRow row;
string branchid;
string ip;
double sale=0;
for(int i=1;i<branch_table.Rows.Count;i++)
{
row=branch_table.Rows[i];
branchid=(string)row["branchid"];
ip=(string)row["ip"];
//远程调用
try
{
int m=0;
string db="";
if(branchid.Trim().Equals("1"))
{
m=8085;
db="branchlww";
}
else if(branchid.Trim().Equals("2"))
{
m=8086;
db="branchyf";
}
Sale obj = (Sale)Activator.GetObject(typeof(Sale), "tcp://"+ ip.Trim() +":"+ m.ToString() +"/remotingSale");
obj.SetSQL("7B1EE60547FB453",db);
double bsale=obj.ComputeOD(ctime);
sale+=bsale;
sqlDataAdapter_Vendition.SelectCommand.CommandText="select * from Sale";
sqlDataAdapter_Vendition.Fill(dataSet_Vendition);
DataTable Vendition=dataSet_Vendition.Tables[0];
int id;
if(Vendition.Rows.Count==0)
id=1;
else
id=(int)Vendition.Rows[Vendition.Rows.Count-1][0]+1;
DataRow newrow=Vendition.NewRow();
newrow[0]=id;
newrow[1]=branchid;
newrow[2]=ctime;
newrow[3]=bsale;
Vendition.Rows.Add(newrow);
Vendition.EndInit();
sqlDataAdapter_Vendition.Update(Vendition);
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
tbGain.Text=sale.ToString();
//本地生成新汇总
}
}
private void bComputeOM_Click(object sender, System.EventArgs e)
{
DateTime ctime=this.dateTimePicker1.Value;
DateTime max=new DateTime(ctime.Year,ctime.Month,31);
DateTime min=new DateTime(ctime.Year,ctime.Month,1);
string vcommand="select * from Sale where ctime<='"+max.Date+"'and ctime>= '"+min.Date+"'";
tbGain.Text=Compute(vcommand).ToString();
}
private void bComputeOY_Click(object sender, System.EventArgs e)
{
DateTime ctime=this.dateTimePicker1.Value;
DateTime max=new DateTime(ctime.Year,12,31);
DateTime min=new DateTime(ctime.Year,1,1);
string vcommand="select * from Sale where ctime<='"+max.Date+"'and ctime>= '"+min.Date+"'";
Compute(vcommand);
}
private double Compute(string VCommand)
{
dataSet_Vendition.Clear();
double gain=0;
DataRow item;
sqlDataAdapter_Vendition.SelectCommand.CommandText=VCommand;
sqlDataAdapter_Vendition.Fill(dataSet_Vendition);
DataTable Vendition=dataSet_Vendition.Tables[0];
for(int i=0;i<Vendition.Rows.Count;i++)
{
item=Vendition.Rows[i];
gain+=Decimal.ToDouble((Decimal)item["gain"]);
}
return gain;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -