承志医疗管理系统技术解析设置商品折扣率(九)

9 篇文章 0 订阅

可以说商品的折扣率是连贯整个系统的中枢,每个病人的医疗的费用都要根据该商品是否设置到折扣的问题,按照不同的医疗方式商品设置不同的折扣,在病人消费的时候根据病人的医疗方式进行对应的折扣。

 打开设置商品折扣价


界面如(图1):可以对一个商品打勾,点击单个保存,也可以全选点击批量保存,进行设置折扣率如(图2


(图1


(图2

表和关系


表1折扣类型表

列名

数据类型

说明

DiscountTypeID

Int(主键)

折扣类型ID

DiscountTypeName

nchar(20)

折扣类型名称

 

 

表2第三方表

说明:第三方表主要是为了让折扣类型表和药品表形成多对多的关系。

列名

数据类型

说明

ThirdPartyID

int(主键)

第三方ID

DiscountTypeID

Int(外键)

折扣类型ID

MedicineID

int(外键)

药品ID

Discountrate

decimal(18, 2)

折扣率

 

 

单个保存操作,首先要对哪个商品进行折扣的勾上,再设置折扣,点击单个保存,实现代码

数据库存储过程

if @Type='Frm_ShangPingZheKouSheZhi_InsertZheKou'
	begin
	insert     BS_ThirdPartyList(DiscountTypeID, MedicineID, Discountrate)
    values       (@DiscountTypeID, @MedicineID, @Discountrate) 
	
	end--新增折扣

	 if @Type='Frm_ShangPingZheKouSheZhi_SelectThirdPartyID'
	begin
	   SELECT   ThirdPartyID   
	   from BS_ThirdPartyList 
	   where BS_ThirdPartyList.MedicineID=@MedicineID
	   and BS_ThirdPartyList.DiscountTypeID=@DiscountTypeID
	end--查询
	 if @Type='Frm_ShangPingZheKouSheZhi_UpdateZheKou'
	begin
	update BS_ThirdPartyList
	   set Discountrate=@Discountrate
	   where BS_ThirdPartyList.ThirdPartyID=@ThirdPartyID
	end --修改折扣

逻辑层代码

 [OperationContract]
        public int Frm_ShangPingZheKouSheZhi_InsertZheKou(int DiscountTypeID, int MedicineID, decimal Discountrate)
        {
            SqlParameter[] mySqlParameters = {
                                               new SqlParameter ("@Type",SqlDbType .Char),
                                               new SqlParameter ("@DiscountTypeID",SqlDbType .Int),
                                               new SqlParameter ("@MedicineID",SqlDbType .Int),
                                               new SqlParameter ("@Discountrate",SqlDbType .Decimal),
                                                                                    
                                           };
            mySqlParameters[0].Value = "Frm_ShangPingZheKouSheZhi_InsertZheKou";
            mySqlParameters[1].Value =DiscountTypeID;
            mySqlParameters[2].Value =MedicineID;
            mySqlParameters[3].Value = Discountrate;
           return  myDALMethod.UpdateData("信息设置_Frm_ShangPingZheKouSheZhi", mySqlParameters);
           
        }
        [OperationContract]
        public DataSet Frm_ShangPingZheKouSheZhi_SelectZheKouHouShuJu(int MedicineID)
        {
            SqlParameter[] mySqlParameters = {
                                               new SqlParameter ("@Type",SqlDbType .Char),
                                                 new SqlParameter ("@MedicineID",SqlDbType .Int),                                    
                                           };
            mySqlParameters[0].Value = "Frm_ShangPingZheKouSheZhi_SelectZheKouHouShuJu";
            mySqlParameters[1].Value = MedicineID;
            DataTable dt = myDALMethod.QueryDataTable("信息设置_Frm_ShangPingZheKouSheZhi", mySqlParameters);
            DataSet ds = new DataSet();
            ds.Tables.Add(dt);
            return ds;
        }
        [OperationContract]
        public DataSet Frm_ShangPingZheKouSheZhi_SelectThirdPartyID(int MedicineID, int DiscountTypeID)
        {
            SqlParameter[] mySqlParameters = {
                                            new SqlParameter ("@Type",SqlDbType .Char),
                                            new SqlParameter ("@MedicineID",SqlDbType .Int),   
                                            new SqlParameter ("@DiscountTypeID",SqlDbType .Int),   
                                           };
            mySqlParameters[0].Value = "Frm_ShangPingZheKouSheZhi_SelectThirdPartyID";
            mySqlParameters[1].Value = MedicineID;
            mySqlParameters[2].Value = DiscountTypeID;
            DataTable dt = myDALMethod.QueryDataTable("信息设置_Frm_ShangPingZheKouSheZhi", mySqlParameters);
            DataSet ds = new DataSet();
            ds.Tables.Add(dt);
            return ds;
        }
        [OperationContract]
        public int Frm_ShangPingZheKouSheZhi_UpdateZheKou(decimal Discountrate, int ThirdPartyID)
        {
            SqlParameter[] mySqlParameters = {
                                               new SqlParameter ("@Type",SqlDbType .Char),
                                                new SqlParameter ("@Discountrate",SqlDbType .Decimal),
                                               new SqlParameter ("@ThirdPartyID",SqlDbType .Int),
                                              
                                                                                    
                                           };
            mySqlParameters[0].Value = "Frm_ShangPingZheKouSheZhi_UpdateZheKou";
            mySqlParameters[1].Value = Discountrate;
            mySqlParameters[2].Value = ThirdPartyID;
            return myDALMethod.UpdateData("信息设置_Frm_ShangPingZheKouSheZhi", mySqlParameters);

        }

界面层代码

点击单个保存


private void btnDanGeBaoCun_Click(object sender, EventArgs e)
        {   int Z=0;
            int ChengGong=0;
            foreach(DataGridViewRow dgv in dgvShangPingXinXi.Rows)
            {
                if (Convert.ToBoolean(dgv.Cells["选择"].Value))
              {
                  for (int i = 0; i < dgvZheKouXinXi.Rows.Count; i++)
                  {
                      int ZheKouLeiXingID = Convert.ToInt32(dgvZheKouXinXi.Rows[i].Cells["DiscountTypeID"].Value);
                      decimal ZheKouBi = Convert.ToDecimal(dgvZheKouXinXi.Rows[i].Cells["Discountrate"].Value);
                      
                      if (ZheKouBi > 1)
                      {
                          MessageBox.Show("折扣比必须在0—1间");
                          return;
                      }
                      //根据药品ID,折扣类型ID,获取数据库的ThirdPartyID
                      DataTable dtThirdPartyID = myFrm_ShangPingZheKouSheZhiClient.
                          Frm_ShangPingZheKouSheZhi_SelectThirdPartyID(YaoPingID, ZheKouLeiXingID).Tables[0];
                      //如果数据库中存在ThirdPartyID
                      if (dtThirdPartyID.Rows.Count > 0)
                      {
                          //获取ThirdPartyID出来
                        int ThirdPartyID = Convert.ToInt32(dtThirdPartyID.Rows[0][0]);
                        //根据ThirdPartyID修改折扣率
                         ChengGong=  myFrm_ShangPingZheKouSheZhiClient.
                             Frm_ShangPingZheKouSheZhi_UpdateZheKou(ZheKouBi,ThirdPartyID);
                      }
                      else
                      {
                          //否则新增
                          Z= myFrm_ShangPingZheKouSheZhiClient.
                              Frm_ShangPingZheKouSheZhi_InsertZheKou(ZheKouLeiXingID, YaoPingID, ZheKouBi);
                      }
                       
                  }
           
              }
            }
            if (ChengGong > 0 || Z > 0)
            {
                MessageBox.Show("保存成功");
                dgvShangPingXinXi_CellClick(null,null);
            }
        }

批量设置折扣

设置窗口的实现,因为折扣类型的不定的变化,根据医院可能会增加或者减少折扣类型,所以为了适应,只能用动态来实现。

 private void plZheKou_Paint(object sender, PaintEventArgs e)
        {
             dt = myFrm_ShangPingZheKouSheZhiClient.Frm_ShangPingZheKouSheZhi_SelectZheKouLeiXing().Tables[0];
            for (int i = 0 ,leftX = 10, leftY = 2; i < dt.Rows.Count; i++)
            {
                leftY += 30; 
                //定义画笔实例
                Pen mypen = new Pen(Color.Black);
                //定义画笔实例
                Graphics myGraphics = e.Graphics;
                //赋值
                string Name = dt.Rows[i]["DiscountTypeName"].ToString().Trim();
                myGraphics.DrawString(Name,new Font("宋体", 10, FontStyle.Regular),
                                         SystemBrushes.ControlText, leftX, leftY);

            }
        }

在窗体Load事件中给每个折扣类型对应赋值ID

private void Frm_ZheKouBiSheZhiXiaoChuanTi_Load(object sender, EventArgs e)
        {
             dt = myFrm_ShangPingZheKouSheZhiClient.Frm_ShangPingZheKouSheZhi_SelectZheKouLeiXing().Tables[0];
             DtCount = dt.Rows.Count;//查询折扣类型ID
             ZheKouShuZhu = new string[DtCount];//定义数组的长度为折扣类型的个数
            //循环给每个折扣类型赋值ID
            for (int i = 0, leftX = 10, leftY = 2; i < dt.Rows.Count; i++)
            {

                leftY += 30;
            
                TextBox txtZheKouLv = new TextBox();
                txtZheKouLv.Size = new Size(100, 21);
                txtZheKouLv.Text = "1.00";
                txtZheKouLv.Tag = dt.Rows[i]["DiscountTypeID"].ToString().Trim();
                //数组记录一开始的折扣比
                ZheKouShuZhu[i] = txtZheKouLv.Text.ToString().Trim();
                txtZheKouLv.Location = new Point(leftX + 120, leftY);
                //设置文本边框格式
                txtZheKouLv.BorderStyle = System.Windows.Forms.BorderStyle.None;
                //设置文本下划线
                txtZheKouLv.Font=new Font(new Font("宋体",15),FontStyle.Underline);
                plZheKou.Controls.Add(txtZheKouLv);
                txtZheKouLv.TextChanged+=new EventHandler(txtZheKouLv_TextChanged);
            }
        }

每次编辑折扣率时对应用数组记录下来

 private void Frm_ZheKouBiSheZhiXiaoChuanTi_Load(object sender, EventArgs e)
        {
             dt = myFrm_ShangPingZheKouSheZhiClient.Frm_ShangPingZheKouSheZhi_SelectZheKouLeiXing().Tables[0];
             DtCount = dt.Rows.Count;//查询折扣类型ID
             ZheKouShuZhu = new string[DtCount];//定义数组的长度为折扣类型的个数
            //循环给每个折扣类型赋值ID
            for (int i = 0, leftX = 10, leftY = 2; i < dt.Rows.Count; i++)
            {

                leftY += 30;
            
                TextBox txtZheKouLv = new TextBox();
                txtZheKouLv.Size = new Size(100, 21);
                txtZheKouLv.Text = "1.00";
                txtZheKouLv.Tag = dt.Rows[i]["DiscountTypeID"].ToString().Trim();
                //数组记录一开始的折扣比
                ZheKouShuZhu[i] = txtZheKouLv.Text.ToString().Trim();
                txtZheKouLv.Location = new Point(leftX + 120, leftY);
                //设置文本边框格式
                txtZheKouLv.BorderStyle = System.Windows.Forms.BorderStyle.None;
                //设置文本下划线
                txtZheKouLv.Font=new Font(new Font("宋体",15),FontStyle.Underline);
                plZheKou.Controls.Add(txtZheKouLv);
                txtZheKouLv.TextChanged+=new EventHandler(txtZheKouLv_TextChanged);
            }
        }

设置好折扣率后点击保存


decimal ZheKouBi;
        int WangChengCount=0;
        private void btnSave_Click(object sender, EventArgs e)
        {

            for (int i = 0; i < Frm_ShangPingZheKouSheZhi.YaoPing.Length; i++)
            {   //获取数组值
                int YaoPingID = Frm_ShangPingZheKouSheZhi.YaoPing[i];
                for (int j = 0; j < dt.Rows.Count; j++)
                { //获取折扣类型ID
                    int ZheKouLeiXingID = Convert.ToInt32(dt.Rows[j]["DiscountTypeID"]);

                    ZheKouBi = Convert.ToDecimal(ZheKouShuZhu[j]);
                    //根据药品ID,折扣类型ID,获取数据库的ThirdPartyID
                    DataTable dtThirdPartyID = myFrm_ShangPingZheKouSheZhiClient.
                        Frm_ShangPingZheKouSheZhi_SelectThirdPartyID(YaoPingID, ZheKouLeiXingID).Tables[0];
                    //如果数据库中存在ThirdPartyID
                    if (dtThirdPartyID.Rows.Count > 0)
                    {
                        //获取ThirdPartyID出来
                        int ThirdPartyID = Convert.ToInt32(dtThirdPartyID.Rows[0][0]);
                        //根据ThirdPartyID修改折扣率
                        myFrm_ShangPingZheKouSheZhiClient.
                            Frm_ShangPingZheKouSheZhi_UpdateZheKou(ZheKouBi, ThirdPartyID);
                    }
                    else
                    {
                        //否则新增
                        myFrm_ShangPingZheKouSheZhiClient.
                            Frm_ShangPingZheKouSheZhi_InsertZheKou(ZheKouLeiXingID, YaoPingID, ZheKouBi);
                    }

                }
                WangChengCount++;//记录成功的数量

            }
            //如果完成数量=全选的商品数量
            if (WangChengCount == Frm_ShangPingZheKouSheZhi.YaoPing.Length)
            {

                plHuanChong.Visible = false;
                MessageBox.Show("设置成功!");
            }

        }
仅供学习,禁止商业用途!



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值