Exemple #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string   userName = txtUsername.Text;
            string   password = txtPassword.Text;
            CheckMD5 md5      = new CheckMD5();

            EmployeeDAO dao = new EmployeeDAO();
            EmployeeDTO dto = dao.CheckLogin(userName, md5.CreateMD5(password));

            if (dto != null && dto.EmpRole == false)
            {
                frmChangeAccount changeAccountForm = new frmChangeAccount(dto, this);
                this.Hide();
                changeAccountForm.Show();
                changeAccountForm.FormClosed += Main_Closed;
            }
            else if (dto != null && dto.EmpRole == true)
            {
                frmMaintainBooks booksForm = new frmMaintainBooks(this);
                this.Hide();
                booksForm.Show();
                booksForm.FormClosed += Main_Closed;
            }
            else if (dto == null)
            {
                MessageBox.Show("Invalid username or password!!!");
            }
        }
        private void btnSaveChange_Click(object sender, EventArgs e)
        {
            EmployeeDAO dao = new EmployeeDAO();
            CheckMD5    md5 = new CheckMD5();

            if (txtPassword.Text.Length < 2 || txtPassword.Text.Length > 15)
            {
                MessageBox.Show("Password require 2 - 15 characters.");
            }
            else
            {
                bool r = dao.ChagePassword(Employee.EmpID, md5.CreateMD5(txtPassword.Text));
                if (r == true)
                {
                    MessageBox.Show("Save successful.");
                }
                else
                {
                    MessageBox.Show("Save fail.");
                }
            }
        }
 public static bool CheckMD5(string F64_Pri, string F64_Hash)
 {
     CheckMD5 a = new CheckMD5();
     return a.verifyCS(F64_Pri, F64_Hash, Key);
 }
 public static string GetMD5(string F64_Pri)
 {
     CheckMD5 a = new CheckMD5();
     return a.GetCS(F64_Pri, Key);
 }
