Esempio n. 1
0
    protected void bt_ComputeMixRate_Click(object sender, EventArgs e)
    {
        if (ViewState["ClientID"] != null && ViewState["Month"] != null)
        {
            int client = (int)ViewState["ClientID"];
            int month  = (int)ViewState["Month"];
            int brand  = ConfigHelper.GetConfigInt("MixesBrandID");

            decimal mixesrate = new CM_ClientBLL(client).GetBrandSalesVolumeRate(month, brand);

            decimal InvoiceCost, DiscountRate, RebateRate, WriteOffCost, WriteOffCost2;
            if (decimal.TryParse(tbx_InvoiceCost.Text, out InvoiceCost) &&
                decimal.TryParse(tbx_DiscountRate.Text, out DiscountRate) &&
                decimal.TryParse(tbx_RebateRate.Text, out RebateRate))
            {
                decimal summary = InvoiceCost * (1 - DiscountRate / 100) * RebateRate / 100;

                WriteOffCost  = summary * (1 - mixesrate);
                WriteOffCost2 = summary * mixesrate;

                if (ViewState["AvailCost"] != null && WriteOffCost > (decimal)ViewState["AvailCost"])
                {
                    WriteOffCost = (decimal)ViewState["AvailCost"];
                }

                tbx_WriteOffCost.Text  = WriteOffCost.ToString("0.00");
                tbx_WriteOffCost2.Text = WriteOffCost2.ToString("0.00");

                MessageBox.Show(this, string.Format("合计总报销金额:{0:0.##元},冲调占当月该客户销量的{1:0.0%},冲调需承担{2:0.00元}费用!", summary, mixesrate, WriteOffCost2));
            }
        }
    }
Esempio n. 2
0
    protected void ComputInvoiceCost()
    {
        if ((int)ViewState["DetailID"] != 0)
        {
            decimal InvoiceCost, DiscountRate, DiscountCost, RebateRate, WriteOffCost, WriteOffCost2;
            if (decimal.TryParse(tbx_InvoiceCost.Text, out InvoiceCost) &&
                decimal.TryParse(tbx_DiscountRate.Text, out DiscountRate) &&
                decimal.TryParse(tbx_RebateRate.Text, out RebateRate) &&
                decimal.TryParse(tbx_WriteOffCost.Text, out WriteOffCost) &&
                decimal.TryParse(tbx_WriteOffCost2.Text, out WriteOffCost2))
            {
                if (DiscountRate > 100)
                {
                    DiscountRate          = 100;
                    tbx_DiscountRate.Text = "100";
                }
                if (RebateRate > 100)
                {
                    RebateRate          = 100;
                    tbx_RebateRate.Text = "100";
                }

                DiscountCost          = InvoiceCost * DiscountRate / 100;
                tbx_DiscountCost.Text = DiscountCost.ToString("0.00");

                if ((WriteOffCost + WriteOffCost2) > (InvoiceCost - DiscountCost) * RebateRate / 100)
                {
                    WriteOffCost = (InvoiceCost - DiscountCost) * RebateRate / 100 - WriteOffCost2;
                    if (WriteOffCost < 0)
                    {
                        WriteOffCost  = (InvoiceCost - DiscountCost) * RebateRate / 100;
                        WriteOffCost2 = 0;
                    }
                }

                if (ViewState["AvailCost"] != null && WriteOffCost > (decimal)ViewState["AvailCost"])
                {
                    WriteOffCost = (decimal)ViewState["AvailCost"];
                }

                tbx_WriteOffCost.Text  = WriteOffCost.ToString("0.00");
                tbx_WriteOffCost2.Text = WriteOffCost2.ToString("0.00");
            }
        }
    }