コード例 #1
0
 protected void btnDelAll_Click(object sender, EventArgs e)
 {
     try
     {
         StringBuilder sb = new StringBuilder();
         foreach (int row in gvList.SelectedRowIndexArray)
         {
             sb.Append(gvList.DataKeys[row][0].ToString());
             sb.Append(",");
         }
         var library = new DictCustomerService();
         int nflag   = new DictcustomertestdiscountService().DelDictcustomerdiscountByID(sb.ToString().TrimEnd(','));
         if (nflag > 0)
         {
             MessageBoxShow("所选项已成功删除", MessageBoxIcon.Information);
             BindGrid();
             gvList.SelectedRowIndexArray = new int[] { };
             //this.Drop_DictTestItemId.SelectedValue = "-1";
             this.tbxFinalprice.Text = string.Empty;
             this.DatePicker1.Text   = string.Empty;
             this.DatePicker2.Text   = string.Empty;
         }
     }
     catch (Exception ex)
     {
         MessageBoxShow(ex.Message, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
        //保存数据的逻辑
        public bool SaveDictlibrary()
        {
            try
            {
                dictcustomercount = new Dictcustomertestdiscount();
                if (gvList.SelectedRowIndexArray.Length > 0)
                {
                    object[] objValue = gvList.DataKeys[gvList.SelectedRowIndexArray[0]];
                    dictcustomercount.Dictcustomerdiscountid = TypeParse.StrToDouble(objValue[0], 0);
                }
                if (this.tbxFinalprice.Text.Trim() != "") //报价
                {
                    dictcustomercount.Finalprice = Convert.ToDouble(this.tbxFinalprice.Text.Trim());
                }
                if (this.Drop_DictTestItemId.SelectedValue != "-1")  //测试项
                {
                    dictcustomercount.Dicttestitemid = Convert.ToDouble(this.Drop_DictTestItemId.SelectedValue);
                }
                else
                {
                    erreyType = "测试项不能为空!";
                    return(false);
                }
                if (this.DatePicker1.Text.Trim() != "")  //开始时间
                {
                    Dictcustomertestdiscount dictCustomer = new DictcustomertestdiscountService().GetDictcustomerdiscountById(Convert.ToDouble(dictcustomercount.Dictcustomerdiscountid));
                    if (dictCustomer != null)
                    {
                        #region
                        if (dictCustomer.Begindate != this.DatePicker1.SelectedDate || dictCustomer.Enddate != this.DatePicker2.SelectedDate)
                        {
                            if (this.DatePicker1.SelectedDate <= this.DatePicker2.SelectedDate)
                            {
                                Hashtable ht1 = new Hashtable();
                                ht1.Add("Enddate", this.DatePicker2.Text.Trim());
                                ht1.Add("begdate", this.DatePicker1.Text.Trim());
                                ht1.Add("itemsId", this.Drop_DictTestItemId.SelectedValue);
                                ht1.Add("Dictcustomerdiscountid", Convert.ToDouble(dictcustomercount.Dictcustomerdiscountid));
                                ht1.Add("Dictcustomerid", CustomerId);

                                IList <Dictcustomertestdiscount> ds = new DictcustomertestdiscountService().GetDictcustomerByTime(ht1);
                                if (ds.Count == 0)
                                {
                                    dictcustomercount.Begindate = Convert.ToDateTime(this.DatePicker1.Text.Trim());
                                }
                                else
                                {
                                    erreyType = "已存在重复时间段!";
                                    return(false);
                                }
                            }
                            else
                            {
                                erreyType = "开始时间应小于结束时间!";
                                return(false);
                            }
                        }
                        else
                        {
                            if (this.DatePicker1.SelectedDate <= this.DatePicker2.SelectedDate)
                            {
                                dictcustomercount.Begindate = Convert.ToDateTime(this.DatePicker1.Text.Trim());
                            }
                            else
                            {
                                erreyType = "开始时间应小于结束时间!";
                                return(false);
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        if (this.DatePicker1.SelectedDate <= this.DatePicker2.SelectedDate)
                        {
                            Hashtable ht1 = new Hashtable();
                            ht1.Add("Enddate", this.DatePicker2.Text.Trim());
                            ht1.Add("begdate", this.DatePicker1.Text.Trim());
                            ht1.Add("itemsId", this.Drop_DictTestItemId.SelectedValue);
                            ht1.Add("Dictcustomerid", CustomerId);
                            IList <Dictcustomertestdiscount> ds = new DictcustomertestdiscountService().GetDictcustomerByTimeTo(ht1);
                            if (ds.Count == 0)
                            {
                                dictcustomercount.Begindate = Convert.ToDateTime(this.DatePicker1.Text.Trim());
                            }
                            else
                            {
                                erreyType = "已存在重复时间段!";
                                return(false);
                            }
                        }
                        else
                        {
                            erreyType = "开始时间应小于结束时间!";
                            return(false);
                        }
                    }
                }
                else
                {
                    erreyType = "开始时间不能为空!";
                    return(false);
                }
                if (this.DatePicker2.Text.Trim() != "")  //结束时间
                {
                    dictcustomercount.Enddate = Convert.ToDateTime(this.DatePicker2.Text.Trim());
                }
                else
                {
                    erreyType = "结束时间不能为空!";
                    return(false);
                }
                dictcustomercount.Dictcustomerid = CustomerId;
                if (Userinfo.userId != 0)
                {
                    dictcustomercount.Updateby = Userinfo.userId;
                }
                else
                {
                    dictcustomercount.Updateby = 1;
                }
                dictcustomercount.Updatedate = DateTime.Now;
                if (dictcustomercount.Dictcustomerdiscountid == 0 || dictcustomercount.Dictcustomerdiscountid == null)
                {
                    dictcustomercount.Createdate = DateTime.Now;
                }
                else
                {
                    List <Dictcustomertestdiscount> dictcustomerdiscountedList = loginservice.GetDictcustomerdiscount();//体检单位总体价格
                    Dictcustomertestdiscount        dictcustomer = dictcustomerdiscountedList.Where <Dictcustomertestdiscount>(c => c.Dictcustomerdiscountid == dictcustomercount.Dictcustomerdiscountid).First <Dictcustomertestdiscount>();
                    dictcustomercount.Createdate = dictcustomer.Createdate;
                }
                return(new DictcustomertestdiscountService().SaveDictcustomerdiscount(dictcustomercount));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        /// <summary>
        /// 重新计算价格
        /// </summary>
        /// <param name="list">Ordergrouptest 集合</param>
        /// <param name="ht"></param>
        /// <returns>重新计算价格后的Ordergrouptest集合</returns>
        public IList <Ordergrouptest> OrdergrouptestNewPrice(IList <Ordergrouptest> grouptestList, Hashtable ht)
        {
            LoginService loginService = new LoginService();
            DictcustomertestdiscountService dctdService = new DictcustomertestdiscountService();
            DictcustomerdiscountedService   dcddService = new DictcustomerdiscountedService();

            List <Dicttestitem>             dtiList  = new List <Dicttestitem>();
            List <Dictlabandtestprice>      dltpList = new List <Dictlabandtestprice>();
            List <Dictproductdetail>        dpdList  = new List <Dictproductdetail>();
            List <Dictcustomerdiscounted>   dcddList = new List <Dictcustomerdiscounted>();
            List <Dictcustomertestdiscount> dctdList = new List <Dictcustomertestdiscount>();

            try
            {
                dtiList  = loginService.GetLoginDicttestitemList();
                dltpList = loginService.GetLoginDictlabandtestpriceList();
                dpdList  = loginService.GetLoginDictproductdetail();
                dcddList = loginService.GetDictcustomerdiscounted();
                dctdList = loginService.GetDictcustomerdiscount();

                string type       = ht["flag"].ToString();
                double?customerid = null;
                double?dictlabid  = null;

                if (ht["customerid"] != null)
                {
                    customerid = double.Parse(ht["customerid"].ToString());
                }
                if (ht["dictlabid"] != null)
                {
                    dictlabid = double.Parse(ht["dictlabid"].ToString());
                }


                foreach (Ordergrouptest item in grouptestList)
                {
                    //标准价格
                    List <Dicttestitem> _dtiList = (from a in dtiList where a.Dicttestitemid == item.Dicttestitemid select a).ToList();

                    //分点价格   item.Createdate取值来源于orders表enterdate表示登记时间
                    List <Dictlabandtestprice> _dltpList = (from a in dltpList where a.Dicttestitemid == item.Dicttestitemid && a.Begindate <= item.Createdate && a.Enddate.AddDays(1) >= item.Createdate && a.Dictlabid == dictlabid select a).ToList();

                    //单位折扣率
                    List <Dictcustomerdiscounted> _dcddList = (from a in dcddList where a.Dictcustomerid == customerid && a.Begindate <= item.Createdate && a.Enddate.AddDays(1) >= item.Createdate select a).ToList();

                    //成交价
                    List <Dictproductdetail> _dpdList = (from a in dpdList
                                                         where a.Productid == item.Dictproductid && a.Testgroupid == item.Dicttestitemid
                                                         select a).ToList();

                    if (_dtiList.Count > 0)
                    {
                        item.Standardprice = _dtiList[0].Price;//达安标准价
                    }
                    if (_dltpList.Count > 0)
                    {
                        item.Groupprice = _dltpList[0].Price;//分点价
                    }
                    //没值时取Standardprice
                    if (item.Groupprice == null || item.Groupprice == 0) //无分点价则取标准价
                    {
                        item.Groupprice = item.Standardprice;
                    }

                    if (_dpdList.Count > 0)
                    {
                        item.Contractprice = _dpdList[0].Finalprice;   //应收价 取 套餐维护的成交价
                    }
                    if (item.Contractprice == null || item.Contractprice == 0)
                    {
                        if (_dcddList.Count > 0)  //折扣率
                        {
                            //维护了客户整体折扣率,取区域价钱*客户整体折扣率;
                            item.Contractprice = item.Groupprice * _dcddList[0].Discounted;
                        }
                        else
                        {
                            //没有整体折扣率取达安标准价钱。
                            item.Contractprice = item.Groupprice;
                        }
                    }

                    //实收价 默认和应收价钱一样
                    item.Finalprice = item.Contractprice;

                    item.Contractsendoutprice = item.Sendoutprice = 0;
                    if (item.Sendoutcustomerid != null)
                    {
                        //外包价格
                        List <Dictcustomertestdiscount> _senddctdList = (from a in dctdList where a.Dicttestitemid == item.Dicttestitemid && a.Dictcustomerid == item.Sendoutcustomerid && a.Begindate <= item.Createdate && a.Enddate.AddDays(1) >= item.Createdate select a).ToList();
                        if (_senddctdList.Count > 0)
                        {
                            item.Contractsendoutprice = item.Sendoutprice = _senddctdList[0].Finalprice;
                        }
                    }

                    //外包账单 【应收=外包价协议价,实收=外报价】
                    if (type == "sendout")
                    {
                        item.Finalprice    = item.Sendoutprice;
                        item.Contractprice = item.Contractsendoutprice;
                    }
                }
                return(grouptestList);
            }
            catch
            {
                return(null);
            }
        }