Exemplo n.º 1
0
        private void UploadFile(String fileNamePath, String uriString)
        {
            SetLoadingLabel("正在上传数据库...");
            try
            {
                //FTPRenameRemoteFile(); // 重命名
                if (!FormBasicFeatrues.GetInstence().FTPRenameRemoteFile(MainWindow.ONLINE_DATABASE_FTP_LOCATION_DIR + MainWindow.ONLINE_DATABASE_FILE_PREFIX, MainWindow.USER_ID + "_backup@" + DateTime.Now.ToString("yyyy-MM-dd&HH-mm-ss") + ".db"))
                {
                    canClose          = true;
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }

                using (WebClient client = new WebClient())
                {
                    Uri uri = new Uri(uriString);
                    client.UploadProgressChanged += new UploadProgressChangedEventHandler(UploadProgressCallback);
                    client.UploadFileCompleted   += new UploadFileCompletedEventHandler(UploadFileCompleteCallback);
                    //DatabaseConnections.Connector.LocalDbClose();
                    client.UploadFileAsync(uri, "STOR", fileNamePath);
                    // client.Proxy = WebRequest.DefaultWebProxy;
                    //client.Proxy.Credentials = new NetworkCredential(ONLINE_FTP_USERNAME, ONLINE_FTP_PASSWORD, ONLINE_FTP_DOMAIN);
                    client.Dispose();
                }
            }
            catch
            {
                SetLoadingLabel("正在上传数据库错误,请在下次登录时重试...");
                canClose          = true;
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }
Exemplo n.º 2
0
 private void RefuseButton_Click(object sender, EventArgs e)
 {
     if (isSendRequest)
     {// 发送请求
         this.Close();
     }
     else
     {//
         InputMessage im = new InputMessage();
         if (im.ShowDialog() == DialogResult.OK)
         {
             Image _signImage = FormBasicFeatrues.GetInstence().Base64StringToImage(FormBasicFeatrues.GetInstence().DecompressString(FormBasicFeatrues.GetInstence().DecompressString(MainWindow.SIGNATURE)));
             if (_signImage != null)
             {
                 using (Graphics gr = Graphics.FromImage(SignPictureBox.Image))
                 {
                     gr.DrawString("拒  绝", new Font("黑体", 12, FontStyle.Bold), new SolidBrush(Color.Red), new Rectangle(150, 480, 104, 36));
                     gr.DrawString("理由:" + im.detailMessage, new Font("宋体", 8, FontStyle.Regular), new SolidBrush(Color.Red), new Rectangle(150, 500, 104, 36));
                 }
                 SignPictureBox.Invalidate();
             }
             Application.DoEvents();
             if (DatabaseConnections.Connector.OnlineUpdateData("gzb_remotesign", new String[] { "isSigned", "refusedMessage", "signTime", "signValue" }, new String[] { "-1", im.detailMessage, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), FormBasicFeatrues.GetInstence().CompressString(FormBasicFeatrues.GetInstence().CompressString(FormBasicFeatrues.GetInstence().ImgToBase64String(new Bitmap(SignPictureBox.Image)))) }, remoteSignId) > 0)
             {
                 MessageBox.Show("发送拒签成功!", "提示");
                 this.DialogResult = System.Windows.Forms.DialogResult.OK;
             }
         }
     }
 }
Exemplo n.º 3
0
 private void clientID_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (clientID.SelectedIndex != -1)
     {
         if (clientID.Text.Equals(""))
         {
             clientName.Clear();
         }
         else if (clientID.SelectedIndex == 1)
         {
             Picker cp = new Picker();
             cp.isClient = true;
             if (cp.ShowDialog() == DialogResult.OK)
             {
                 clientID.Text = cp.selectedClientID;
             }
             else
             {
                 clientID.SelectedIndex = 0;
             }
         }
         else
         {
             FormBasicFeatrues.GetInstence().SetControlsVauleByControlList(new List <Control>()
             {
                 clientName
             }, DatabaseConnections.Connector.LocalGetOneRowDataById("clients", new String[] { "company" }, "clientID", clientID.Text).ToList <String>());
         }
     }
 }
        public Setting()
        {
            InitializeComponent();
            tbInfo1.Text  = MainWindow.COMPANY_NAME;
            tbInfo2.Text  = MainWindow.COMPANY_NICKNAME;
            tbInfo3.Text  = MainWindow.PHONE;
            tbInfo4.Text  = MainWindow.EMAIL;
            tbInfo5.Text  = MainWindow.FAX;
            tbInfo6.Text  = MainWindow.ADDRESS;
            tbInfo7.Text  = MainWindow.BANK_NAME;
            tbInfo8.Text  = MainWindow.BANK_CARD;
            tbInfo9.Text  = MainWindow.COMPANY_OWNER;
            tbInfo10.Text = MainWindow.QQ;
            if (MainWindow.DEGREE > 0)
            {
                DatabaseResetqqButton.Visible = true;
            }

            if (!MainWindow.SIGNATURE.Equals(""))
            {
                compressedBitmap = FormBasicFeatrues.GetInstence().Base64StringToImage(FormBasicFeatrues.GetInstence().DecompressString(FormBasicFeatrues.GetInstence().DecompressString(MainWindow.SIGNATURE)));
                //Console.WriteLine("之前:" + MainWindow.SIGNATURE);
                //Console.WriteLine("之后:" + ImgToBase64String(compressedBitmap));
                SignPictureShowBox.Image = compressedBitmap;
            }
        }
        public void UserLogin(string acc, string psw)
        {
            MD5    md5Hash = MD5.Create();
            string hash    = FormBasicFeatrues.GetInstence().GetMd5Hash(md5Hash, psw);

            StringBuilder sbSQL = new StringBuilder(
                @"SELECT Count(loginId), loginId, name, nickName, notification, lastLogonTime
                    FROM caiyyUser WHERE loginId = '");

            sbSQL.Append(acc);
            sbSQL.Append(@"'");
            sbSQL.Append(@" AND password = '******'");

            string SQLforGeneral = sbSQL.ToString();

            MySqlCommand cmd = new MySqlCommand(SQLforGeneral, onlineSqlConnection);

            OnlineDbOpen();
            MySqlDataReader dataReader = cmd.ExecuteReader();

            while (dataReader.Read())
            {
                MainWindow.IS_LOGED_IN     = (int.Parse((dataReader["Count(loginId)"].ToString() == "") ? "0" : dataReader["Count(loginId)"].ToString()) == 1) ? true : false;
                MainWindow.LOGIN_ID        = dataReader["loginId"].ToString();
                MainWindow.NAME            = dataReader["name"].ToString();
                MainWindow.NICK_NAME       = dataReader["nickName"].ToString();
                MainWindow.NOTIFICATION    = dataReader["notification"].ToString();
                MainWindow.LAST_LOGON_TIME = dataReader["lastLogonTime"].ToString().Equals("") ? "首次登录" : dataReader["lastLogonTime"].ToString();
            }

            dataReader.Close();
            OnlineDbClose();
        }
Exemplo n.º 6
0
 // 同步数据库
 private void SyncDataBase(Boolean isRemoteFileExists)
 {
     if (isRemoteFileExists)
     {
         if (FormBasicFeatrues.GetInstence().getLocalFileSize(MainWindow.LOCAL_DATABASE_LOCATION) > 0)
         {
             if (FormBasicFeatrues.GetInstence().ifUpdateDatabasecheckLastModifiedTime(true))
             {
                 File.SetAttributes(MainWindow.LOCAL_DATABASE_LOCATION, FileAttributes.Normal);
                 DownloadFile(MainWindow.ONLINE_DATABASE_LOCATION_DIR + MainWindow.ONLINE_DATABASE_FILE_PREFIX, MainWindow.LOCAL_DATABASE_LOCATION);
                 File.SetAttributes(MainWindow.LOCAL_DATABASE_LOCATION, FileAttributes.Hidden);
             }
             else
             {
                 //System.IO.File.Copy(MainWindow.LOCAL_DATABASE_LOCATION, MainWindow.LOCAL_DATABASE_LOCATION_COPY, true);
                 //UploadFile(MainWindow.LOCAL_DATABASE_LOCATION_COPY, MainWindow.ONLINE_DATABASE_FTP_LOCATION_DIR + MainWindow.ONLINE_DATABASE_FILE_PREFIX);
                 UploadFile(MainWindow.LOCAL_DATABASE_LOCATION, MainWindow.ONLINE_DATABASE_FTP_LOCATION_DIR + MainWindow.ONLINE_DATABASE_FILE_PREFIX);
             }
         }
         else
         {
             File.SetAttributes(MainWindow.LOCAL_DATABASE_LOCATION, FileAttributes.Normal);
             DownloadFile(MainWindow.ONLINE_DATABASE_LOCATION_DIR + MainWindow.ONLINE_DATABASE_FILE_PREFIX, MainWindow.LOCAL_DATABASE_LOCATION);
             File.SetAttributes(MainWindow.LOCAL_DATABASE_LOCATION, FileAttributes.Hidden);
         }
     }
     else
     {
         UploadFile(MainWindow.LOCAL_DATABASE_LOCATION, MainWindow.ONLINE_DATABASE_FTP_LOCATION_DIR + MainWindow.ONLINE_DATABASE_FILE_PREFIX);
     }
 }
Exemplo n.º 7
0
 public static FormBasicFeatrues GetInstence()
 {
     if (_formBasicFeatrues == null)
     {
         _formBasicFeatrues = new FormBasicFeatrues();
     }
     return(_formBasicFeatrues);
 }
Exemplo n.º 8
0
        // MySQL

        /*
         * public void OnlineDbOpen()
         * {
         *  try
         *  {
         *      if (onlineSqlConnection.State == ConnectionState.Open)
         *      {
         *          onlineSqlConnection.Close();
         *      }
         *      onlineSqlConnection.Open();
         *  }
         *  catch
         *  {
         *      //RecordLog("无法打开连接!\r\nTargetSite: " + ex.TargetSite + "\r\n" + ex.ToString());
         *      //System.Windows.Forms.MessageBox.Show(ex.Message, "无法打开数据库连接!");
         *      throw;
         *  }
         * }
         *
         * public void OnlineDbClose()
         * {
         *  onlineSqlConnection.Close();
         * }
         */

        public void UserLogin(string acc, string psw)
        {
            using (MySqlConnection con = new MySqlConnection(OnlineConnStr))
            {
                string hash = FormBasicFeatrues.GetInstence().GetMd5Hash(MD5.Create(), psw);

                StringBuilder sbSQL = new StringBuilder(
                    @"SELECT Count(id),id,userid,password,companyNickname,workloads,company,companyowner,address,bankname,bankcard,phone,fax,QQ,email,cast(GZB_addtime as char) as GZB_addtime,GZB_degree,GZB_expiretime,GZB_isonline,notification,companyBalance,GZB_signature FROM users WHERE userid = '");
                sbSQL.Append(acc);
                sbSQL.Append(@"'");
                sbSQL.Append(@" AND password = '******'");

                string SQLforGeneral = sbSQL.ToString();

                using (MySqlCommand cmd = new MySqlCommand(SQLforGeneral, con))
                {
                    con.Open();
                    MySqlDataReader dataReader = cmd.ExecuteReader();

                    while (dataReader.Read())
                    {
                        MainWindow.IS_PASSWORD_CORRECT = (int.Parse((dataReader["Count(id)"].ToString() == "") ? "0" : dataReader["Count(id)"].ToString()) == 1) ? true : false;
                        if (MainWindow.IS_PASSWORD_CORRECT)
                        {
                            MainWindow.ID               = dataReader["id"].ToString();
                            MainWindow.USER_ID          = dataReader["userid"].ToString();
                            MainWindow.PASSWORD_HASH    = dataReader["password"].ToString();
                            MainWindow.COMPANY_NICKNAME = dataReader["companyNickname"].ToString();
                            MainWindow.WORKLOADS        = dataReader["workloads"].ToString();
                            MainWindow.COMPANY_NAME     = dataReader["company"].ToString();
                            MainWindow.COMPANY_OWNER    = dataReader["companyowner"].ToString();
                            MainWindow.ADDRESS          = dataReader["address"].ToString();
                            MainWindow.BANK_NAME        = dataReader["bankname"].ToString();
                            MainWindow.BANK_CARD        = dataReader["bankcard"].ToString();
                            MainWindow.PHONE            = dataReader["phone"].ToString();
                            MainWindow.FAX              = dataReader["fax"].ToString();
                            MainWindow.QQ               = dataReader["QQ"].ToString();
                            MainWindow.EMAIL            = dataReader["email"].ToString();
                            MainWindow.NOTIFICATION     = dataReader["notification"].ToString();
                            MainWindow.IS_USER_ONLINE   = (int.Parse(dataReader["GZB_isonline"].ToString().Equals("") ? "0" : dataReader["GZB_isonline"].ToString()) == 0) ? false : true;
                            MainWindow.DEGREE           = int.Parse(dataReader["GZB_degree"].ToString());
                            MainWindow.ADDTIME          = DateTime.Parse(dataReader["GZB_addtime"].ToString());
                            MainWindow.EXPIRETIME       = DateTime.Parse(dataReader["GZB_expiretime"].ToString());
                            MainWindow.COMPANY_BALANCE  = float.Parse(dataReader["companyBalance"].ToString());
                            MainWindow.SIGNATURE        = dataReader["GZB_signature"].ToString();
                            //MainWindow.LAST_LOGON_TIME = dataReader["lastLogonTime"].ToString().Equals("") ? "首次登录" : dataReader["lastLogonTime"].ToString();
                        }
                    }
                    dataReader.Close();
                }
            }
        }
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (FormBasicFeatrues.GetInstence().isPassValidateControls(new List <Control>()
            {
                tbInfo1, tbInfo2, tbInfo3, tbInfo4, tbInfo5, tbInfo6, tbInfo7, tbInfo8, tbInfo9
            }))
            {
                try
                {
                    if (DatabaseConnections.Connector.OnlineUpdateData(
                            "users",
                            new string[] { "company", "companyNickname", "phone", "email", "fax", "address", "bankname", "bankcard", "companyowner", "QQ" },
                            new string[] { tbInfo1.Text, tbInfo2.Text, tbInfo3.Text, tbInfo4.Text, tbInfo5.Text, tbInfo6.Text, tbInfo7.Text, tbInfo8.Text, tbInfo9.Text, tbInfo10.Text },
                            MainWindow.ID) > 0)
                    {
                        MessageBox.Show("修改用户信息成功!", "成功!");
                        MainWindow.COMPANY_NAME     = tbInfo1.Text;
                        MainWindow.COMPANY_NICKNAME = tbInfo2.Text;
                        MainWindow.PHONE            = tbInfo3.Text;
                        MainWindow.EMAIL            = tbInfo4.Text;
                        MainWindow.FAX           = tbInfo5.Text;
                        MainWindow.ADDRESS       = tbInfo6.Text;
                        MainWindow.BANK_NAME     = tbInfo7.Text;
                        MainWindow.BANK_CARD     = tbInfo8.Text;
                        MainWindow.COMPANY_OWNER = tbInfo9.Text;
                        MainWindow.QQ            = tbInfo10.Text;
                    }

                    if (isChangedSignature)
                    {
                        //GZB_signature
                        String signatureString = FormBasicFeatrues.GetInstence().CompressString(FormBasicFeatrues.GetInstence().CompressString(FormBasicFeatrues.GetInstence().ImgToBase64String(compressedBitmap)));
                        if (!signatureString.Equals(""))
                        {
                            if (DatabaseConnections.Connector.OnlineUpdateData("users", new string[] { "GZB_signature" }, new string[] { signatureString }, MainWindow.ID) > 0)
                            {
                                MainWindow.SIGNATURE = signatureString;
                            }
                        }
                    }
                    this.Close();
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message, "用户信息修改错误");
                    //throw;
                }
            }
            else
            {
                MessageBox.Show("请先填入必填项(带*项目)!", "提示");
            }
        }
