1
zrg
2025-03-10 192bd758abd0dbadff721b3f58700e95cf1ee230
Pub_Class/CustomerCls/ClsPub.cs
@@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Windows.Forms;
using System.Drawing;
using System.Data.SqlClient;
using System.Net.Sockets;
using System.Net;
using SyntacticSugar.constant;
namespace Pub_Class
{
@@ -59,11 +58,12 @@
        public static DateTime XFCurEDate;
        public static DateTime KQCurBDate;
        public static DateTime KQCurEDate;
        public static bool check;
        public static int HCheckStatus;
        public static string sSQLInfo;
        public static string sErrInfo;
        public enum Enum_BillStatus : int
        {
@@ -897,6 +897,76 @@
        }
        //得到最大基础资料的流水号 HNumber
        public static string CreateHNumber(string BillCode,string HName,string TableName, ref string sReturn, bool Add)
        {
            Int64 Glida;
            Int32 CodeLen;
            string sBillNumber = "";
            char c = Convert.ToChar("0");
            string sKjYear = DateTime.Today.Year.ToString();
            string sPeriod = DateTime.Today.Month.ToString();
            string sDay = DateTime.Today.Day.ToString();
            //得到单据号表 信息
            ClsSqlHelper oCn = new ClsSqlHelper();
            DataSet Ds = new DataSet();
            DataSet Dss = new DataSet();
            //第一次查询数据是否存在  不存在就添加
            Ds = oCn.RunProcReturn("Select * from Gy_MaxNumber where BillName='" + HName.Trim() + "'", "Gy_MaxNumber");
            //插入新记录    表名,表名称,当前id
            if (Ds.Tables[0].Rows.Count == 0)
            {
                oCn.RunProc("insert into Gy_MaxNumber(BillType,BillName,IDNow) values('" + TableName.Trim() + "','" + HName.Trim() + "',1)");
            }
            //第二次查询 是查询插入的新数据
            Dss = oCn.RunProcReturn("Select * from Gy_MaxNumber where BillName='" + HName.Trim() + "'", "Gy_MaxNumber");
            if (Dss.Tables[0].Rows.Count != 0)
            {
                Glida = ClsPub.isLong(Dss.Tables[0].Rows[0]["Glida"].ToString());
                CodeLen = ClsPub.isInt(Dss.Tables[0].Rows[0]["CodeLen"].ToString());
            }
            else
            {
                return "";
            }
            string sStr;
            switch (Glida)
            {
                case 0://纯流水号
                    Ds = oCn.RunProcReturn("Select * from Gy_MaxNumber where BillName='" + HName.Trim() + "'", "Gy_MaxNumber");
                    if (Ds.Tables[0].Rows.Count != 0)
                    {
                        sStr = new string(c, CodeLen - (Ds.Tables[0].Rows[0]["IDNow"].ToString()).Length);
                        sBillNumber = BillCode.Trim() + sStr + Ds.Tables[0].Rows[0]["IDNow"].ToString().Trim();
                    }
                    if (Add == true)
                    {
                        oCn.RunProc("update Gy_MaxNumber set IDNow=IDNow+1 where BillName='" + HName.Trim() + "'");
                    }
                    return sBillNumber;
                case 1://根据 YY年+MM月 日 + 流水号  生成单据号 (日 采用了 仓库的字段)
                    return sBillNumber;
                case 2:      //根据年+月+日  生成单据号
                    return sBillNumber;
                case 3: //根据 乔一 (S + 年(23)+五位流水号)实例:S2300001
                    return sBillNumber;
                case 4: //根据 乔一 工序流转卡号改成年+月+四位流水号(23050001)
                    return sBillNumber;
                default:
                    return sBillNumber;
            }
            oCn.CnClose();
            oCn.CnDispose();
            oCn = null;
        }
        //判断是否存在权限,并写入日志
        public static bool Security_Log(string gnsy, int LogTF, bool Msg,string CurUserName)
        {
@@ -946,7 +1016,7 @@
                    }
                    else
                    {
                        if (ClsPub.isStrNull(DsUser.Tables[0].Rows[0]["AuthorityID"]).Length > ModID
                        if (ClsPub.isStrNull(DsUser.Tables[0].Rows[0]["AuthorityID"]).Length >= ModID
                            && DsUser.Tables[0].Rows[0]["AuthorityID"].ToString().Trim().Substring((int)ModID - 1, 1) == "1")
                        {
                            HavRight = true;
@@ -963,10 +1033,10 @@
                            }
                            else
                            {
                                HavRight = false;
                                //HavRight = false;
                                for (int i = 0; i < DsJS.Tables[0].Rows.Count; i++)
                                {
                                    if (ClsPub.isStrNull(DsJS.Tables[0].Rows[i]["AuthorityID"]).Length > ModID)
                                    if (ClsPub.isStrNull(DsJS.Tables[0].Rows[i]["AuthorityID"]).Length >= ModID)
                                    {
                                        if (DsJS.Tables[0].Rows[i]["AuthorityID"].ToString().Trim().Substring((int)ModID - 1, 1) == "1")
                                        {
@@ -1055,7 +1125,7 @@
                    }
                    else
                    {
                        if (DsUser.Tables[0].Rows[0]["AuthorityID"].ToString().Trim().Substring((int)ModID - 1, 1) == "1")
                        if (ClsPub.isStrNull(DsUser.Tables[0].Rows[0]["AuthorityID"]).Length >= ModID && DsUser.Tables[0].Rows[0]["AuthorityID"].ToString().Trim().Substring((int)ModID - 1, 1) == "1")
                        {
                            HavRight = true;
                        }
@@ -1064,7 +1134,7 @@
                            //获取用户组  并循环判断权限
                            //判断角色是否有权限
                            DsJS = oCn.RunProcReturn("select isnull(AuthorityID,'') AuthorityID from System_UserGroupinfo a inner join System_UserGroup b on a.GroupID=b.GroupID " +
                                " Where a.USERID='" + UserID.Trim() + "'", "gy_czygl");
                                " Where a.USERID='" + DsUser.Tables[0].Rows[0]["Czybm"].ToString().Trim() + "'", "gy_czygl");
                            if (DsJS == null)
                            {
                                HavRight = false;
@@ -1074,7 +1144,7 @@
                                HavRight = false;
                                for (int i = 0; i < DsJS.Tables[0].Rows.Count; i++)
                                {
                                    if (ClsPub.isStrNull(DsJS.Tables[0].Rows[i]["AuthorityID"]).Length > ModID)
                                    if (ClsPub.isStrNull(DsJS.Tables[0].Rows[i]["AuthorityID"]).Length >= ModID)
                                    {
                                        if (DsJS.Tables[0].Rows[i]["AuthorityID"].ToString().Trim().Substring((int)ModID - 1, 1) == "1")
                                        {
@@ -1327,16 +1397,17 @@
        {
            ClsSqlHelper oCn = new ClsSqlHelper();
            DataSet Ds = new DataSet();
            try
            {
                Ds = oCn.RunProcReturn("Select GetDate() as CurDate", "xt_xtgnb");
                switch (iType)
                {
                    case 0:
                    case TimeConstant.TIME_OF_THE_MONTH:
                        return Convert.ToDateTime(Ds.Tables[0].Rows[0]["CurDate"]).ToString("yyyy-MM-dd");
                    case 1:
                    case TimeConstant.TIME_OF_THE_HOUR:
                        return Convert.ToDateTime(Ds.Tables[0].Rows[0]["CurDate"]).ToString("HH:mm:ss");
                    case -1:
                    case TimeConstant.PRECISE_TIME:
                        return Convert.ToDateTime(Ds.Tables[0].Rows[0]["CurDate"]).ToString("yyyy-MM-dd HH:mm:ss");
                    default:
                        return "1900-01-01";
@@ -1357,11 +1428,13 @@
                Ds = oCn.RunProcReturn("Select GetDate() as CurDate", "xt_xtgnb");
                switch (iType)
                {
                    case 0:
                    case TimeConstant.TIME_OF_THE_MONTH:
                        return Convert.ToDateTime(Ds.Tables[0].Rows[0]["CurDate"]).ToString("yyyy-MM-dd");
                    case 1:
                    case TimeConstant.TIME_OF_THE_HOUR:
                        return Convert.ToDateTime(Ds.Tables[0].Rows[0]["CurDate"]).ToString("hh:mm:ss");
                    case -1:
                    case TimeConstant.PRECISE_TIME:
                        return Convert.ToDateTime(Ds.Tables[0].Rows[0]["CurDate"]).ToString("yyyy-MM-dd HH:mm:ss");
                    default:
                        return "1900-01-01";
@@ -1515,7 +1588,6 @@
                }
            }
        }
        // 读取列宽datagridview
        public static void GetGridView(DataGridView oGrd, string KeyItem, string AppPath)