Exemple #5
0
 private void CreateMD5_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     CheckMD5.RunWorkerAsync();
 }
        private void button2_Click(object sender, EventArgs e)
        {
            //string excep = "insert into CARD_BNK_EXCEPTION(SWIM_ID, RECORD_SEQ, ARN, CARD_NUMBER, ACCOUNT_NUMBER, ACCOUNT_CURRENCY, TXNAMT," +
            //    " TXN_CURRENCY, BILLING_AMT, BILLING_CURRENCY, TXN_CODE, MERCHANT_NAME, TRANSACTION_DATETIME, AUTHOYN, ACQID, REVERSALYN, FILE_RECORD, error_type, error_message) values";
            //string excep1 = "";
            // SU DUNG DOAN NAY
            string lvnstt, lvnseqpayment;
            int templvnstt;
            string sfilename = "";
            string text = "";
            string lvschecksum = "";
            string lvskey = Businessbp.executedb.paymentKey;
            bool check;
            int succ = 0, unsucc = 0;
            string sqlexcept = "";
            CheckMD5 a = new CheckMD5();
            try
            {
                if (tbFileName.Text != "")
                {

                    string name = " " + Businessbp.executedb.owner + "proc_InputPayment";
                    string[] InParaName = new string[4] { "instt", "inseqpayment", "infilename", "inmsg" };
                    string[] OutParaName = new string[1] { "outret" };

                    OleDbType[] InParaType = new OleDbType[4] { OleDbType.Numeric, OleDbType.Numeric, OleDbType.VarChar, OleDbType.VarChar };
                    OleDbType[] OutParaType = new OleDbType[1] { OleDbType.Numeric };

                    //string[] InParaValues = new string[1] { tbFileName.Text }; // CHUA GAN HET 4 GIA TRI
                    string[] OutParaValues = new string[1];
                    for (int i = 0; i < 1; i++)
                        OutParaValues[i] = "";
                    int[] OutParaSize = new int[1] { 0 };
                    sfilename = tbFileName.Text;
                    string err = "";
                    // Doc file
                    FileStream ft = new FileStream(tbFileName.Text.Trim(), FileMode.Open, FileAccess.Read);
                    StreamReader trr = new StreamReader(ft);
                    // HEADER FILE
                    lvnstt = "0";
                    lvnseqpayment = "0";
                    text = trr.ReadLine();
                    string[] InParaValues = new string[4] { lvnstt, lvnseqpayment, sfilename, text };
                    Businessbp.executedb.ExecuteProcELECTRA(name, InParaName, InParaType, InParaValues, OutParaName, OutParaType, OutParaSize, ref  OutParaValues, ref  err);
                    if (err != "")
                        MessageBox.Show(err);
                    else
                    {
                        if (OutParaValues[0].ToString() == "-1")
                        {
                            MessageBox.Show("Occur error during import", "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        if (OutParaValues[0].ToString() == "1")
                        {
                            MessageBox.Show("File already import", "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    if (lvnstt == "0")
                        lvnseqpayment = OutParaValues[0].ToString();
                    lvnstt = "1";
                    // DETAIL FILE
                    while((text = trr.ReadLine()) != null)
                    {
                        if (text.Substring(0, 3) == "002") // detail
                        {
                            lvschecksum = text.Substring(347, 32);
                            check = a.verifyCS(text.Substring(0, 347), lvschecksum, lvskey);
                        }
                        else // text.Substring(0, 3) == "009" -- footer
                        {
                            lvschecksum = text.Substring(27, 32);
                            check = a.verifyCS(text.Substring(0, 27), lvschecksum, lvskey);
                        }
                        // sau moi lan doc dong moi, thi gan lai InParaValues
                        InParaValues[0] = lvnstt;
                        InParaValues[1] = lvnseqpayment;
                        InParaValues[2] = sfilename;
                        InParaValues[3] = text;
                        if (check == true)
                        {
                            Businessbp.executedb.ExecuteProcELECTRA(name, InParaName, InParaType, InParaValues, OutParaName, OutParaType, OutParaSize, ref OutParaValues, ref err);
                             {
                                if (err != "")
                                {
                                    unsucc += 1;
                                    // insert vao table banknet_import_reject dong hien tai : ghi chu "loi he thong"
                                    err = "";
                                    sqlexcept = "insert into banknet_import_reject(strdata,ghichu) values('" + text + "'," + "'system error'" + " )";
                                    Businessbp.executedb.ExecuteDML(sqlexcept, ref err);
                                }
                                else // nguoc lai proc thuc thi finish nhung tra ra nhung gia tri sau
                                {
                                    if (OutParaValues[0].ToString() == "-1")
                                    {
                                        unsucc += 1;
                                        // insert vao table banknet_import_reject dong hien tai : ghi chu "loi database"
                                        err = "";
                                        sqlexcept = "insert into banknet_import_reject(strdata,ghichu) values('" + text + "'," + "'database error'" + " )";
                                        Businessbp.executedb.ExecuteDML(sqlexcept, ref err);
                                    }
                                    else// OutParaValues[0].ToString() tra ra gia tri la payment_number -> success
                                        succ += 1;
                                }
                            }
                        }
                        else
                        {
                            // insert vao table banknet_import_reject dong hien tai: ghi chu "loi checksum"
                            unsucc += 1;
                            // insert vao table banknet_import_reject dong hien tai : ghi chu "loi database"
                            err = "";
                            sqlexcept = "insert into banknet_import_reject(strdata,ghichu) values('" + text + "'," + "'checksum error'" + " )";
                            Businessbp.executedb.ExecuteDML(sqlexcept, ref err);
                        }
                        templvnstt = Convert.ToInt32(lvnstt) + 1;
                        lvnstt = Convert.ToString(templvnstt);
                    }
                    trr.Close();
                    ft.Close();
                }
                this.Cursor = Cursors.Default;
                MessageBox.Show("Inported: " + succ.ToString() + "." + Environment.NewLine + "Rejected: " + unsucc.ToString() + ".");
                if (unsucc < 1)
                    tbStatus.Text = "Import complete without rejects.";
                else
                    tbStatus.Text = "Import complete with rejects.";
                //button2.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string lvskey = Businessbp.executedb.paymentKey;
                string chuoidong;
                CheckMD5 a = new CheckMD5();
                string fromtime = dtFrom.Text + " " + tbFh.Text + ":" + tbFm.Text + ":" + tbFs.Text;
                string totime = dtTo.Text + " " + tbTh.Text + ":" + tbTm.Text + ":" + tbTs.Text;
                string userid = Businessbp.executedb.Usrid;
                string name = " " + Businessbp.executedb.owner + "proc_OutPayment";
                string[] InParaName = new string[3] { "infromdate", "intodate", "inuserid" };
                string[] OutParaName = new string[1] { "outret" };
                OleDbType[] InParaType = new OleDbType[3] { OleDbType.VarChar, OleDbType.VarChar, OleDbType.VarChar };
                OleDbType[] OutParaType = new OleDbType[1] { OleDbType.Numeric };

                string[] InParaValues = new string[3] { fromtime, totime, userid };
                string[] OutParaValues = new string[1];
                for (int i = 0; i < 1; i++)
                    OutParaValues[i] = "";
                int[] OutParaSize = new int[1] { 0 };
                string err = "";
                Businessbp.executedb.ExecuteProcELECTRA(name, InParaName, InParaType, InParaValues, OutParaName, OutParaType, OutParaSize, ref  OutParaValues, ref  err);
                if (err != "")
                    MessageBox.Show(err);
                else
                {
                    if (OutParaValues[0].ToString() == "-2")
                    {
                        MessageBox.Show("File already extract.", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);

                    }
                    else if (OutParaValues[0].ToString() == "-1")
                    {
                        MessageBox.Show("Extract file dispute unsuccessful.", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);

                    }
                    else
                    {
                        string sql = "";
                        err = "";
                        //folder += DateTime.Now.Month.ToString()+ DateTime.Now.Day.ToString()+ DateTime.Now.Year.ToString() + "_ISS_DISP_NAB970428.dat";
                        folder += "I_" + DateTime.Now.ToString("yyyyMMdd") + "_970428_DISPUTE.dat";
                        sql = "select p.strdispute" +
                              " from  " + Businessbp.executedb.owner + "banknet_payment_dispute p" +
                            //" where p.transaction_local_date >= to_date('" + fromtime + "'," + "'mm/dd/yyyy hh24:mi:ss'" + ")" +
                            //" and p.transaction_local_date <= to_date('" + totime + "'," + "'mm/dd/yyyy hh24:mi:ss'" + ")" +
                              " where p.effdate = trunc(sysdate)" +
                              " order by p.record_seq";
                        DataTable dt = Businessbp.executedb.getTable(sql, ref err);
                        if (err != "")
                            MessageBox.Show(err);
                        else
                        {
                            if (dt.Rows.Count > 0)
                            {
                                FileStream ft = new FileStream(folder, FileMode.Create, FileAccess.Write, FileShare.None);
                                StreamWriter tw = new StreamWriter(ft);
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    chuoidong = dt.Rows[i][0].ToString();
                                    // thuc hien cong checksum dong vao cuoi
                                    chuoidong += a.GetCS(chuoidong, lvskey);
                                    // ghi vao file
                                    tw.WriteLine(chuoidong);

                                }
                                tw.Flush();
                                ft.Close();
                            }
                            //-------- Successful
                            MessageBox.Show("Extract file dispute successful.", "Exclamation",
                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        button2.Enabled = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public static bool Varify_F128(string F128_Pri, string F128_Hash)
 {
     CheckMD5 a = new CheckMD5();
     if (a.verifyCS(F128_Pri, F128_Hash, Key))
     {
         return true;
     }
     return false;
 }
 public static string Get_F128_Hash(string F128_Pri)
 {
     CheckMD5 a = new CheckMD5();
     return a.GetCS(F128_Pri, Key);
 }