📄 sms_goodsin.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace FORU_SMS_
{
public partial class SMS_GoodsIn : Form
{
BaseClass.DataClass Dclass = new FORU_SMS_.BaseClass.DataClass();
BaseClass.AddGoods AGood = new FORU_SMS_.BaseClass.AddGoods();
public SMS_GoodsIn()
{
InitializeComponent();
}
private void SMS_GoodsIn_Load(object sender, EventArgs e)
{
dgvISManage.Controls.Add(hScrollBar1);
Dclass.BindComboBox("select StoreName from SMS_Store", "SMS_Store", "StoreName", cboxSName);
Dclass.BindComboBox("select SupName from SMS_Sup", "SMS_Sup", "SupName", cboxPName);
DataSet ds = Dclass.GetDataSet("select * from V_Goods", "V_Goods");
dgvISManage.DataSource = ds.Tables[0];
this.txtISGID.Text = System.DateTime.Parse(Convert.ToString(System.DateTime.Now)).ToString("yyyyMMddhhmmss");
}
private void btnAdd_Click(object sender, EventArgs e)
{
if (this.txtISGID.Text == "")
{
MessageBox.Show("产品编号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtISGID.Focus();
}
else if (this.txtISGName.Text == "")
{
MessageBox.Show("产品名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtISGName.Focus();
}
else if (this.txtISGNum.Text == "")
{
MessageBox.Show("产品数量不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtISGNum.Focus();
}
else if (this.txtGIPrice.Text == "")
{
MessageBox.Show("产品单价不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtGIPrice.Focus();
}
else if (this.txtHPeople.Text == "")
{
MessageBox.Show("经手人不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtHPeople.Focus();
}
else
{
AGood._GoodsID = this.txtISGID.Text.ToString();
AGood._GoodsName = this.txtISGName.Text.Trim();
AGood._SupName = this.cboxSName.Text.Trim(); //仓库
AGood._SpecName = this.txtGSpec.Text.Trim(); //货物规格
AGood._StoreName = this.cboxPName.Text.Trim(); //供应商
AGood._UnitName = this.cboxGUnit.Text.Trim();
AGood._GoodsNum = int.Parse(this.txtISGNum.Text.Trim());
AGood._GoodsPrice = double.Parse(this.txtGIPrice.Text.Trim());
AGood._GoodsAPrice = double.Parse(this.txtGSPrice.Text);
AGood._GoodsPeople = this.txtHPeople.Text.Trim();
AGood._GoodsRemarks = this.txtISRemark.Text.Trim();
Dclass.saveGoods(AGood);
DataSet ds = Dclass.GetDataSet("select * from V_Goods", "V_Goods");
dgvISManage.DataSource = ds.Tables[0];
MessageBox.Show("数据保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtISGID.Text = System.DateTime.Parse(Convert.ToString(System.DateTime.Now)).ToString("yyyyMMddhhmmss");
this.txtISGName.Text = "";
this.cboxPName.Text = "";
this.txtGSpec.Text = "";
this.cboxGUnit.Text = "";
this.txtISGNum.Text = "";
this.txtGIPrice.Text = "";
this.txtGSPrice.Text = "";
this.txtHPeople.Text = "";
this.txtISRemark.Text = "";
}
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void txtISGNum_TextChanged(object sender, EventArgs e)
{
if (txtGIPrice.Text != "" && txtISGNum.Text != "")
{
this.txtGSPrice.Text = Convert.ToString(Convert.ToUInt64(this.txtGIPrice.Text) * Convert.ToUInt64(this.txtISGNum.Text));
}
}
private void txtGIPrice_TextChanged(object sender, EventArgs e)
{
if (txtISGNum.Text != "")
{
this.txtGSPrice.Text = Convert.ToString(Convert.ToUInt64(this.txtGIPrice.Text) * Convert.ToUInt64(this.txtISGNum.Text));
}
else
{
this.txtGSPrice.Text = this.txtGIPrice.Text;
}
}
private void btnDel_Click(object sender, EventArgs e)
{
if (dgvISManage.SelectedRows.Count == 0)
{
MessageBox.Show("请选择一条要删除的项!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
try
{
Dclass.ExecuteSql("delete from V_Goods where 货物编号='" + this.dgvISManage.SelectedRows[0].Cells[0].Value.ToString().Trim() + "'");
//SMS_GoodsIn_Load()
DataSet ds = Dclass.GetDataSet("select * from V_Goods", "V_Goods");
dgvISManage.DataSource = ds.Tables[0];
MessageBox.Show("删除成功!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
private void txtGIPrice_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar <= 57 && e.KeyChar >= 48 || e.KeyChar == 46 || e.KeyChar == 8)
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
private void txtISGNum_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar <= 57 && e.KeyChar >= 48 || e.KeyChar == 46 || e.KeyChar == 8)
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
dgvISManage.Refresh();
DataSet ds = Dclass.GetDataSet("select * from V_Goods", "V_Goods");
dgvISManage.DataSource = ds.Tables[0];
this.txtISGID.Refresh();
this.txtISGID.Text = System.DateTime.Parse(Convert.ToString(System.DateTime.Now)).ToString("yyyyMMddhhmmss");
}
private void dgvISManage_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (this.dgvISManage.SelectedRows.Count == 0)
{
MessageBox.Show("至于选择一个项!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
SMS_UpGoods UG = new SMS_UpGoods(this.dgvISManage.SelectedRows[0].Cells[0].Value.ToString());
UG.ShowDialog();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -