예제 #1
0
        /// <summary>
        ///  根据税区和条目税种计算税额
        /// </summary>
        private void GetTaxSum(HttpContext context, long tax_id, string accDedIds)
        {
            if (tax_id == 0 || string.IsNullOrEmpty(accDedIds))
            {
                context.Response.Write("0.00");
                return;
            }

            decimal totalMoney = 0;
            // 所有需要计算的条目的Id的集合
            var accDedIdList = accDedIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            if (accDedIdList != null && accDedIdList.Count() > 0)
            {
                var adDal = new crm_account_deduction_dal();
                foreach (var accDedId in accDedIdList)
                {
                    var accDedList = adDal.GetInvDedDtoList($" and id={accDedId}");
                    var thisAccDed = adDal.FindNoDeleteById(long.Parse(accDedId));
                    if (accDedList != null && accDedList.Count > 0)
                    {
                        var accDed = accDedList.FirstOrDefault(_ => _.id.ToString() == accDedId);
                        if (accDed.tax_category_id != null)
                        {
                            var thisTax = new d_tax_region_cate_dal().GetSingleTax(tax_id, (long)accDed.tax_category_id);
                            if (thisTax != null && thisAccDed.extended_price != null)
                            {
                                totalMoney += (decimal)(thisAccDed.extended_price * thisTax.total_effective_tax_rate);
                            }
                        }
                    }
                }
            }
            context.Response.Write(totalMoney.ToString("#0.00"));
        }
예제 #2
0
        /// <summary>
        /// 根据第一页的查询条件,显示第二页的内容
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbnext_Click(object sender, EventArgs e)
        {
            var accountId           = account_idHidden.Value;
            var showChildAcc        = ckchildAccounts.Checked;
            var showserviceContract = ckserviceContract.Checked;
            var showFixPrice        = ckFixPrice.Checked;
            var showPriceZero       = ckPirceZero.Checked;
            var project_id          = project_idHidden.Value;
            var department          = department_id.SelectedValue;
            var startDate           = itemStartDate.Value;
            var endDate             = itemEndDate.Value;
            var contractType        = contract_type_id.SelectedValue;
            var contractCate        = contract_cate_id.SelectedValue;
            var project_item        = projectItem.SelectedValue;
            var type   = thisItemTypeId.Value; // 条目类型-多选--toTest
            var cadDal = new crm_account_deduction_dal();

            var chooseAccount = new CompanyBLL().GetCompany(long.Parse(accountId));

            if (chooseAccount == null)
            {
                return;
            }

            //accDedList = cadDal.GetAccDed(chooseAccount.id);  // 将要在页面上显示的条目
            //if (accDedList == null)
            //    accDedList = new List<crm_account_deduction>();

            StringBuilder sqlWhere = new StringBuilder();

            if (!string.IsNullOrEmpty(project_id))
            {
                sqlWhere.Append($" and project_id={project_id}");
            }
            if ((!string.IsNullOrEmpty(department)) && (department != "0"))
            {
                sqlWhere.Append($" and department_id={department}");
            }
            if (!string.IsNullOrEmpty(startDate))
            {
                sqlWhere.Append($" and item_date>='{startDate}'");
            }
            if (!string.IsNullOrEmpty(endDate))
            {
                sqlWhere.Append($" and item_date<='{endDate}'");
            }
            if (!string.IsNullOrEmpty(type))
            {
                sqlWhere.Append($" and item_type in ({type}) ");
            }
            if ((!string.IsNullOrEmpty(contractType)) && contractType != "0")
            {
                sqlWhere.Append($" and contract_type_id={contractType}");
            }
            if ((!string.IsNullOrEmpty(contractCate)) && contractCate != "0")
            {
                sqlWhere.Append($" and contract_cate_id={contractCate}");
            }
            if (project_item == "onlyProject")
            {
                sqlWhere.Append($" and project_id is not null");
            }
            if (project_item == "onlyNoProject")
            {
                sqlWhere.Append($" and project_id is null");
            }

            // todo 其余三个Show的过滤

            if (!showserviceContract)
            {
                sqlWhere.Append($" and (item_type in(1318,1319) and contract_type_id not in(1199) or  item_type not in(1318,1319) )");
            }
            if (!showFixPrice)
            {
                sqlWhere.Append($" and  (item_type in(1318,1319) and contract_type_id not in(1201) or  item_type not in(1318,1319) )");
            }
            if (showPriceZero)
            {
                sqlWhere.Append($" and dollars <>0");
            }

            List <InvoiceDeductionDto> deeList = null;
            var sortOrder = Request.QueryString["sortOrder"];

            switch (sortOrder)
            {
            case "1":        // 客户
                deeList = cadDal.GetInvDedDtoList(sqlWhere.ToString() + " and account_id=" + chooseAccount.id.ToString() + " and    invoice_id is null and purchase_order_no is null");
                break;

            case "2":        // ticket
                deeList = cadDal.GetInvDedDtoList(sqlWhere.ToString() + " and account_id=" + chooseAccount.id.ToString() + " and    invoice_id is null and purchase_order_no is null AND project_id is null");
                break;

            case "3":        // 项目
                var thisProject = Request.QueryString["thisProject"];
                deeList = cadDal.GetInvDedDtoList(sqlWhere.ToString() + " and account_id=" + chooseAccount.id.ToString() + " and    invoice_id is null and purchase_order_no is null AND project_id = " + thisProject);
                break;

            case "4":        // 采购订单
                var thisPurOrder = Request.QueryString["thisPurOrder"];
                if (!string.IsNullOrEmpty(thisPurOrder))
                {
                    thisPurOrder = thisPurOrder.Substring(5, thisPurOrder.Length - 5);
                    deeList      = cadDal.GetInvDedDtoList(sqlWhere.ToString() + " and account_id=" + chooseAccount.id.ToString() + " and    invoice_id is null and purchase_order_no =" + thisPurOrder);
                }
                break;

            default:
                break;
            }


            #region  加上子公司的条目
            if (showChildAcc) // 代表用户选中展示子客户条目
            {
                var childAccList = new crm_account_dal().GetSubsidiariesById(chooseAccount.id);
                if (childAccList != null && childAccList.Count > 0)
                {
                    foreach (var childAcc in childAccList)
                    {
                        var childAccDedList = cadDal.GetInvDedDtoList(sqlWhere.ToString() + " and account_id=" + childAcc.id);  //+ " and bill_account_id <>"+ chooseAccount.id
                        if (childAccDedList != null && childAccDedList.Count > 0)
                        {
                            childAccDedList.ForEach(_ => {
                                _.isSub = "1";
                            });
                            deeList.AddRange(childAccDedList); // 循环添加子客户条目
                        }
                    }
                }
            }
            StringBuilder dedHtml = new StringBuilder();
            if (deeList != null && deeList.Count > 0)
            {
                deeList = deeList.Distinct().ToList();
                foreach (var invDedDto in deeList)
                {
                    // 1 代表是不可选的子客户
                    // 2 待定 可选但是默认不选
                    var ischeck = invDedDto.isSub == "1" ? "disabled" : invDedDto.isSub == "2"?"": "checked";

                    var imgSrc = invDedDto.type_icon;         // 根据类型选择图片位置

                    var itemName       = invDedDto.item_name; // todo 部分有下标名
                    var rate           = invDedDto.rate == null ? "" : ((decimal)invDedDto.rate).ToString("#0.00");
                    var quantity       = invDedDto.quantity == null ? "" : ((decimal)invDedDto.quantity).ToString("#0.00");
                    var dollars        = invDedDto.dollars == null ? "" : ((decimal)invDedDto.dollars).ToString("#0.00");
                    var bill_to_parent = string.IsNullOrEmpty(invDedDto.bill_to_parent) ? "" : "√";
                    var bill_to_sub    = string.IsNullOrEmpty(invDedDto.bill_to_sub) ? "" : "√";

                    dedHtml.Append($"<tr><td align='center' style='width: 20px;'><input type='checkbox' class='thisDedCheck' style='margin: 0;' value='{invDedDto.id}' {ischeck}></td><td width='20px' align='center'><img src='{imgSrc}' /></td> <td width='20' align='center'>{invDedDto.item_date}</td><td>{itemName}</td><td>{invDedDto.account_name}</td><td>{invDedDto.contract_name}</td><td>{invDedDto.department_name}</td><td>{invDedDto.cost_code_name}</td><td>{invDedDto.resource_name}</td><td>{invDedDto.role_name}</td><td>{invDedDto.project_name}</td><td>{rate}</td><td>{quantity}</td><td>{dollars}</td><td>{invDedDto.tax_category_name}</td><td>{bill_to_parent}</td><td>{bill_to_sub}</td></tr>");
                    //showAccountDed
                }
                //ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script></script>");
            }


            ClientScript.RegisterStartupScript(this.GetType(), "页面跳转", "<script>document.getElementById('showAccountDed').innerHTML=\"" + dedHtml.ToString() + "\";document.getElementsByClassName('Workspace1')[0].style.display = 'none';document.getElementsByClassName('Workspace2')[0].style.display = '';document.getElementById('date_range_from').value=\"" + startDate + "\";document.getElementById('date_range_to').value=\"" + endDate + "\";</script>");

            #endregion
        }