📄 sms_returngoods.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_ReturnGoods : Form
{
BaseClass.DataConn Dconn = new FORU_SMS_.BaseClass.DataConn();
BaseClass.DataClass Dclass = new FORU_SMS_.BaseClass.DataClass();
BaseClass.GoodsReturn Gre = new FORU_SMS_.BaseClass.GoodsReturn();
DataSet ds;
SqlDataReader sqlRead;
public string ID;
public SMS_ReturnGoods(string a)
{
InitializeComponent();
ID = a;
}
private void SMS_ReturnGoods_Load(object sender, EventArgs e)
{
Dclass.BindComboBox("select GoodsID from SMS_Borrow", "SMS_Borrow", "GoodsID", cboxBGID);
ds = Dclass.GetDataSet("SELECT GoodsID AS 产品编号, GoodsName AS 产品名称, SupName AS 仓库名称,SpecName AS 产品规格,ReturnNum AS 还货数量,"
+ "NoReturnNum AS 未还数量, ReturnPeople AS 还货人, GoodsPeople AS 经手人, GoodsRemarks AS 备注 FROM SMS_Return", "SMS_Return");
dgvRGManage.DataSource = ds.Tables["SMS_Return"];
if (ID != "")
{
sqlRead = Dclass.GetRead("select GoodsID,GoodsName,SupName,SpecName,GoodsNum from SMS_Borrow where GoodsID='" + ID + "'");
if (sqlRead.Read())
{
this.cboxBGID.Text = sqlRead["GoodsID"].ToString().Trim();
this.txtSName.Text = sqlRead["SupName"].ToString().Trim();
this.txtGName.Text = sqlRead["GoodsName"].ToString().Trim();
this.txtGSpec.Text = sqlRead["SpecName"].ToString().Trim();
this.txtNRGNum.Text = sqlRead["GoodsNum"].ToString().Trim();
}
sqlRead.Close();
}
}
private void btnAdd_Click(object sender, EventArgs e)
{
if (this.txtRGNum.Text == "")
{
MessageBox.Show("归还数量不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtRGNum.Focus();
}
else if (Convert.ToInt32(this.txtRGNum.Text) == 0)
{
MessageBox.Show("归还数量不能为0!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtRGNum.Text = "";
this.txtRGNum.Focus();
}
else if (this.txtRGPeople.Text == "")
{
MessageBox.Show("还货人不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtRGPeople.Focus();
}
else if (this.txtRGPeople.Text == "")
{
MessageBox.Show("经手人不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtRGPeople.Focus();
}
else
{
sqlRead = Dclass.GetRead("select GoodsID,GoodsName,SupName,SpecName,GoodsNum from SMS_Borrow where GoodsID='" + this.cboxBGID.Text.Trim() + "'");
if (sqlRead.Read())
{
if (Convert.ToInt32(this.txtRGNum.Text.Trim()) < 1)
{
MessageBox.Show("库存不足!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (Convert.ToInt32(this.txtRGNum.Text.Trim()) > Convert.ToInt32(sqlRead["GoodsNum"].ToString().Trim()))
{
MessageBox.Show("没有足够的货物!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtRGNum.Text = "";
this.txtRGNum.Focus();
}
else
{
Gre._GoodsID = this.cboxBGID.Text.Trim();
Gre._GoodsName = this.txtGName.Text.Trim();
Gre._GoodsPeople = this.txtHPeople.Text.Trim();
Gre._GoodsRemarks = this.txtRGRemark.Text.Trim();
Gre._NoReturnNum = int.Parse(this.txtNRGNum.Text.Trim());
Gre._ReturnNum = int.Parse(this.txtRGNum.Text.Trim());
Gre._ReturnPeople = this.txtRGPeople.Text.Trim();
Gre._SpecName = this.txtGSpec.Text.Trim();
Gre._SupName = this.txtSName.Text.Trim();
Gre.returnGoods();
MessageBox.Show("提交成功!");
dgvRGManage.Refresh();
ds = Dclass.GetDataSet("SELECT GoodsID AS 产品编号, GoodsName AS 产品名称, SupName AS 仓库名称,SpecName AS 产品规格,ReturnNum AS 还货数量,"
+ "NoReturnNum AS 未还数量, ReturnPeople AS 还货人, GoodsPeople AS 经手人, GoodsRemarks AS 备注 FROM SMS_Return", "SMS_Return");
dgvRGManage.DataSource = ds.Tables["SMS_Return"];
}
}
}
}
private void btnDel_Click(object sender, EventArgs e)
{
if (this.dgvRGManage.SelectedRows.Count == 0)
{
MessageBox.Show("请选择一个操作项!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (this.dgvRGManage.SelectedRows[0].Cells[0].Value.ToString().Trim() == "")
{
MessageBox.Show("请选择一个操作项!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
try
{
Dclass.ExecuteSql("delete from SMS_Return where GoodsID='" + this.dgvRGManage.SelectedRows[0].Cells[0].Value.ToString().Trim() + "'");
MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
SMS_ReturnGoods_Load(sender, e);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
private void txtRGNum_TextChanged(object sender, EventArgs e)
{
sqlRead = Dclass.GetRead("select GoodsID,GoodsName,SupName,SpecName,GoodsNum from SMS_Borrow where GoodsID='" + ID + "'");
if (sqlRead.Read())
{
if (Convert.ToInt32(this.txtRGNum.Text.Trim()) > Convert.ToInt32(sqlRead["GoodsNum"].ToString().Trim()))
{
MessageBox.Show("超出所借数量!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtRGNum.Text = sqlRead["GoodsNum"].ToString().Trim();
}
else
{
this.txtNRGNum.Text =Convert.ToString(Convert.ToInt32(sqlRead["GoodsNum"].ToString().Trim()) - Convert.ToInt32(this.txtRGNum.Text.Trim()));
}
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
if (this.dgvRGManage.SelectedRows.Count == 0)
{
MessageBox.Show("请选择一个操作项!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (this.dgvRGManage.SelectedRows[0].Cells[0].ToString().Trim() == "")
{
MessageBox.Show("请选择一个操作项!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
sqlRead = Dclass.GetRead("select GoodsID,GoodsName,SupName,SpecName,ReturnNum,NoReturnNum,ReturnPeople,GoodsPeople,GoodsRemarks from SMS_Return where GoodsID='" + this.dgvRGManage.SelectedRows[0].Cells[0].ToString().Trim() + "'");
if (sqlRead.Read())
{
this.cboxBGID.Text = sqlRead["GoodsID"].ToString().Trim();
this.txtSName.Text = sqlRead["SupName"].ToString().Trim();
this.txtGName.Text = sqlRead["GoodsName"].ToString().Trim();
this.txtGSpec.Text = sqlRead["SpecName"].ToString().Trim();
this.txtNRGNum.Text = sqlRead["NoReturnNum"].ToString().Trim();
this.txtRGNum.Text = sqlRead["ReturnNum"].ToString().Trim();
this.txtRGPeople.Text = sqlRead["ReturnPeople"].ToString().Trim();
this.txtHPeople.Text = sqlRead["GoodsPeople"].ToString().Trim();
this.txtRGRemark.Text = sqlRead["GoodsRemarks"].ToString().Trim();
}
sqlRead.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -