⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 goodsin.cs

📁 csharp 商品进销存报表系统 提供学习
💻 CS
📖 第 1 页 / 共 2 页
字号:
                        }
                        if (this.txtGoodsInPrice.Text == "")
                        {
                            MessageBox.Show("商品进价不能为空!", "提示对话框", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (this.txtSellPrice.Text == "")
                        {
                            MessageBox.Show("销售价格不能为空!", "提示对话框", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (!G_OperationForm.IsNumeric(this.txtNum.Text) && !G_OperationForm.IsNumeric(this.txtGoodsInPrice.Text)
                            && !G_OperationForm.IsNumeric(this.txtHasPay.Text) && !G_OperationForm.IsNumeric(this.txtSellPrice.Text))
                        {
                            MessageBox.Show("您输入的数据格式有误!", "提示对话框", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            //执行SQL语句并返回执行结果
                            if (G_SqlClass.GetExecute(P_Str_cmdtxt))
                            {

                                MessageBox.Show("数据添加成功!");
                                ControlStatus();
                            }
                            else
                            {
                                MessageBox.Show("数据添加失败!");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("请选择销售员姓名!", "提示对话框", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    break;
                case 2:
                    if (this.cbxEmployeeName.SelectedValue.ToString() != "")
                    {
                        string P_Str_Id = String.Empty;

                        //检索数据库中对应客户的ID
                        string P_Str_cmdtxt2 = "SELECT UserID,Name FROM tb_User WHERE Name='" + this.cbxEmployeeName.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.dgvGoodsInfo[0, this.dgvGoodsInfo.CurrentCell.RowIndex].Value.ToString();
                        P_Str_cmdtxt = "UPDATE tb_Goods SET GoodsName='" + this.txtGoodsName.Text + "',CompanyName='" + this.cbxCompanyName.SelectedValue.ToString() + "'";
                        P_Str_cmdtxt += ",DepotName='" + this.cbxDepot.SelectedValue.ToString() + "',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 GoodsID='" + 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 cmdtxt = "SELECT GoodsID as 商品ID,GoodsName as 商品名称,GoodsTime as 进货日期,CompanyName as 供应商名称";
            cmdtxt += ",GoodsNum as 进货数量,GoodsUnit as 商品单位,GoodsPrice as 商品进价,DepotName as 所属仓库,GoodsSpec as 商品规格";
            cmdtxt += ",SellPrice as 销售价格,NeedPay as 应付金额,HasPay as 实付金额,Remark as 备注 FROM tb_Goods";
            this.dgvGoodsInfo.DataSource = G_SqlClass.GetDs(cmdtxt).Tables[0];
        }

        private void toolCancel_Click(object sender, EventArgs e)
        {
            ControlStatus();
            ClearControls();
            this.txtNum.ReadOnly = true;
        }

        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_Goods ORDER BY GoodsID DESC");
            P_dr.Read();
            if (P_dr.HasRows)
            {
                string P_Str_GoodsID = P_dr["GoodsID"].ToString();
                P_Int_Num = Convert.ToInt16(P_Str_GoodsID.Substring(11)) + 1;
            }
            else
            {
                this.labGoodsID.Text = "JH" + DateTime.Now.ToString("yyyyMMdd") + "-" + "1000";
                P_dr.Close();
                return;
            }
            P_dr.Close();
            this.labGoodsID.Text = "JH" + DateTime.Now.ToString("yyyyMMdd") + "-" + P_Int_Num.ToString();
        }

        private void toolAmend_Click(object sender, EventArgs e)
        {
            ControlStatus();
            G_Int_status = 2;
            this.txtNum.ReadOnly = true;
        }

        private void toolDelete_Click(object sender, EventArgs e)
        {
            string P_Str_condition = this.dgvGoodsInfo[0, this.dgvGoodsInfo.CurrentCell.RowIndex].Value.ToString();
            string P_Str_cmdtxt = "DELETE FROM tb_Goods WHERE GoodsID='" + P_Str_condition + "'";
            if (G_SqlClass.GetExecute(P_Str_cmdtxt))
            {
                MessageBox.Show("数据删除成功!");
            }
            else
            {
                MessageBox.Show("数据删除失败!");
            }
            string cmdtxt = "SELECT GoodsID as 商品ID,GoodsName as 商品名称,GoodsTime as 进货日期,CompanyName as 供应商名称";
            cmdtxt += ",GoodsNum as 进货数量,GoodsUnit as 商品单位,GoodsPrice as 商品进价,DepotName as 所属仓库,GoodsSpec as 商品规格";
            cmdtxt += ",SellPrice as 销售价格,NeedPay as 应付金额,HasPay as 实付金额,Remark as 备注 FROM tb_Goods";
            this.dgvGoodsInfo.DataSource = G_SqlClass.GetDs(cmdtxt).Tables[0];
        }

        private void toolrefulsh_Click(object sender, EventArgs e)
        {
            string cmdtxt = "SELECT GoodsID as 商品ID,GoodsName as 商品名称,GoodsTime as 进货日期,CompanyName as 供应商名称";
            cmdtxt += ",GoodsNum as 进货数量,GoodsUnit as 商品单位,GoodsPrice as 商品进价,DepotName as 所属仓库,GoodsSpec as 商品规格";
            cmdtxt += ",SellPrice as 销售价格,NeedPay as 应付金额,HasPay as 实付金额,Remark as 备注 FROM tb_Goods";
            this.dgvGoodsInfo.DataSource = G_SqlClass.GetDs(cmdtxt).Tables[0];
        }

        private void toolExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void dgvGoodsInfo_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            FillControls();
        }

        private void txtGoodsInPrice_TextChanged(object sender, EventArgs e)
        {
            if (this.txtGoodsInPrice.Text != "" && this.txtNum.Text != ""&&G_OperationForm.IsNumeric(this.txtGoodsInPrice.Text)&&G_OperationForm.IsNumeric(this.txtNum.Text))
            {
                this.txtNeedPay.Text = Convert.ToString(Convert.ToInt32(this.txtGoodsInPrice.Text) * Convert.ToInt32(this.txtNum.Text));
            }
        }

        private void txtNum_TextChanged(object sender, EventArgs e)
        {
            if (this.txtGoodsInPrice.Text != "" && this.txtNum.Text != "" && G_OperationForm.IsNumeric(this.txtNum.Text))
            {
                this.txtNeedPay.Text = Convert.ToString(Convert.ToDecimal(this.txtGoodsInPrice.Text) * Convert.ToInt32(this.txtNum.Text));
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -