1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.Infrastructure.Common;
using CY.Model;
using CY.BLL;
namespace CY.WebForm.Pages.sysInquiry
{
    public partial class PriceTool : FrontBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txtRemenderTime.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
            }
            if (Request.Params["paperSize"] != null)
            {
                string paperSize = string.Empty;
                int? gramWeight = null;
                decimal? tonsPrice = null;
                decimal? reamPrice = null;
                int? paperOfQua = 0;
                paperSize = Request.Params["paperSize"].ToString();
                if (!string.IsNullOrEmpty(Request.Params["gramWeight"].ToString()))
                {
                    gramWeight = int.Parse(Request.Params["gramWeight"].ToString());
                }
                if (!string.IsNullOrEmpty(Request.Params["tonsPrice"].ToString()))
                {
                    tonsPrice = Convert.ToDecimal(Request.Params["tonsPrice"].ToString());
                }
                if (!string.IsNullOrEmpty(Request.Params["reamPrice"].ToString()))
                {
                    reamPrice = Convert.ToDecimal(Request.Params["reamPrice"].ToString());
                }
                if (!string.IsNullOrEmpty(Request.Params["paperOfQua"].ToString()))
                {
                    paperOfQua = int.Parse(Request.Params["paperOfQua"].ToString());
                }
                Response.Write(CalculatePaperPrice(paperSize, gramWeight, tonsPrice, reamPrice, paperOfQua));
                Response.End();
            }
 
            //提交备忘录
            if (Request["SaveMemo"] != null)
            {
                string remenderTime = Request["RemenderTime"].ToString();
                string content = Request["Content"].ToString();
                OA_WorkReminder m_OA_WorkReminder = new OA_WorkReminder();
                m_OA_WorkReminder.FirmId = CurrentUser.MemberId;
                m_OA_WorkReminder.Content = content;
                m_OA_WorkReminder.RemenderObject = CurrentUser.TrueName;
                m_OA_WorkReminder.Remender = CurrentUser.TrueName;
                m_OA_WorkReminder.RemenderTime = Convert.ToDateTime(remenderTime);
                m_OA_WorkReminder.Remark = string.Empty;
                m_OA_WorkReminder.RemenderDept = string.Empty;
                m_OA_WorkReminder.RemenderType = 2; //提醒类别为2代表的是备忘录
                m_OA_WorkReminder.IsFinish = 0;
                OA_WorkReminderBll oA_WorkReminderBll = new OA_WorkReminderBll();
                m_OA_WorkReminder.RemenderDelState = 0;
                m_OA_WorkReminder.RemenderObjectDelState = 0;
                m_OA_WorkReminder.RemindState = 0;
                bool IsSuccess=oA_WorkReminderBll.InsertModel(m_OA_WorkReminder);
                Response.Write(IsSuccess ? "1" : "0");
                Response.End();
            }
        }
 
        /// <summary>
        /// 纸价转换计算
        /// </summary>
        /// <param name="paperSize">纸张尺寸</param>
        /// <param name="gramgramWeight">克重</param>
        /// <param name="tonsPrice">吨价</param>
        /// <param name="reamPrice">令价</param>
        /// <returns>前台显示json字符串</returns>
        public string CalculatePaperPrice(string paperSize, int? gramWeight, decimal? tonsPrice, decimal? reamPrice,int? paperOfQua)
        {
            //纸张单价
            decimal? price = 0;
 
            //令重
            decimal? reamWeight = 0;
 
            //令数
            double? reamNumber = 0;
 
            //总价
            decimal? AllPrice = 0;
 
            string html = "";
 
            if (gramWeight != null)
            {
                if (reamPrice == null)
                {
 
                    if (!string.IsNullOrEmpty(paperSize) && gramWeight != null && tonsPrice != null)
                    {
                        string[] paperSizes = paperSize.Split('×');
 
                        double widht = paperSizes[0].ToDouble2().Value / 1000;
                        double height = paperSizes[1].ToDouble2().Value / 1000;
 
                        double _gramWeight = gramWeight.ToDouble2().Value / 1000;
 
                        double area = widht * height;
 
                        price = (area * _gramWeight * (tonsPrice.ToDouble2() / 1000)).ToDecimal2();
 
                        reamWeight = (widht * height * _gramWeight * 500).ToDecimal2();
 
                        reamWeight = reamWeight.ToDecimal2();
 
                        reamNumber = (1000 / reamWeight).ToDouble2().Value.ToString("0.00").ToDouble2();
 
                        reamPrice = price * 500;
 
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(paperSize) && gramWeight != null && reamPrice != null)
                    {
                        string[] paperSizes = paperSize.Split('×');
 
                        double widht = paperSizes[0].ToDouble2().Value / 1000;
 
                        double height = paperSizes[1].ToDouble2().Value / 1000;
 
                        double _gramWeight = gramWeight.ToDouble2().Value / 1000;
 
                        double area = (widht * height) / 2;
 
                        price = reamPrice / 500;
 
                        tonsPrice = (reamPrice.ToDouble2() / (area.ToDouble2() * (gramWeight.ToDouble2())) * 1000).ToDecimal2();
 
                        tonsPrice = tonsPrice.ToDecimal2();
 
                        reamWeight = (widht * height * _gramWeight * 500).ToDecimal2();
 
                        reamWeight = reamWeight.ToDecimal2();
 
                        reamNumber = (1000 / reamWeight).ToDouble2().Value.ToString("0.00").ToDouble2();
                    }
                }
            }
            else
            {
                string[] paperSizes = paperSize.Split('×');
 
                double widht = paperSizes[0].ToDouble2().Value / 1000;
 
                double height = paperSizes[1].ToDouble2().Value / 1000;
 
                double area = (widht * height) / 2;
 
                price = reamPrice / 500;
 
                gramWeight = ((reamPrice.ToDouble2() / (tonsPrice.ToDouble2() / 1000)) / area).ToInt32();
 
                double _gramWeight = gramWeight.ToDouble2().Value / 1000;
 
                reamWeight = (widht * height * _gramWeight * 500).ToDecimal2();
 
                reamWeight = reamWeight.ToDecimal2();
 
                reamNumber = (1000 / reamWeight).ToDouble2().Value.ToString("0.00").ToDouble2();
            }
            AllPrice = paperOfQua * price;
            html = paperSize + "|" + gramWeight.ToDecimal2Yen() + "|" + reamWeight.ToDecimal2Yen() + "|" + reamNumber.ToDecimal2Yen() + "|" + tonsPrice.ToDecimal2Yen() + "|" + reamPrice.ToDecimal2Yen() + "|" + price.ToDecimal2Yen() + "|" + AllPrice.ToDecimal2Yen();
            return html;
        }
 
    }
}