Exemplo n.º 10
0
 private void ConfirmPasswordButton_Click(object sender, EventArgs e)
 {
     if (MainWindow.PASSWORD_HASH.Equals(FormBasicFeatrues.GetInstence().GetMd5HashFromString(confirmPasswordText.Text)))
     {
         this.DialogResult = System.Windows.Forms.DialogResult.OK;
     }
     else
     {
         MessageBox.Show("验证密码错误!", "提示");
         confirmPasswordText.Text = "";
     }
 }
        private float checkNumberValue(String str)
        {
            str = str.Trim();
            float result = 0.0f;

            if (!str.Equals(""))
            {
                if (FormBasicFeatrues.GetInstence().IsNumeric(str))
                {
                    result = float.Parse(str);
                }
            }
            return(result);
        }
Exemplo n.º 12
0
        public void UploadFiles(string moreInfo)
        {
            string fileName = System.Environment.CurrentDirectory + @"\data\data.db";

            try
            {
                FormBasicFeatrues.GetInstence().UpLoadFile(fileName, "", "ftp://*****:*****@www.vividapp.net/Project/VMA/Users/00000000/" + dataBaseFilePrefix + "data.txt");
                //FormBasicFeatrues.GetInstence().UpLoadFile(fileName, "", "ftp://*****:*****@qyw28051.my3w.com/products/caiYY/backup/" + dataBaseFilePrefix + "data.txt");
                MessageBox.Show(moreInfo + "数据库备份成功!", "成功!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "上传文件出现异常");
            }
        }
Exemplo n.º 13
0
        private void LoadCyy_Click(object sender, EventArgs e)
        {
            this.Text = "正在登录...";
            try
            {
                DatabaseConnections.Connector.UserLogin(cbAccount.Text, tbPassword.Text);
            }
            catch
            {
                this.Text = windowText;
                MessageBox.Show("登录错误!", "错误");
                return;
            }

            if (!MainWindow.IS_PASSWORD_CORRECT)
            {
                this.Text = windowText;
                MessageBox.Show("帐号或者密码错误, 请与管理员联系!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (FormBasicFeatrues.GetInstence().ConvertDateTimeToTimestamp(MainWindow.EXPIRETIME) < FormBasicFeatrues.GetInstence().ConvertDateTimeToTimestamp(DateTime.Now))
                {
                    this.Text = windowText;
                    MessageBox.Show("您的账户以到期, 请与管理员联系!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (MainWindow.IS_USER_ONLINE)
                    {
                        this.Text = windowText;
                        MessageBox.Show("此用户已在某处登录, 因为用户数据隐私的问题, 此版本不允许重复登录, 如有错误, 请与管理员联系!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        Properties.Settings.Default.accountName = cbAccount.Text;
                        MainWindow.IS_LOGED_IN                  = true;
                        MainWindow.LOCAL_DATABASE_LOCATION      = Environment.CurrentDirectory + "\\data\\" + MainWindow.USER_ID + "_data.db";
                        MainWindow.LOCAL_DATABASE_LOCATION_COPY = Environment.CurrentDirectory + "\\temp\\" + MainWindow.USER_ID + "_temp.gzb";
                        MainWindow.ONLINE_DATABASE_FILE_PREFIX  = MainWindow.USER_ID + "_online.db";;
                        //this.Visible = false;
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    }
                }
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// 修改密码
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ChangePasswordQQButton_Click(object sender, EventArgs e)
 {
     if (FormBasicFeatrues.GetInstence().GetMd5Hash(MD5.Create(), OldPasswordTextBox.Text).Equals(MainWindow.PASSWORD_HASH))
     {
         if (NewPasswordTextBox.Text.Equals(NewPasswordTextBox2.Text))
         {
             try
             {
                 if (DatabaseConnections.Connector.OnlineUpdateData(
                         "users",
                         new string[] { "password" },
                         new string[] { FormBasicFeatrues.GetInstence().GetMd5Hash(MD5.Create(), NewPasswordTextBox.Text) },
                         MainWindow.ID) > 0)
                 {
                     OldPasswordTextBox.Clear();
                     NewPasswordTextBox.Clear();
                     NewPasswordTextBox2.Clear();
                     MessageBox.Show("修改密码成功!下次登录时候您将需要使用新密码!", "成功");
                     //MainWindow.PASSWORD_HASH = FormBasicFeatrues.GetInstence().GetMd5Hash(MD5.Create(), NewPasswordTextBox.Text);
                     ChangePasswordCheckBox.Checked = false;
                     isChangedPassword = true;
                 }
             }
             catch (Exception ee)
             {
                 MessageBox.Show(ee.Message, "密码修改错误");
                 //throw;
             }
         }
         else
         {
             MessageBox.Show("两次密码不同!", "错误");
             NewPasswordTextBox.Clear();
             NewPasswordTextBox2.Clear();
         }
     }
     else
     {
         MessageBox.Show("旧密码输入错误!", "错误");
         OldPasswordTextBox.Clear();
         NewPasswordTextBox.Clear();
         NewPasswordTextBox2.Clear();
     }
 }
Exemplo n.º 15
0
 private void SaveButton_Click(object sender, EventArgs e)
 {
     try
     {
         DatabaseConnections.GetInstence().LocalReplaceIntoData(table, queryArray, FormBasicFeatrues.GetInstence().GetControlsVaule(controlsPreName, detailedPanel, indexCount), mainID);
         if (ItemId.Equals("-1"))
         {
             MessageBox.Show("新建成功!", "恭喜");
         }
         else
         {
             MessageBox.Show("保存成功!", "恭喜");
         }
     }
     catch (Exception ex)
     {
         FormBasicFeatrues.GetInstence().RecordLog(ex, "");
         MessageBox.Show(ex.Message, "错误");
     }
     this.Close();
 }
Exemplo n.º 16
0
        private void BillSign_Load(object sender, EventArgs e)
        {
            if (signImage != null)
            {
                SignPictureBox.Image = signImage;
            }

            if (isSendRequest)
            {
                OKButton.Text     = "发送请求";
                RefuseButton.Text = "取消";
                Image _signImage = FormBasicFeatrues.GetInstence().Base64StringToImage(FormBasicFeatrues.GetInstence().DecompressString(FormBasicFeatrues.GetInstence().DecompressString(MainWindow.SIGNATURE)));
                if (_signImage != null)
                {
                    using (Graphics gr = Graphics.FromImage(SignPictureBox.Image))
                    {
                        gr.DrawImage(_signImage, new Rectangle(420, 480, 104, 36));
                    }
                    SignPictureBox.Invalidate();
                }
            }
            else
            {
                OKButton.Text     = "确认签名";
                RefuseButton.Text = "拒绝";
            }

            if (isSigned || gzbIDStirng.Equals(MainWindow.USER_ID))
            {
                OKButton.Enabled     = false;
                RefuseButton.Enabled = false;
            }
            else
            {
                OKButton.Enabled     = true;
                RefuseButton.Enabled = true;
            }
        }
Exemplo n.º 17
0
        // 自动生成ID
        public String LocalAutoincreaseID(string table, string baseName)
        {
            using (SQLiteConnection conn = new SQLiteConnection(LocalConnStr))
            {
                String maxNumber = "";
                // SELECT max(jcdID) as max FROM jcdList
                // cast(yysid as UNSIGNED INTEGER)
                string sql = "SELECT max(cast(" + baseName + " as UNSIGNED INTEGER)) as max FROM " + table;//建表语句
                using (SQLiteCommand cmdCreateTable = new SQLiteCommand(sql, conn))
                {
                    cmdCreateTable.CommandText = sql;
                    conn.Open();
                    System.Data.SQLite.SQLiteDataReader reader = cmdCreateTable.ExecuteReader();

                    while (reader.Read())
                    {
                        maxNumber = (int.Parse(reader["max"].ToString().Equals("") ? "0" : reader["max"].ToString()) + 1).ToString();
                    }

                    return(FormBasicFeatrues.GetInstence().FormatID(maxNumber, 6, "0"));
                }
            }
        }
Exemplo n.º 18
0
 private void OKButton_Click(object sender, EventArgs e)
 {
     if (isSendRequest)
     {// 发送请求
         if (DatabaseConnections.Connector.OnlineInsertData("gzb_remotesign",
                                                            "fromGZBID,toGZBID,companyNickName,sendTime,signValue",
                                                            "'" + MainWindow.USER_ID + "','" + gzbIDStirng + "','" + companyNameStirng + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + FormBasicFeatrues.GetInstence().CompressString(FormBasicFeatrues.GetInstence().CompressString(FormBasicFeatrues.GetInstence().ImgToBase64String(new Bitmap(signImage)))) + "'") > 0)
         {
             MessageBox.Show("发送请求成功!", "提示");
             //this.Close();
             this.DialogResult = System.Windows.Forms.DialogResult.OK;
         }
     }
     else
     {// 确认签名
         ConfirmPassword cp = new ConfirmPassword();
         if (cp.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             Image _signImage = FormBasicFeatrues.GetInstence().Base64StringToImage(FormBasicFeatrues.GetInstence().DecompressString(FormBasicFeatrues.GetInstence().DecompressString(MainWindow.SIGNATURE)));
             if (_signImage != null)
             {
                 using (Graphics gr = Graphics.FromImage(SignPictureBox.Image))
                 {
                     gr.DrawImage(_signImage, new Rectangle(150, 480, 104, 36));
                 }
                 SignPictureBox.Invalidate();
                 if (DatabaseConnections.Connector.OnlineUpdateData("gzb_remotesign", new String[] { "isSigned", "signTime", "signValue" }, new String[] { "1", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), FormBasicFeatrues.GetInstence().CompressString(FormBasicFeatrues.GetInstence().CompressString(FormBasicFeatrues.GetInstence().ImgToBase64String(new Bitmap(SignPictureBox.Image)))) }, remoteSignId) > 0)
                 {
                     OKButton.Enabled     = false;
                     RefuseButton.Enabled = false;
                     MessageBox.Show("远程签名成功!", "提示");
                     this.DialogResult = System.Windows.Forms.DialogResult.OK;
                 }
             }
         }
     }
 }
Exemplo n.º 19
0
        private void checkUpdateApp()
        {
            LoadCyy.Enabled = false;
            this.Text       = "正在检测更新...";
            try
            {
                // 检测是否有最新版本
                String updateVersion = "";
                String updateLog     = "";

                /*
                 * List<String> updateVersionString = DatabaseConnections.Connector.OnlineGetOneRowDataById("config", new List<string>() { "configValue" }, "configKey", "GZB_update_version");
                 * List<String> updateVersionLogString = DatabaseConnections.Connector.OnlineGetOneRowDataById("config", new List<string>() { "configValue" }, "configKey", "GZB_update_version_log");
                 * List<String> updateAppURLString = DatabaseConnections.Connector.OnlineGetOneRowDataById("config", new List<string>() { "configValue" }, "configKey", "GZB_update_app_url");
                 *
                 * updateVersion = updateVersionString[0];
                 * updateLog = updateVersionLogString[0];
                 * MainWindow.UPDATE_APP_URL_DIR = updateAppURLString[0];
                 */

                List <List <String> > updateListString = DatabaseConnections.Connector.OnlineGetRowsDataByCondition("config", new List <string>()
                {
                    "id", "configValue"
                }, " WHERE id < 4");

                updateVersion = updateListString[0][1];
                updateLog     = updateListString[1][1];
                MainWindow.UPDATE_APP_URL_DIR = updateListString[2][1];

                if (!updateVersion.Equals(""))
                {
                    if (!MainWindow.CURRENT_APP_VERSION_NAME.Equals("") && !MainWindow.CURRENT_APP_VERSION_ID.Equals("-1"))
                    {
                        string localVersionString = "";
                        if (MainWindow.CURRENT_APP_VERSION_ID.Split('.').Length == 2)
                        {
                            localVersionString = MainWindow.CURRENT_APP_VERSION_ID + ".0";
                        }
                        else
                        {
                            localVersionString = MainWindow.CURRENT_APP_VERSION_ID;
                        }

                        if (FormBasicFeatrues.GetInstence().compareVersion(localVersionString, updateVersion, 2))
                        {
                            //string updateLog = FormBasicFeatrues.GetInstence().getOnlineFile(MainWindow.UPDATE_VERSION_LOG_URL);
                            if (!updateLog.Equals(""))
                            {
                                //this.Visible = false;
                                update ud = new update(MainWindow.UPDATE_APP_URL_DIR + MainWindow.CURRENT_APP_NAME + "-" + MainWindow.CURRENT_APP_VERSION_NAME + "v" + updateVersion + ".exe", updateVersion, updateLog);
                                ud.ShowDialog(this);
                            }
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("系统检测到您使用的是最新版本!", "提示");
            }
            this.Text       = windowText;
            LoadCyy.Enabled = true;
        }
Exemplo n.º 20
0
        public void DownLoadFile()
        {
            string urlName = "http://www.vividapp.net/Project/VMA/Users/00000000/" + dataBaseFilePrefix + "data.txt";

            //string urlName = "http://www.caiyingying.com/products/caiYY/backup/" + dataBaseFilePrefix + "data.txt";
            //string urlName = "http://www.caiyingying.com/products/caiYY/backup/test.txt";
            try
            {
                WebClient wcClient = new WebClient();

                long fileLength = 0;

                WebRequest  webReq = WebRequest.Create(urlName);
                WebResponse webRes = webReq.GetResponse();

                pbDownFile.Visible = true;
                fileLength         = webRes.ContentLength;

                pbDownFile.Value   = 0;
                pbDownFile.Maximum = (int)fileLength;

                srm       = webRes.GetResponseStream();
                srmReader = new StreamReader(srm);

                byte[] bufferbyte = new byte[fileLength];
                int    allByte    = (int)bufferbyte.Length;
                int    startByte  = 0;
                while (fileLength > 0)
                {
                    Application.DoEvents();
                    int downByte = srm.Read(bufferbyte, startByte, allByte);
                    if (downByte == 0)
                    {
                        break;
                    }
                    ;
                    startByte        += downByte;
                    allByte          -= downByte;
                    pbDownFile.Value += downByte;

                    //Text = "数据库更新 [" + Convert.ToInt32(pbDownFile.Value / (float)pbDownFile.Maximum * 100) + "%]";

                    // float part = (float)startByte / 1024;
                    //float total = (float)bufferbyte.Length / 1024;
                    //int percent = Convert.ToInt32((part / total) * 100);
                }

                using (FileStream fs = new FileStream(System.Environment.CurrentDirectory + @"\data\data.db", FileMode.Create, FileAccess.Write))
                {
                    fs.Write(bufferbyte, 0, bufferbyte.Length);
                }

                webRes.Close();
                srm.Close();
                srmReader.Close();
                pbDownFile.Visible = false;
                FormBasicFeatrues.GetInstence().SoundPlay(System.Environment.CurrentDirectory + @"\config\complete.wav");
                MessageBox.Show("数据库更新成功!", "成功");
            }
            catch (WebException webE)
            {
                if (webE.Status == WebExceptionStatus.ProtocolError)
                {
                    UploadFiles("初次备份, ");
                }
            }
            catch (Exception e)
            {
                if (MessageBox.Show("(" + urlName + ")错误信息:" + e.Message, "更新出现错误", MessageBoxButtons.OK) == DialogResult.OK)
                {
                    this.Close();
                }
            }
        }
Exemplo n.º 21
0
        private void InitDetailedInfoWindow()
        {
            int detailedLocationY = 60;
            int detailedHeightDis = 100;

            string[] resultStringArray = new string[] { };

            switch (MainWindow.CURRENT_TAB)
            {
            case 1:
                detailedHeightDis = 200;
                table             = "clients";
                detailedPanel     = DetailedClientPanel;
                queryArray        = new string[] { "id", "sex", "type", "name", "contact", "address", "phone", "taxNumber", "email", "bankInfo", "otherContacts", "PrimaryAccount", "beizhu" };
                controlsPreName   = "tbClient";
                indexCount        = 13;
                mainID            = tbClient1.Text;
                canPrint          = false;
                break;

            case 2:
                detailedHeightDis = 200;
                table             = "goods";
                detailedPanel     = DetailedGoodsPanel;
                queryArray        = new string[] { "id", "dengji", "name", "guige", "unit", "storageName", "storageManager", "storageManagerPhone", "storageLocation", "storageAddress", "initalCount", "purchasePrice", "purchaseTotal", "currentCount", "currntsalesPrice", "currentTotal", "beizhu" };
                controlsPreName   = "tbGoods";
                indexCount        = 17;
                mainID            = tbGoods1.Text;
                canPrint          = false;
                break;

            case 3:
                // 进仓单 出仓单
                detailedHeightDis = 60;
                detailedPanel     = DetailedDanziPanel;
                canPrint          = true;
                danziComboBox.Items.Clear();
                danziComboBox.SelectedIndex = 0;
                danziComboBox.Items.Add("进仓单");
                danziComboBox.Items.Add("出仓单");
                break;

            case 4:
                // 采购单 销售单
                detailedPanel     = DetailedDanziPanel;
                detailedHeightDis = 60;
                danziComboBox.Items.Clear();
                danziComboBox.Items.Add("进仓单");
                danziComboBox.Items.Add("出仓单");
                break;

            case 5:
                detailedPanel     = DetailedDanziPanel;
                detailedHeightDis = 60;

                break;

            /*
             *         default:
             *             detailedHeightDis = 60;
             *             detailedPanel = DetailedDanziPanel;
             *             canPrint = true;
             *             break;
             */
            case 6:
                detailedPanel     = DetailedHTPanel;
                detailedLocationY = 80;
                detailedHeightDis = 60;
                canPrint          = true;
                break;
            }

            if (!ItemId.Equals("-1"))
            {
                try
                {
                    FormBasicFeatrues.GetInstence().SetControlsVaule(controlsPreName, detailedPanel, DatabaseConnections.GetInstence().LocalGetOneRowDataById(table, queryArray, ItemId));
                }
                catch (Exception ex)
                {
                    FormBasicFeatrues.GetInstence().RecordLog(ex, "无法查看详细");
                    MessageBox.Show("无法查看详细" + ex.Message, "错误");
                    this.Close();
                }
            }

            this.Size = new Size(this.Size.Width, this.Size.Height - detailedHeightDis);
            PreviewPrintButton.Location = new Point(PreviewPrintButton.Location.X, PreviewPrintButton.Location.Y - detailedHeightDis);
            SaveButton.Location         = new Point(SaveButton.Location.X, SaveButton.Location.Y - detailedHeightDis);
            detailedPanel.Parent        = this;
            detailedPanel.Location      = new Point(15, 5);
            DetailedTabView.Visible     = false;

            if (!canPrint)
            {
                PreviewPrintButton.Visible = false;
            }
        }
Exemplo n.º 22
0
        private void StartTimer_Tick(object sender, EventArgs e)
        {
            StartTimer.Enabled = false;
            SetLoadingProgressBar(5);

            if (!isExiting) // 打开软件时
            {
                // 更新在线
                SetLoadingLabel("正在更新在线状态...");
                DatabaseConnections.Connector.OnlineUpdateDataFromOriginalSQL("UPDATE users SET GZB_isonline = 1, GZB_lastlogontime = NOW() WHERE userid = '" + MainWindow.USER_ID + "'");
                SetLoadingProgressBar(15);

                // 检测未处理签单的个数
                SetLoadingLabel("正在检查远程签单消息...");
                SetLoadingProgressBar(30);
                List <List <String> > remoteSignList = new List <List <string> >();
                try
                {
                    updateRemoteSignUndealedCountCheck();
                    remoteSignList = updateRemoteSign();
                }
                catch
                {
                    SetLoadingProgressBar(100);
                    canClose          = true;
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }

                SetLoadingLabel("检查远程签单消息完成...");
                SetLoadingProgressBar(60);

                SetLoadingLabel("正在检测数据库...");
                DatabaseConnections.Connector.LocalCreateDatabase(MainWindow.LOCAL_DATABASE_LOCATION);

                // 初始化数据库 备份数据库
                if (MainWindow.DEGREE > 0)
                {
                    SetLoadingLabel("正在同步数据库...");
                    SetLoadingProgressBar(databaseSyncStart);

                    Boolean isRemoteFileExists = FormBasicFeatrues.GetInstence().UriExists(MainWindow.ONLINE_DATABASE_LOCATION_DIR + MainWindow.ONLINE_DATABASE_FILE_PREFIX);

                    if (isRemoteFileExists)
                    {
                        DownloadFileDirectly(MainWindow.ONLINE_DATABASE_LOCATION_DIR + MainWindow.ONLINE_DATABASE_FILE_PREFIX, MainWindow.LOCAL_DATABASE_LOCATION);
                    }

                    DatabaseConnections.Connector.LocalClearTable("remoteSign");

                    if (remoteSignList.Count != 0)
                    {
                        foreach (List <String> item in remoteSignList)
                        {
                            DatabaseConnections.Connector.LocalReplaceIntoData("remoteSign", (new List <String>()
                            {
                                "Id", "fromGZBID", "toGZBID", "companyNickName", "isSigned", "signValue", "sendTime", "signTime", "refusedMessage"
                            }).ToArray(), item.ToArray(), MainWindow.USER_ID);
                        }
                    }
                    SyncDataBase(isRemoteFileExists);
                }
                else
                {
                    DatabaseConnections.Connector.LocalClearTable("remoteSign");
                    if (remoteSignList.Count != 0)
                    {
                        foreach (List <String> item in remoteSignList)
                        {
                            DatabaseConnections.Connector.LocalReplaceIntoData("remoteSign", (new List <String>()
                            {
                                "Id", "fromGZBID", "toGZBID", "companyNickName", "isSigned", "signValue", "sendTime", "signTime", "refusedMessage"
                            }).ToArray(), item.ToArray(), MainWindow.USER_ID);
                        }
                    }
                    SetLoadingProgressBar(100);
                    canClose          = true;
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
            }
            else // 关闭软件时
            {
                // 更新在线状态
                SetLoadingLabel("正在更新在线状态...");
                SetLoadingProgressBar(30);
                DatabaseConnections.Connector.OnlineUpdateDataFromOriginalSQL("UPDATE users SET GZB_isonline = 0 WHERE userid = '" + MainWindow.USER_ID + "'");

                // 初始化数据库 备份数据库
                if (MainWindow.DEGREE > 0)
                {
                    SetLoadingLabel("正在启动数据备份...请稍等..");
                    SetLoadingProgressBar(databaseSyncStart);
                    Boolean isRemoteFileExists = FormBasicFeatrues.GetInstence().UriExists(MainWindow.ONLINE_DATABASE_LOCATION_DIR + MainWindow.ONLINE_DATABASE_FILE_PREFIX);

                    SyncDataBase(isRemoteFileExists);
                }
                else
                {
                    SetLoadingProgressBar(100);
                    canClose          = true;
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
            }
        }