private void UnSelectedAllConsignmentBill(object obj)
        {
            if (ConsignmentBills.Count == 0)
            {
                return;
            }

            if (ConsignmentBills.Where(m => m.SelectedStatus > 0).Count() > 0)// 反选
            {
                var bills = ConsignmentBills.Where(m => m.SelectedStatus > 0);
                if (bills.Count() > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (var item in bills)
                    {
                        SelectedConsignmentBillLists.Remove(SelectedConsignmentBillLists.FirstOrDefault(x => x.InterId == item.InterId));
                        sb.Append(",'" + item.BillNo + "'");
                    }
                    _consignmentService.RemoveUserCurrencyOperation(sb.ToString().Substring(1));
                    SelectedConsignmentSum = SelectedConsignmentBillLists.Where(m => m.SelectedStatus > 0).Sum(m => m.CurrencyQuantity);
                    QuerySignmentBill(null);
                }
            }
        }
        private void SelectedAllConsignmentBill(object obj)
        {
            if (ConsignmentBills.Count == 0)
            {
                return;
            }

            if (ConsignmentBills.Where(m => m.SelectedStatus == 0).Count() > 0)
            {
                // 查询有没有被锁定的数据
                string        billNos    = "'" + string.Join("','", ConsignmentBills.Select(m => m.BillNo)) + "'";
                string        lockstring = _consignmentService.GetConsignmentBillLockOwner(user.ID, billNos);
                bool          r          = ConsignmentBills.Where(m => m.CurrencyQuantity == 0).Count() > 0;
                StringBuilder sb         = new StringBuilder();

                if (string.IsNullOrEmpty(lockstring) || r)
                {
                    foreach (var item in ConsignmentBills)
                    {
                        if (SelectedConsignmentBillLists.Where(x => x.InterId == item.InterId).Count() == 0)
                        {
                            item.SelectedStatus = item.TotalQuantity == item.CurrencyQuantity ? 2 : 1;
                            SelectedConsignmentBillLists.Add(item);
                            sb.Append(",'" + item.BillNo + "'");
                        }
                    }
                    _consignmentService.AddUserCurrencyOperation(user.ID, sb.ToString().Substring(1));
                    SelectedConsignmentSum = SelectedConsignmentBillLists.Where(m => m.SelectedStatus > 0).Sum(m => m.CurrencyQuantity);
                    QuerySignmentBill(null);
                }
                else
                {
                    MessageBox.Show(lockstring + "!\r\n 或者已选数据的当前数量不能为0 ,不能批量选择");
                }
            }
        }
        private void QuerySignmentBill(object obj)
        {
            ConsignmentBills.Clear();
            //var para = Filter;//(ConsignmentBillParameterModel)obj;

            List <string> filters = new List <string>();

            if (Filter.ParamBillBeginSeq > 0 && Filter.ParamBillEndSeq > 0)
            {
                filters.Add($" and BillSeq between {Filter.ParamBillBeginSeq}  and  {Filter.ParamBillEndSeq} ");
            }
            else if (Filter.ParamBillBeginSeq > 0)
            {
                filters.Add($" and a.BillNo like '%{Filter.ParamBillBeginSeq}%' ");
            }


            //if (!string.IsNullOrEmpty(para.ParamBillNo))
            //{
            //    filters.Add($" and a.BillNo like '%{para.ParamBillNo}%' ");
            //}

            if (!string.IsNullOrEmpty(Filter.ParamDeptName))
            {
                string deptName = Filter.ParamDeptName.Replace(",", ",");
                if (deptName.Contains(","))
                {
                    string orfield = string.Empty;
                    foreach (var item in deptName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        orfield += $"or DeptName like '%{item}%' ";
                    }
                    orfield = orfield.Length > 2 ? orfield.Substring(2) : " 1 = 1 ";
                    filters.Add($" and ( {orfield}  )");
                }
                else
                {
                    filters.Add($" and DeptName like '%{deptName}%' ");
                }
            }

            if (!string.IsNullOrEmpty(Filter.ParamCustName))
            {
                string custName = Filter.ParamCustName.Replace(",", ",");
                if (custName.Contains(","))
                {
                    string orfield = string.Empty;
                    foreach (var item in custName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        orfield += $"or CustName like '%{item}%'  ";
                    }
                    orfield = orfield.Length > 2 ? orfield.Substring(2) : " 1 = 1 ";
                    filters.Add($" and ( {orfield}  )");
                }
                else
                {
                    filters.Add($" and CustName like '%{custName}%' ");
                }
            }

            if (Filter.IsSelected)
            {
                filters.Add($" and SelectedStatus > 0  ");
            }

            string filter = $" and BillDate >= '{Filter.ParamBeginDate}' and BillDate <= '{Filter.ParamEndDate}' and BillType={Filter.ParamBillType}  and UndoQuantity>{Filter.ParamRestQuatity} " + string.Join(" ", filters);

            _consignmentService.GetAllConsignmentBills(user.ID, filter).ToList().ForEach(x =>
            {
                ConsignmentBills.Add(x);
            });
            ConsignmentBillsCount        = ConsignmentBills.Count();
            ConsignmentBillsSumQuantity  = ConsignmentBills.Sum(m => m.CurrencyQuantity);
            SelectedConsignmentBillEntry = null;
            SelectedConsignmentBill      = null;
            ConsignmentBillEntries.Clear();
        }
 public void GetConsignmentBills()
 {
     ConsignmentBills.Clear();
     _consignmentService.GetAllConsignmentBills(0).ToList().ForEach(x => ConsignmentBills.Add(x));
 }