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

📄 customerregoods.cs

📁 csharp 商品进销存报表系统 提供学习
💻 CS
📖 第 1 页 / 共 2 页
字号:
                                //执行SQL语句并返回执行结果
                                if (G_SqlClass.GetExecute(P_Str_cmdtxt))
                                {
                                    MessageBox.Show("数据添加成功!");
                                    ControlStatus();
                                }
                                else
                                {
                                    MessageBox.Show("数据添加失败!");
                                }
                            }
                            P_dr2.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("请选择客户姓名!", "提示对话框", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    break;
                case 2:
                    if (this.cbxCustomerName.SelectedValue.ToString() != "")
                    {
                        string P_Str_Id = String.Empty;

                        //检索数据库中对应客户的ID
                        string P_Str_cmdtxt2 = "SELECT CustomerID,Name FROM tb_Customer WHERE Name='" + this.cbxCustomerName.SelectedValue.ToString() + "'";
                        SqlDataReader P_dr = G_SqlClass.GetReader(P_Str_cmdtxt2);
                        P_dr.Read();
                        if (P_dr.HasRows)
                        {
                            P_Str_Id = P_dr["CustomerID"].ToString();
                        }
                        P_dr.Close();

                        P_Str_condition = this.dgvReGoodsInfo[0, this.dgvReGoodsInfo.CurrentCell.RowIndex].Value.ToString();
                        P_Str_cmdtxt = "UPDATE tb_ReGoods SET ReGoodsName='" + this.txtGoodsName.Text + "',ReGoodsSpec='" + this.txtSpec.Text + "'";
                        P_Str_cmdtxt += ",ReGoodsTime='" + this.dtBirthday.Value + "',CustomerID = "+P_Str_Id+",ReGoodsNum='" + this.txtNum.Text + "'";
                        P_Str_cmdtxt += ",ReGoodsUnit='" + this.cbxUnit.SelectedValue.ToString() + "',ReGoodsPrice=" + Convert.ToDecimal(this.txtReGoodsPrice.Text) + "";
                        P_Str_cmdtxt += ",ReGoodsResult='" + this.txtResult.Text + "',NeedPay=" + Convert.ToDecimal(this.txtNeedPay.Text) + ",HasPay=" + Convert.ToDecimal(this.txtHasPay.Text) + "";
                        P_Str_cmdtxt += " WHERE ReGoodsID='" + P_Str_condition + "'";

                        if (G_SqlClass.GetExecute(P_Str_cmdtxt))
                        {
                            MessageBox.Show("数据修改成功!");
                            ControlStatus();
                            PropertyClass.GetGoodsID = null;
                        }
                        else
                        {
                            MessageBox.Show("数据修改失败!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("请选择客户姓名!", "提示对话框", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    break;
                default:
                    break;
            }
            //绑定数据显示控件
            string P_Str_cmdtxt1 = "SELECT ReGoodsID as 退货ID,GoodsID as 进货ID,ReGoodsName as 商品名称,Name as 顾客姓名,ReGoodsTime as 退货日期";
            P_Str_cmdtxt1 += ",ReGoodsNum as 退货数量,ReGoodsUnit as 商品单位,ReGoodsSpec as 商品规格,ReGoodsPrice as 进货价格,NeedPay as 应付金额";
            P_Str_cmdtxt1 += ",HasPay as 实付金额,ReGoodsResult as 退货原因 FROM v_ReGoods WHERE ReGoodsSort='1'";
            this.dgvReGoodsInfo.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_ReGoods ORDER BY ReGoodsID DESC");
            P_dr.Read();
            if (P_dr.HasRows)
            {
                string P_Str_GoodsID = P_dr["ReGoodsID"].ToString();
                P_Int_Num = Convert.ToInt16(P_Str_GoodsID.Substring(11)) + 1;
            }
            else
            {
                this.labReGoodsID.Text = "TH" + DateTime.Now.ToString("yyyyMMdd") + "-" + "1000";
                P_dr.Close();
                return;
            }
            P_dr.Close();
            this.labReGoodsID.Text = "TH" + 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.dgvReGoodsInfo[0, this.dgvReGoodsInfo.CurrentCell.RowIndex].Value.ToString();
            string P_Str_cmdtxt = "DELETE FROM tb_ReGoods WHERE ReGoodsID='" + P_Str_condition + "'";
            if (G_SqlClass.GetExecute(P_Str_cmdtxt))
            {
                MessageBox.Show("数据删除成功!");
            }
            else
            {
                MessageBox.Show("数据删除失败!");
            }
            string P_Str_cmdtxt1 = "SELECT ReGoodsID as 退货ID,GoodsID as 进货ID,ReGoodsName as 商品名称,Name as 顾客姓名,ReGoodsTime as 退货日期";
            P_Str_cmdtxt1 += ",ReGoodsNum as 退货数量,ReGoodsUnit as 商品单位,ReGoodsSpec as 商品规格,ReGoodsPrice as 进货价格,NeedPay as 应付金额";
            P_Str_cmdtxt1 += ",HasPay as 实付金额,ReGoodsResult as 退货原因 FROM v_ReGoods WHERE ReGoodsSort='1'";
            this.dgvReGoodsInfo.DataSource = G_SqlClass.GetDs(P_Str_cmdtxt1).Tables[0];
        }

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

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

        private void btnFind_Click(object sender, EventArgs e)
        {
            SellFind sellfind = new SellFind();
            sellfind.StartPosition = FormStartPosition.CenterParent;
            sellfind.ShowDialog();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (PropertyClass.GetDgvData != null)
            {
                this.txtGoodsName.Text = PropertyClass.GetDgvData;
                this.txtReGoodsPrice.Text = PropertyClass.GetSellPrice;
                this.txtSpec.Text = PropertyClass.GetStockSpec;
            }
        }

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

⌨️ 快捷键说明

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