📄 formpos.cs
字号:
catch
{
MessageBox.Show("对不起你您输入的金币的格式不正确。请从新输入");
this.textBox4.Focus();
textBox4.Clear();
}
}
//结帐按钮
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
shijian();
//if (textBox4.Text != "")
//{
//try
//{
// if (Convert.ToDecimal(textBox4.Text) >= Convert.ToDecimal(textBox3.Text))
// {
// for (int j = 0; j < dataGridView1.Rows.Count - 1; j++)
// {
// a = Convert.ToDecimal(textBox4.Text);
// b = Convert.ToDecimal(textBox3.Text);
// h = a - b;
// textBox5.Text = Convert.ToString(h);
// }
// h = 0;
// }
// else
// {
// a = Convert.ToDecimal(textBox4.Text);
// b = Convert.ToDecimal(textBox3.Text);
// h = b - a;
// textBox5.Text = Convert.ToString(h);
// MessageBox.Show("您付的钱不够还差" + Convert.ToString(h) + "元:请从新输入");
// textBox4.Text = "";
// textBox5.Text = "";
// this.textBox5.Focus();
// return;
// }
//}
//catch
//{
// MessageBox.Show("对不起!您输入信息!");
// this.textBox1.Focus();
// textBox2.Text = "";
// textBox1.Clear();
//}
//}
if (textBox7.Text == "1")
{
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
decimal u = 0.85M;
//根据数据集查找字段的值,将两个值相乘
k = k + (Convert.ToDecimal(dataGridView1.Rows[i].Cells[2].Value) * Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value));
//相乘的值付给应收金额
textBox3.Text = Convert.ToString(k * u).Substring(0,(Convert.ToString(k * u).IndexOf('.')+3));
}
k = 0;
}
if (textBox7.Text == "2")
{
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
decimal d = 0.90M;
//根据数据集查找字段的值,将两个值相乘
k = k + (Convert.ToDecimal(dataGridView1.Rows[i].Cells[2].Value) * Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value));
//相乘的值付给应收金额
textBox3.Text = Convert.ToString(k * d).Substring(0, (Convert.ToString(k * d).IndexOf('.') + 3));
}
k = 0;
}
if (textBox7.Text == "3")
{
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
decimal n = 0.95M;
//根据数据集查找字段的值,将两个值相乘
k = k + (Convert.ToDecimal(dataGridView1.Rows[i].Cells[2].Value) * Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value));
//相乘的值付给应收金额
textBox3.Text = Convert.ToString(k * n).Substring(0, (Convert.ToString(k * n).IndexOf('.') + 3));
}
k = 0;
}
if (dataGridView1.Rows.Count > 0)
{ //-------------------------------------------向总表里插数据
//string str = "insert into xszBiao(xsDjID,xsSum,xsSszje,hyID) values('" + label12.Text + "','" +textBox2.Text + "','" + Convert.ToDecimal(textBox4.Text) + "','" + DateTime.Now.Year.ToString() + "年" + DateTime.Now.Month.ToString() + "月" + DateTime.Now.Day.ToString() + "日" + "')";
//int n, m;
//n = Convert.ToInt32(textBox2.Text);
//m = n + Convert.ToInt32(dataGridView1.Rows[0].Cells[5].Value);
for (int g = 0; g < dataGridView1.Rows.Count - 1; g++)
{
m=m+ Convert.ToInt32(dataGridView1.Rows[g].Cells[5].Value);
}
try
{
myCom.CommandText = "insert into xszBiao(xsDjID,xsSum,xsSszje,hyID) values('" + label12.Text + "','" + m + "','" + Convert.ToDecimal(textBox3.Text) + "','10')";
myCom.ExecuteNonQuery();
m = 0;
for (int z = 0; z < dataGridView1.Rows.Count - 1; z++)
{
myCom.CommandText = "insert into xsxqBiao(xsDjID,xsID,spID,jhDjID,spSl,spSjdj,spZje,spSpXsJe,beiZhu) values ('" + label1.Text + "','" + label12.Text + "','" + Convert.ToInt32(dataGridView1.Rows[z].Cells[0].Value) + "','" + label12.Text + "','" + Convert.ToInt32(dataGridView1.Rows[z].Cells[5].Value) + "','" + Convert.ToInt32(dataGridView1.Rows[z].Cells[2].Value) + "','" + textBox3.Text + "','" + Convert.ToInt32(dataGridView1.Rows[z].Cells[2].Value) + "','" + textBox1.Text + "')";
myCom.ExecuteNonQuery();
}
clear();
ds.Clear();
MessageBox.Show("本次交易完成!谢谢您的光临!");
}
catch
{ }
//ff.SqlZhiXing(str);
//------------------------------------------------向销售详情表里插数据
//for (int z = 0; z < dataGridView1.Rows.Count - 1; z++)
//{
// ff.SqlZhiXing(st);
//}
//for (int j = 0; j < dataGridView1.Rows.Count - 1; j++)//修改卖场库存数量
//{
// string ww = "update 卖场库存表 set 卖场库存=卖场库存-'" + dataGridView1.Rows[j].Cells[3].Value + "' where 商品编号='" + dataGridView1.Rows[j].Cells[1].Value + "'";
// ff.SqlZhiXing(ww);
//}
}
}
else
{
MessageBox.Show("请输入商品信息!");
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
textBox6.Enabled = !textBox6.Enabled;
textBox7.Enabled = !textBox7.Enabled;
textBox6.Text = "";
textBox7.Text = "";
this.textBox6.Focus();
}
private void button4_Click(object sender, EventArgs e)
{
//textBox3.Text = "";
//textBox4.Text = "";
//textBox5.Text = "";
clear();
}
private void clear()
{
this.textBox1.Text = "";
this.textBox2.Text = "";
this.textBox3.Text = "";
this.textBox4.Text = "";
this.textBox5.Text = "";
}
private void button5_Click(object sender, EventArgs e)
{
ds.Clear();
clear();
textBox7.Text = "";
textBox6.Enabled = !textBox6.Enabled;
textBox7.Enabled = !textBox7.Enabled;
//Form3_Load(sender, e);
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
// try
//{
// if (Convert.ToDecimal(textBox4.Text) >= Convert.ToDecimal(textBox3.Text))
// {
// for (int j = 0; j < dataGridView1.Rows.Count - 1; j++)
// {
// a = Convert.ToDecimal(textBox4.Text);
// b = Convert.ToDecimal(textBox3.Text);
// h = a - b;
// textBox5.Text = Convert.ToString(h);
// }
// h = 0;
// }
// else
// {
// a = Convert.ToDecimal(textBox4.Text);
// b = Convert.ToDecimal(textBox3.Text);
// h = b - a;
// textBox5.Text = Convert.ToString(h);
// MessageBox.Show("您付的钱不够还差" + Convert.ToString(h) + "元:请从新输入");
// textBox4.Text = "";
// textBox5.Text = "";
// this.textBox5.Focus();
// return;
// }
//}
//catch
//{
// //MessageBox.Show("对不起!您输入信息!");
// //this.textBox1.Focus();
// //textBox2.Text = "";
// //textBox1.Clear();
//}
}
private void textBox4_Leave(object sender, EventArgs e)
{
try
{
if (Convert.ToDecimal(textBox4.Text) >= Convert.ToDecimal(textBox3.Text))
{
for (int j = 0; j < dataGridView1.Rows.Count - 1; j++)
{
a = Convert.ToDecimal(textBox4.Text);
b = Convert.ToDecimal(textBox3.Text);
h = a - b;
textBox5.Text = Convert.ToString(h);
}
h = 0;
}
else
{
a = Convert.ToDecimal(textBox4.Text);
b = Convert.ToDecimal(textBox3.Text);
h = b - a;
textBox5.Text = Convert.ToString(h);
MessageBox.Show("您付的钱不够还差" + Convert.ToString(h) + "元:请从新输入");
textBox4.Text = "";
textBox5.Text = "";
this.textBox5.Focus();
return;
}
}
catch
{
//MessageBox.Show("对不起!您输入信息!");
//this.textBox1.Focus();
//textBox2.Text = "";
//textBox1.Clear();
}
}
private void button6_Click(object sender, EventArgs e)
{
if (textBox7.Text == "1")
{
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
decimal u = 0.85M;
//根据数据集查找字段的值,将两个值相乘
k = k + (Convert.ToDecimal(dataGridView1.Rows[i].Cells[2].Value) * Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value));
//相乘的值付给应收金额
textBox3.Text = Convert.ToString(k * u).Substring(0, (Convert.ToString(k * u).IndexOf('.') + 3));
}
k = 0;
}
if (textBox7.Text == "2")
{
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
decimal d = 0.90M;
//根据数据集查找字段的值,将两个值相乘
k = k + (Convert.ToDecimal(dataGridView1.Rows[i].Cells[2].Value) * Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value));
//相乘的值付给应收金额
textBox3.Text = Convert.ToString(k * d).Substring(0, (Convert.ToString(k * d).IndexOf('.') + 3));
}
k = 0;
}
if (textBox7.Text == "3")
{
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
decimal n = 0.95M;
//根据数据集查找字段的值,将两个值相乘
k = k + (Convert.ToDecimal(dataGridView1.Rows[i].Cells[2].Value) * Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value));
//相乘的值付给应收金额
textBox3.Text = Convert.ToString(k * n).Substring(0, (Convert.ToString(k * n).IndexOf('.') + 3));
}
k = 0;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -