private void emailToolStripMenuItem_Click ( object sender, EventArgs e )
        {
            //string sql = "", err = "";
            if (dtgvDetail.Rows.Count == 0)
            {
                MessageBox.Show ( "Please choose 1 row for editing" );
                return;
            }
            if (dtgvDetail.Rows.Count > 0)
            {
                this.Cursor = Cursors.WaitCursor;
                string app_no = dtgvDetail["application_no", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string legal_id = dtgvDetail["legal_id", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                //string client_code = dataGridView1["client_code", dataGridView1.CurrentCell.RowIndex].Value.ToString(); //2014-09-16 (7)
                string hold_flag = dtgvDetail["Hold_Release", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string embosing_name = dtgvDetail["embossed_name", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string branch = dtgvDetail["Branch", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string ma_chinh_sach = dtgvDetail["machinhsachtd", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string credit_limit = dtgvDetail["credit_limit", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string cash_limit = dtgvDetail["cash_limit", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string product = dtgvDetail["Product", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string Organization = dtgvDetail["Organization", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string basic_card = dtgvDetail["The_Chinh_The_Phu", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );

                Frm_SendMail a = new Frm_SendMail ( );
                a.gb_mail_to = Get_Email_To ( branch );  
                a.gb_mail_cc = "[email protected];[email protected]";
                a.gb_subject = "Về việc gửi hồ sơ thẻ tín dụng";
                a.gb_body = Get_Email_Content_Manual ( branch, embosing_name, app_no, legal_id, credit_limit, cash_limit, product, Organization, ma_chinh_sach, basic_card );
                a.ShowDialog ( );

                this.Cursor = Cursors.Default;

            }
            else
                return;
        }
        private void cancelToolStripMenuItem_Click ( object sender, EventArgs e )
        {
            string sql = "", err = "";
            if (dtgvDetail.Rows.Count == 0)
            {
                MessageBox.Show ( "Please choose 1 row for editing" );
                return;
            }
            if (dtgvDetail.Rows.Count > 0)
            {
                this.Cursor = Cursors.WaitCursor;
                string app_no = dtgvDetail["application_no", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string legal_id = dtgvDetail["legal_id", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string hold_flag = dtgvDetail["Hold_Release", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string embosing_name = dtgvDetail["embossed_name", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );

                #region 2015-09-22 (8)
                string branch = dtgvDetail["Branch", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string ma_chinh_sach = dtgvDetail["machinhsachtd", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string credit_limit = dtgvDetail["credit_limit", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string cash_limit = dtgvDetail["cash_limit", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string product = dtgvDetail["Product", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string Organization = dtgvDetail["Organization", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                string basic_card = dtgvDetail["The_Chinh_The_Phu", dtgvDetail.CurrentCell.RowIndex].Value.ToString ( );
                #endregion 2015-09-22 (8)

                if (MessageBox.Show ( "Bạn có muốn CANCEL khách hàng " + embosing_name + "?", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question ) == DialogResult.Yes)
                {
                    #region 2014-09-15 (6)
                    #region Lay gia tri truoc khi update
                    sql = " select rowid, nvl(authorize,'') authorize from nab_cp_card";
                    sql += " where trim(source_application_no)='" + app_no.Trim ( ) + "'";
                    sql += "      and trim(legal_id)='" + legal_id.Trim ( ) + "'";
                    //sql += "      and trim(client_code)='" + client_code.Trim() + "'"; ////2014-09-16 (7)
                    DataTable dt = Businessbp.executedb.getTable ( sql, ref err );
                    string authorize_old = dt.Rows[0]["authorize"].ToString ( );
                    string row_id = dt.Rows[0]["rowid"].ToString ( );
                    #endregion
                    #endregion

                    sql = " update nab_cp_card set";
                    sql += " authorize='R'";
                    sql += " ,user_modify = '" + Businessbp.executedb.Usrid + "'";
                    sql += " ,date_modify = sysdate";
                    sql += " where trim(source_application_no)='" + app_no.Trim ( ) + "'";
                    sql += "      and trim(legal_id)='" + legal_id.Trim ( ) + "'";
                    //sql += "      and trim(client_code)='" + client_code.Trim() + "'"; //2014-09-16 (7)

                    Businessbp.executedb.ExecuteDML ( sql, ref err );
                    if (err != "")
                    {
                        MessageBox.Show ( err );
                        this.Cursor = Cursors.Default;
                        return;
                    }
                    else
                        MessageBox.Show ( "CANCEL cấp thẻ khách hàng " + embosing_name + " thành công!!!" );

                    #region 2014-09-15 (6)
                    #region Insert vao log
                    string type = "func_insert_staff_process_log";
                    err = "";
                    string name = "NAB_PCK_PROCESS_QUERY." + type;

                    string[] InParaName = new string[20] { "function_type", "table_name", "row_id", "tag_value", "column_1", "old_value_1", "new_value_1",
                                                        "column_2", "old_value_2", "new_value_2", "column_3", "old_value_3", "new_value_3",
                                                        "column_4", "old_value_4", "new_value_4", "column_5", "old_value_5", "new_value_5", "user_create"};
                    OracleType[] InParaType = new OracleType[20] { OracleType.VarChar, OracleType.VarChar, OracleType.VarChar, OracleType.VarChar, OracleType.VarChar,
                                                                   OracleType.VarChar, OracleType.VarChar, OracleType.VarChar, OracleType.VarChar, OracleType.VarChar,
                                                                   OracleType.VarChar, OracleType.VarChar, OracleType.VarChar, OracleType.VarChar, OracleType.VarChar,
                                                                   OracleType.VarChar, OracleType.VarChar, OracleType.VarChar, OracleType.VarChar, OracleType.VarChar,};
                    //Khai bao bien va set gia tri
                    string FUNCTION_TYPE = "", TABLE_NAME = "", ROW_ID = "", TAG_VALUE = "", COLUMN_1 = "", OLD_VALUE_1 = "", NEW_VALUE_1 = "",
                           COLUMN_2 = "", OLD_VALUE_2 = "", NEW_VALUE_2 = "", COLUMN_3 = "", OLD_VALUE_3 = "", NEW_VALUE_3 = "",
                           COLUMN_4 = "", OLD_VALUE_4 = "", NEW_VALUE_4 = "", COLUMN_5 = "", OLD_VALUE_5 = "", NEW_VALUE_5 = "", USER_CREATE = "";
                    //set gia tri
                    FUNCTION_TYPE = "CANCEL CARD";
                    TABLE_NAME = "CP_CARD";
                    ROW_ID = row_id;
                    TAG_VALUE = "<APP_NO>" + app_no + "</APP_NO>";
                    COLUMN_1 = "AUTHORIZE";
                    OLD_VALUE_1 = authorize_old;
                    NEW_VALUE_1 = "R";
                    USER_CREATE = Businessbp.executedb.Usrid;

                    string[] InParaValues = new string[20] { FUNCTION_TYPE, TABLE_NAME, ROW_ID, TAG_VALUE, COLUMN_1, OLD_VALUE_1, NEW_VALUE_1,
                                                             COLUMN_2, OLD_VALUE_2, NEW_VALUE_2, COLUMN_3, OLD_VALUE_3, NEW_VALUE_3,
                                                             COLUMN_4, OLD_VALUE_4, NEW_VALUE_4, COLUMN_5, OLD_VALUE_5, NEW_VALUE_5, USER_CREATE};
                    string[] OutParaName = new string[1] { "Emsg_out" };
                    OracleType[] OutParaType = new OracleType[1] { OracleType.VarChar };
                    int[] OutParaSize = new int[1] { 100 };
                    string[] OutParaValues = new string[1];

                    OracleType reParaType = OracleType.VarChar;
                    int reParaSize = 1;
                    string returnValue = "";
                    err = "";
                    Businessbp.executedb.ExecuteFunc ( name, InParaName, InParaType, InParaValues, OutParaName, OutParaType, OutParaSize, reParaType, reParaSize, ref OutParaValues, ref returnValue, ref err );

                    if (err != "")
                    {
                        MessageBox.Show ( "Err Authorize\n" + err );
                    }
                    else
                    {
                        if (returnValue == "1")
                        {
                            MessageBox.Show ( "Insert log success!!!" );
                        }
                        else
                        {
                            err = OutParaValues[0].ToString ( );
                            MessageBox.Show ( "Insert log fail: \n" + err );
                        }
                    }
                    #endregion
                    #endregion

                    LoadData ( );

                    #region 2015-09-22 (8)
                    Frm_SendMail a = new Frm_SendMail ( );
                    a.gb_mail_to = Get_Email_To ( branch ); 
                    //a.gb_mail_cc = "*****@*****.**" ; //OLD 2015-09-29 (9)
                    a.gb_mail_cc = "[email protected];[email protected]";// 2015-09-29 (9)
                    a.gb_subject = "Thông báo hủy thẻ";
                    a.gb_body = Get_Email_Content ( branch, embosing_name, app_no, legal_id, credit_limit, cash_limit, product, Organization, ma_chinh_sach, basic_card );
                    a.ShowDialog ( );
                    #endregion 2015-09-22 (8)

                    this.Cursor = Cursors.Default;
                }
                else// Nếu chọn NO thì khong hold
                {
                    this.Cursor = Cursors.Default;
                    return;
                }

            }
            else
                return;
        }