求帮忙,解释C#部分代码
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace yaopinguanli.sale
{
public partial class 销售 : Form
{
public 销售()
{
InitializeComponent();
}
private void xiaoshou_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt = ClassInfo.DataBase.sel("select * from M_saleListSum");
int b;
b = dt.Rows.Count + 1;
txtsalecode.Text = "s00" + b.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
if (txtCustomname.Text == string.Empty || txtEname.Text == string.Empty)
{
MessageBox.Show("经办人和客户名称不能为空!", "错误提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
Hashtable sqls = new Hashtable();
for (int i = 0; i < salelistView.RowCount - 1; i++)
{
sqls.Add(2 + i, "insert into M_saleList values('" + txtsalecode.Text.Trim() + "','" + salelistView.Rows[i].Cells[0].Value.ToString() + "','" + salelistView[1, i].Value.ToString() + "','" + salelistView.Rows[i].Cells[2].Value.ToString() + "','" + salelistView.Rows[i].Cells[3].Value.ToString() + "','" + salelistView.Rows[i].Cells[4].Value.ToString() + "','" + salelistView.Rows[i].Cells[5].Value.ToString() + "')");
}
sqls.Add(1, "insert into M_saleListSum values('" + txtsalecode.Text.Trim() + "','" + txtEname.Text.Trim() + "','" + txtS_time.Text.Trim() + "','" + txtCustomname.Text.Trim() + "','" + txtS_sum.Text.Trim() + "','" + txtS_Ypay.Text.Trim() + "','" + txtS_spay.Text.Trim() + "','" + txt_S_chae.Text.Trim() + "')");
//if (db.DoTrans.DoManyTran(sqls))
if (ClassInfo.DataBase.Domanytran(sqls))
MessageBox.Show("保存成功!");
else MessageBox.Show("保存失败!", "错误提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);// 总是保存失败,咋回事,是代码问题吗?求高手赐教!
}
}
private void label10_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
yaopinguanli.储存表.handed selectedHD;
selectedHD = new yaopinguanli.储存表.handed();
selectedHD.sl = this;
selectedHD.selected = "sale";
selectedHD.ShowDialog();
}
private void button4_Click(object sender, EventArgs e)
{
yaopinguanli.储存表.customed selectedCN;
selectedCN = new yaopinguanli.储存表.customed(this);
selectedCN.ShowDialog();
}
private void salelistView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void salelistView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
yaopinguanli.储存表.yaopin selectYP = new yaopinguanli.储存表.yaopin(this);
selectYP.ShowDialog();
}
private void txtS_Ypay_TextChanged(object sender, EventArgs e)
{
}
private void salelistView_CellStateChanged(object sender, DataGridViewCellStateChangedEventArgs e)
{
try
{
float s_sum = 0;//总数量
float Y_money = 0;//应收金额
for (int n = 0; n <= salelistView.RowCount; n++)
{
s_sum = s_sum + Convert.ToSingle(salelistView[4, n].Value.ToString());
Y_money = Y_money + Convert.ToSingle(salelistView[5, n].Value.ToString());
txtS_Ypay.Text = Y_money.ToString();
txtS_sum.Text = s_sum.ToString();
}
}
catch { }
}
private void salelistView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 3)
{
try
{
float M_sum;//金额
M_sum = Convert.ToSingle(salelistView[3, e.RowIndex].Value.ToString()) * Convert.ToSingle(salelistView[4, e.RowIndex].Value.ToString());
salelistView[5, e.RowIndex].Value = M_sum.ToString();
}
catch { }
}
if (e.ColumnIndex == 4)
{
try
{
float M_sum;//金额
M_sum = Convert.ToSingle(salelistView[3, e.RowIndex].Value.ToString()) * Convert.ToSingle(salelistView[4, e.RowIndex].Value.ToString());
salelistView[5, e.RowIndex].Value = M_sum.ToString();
}
catch { }
}
}
private void txtS_spay_TextChanged(object sender, EventArgs e)
{
try
{
txt_S_chae.Text = Convert.ToString(Convert.ToSingle(txtS_spay.Text) - Convert.ToSingle(txtS_Ypay.Text));
}
catch { }
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void label2_Click(object sender, EventArgs e)
{
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
}
}