Esempio n. 1
0
        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            status.Text = "";
            try
            {
                byte[] buffer = File.ReadAllBytes(txtFilePath.Text);

                using (DB db = new DB())
                {
                    SqlParameter[] par = new SqlParameter[1];
                    par[0] = new SqlParameter("@image", DalRules.EncryptSignature(buffer));
                    int cnt = db.ExecNonQuerySP("UpdateSignature", par);
                }
                status.Text = "Saved to DB!";
            }
            catch (Exception ex)
            {
                status.Text = ex.Message;
            }
        }
Esempio n. 2
0
        private void doInsertToDB()
        {
            using (DB db = new DB())
            {
                try
                {
                    db.BeginTransaction();

                    //TRUNCATE table Raw_Transaction
                    SqlParameter[] par = new SqlParameter[1];
                    par[0] = new SqlParameter("@batchNo", _batchNo);

                    db.ExecNonQuerySP("DeleteRawDataByFileName", par);

                    //Insert transaction records
                    foreach (string txVals in _alTX)
                    {
                        db.ExecNonQuery(string.Format("INSERT Raw_Transaction VALUES ({0})", txVals));
                    }

                    //Insert detail records
                    foreach (var detail in _dicDetail)
                    {
                        db.ExecNonQuery(string.Format("INSERT Raw_Detail VALUES ('{0}',N'{1}')", detail.Key, detail.Value.Replace("'", "''")));
                    }

                    //Insert BatchInfo
                    SqlParameter[] par1 = new SqlParameter[3];
                    par1[0] = new SqlParameter("batchNo", _batchNo);
                    par1[1] = new SqlParameter("fileName", _fileName);
                    par1[2] = new SqlParameter("inputBy", GlobalParam.Inst.gsUserID);
                    db.ExecNonQuerySP("InsertBatchInfo", par1);

                    db.CommitTransaction();
                    status.Text = "Inserted to DB.";
                }
                catch (Exception ex)
                {
                    db.AbortTransaction();
                    status.Text = ex.Message;
                    Log.LogErr(ex);
                }
            }
        }