📄 sellgoods.cs
字号:
{
MessageBox.Show("库存中没有足够数量的教材,请重新填写销售数量!");
txtNum.Text = "";
txtNum.Focus();
}
else
{
//执行SQL语句并返回执行结果
if (G_SqlClass.GetExecute(P_Str_cmdtxt))
{
MessageBox.Show("数据添加成功!");
ControlStatus();
PropertyClass.GetGoodsID = null;
}
else
{
MessageBox.Show("数据添加失败!");
}
}
P_dr2.Close();
}
else
{
MessageBox.Show("请选择销售员姓名!", "提示对话框", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
break;
case 2:
if (this.cbxSellName.SelectedValue.ToString() != "")
{
string P_Str_Id = String.Empty;
//检索数据库中对应客户的ID
string P_Str_cmdtxt2 = "SELECT UserID,Name FROM tb_User WHERE Name='" + this.cbxSellName.SelectedValue.ToString() + "'";
SqlDataReader P_dr = G_SqlClass.GetReader(P_Str_cmdtxt2);
P_dr.Read();
if (P_dr.HasRows)
{
P_Str_Id = P_dr["UserID"].ToString();
}
P_dr.Close();
P_Str_condition = this.dgvSellInfo[0, this.dgvSellInfo.CurrentCell.RowIndex].Value.ToString();
P_Str_cmdtxt = "UPDATE tb_Sell SET GoodsName='" + this.txtGoodsName.Text + "',GoodsNum='" + this.txtNum.Text + "'";
P_Str_cmdtxt += ",GoodsUnit='" + this.cbxUnit.SelectedValue.ToString() + "',GoodsTime='" + this.dtBirthday.Value + "'";
P_Str_cmdtxt += ",GoodsSpec='" + this.txtSpec.Text + "',UserID='"+P_Str_Id+"',GoodsPrice=" + this.txtGoodsInPrice.Text + "";
P_Str_cmdtxt += ",SellPrice=" + this.txtSellPrice.Text + ",Remark='" + this.txtRemark.Text + "'";
P_Str_cmdtxt += ",NeedPay=" + this.txtNeedPay.Text + ",HasPay=" + this.txtHasPay.Text + " WHERE SellID='" + P_Str_condition + "'";
if (G_SqlClass.GetExecute(P_Str_cmdtxt))
{
MessageBox.Show("数据修改成功!");
ControlStatus();
}
else
{
MessageBox.Show("数据修改失败!");
}
}
else
{
MessageBox.Show("请选择销售员姓名!", "提示对话框", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
break;
default:
break;
}
//绑定数据显示控件
string P_Str_cmdtxt1 = "SELECT SellID,GoodsID as 教材ID,[Name] as 销售员姓名,GoodsName as 教材名称";
P_Str_cmdtxt1 += ",GoodsNum as 销售数量,GoodsUnit as 教材单位,GoodsSpec as 教材规格,GoodsTime as 销售时间";
P_Str_cmdtxt1 += ",GoodsPrice 进货价格,SellPrice as 销售价格,NeedPay as 应收金额,HasPay as 实收金额,Remark as 备注";
P_Str_cmdtxt1 += " FROM v_UserSell";
this.dgvSellInfo.DataSource = G_SqlClass.GetDs(P_Str_cmdtxt1).Tables[0];
}
private void toolCancel_Click(object sender, EventArgs e)
{
ControlStatus();
ClearControls();
}
private void toolAdd_Click(object sender, EventArgs e)
{
ControlStatus();
ClearControls();
G_Int_status = 1;
int P_Int_Num = 0;
SqlDataReader P_dr = G_SqlClass.GetReader("SELECT TOP 1 * FROM tb_Sell ORDER BY SellID DESC");
P_dr.Read();
if (P_dr.HasRows)
{
string P_Str_GoodsID = P_dr["SellID"].ToString();
P_Int_Num = Convert.ToInt16(P_Str_GoodsID.Substring(11)) + 1;
}
else
{
this.labGoodsID.Text = "XS" + DateTime.Now.ToString("yyyyMMdd") + "-" + "1000";
P_dr.Close();
return;
}
P_dr.Close();
this.labGoodsID.Text = "XS" + DateTime.Now.ToString("yyyyMMdd") + "-" + P_Int_Num.ToString();
}
private void toolAmend_Click(object sender, EventArgs e)
{
ControlStatus();
G_Int_status = 2;
}
private void toolDelete_Click(object sender, EventArgs e)
{
string P_Str_condition = this.dgvSellInfo[0, this.dgvSellInfo.CurrentCell.RowIndex].Value.ToString();
string P_Str_cmdtxt = "DELETE FROM tb_Sell WHERE SellID='" + P_Str_condition + "'";
if (G_SqlClass.GetExecute(P_Str_cmdtxt))
{
MessageBox.Show("数据删除成功!");
}
else
{
MessageBox.Show("数据删除失败!");
}
string P_Str_cmdtxt1 = "SELECT SellID,GoodsID as 教材ID,[Name] as 销售员姓名,GoodsName as 教材名称";
P_Str_cmdtxt1 += ",GoodsNum as 销售数量,GoodsUnit as 教材单位,GoodsSpec as 教材规格,GoodsTime as 销售时间";
P_Str_cmdtxt1 += ",GoodsPrice 进货价格,SellPrice as 销售价格,NeedPay as 应收金额,HasPay as 实收金额,Remark as 备注";
P_Str_cmdtxt1 += " FROM v_UserSell";
this.dgvSellInfo.DataSource = G_SqlClass.GetDs(P_Str_cmdtxt1).Tables[0];
}
private void toolExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void dgvSellInfo_CellClick(object sender, DataGridViewCellEventArgs e)
{
FillControls();
this.txtGoodsName.Text = PropertyClass.GetDgvData;
this.txtGoodsInPrice.Text = PropertyClass.GetGoodsInPrice;
this.txtSellPrice.Text = PropertyClass.GetSellPrice;
this.txtSpec.Text = PropertyClass.GetStockSpec;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (PropertyClass.GetGoodsID != null)
{
this.txtGoodsName.Text = PropertyClass.GetDgvData;
this.txtGoodsInPrice.Text = PropertyClass.GetGoodsInPrice;
this.txtSellPrice.Text = PropertyClass.GetSellPrice;
this.txtSpec.Text = PropertyClass.GetStockSpec;
}
}
private void txtNum_TextChanged(object sender, EventArgs e)
{
if (this.txtSellPrice.Text != "" && this.txtNum.Text != "" && G_OperationClass.IsNumeric(this.txtNum.Text))
{
this.txtNeedPay.Text = Convert.ToString(Convert.ToDecimal(PropertyClass.GetSellPrice) * Convert.ToInt32(this.txtNum.Text));
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -