Merge branch 'master' of http://47.104.102.122:3000/gaofei/HJGL_DS
This commit is contained in:
+85
-61
@@ -4,19 +4,20 @@ namespace BLL
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Data.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
/// <summary>
|
||||
/// 通用方法类。
|
||||
/// ͨ�÷����ࡣ
|
||||
/// </summary>
|
||||
public static class Funs
|
||||
{
|
||||
/// <summary>
|
||||
/// 维护一个DB集合
|
||||
/// ά��һ��DB����
|
||||
/// </summary>
|
||||
private static Dictionary<int, Model.SGGLDB> dataBaseLinkList = new System.Collections.Generic.Dictionary<int, Model.SGGLDB>();
|
||||
|
||||
/// <summary>
|
||||
/// 维护一个DB集合
|
||||
/// ά��һ��DB����
|
||||
/// </summary>
|
||||
public static System.Collections.Generic.Dictionary<int, Model.SGGLDB> DBList
|
||||
{
|
||||
@@ -27,7 +28,7 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据库连接字符串
|
||||
/// ���ݿ������ַ���
|
||||
/// </summary>
|
||||
private static string connString;
|
||||
|
||||
@@ -37,7 +38,7 @@ namespace BLL
|
||||
public static string usingMatId;
|
||||
|
||||
/// <summary>
|
||||
/// 数据库连结字符串。
|
||||
/// ���ݿ������ַ�����
|
||||
/// </summary>
|
||||
public static string ConnString
|
||||
{
|
||||
@@ -45,7 +46,7 @@ namespace BLL
|
||||
{
|
||||
if (connString == null)
|
||||
{
|
||||
throw new NotSupportedException("请设置连接字符串!");
|
||||
throw new NotSupportedException("�����������ַ�����");
|
||||
}
|
||||
|
||||
return connString;
|
||||
@@ -55,7 +56,7 @@ namespace BLL
|
||||
{
|
||||
if (connString != null)
|
||||
{
|
||||
throw new NotSupportedException("连接已设置!");
|
||||
throw new NotSupportedException("���������ã�");
|
||||
}
|
||||
|
||||
connString = value;
|
||||
@@ -69,7 +70,7 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单位设置
|
||||
/// �����
|
||||
/// </summary>
|
||||
public static string UnitSet
|
||||
{
|
||||
@@ -78,7 +79,7 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 路径
|
||||
/// ·��
|
||||
/// </summary>
|
||||
public static string RootPath
|
||||
{
|
||||
@@ -87,7 +88,7 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 系统名
|
||||
/// ϵͳ��
|
||||
/// </summary>
|
||||
public static string SystemName
|
||||
{
|
||||
@@ -95,7 +96,7 @@ namespace BLL
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// AD域名
|
||||
/// AD����
|
||||
/// </summary>
|
||||
public static string ADomainUrl
|
||||
{
|
||||
@@ -103,7 +104,7 @@ namespace BLL
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// APP下载地址
|
||||
/// APP���ص�ַ
|
||||
/// </summary>
|
||||
public static string APPUrl
|
||||
{
|
||||
@@ -121,7 +122,7 @@ namespace BLL
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 每页数量
|
||||
/// ÿҳ����
|
||||
/// </summary>
|
||||
public static int PageSize
|
||||
{
|
||||
@@ -130,7 +131,7 @@ namespace BLL
|
||||
} = 15;
|
||||
|
||||
/// <summary>
|
||||
/// 数据库上下文。
|
||||
/// ���ݿ������ġ�
|
||||
/// </summary>
|
||||
public static Model.SGGLDB DB
|
||||
{
|
||||
@@ -146,50 +147,50 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为目标下拉框加上 "请选择" 项
|
||||
/// ΪĿ����������� "��ѡ��" ��
|
||||
/// </summary>
|
||||
/// <param name="DLL">目标下拉框</param>
|
||||
/// <param name="DLL">Ŀ��������</param>
|
||||
public static void PleaseSelect(System.Web.UI.WebControls.DropDownList DDL)
|
||||
{
|
||||
DDL.Items.Insert(0, new System.Web.UI.WebControls.ListItem("- 请选择 -", "0"));
|
||||
DDL.Items.Insert(0, new System.Web.UI.WebControls.ListItem("- ��ѡ�� -", "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为目标下拉框加上 "请选择" 项
|
||||
/// ΪĿ����������� "��ѡ��" ��
|
||||
/// </summary>
|
||||
/// <param name="DLL">目标下拉框</param>
|
||||
/// <param name="DLL">Ŀ��������</param>
|
||||
public static void FineUIPleaseSelect(FineUIPro.DropDownList DDL)
|
||||
{
|
||||
DDL.Items.Insert(0, new FineUIPro.ListItem("- 请选择 -", BLL.Const._Null));
|
||||
DDL.Items.Insert(0, new FineUIPro.ListItem("- ��ѡ�� -", BLL.Const._Null));
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为目标下拉框加上 "重新编制" 项
|
||||
/// ΪĿ����������� "���±���" ��
|
||||
/// </summary>
|
||||
/// <param name="DLL">目标下拉框</param>
|
||||
/// <param name="DLL">Ŀ��������</param>
|
||||
public static void ReCompileSelect(System.Web.UI.WebControls.DropDownList DDL)
|
||||
{
|
||||
DDL.Items.Insert(0, new System.Web.UI.WebControls.ListItem("重新编制", "0"));
|
||||
DDL.Items.Insert(0, new System.Web.UI.WebControls.ListItem("���±���", "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为目标下拉框加上 "重新编制" 项
|
||||
/// ΪĿ����������� "���±���" ��
|
||||
/// </summary>
|
||||
/// <param name="DLL">目标下拉框</param>
|
||||
/// <param name="DLL">Ŀ��������</param>
|
||||
public static void FineUIReCompileSelect(FineUIPro.DropDownList DDL)
|
||||
{
|
||||
DDL.Items.Insert(0, new FineUIPro.ListItem("重新编制", "0"));
|
||||
DDL.Items.Insert(0, new FineUIPro.ListItem("���±���", "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字符串是否为浮点数
|
||||
/// �ַ����Ƿ�Ϊ������
|
||||
/// </summary>
|
||||
/// <param name="decimalStr">要检查的字符串</param>
|
||||
/// <returns>返回是或否</returns>
|
||||
/// <param name="decimalStr">Ҫ�����ַ���</param>
|
||||
/// <returns>�����ǻ��</returns>
|
||||
public static bool IsDecimal(string decimalStr)
|
||||
{
|
||||
if (String.IsNullOrEmpty(decimalStr))
|
||||
@@ -210,10 +211,10 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断一个字符串是否是整数
|
||||
/// �ж�һ���ַ����Ƿ�������
|
||||
/// </summary>
|
||||
/// <param name="integerStr">要检查的字符串</param>
|
||||
/// <returns>返回是或否</returns>
|
||||
/// <param name="integerStr">Ҫ�����ַ���</param>
|
||||
/// <returns>�����ǻ��</returns>
|
||||
public static bool IsInteger(string integerStr)
|
||||
{
|
||||
if (String.IsNullOrEmpty(integerStr))
|
||||
@@ -234,10 +235,10 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取新的数字
|
||||
/// ��ȡ�µ�����
|
||||
/// </summary>
|
||||
/// <param name="number">要转换的数字</param>
|
||||
/// <returns>新的数字</returns>
|
||||
/// <param name="number">Ҫת��������</param>
|
||||
/// <returns>�µ�����</returns>
|
||||
public static string InterceptDecimal(object number)
|
||||
{
|
||||
if (number == null)
|
||||
@@ -284,11 +285,11 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断字符串从第n位开始以后是否都为0
|
||||
/// �ж��ַ����ӵ�nλ��ʼ�Ժ��Ƿ�Ϊ0
|
||||
/// </summary>
|
||||
/// <param name="number">要判断的字符串</param>
|
||||
/// <param name="n">开始的位数</param>
|
||||
/// <returns>false不都为0,true都为0</returns>
|
||||
/// <param name="number">Ҫ�жϵ��ַ���</param>
|
||||
/// <param name="n">��ʼ��λ��</param>
|
||||
/// <returns>false����Ϊ0��true��Ϊ0</returns>
|
||||
public static bool GetStr(string number, int n)
|
||||
{
|
||||
for (int i = n; i < number.Length; i++)
|
||||
@@ -302,11 +303,11 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 截取字符串长度
|
||||
/// ��ȡ�ַ�������
|
||||
/// </summary>
|
||||
/// <param name="str">要截取的字符串</param>
|
||||
/// <param name="n">长度</param>
|
||||
/// <returns>截取后字符串</returns>
|
||||
/// <param name="str">Ҫ��ȡ���ַ���</param>
|
||||
/// <param name="n">����</param>
|
||||
/// <returns>��ȡ���ַ���</returns>
|
||||
public static string GetSubStr(object str, object n)
|
||||
{
|
||||
if (str != null)
|
||||
@@ -325,7 +326,7 @@ namespace BLL
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 输入文本转换时间类型
|
||||
/// �����ı�ת��ʱ������
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static DateTime? GetNewDateTime(string time)
|
||||
@@ -349,7 +350,7 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 输入文本转换数字
|
||||
/// �����ı�ת������
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static decimal? GetNewDecimal(string value)
|
||||
@@ -373,7 +374,7 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 输入文本转换数字
|
||||
/// �����ı�ת������
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static decimal GetNewDecimalOrZero(string value)
|
||||
@@ -385,19 +386,42 @@ namespace BLL
|
||||
{
|
||||
returnValue = decimal.Parse(value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
ErrLogInfo.WriteLog(ex);
|
||||
return returnValue;
|
||||
// 如果直接解析失败(如带单位 "10M", "5KM", "3KG"),取前面的数字部分
|
||||
try
|
||||
{
|
||||
Match match = Regex.Match(value, @"\d+\.?\d*");
|
||||
if (match.Success && decimal.TryParse(match.Value, out decimal number))
|
||||
{
|
||||
returnValue = number;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ErrLogInfo.WriteLog(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从qty字符串中提取单位(如 "10M" → "M", "5KG" → "KG", "33.4 mm" → "mm", "10" → "")
|
||||
/// </summary>
|
||||
public static string GetUnitFromQty(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return "";
|
||||
Match match = Regex.Match(value.Trim(), @"^\d+\.?\d*\s*(.*)$");
|
||||
if (match.Success)
|
||||
return match.Groups[1].Value.Trim();
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 输入文本转换数字类型
|
||||
/// �����ı�ת����������
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static int? GetNewInt(string value)
|
||||
@@ -421,7 +445,7 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 输入文本转换数字类型
|
||||
/// �����ı�ת����������
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static int GetNewIntOrZero(string value)
|
||||
@@ -443,7 +467,7 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 指定上传文件的名称
|
||||
/// ָ���ϴ��ļ�������
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetNewFileName()
|
||||
@@ -453,7 +477,7 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据标识返回字符串list
|
||||
/// ���ݱ�ʶ�����ַ���list
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <param name="n"></param>
|
||||
@@ -470,24 +494,24 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据第一页和第二页行数及总记录数,确定需要打印几页
|
||||
/// ���ݵ�һҳ�͵ڶ�ҳ�������ܼ�¼����ȷ����Ҫ��ӡ��ҳ
|
||||
/// </summary>
|
||||
/// <param name="pageSize1">第一页行数</param>
|
||||
/// <param name="pageSize2">第二页行数</param>
|
||||
/// <param name="count">总记录数</param>
|
||||
/// <param name="pageSize1">��һҳ����</param>
|
||||
/// <param name="pageSize2">�ڶ�ҳ����</param>
|
||||
/// <param name="count">�ܼ�¼��</param>
|
||||
/// <returns></returns>
|
||||
public static int GetPagesCountByPageSize(int pageSize1, int pageSize2, int count)
|
||||
{
|
||||
int pagesCount = 0;
|
||||
if (pageSize1 >= count) //总记录数小于等于第一页行数
|
||||
if (pageSize1 >= count) //�ܼ�¼��С�ڵ��ڵ�һҳ����
|
||||
{
|
||||
pagesCount = 1;
|
||||
}
|
||||
else if (count > pageSize1 && count <= (pageSize1 + pageSize2)) //总记录数大于第一页行数且小于等于第一页加第二页总行数
|
||||
else if (count > pageSize1 && count <= (pageSize1 + pageSize2)) //�ܼ�¼�����ڵ�һҳ������С�ڵ��ڵ�һҳ�ӵڶ�ҳ������
|
||||
{
|
||||
pagesCount = 2;
|
||||
}
|
||||
else //总记录数大于第一页加第二页总行数
|
||||
else //�ܼ�¼�����ڵ�һҳ�ӵڶ�ҳ������
|
||||
{
|
||||
int lastCount = count - pageSize1;
|
||||
decimal c = Convert.ToDecimal(Math.Round(Convert.ToDecimal(lastCount) / Convert.ToDecimal(pageSize2), 2));
|
||||
@@ -506,7 +530,7 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取上次返修情况
|
||||
/// ��ȡ�ϴη������
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetRepariMark(string repairMark)
|
||||
|
||||
@@ -462,7 +462,8 @@ namespace FineUIPro.Web.HJGL.DataIn
|
||||
g.Key.category,
|
||||
g.Key.spec,
|
||||
g.Key.description,
|
||||
qty = g.Sum(r => Funs.GetNewDecimalOrZero(r.Field<string>("qty")))
|
||||
qty = g.Sum(r => Funs.GetNewDecimalOrZero(r.Field<string>("qty"))),
|
||||
unit = g.Select(r => Funs.GetUnitFromQty(r.Field<string>("qty") ?? "")).FirstOrDefault(u => !string.IsNullOrEmpty(u)) ?? ""
|
||||
});
|
||||
foreach (var g in groups2)
|
||||
{
|
||||
@@ -471,7 +472,7 @@ namespace FineUIPro.Web.HJGL.DataIn
|
||||
newRow["drawing_number"] = g.drawing_number;
|
||||
newRow["category"] = g.category;
|
||||
newRow["spec"] = g.spec;
|
||||
newRow["qty"] = g.qty;
|
||||
newRow["qty"] = g.qty.ToString() + g.unit;
|
||||
newRow["description"] = g.description;
|
||||
dtGroupByDrawing.Rows.Add(newRow);
|
||||
}
|
||||
@@ -507,7 +508,8 @@ namespace FineUIPro.Web.HJGL.DataIn
|
||||
g.Key.category,
|
||||
g.Key.spec,
|
||||
g.Key.description,
|
||||
qty = g.Sum(r => Funs.GetNewDecimalOrZero(r.Field<string>("qty")))
|
||||
qty = g.Sum(r => Funs.GetNewDecimalOrZero(r.Field<string>("qty"))),
|
||||
unit = g.Select(r => Funs.GetUnitFromQty(r.Field<string>("qty") ?? "")).FirstOrDefault(u => !string.IsNullOrEmpty(u)) ?? ""
|
||||
});
|
||||
foreach (var g in groups3)
|
||||
{
|
||||
@@ -516,7 +518,7 @@ namespace FineUIPro.Web.HJGL.DataIn
|
||||
newRow["pipe_no"] = g.pipe_no;
|
||||
newRow["category"] = g.category;
|
||||
newRow["spec"] = g.spec;
|
||||
newRow["qty"] = g.qty;
|
||||
newRow["qty"] = g.qty.ToString() + g.unit;
|
||||
newRow["description"] = g.description;
|
||||
dtGroupByPipe.Rows.Add(newRow);
|
||||
}
|
||||
@@ -559,12 +561,14 @@ namespace FineUIPro.Web.HJGL.DataIn
|
||||
row["description"] = g.Key.desc;
|
||||
|
||||
decimal totalQty = 0;
|
||||
string unit = "";
|
||||
foreach (var r in g)
|
||||
{
|
||||
if (decimal.TryParse(r["qty"].ToString(), out decimal qty))
|
||||
totalQty += qty;
|
||||
totalQty += Funs.GetNewDecimalOrZero(r["qty"].ToString());
|
||||
if (string.IsNullOrEmpty(unit))
|
||||
unit = Funs.GetUnitFromQty(r["qty"].ToString());
|
||||
}
|
||||
row["qty"] = totalQty.ToString();
|
||||
row["qty"] = totalQty.ToString() + unit;
|
||||
dtSummary.Rows.Add(row);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user