Exemple #1
0
        public static int SetSysParaToDb(CDb oDb, string szItem, string szVal, ref string szErr)
        {
            string szSql = "update sys_para set para_val='" + szVal.Trim()
                           + "' where para_name='" + szItem.Trim() + "'";

            return(oDb.WriteData(szSql, ref szErr));
        }
Exemple #2
0
        public static int GetSysParaFromDb(CDb oDb, ref string szErr)
        {
            int     iRst;
            string  szSql = "select para_val,para_name from sys_para";
            DataSet odt   = new DataSet();

            iRst = oDb.ReadData(szSql, "TableA", ref odt, ref szErr);
            if (iRst != 0)
            {
                return(CDb.ERR_READ);
            }

            int iNum = odt.Tables[0].Rows.Count;

            for (int i = 0; i < iNum; i++)
            {
                DataRow dr     = odt.Tables[0].Rows[i];
                string  szItem = dr[1].ToString();
                switch (szItem)
                {
                case "YTB_SRV": MyStart.gszYTBIp = dr[0].ToString(); break;

                case "YTB_PORT": MyStart.gszYTBPort = dr[0].ToString(); break;

                case "RDR_PORT": MyStart.gszRdrPort = dr[0].ToString(); break;

                case "RDR2_PORT": MyStart.gszRdr2Port = dr[0].ToString(); break;

                case "RDR_BAUD": MyStart.gszRdrBaud = dr[0].ToString(); break;

                case "PS_PORT": MyStart.gszPsPort = dr[0].ToString(); break;

                case "PS_BAUD": MyStart.gszPsBaud = dr[0].ToString(); break;

                case "CARD_YTB": MyStart.gszCardYtbFirst = dr[0].ToString(); break;

                case "CARD_FIRM": MyStart.gszCardFirmFirst = dr[0].ToString(); break;

                case "FIRM_ID": MyStart.gszFirmID = dr[0].ToString(); break;

                case "POS_ID": MyStart.gszPosID = dr[0].ToString(); break;

                case "MKT_GROUP": MyStart.gszMrktMnger = dr[0].ToString(); break;

                case "MKT_NAME": MyStart.gszMrktName = dr[0].ToString(); break;

                case "MKT_ADDR": MyStart.gszMrktAddr = dr[0].ToString(); break;

                case "MKT_TELE": MyStart.gszMrktTel = dr[0].ToString(); break;

                case "WEIGHT_UNIT": MyStart.gszWeight = (dr[0].ToString() == "1"?"斤":"公斤"); break;

                case "FEE_CHG_CARD": MyStart.giFeeChgCard = Convert.ToInt16(dr[0]); break;

                default: break;    //return MY_ERR_PARA;
                }
            }
            return(0);
        }
Exemple #3
0
        static void Main()
        {
            //Process current = Process.GetCurrentProcess();
            //Process[] processes = Process.GetProcessesByName(current.ProcessName);

            //if (processes.GetLength(0) > 1)
            //{
            //    MessageBox.Show("该程序已经运行,请退出!", "系统提示",
            //                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //    return;
            //}

            if (File.Exists(Application.StartupPath + "\\YTB.ini") != true)
            {
                MessageBox.Show("没有找到配置文件YTB.ini,请修改后再运行!", "系统提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (MyFunc.GetSysParaFromIni(Application.StartupPath + MyIniFile.mszIniFile) != 0)
            {
                MessageBox.Show("读取配置文件YTB.ini失败,请检查后再运行!", "系统提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            oMyDb = new CDb("MYSQL", gszDbIp, gszDbPort, gszDbSrv, gszDbLogin, gszDbPwd);
            if (oMyDb == null)
            {
                MessageBox.Show("连接数据库失败,请检查后再运行!", "系统提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string szErr = "";

            if (MyFunc.GetSysParaFromDb(oMyDb, ref szErr) != 0)
            {
                MessageBox.Show("读取数据库失败(错误原因=" + szErr + "),请检查后再运行!", "系统提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            oMyDb.Close();

            if (gszYTBIp.CompareTo("183.58.24.209") == 0)//生产环境
            {
                gszHttpSrv = "https://183.58.24.209:8088/ytb-http-sersc/servlet/server";
            }
            else
            {
                gszHttpSrv = "http://58.213.110.146:9082/ytb-http-server/servlet/server";
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            UserCheckIn = false;
            frm_Login Frm_Login = new frm_Login();

            Frm_Login.ShowDialog();

            giUserID = 1;//only for test

            if (UserCheckIn)
            {
                Application.Run(new frm_Main());
            }
        }