public void AddAndGetStringKey()
        {
            var sa1 = new LString( "A" );
            var sa2 = new LString( "A" );
            var sb = new LString( "B" );

            var ta = new Table();

            Assert.AreEqual( 0, ta.Count() );

            ta[sa1] = 213;

            Assert.AreEqual( 213, ta[sa1] );
            Assert.AreEqual( 213, ta[sa2] );
            Assert.AreEqual( 1, ta.Count() );
            Assert.AreEqual( Value.Nil, ta[sb] );
            Assert.AreEqual( 213, ta[sa1] );

            ta[sa1] = Value.Nil;

            Assert.AreEqual( 0, ta.Count() );
            Assert.AreEqual( Value.Nil, ta[sa1] );

            ta[sb] = 2354;

            Assert.AreEqual( 2354, ta[sb] );
            Assert.AreEqual( 1, ta.Count() );
            Assert.AreEqual( Value.Nil, ta[sa2] );
            Assert.AreEqual( 2354, ta[sb] );

            ta[sb] = Value.Nil;

            Assert.AreEqual( 0, ta.Count() );
            Assert.AreEqual( Value.Nil, ta[sb] );
        }
Beispiel #2
0
 private void grGiaoDichDS_GotFocus(object sender, RoutedEventArgs e)
 {
     if (!LString.IsNullOrEmptyOrSpace(txtLyDoChung.Text))
     {
         foreach (DataRow dr in _dtGiaoDich.Rows)
         {
             if (dr["LY_DO"] == null || LString.IsNullOrEmptyOrSpace(dr["LY_DO"].ToString()))
             {
                 dr["LY_DO"] = txtLyDoChung.Text;
             }
         }
     }
 }
Beispiel #3
0
 /// <summary>
 /// Đưa các control của form về trạng thái mặc định
 /// </summary>
 private void SetFormThanhVienGD(int idKhachHang)
 {
     Presentation.Process.KhachHangProcess process = new Presentation.Process.KhachHangProcess();
     try
     {
         DataSet dsSourceKHang = process.getThongTinKHTheoID(idKhachHang);
         if (dsSourceKHang != null && dsSourceKHang.Tables.Count > 0)
         {
             DataRow dr = dsSourceKHang.Tables["KH_KHANG_HSO"].Rows[0];
             isUpdate = false;
             txtMaThanhVienGD.Text = dr["MA_KHANG"].ToString();
             txtTenKhachHang.Text  = dr["TEN_KHANG"].ToString();
             raddtNgaySinh.Value   = LDateTime.StringToDate(dr["DD_NGAY_SINH"].ToString(), "yyyyMMdd");
             if (!LString.IsNullOrEmptyOrSpace(dr["DD_GIOI_TINH"].ToString()))
             {
                 cmbGioiTinh.SelectedIndex = lstSourceGioiTinh.IndexOf(lstSourceGioiTinh.FirstOrDefault(f => f.KeywordStrings.First().Equals(dr["DD_GIOI_TINH"].ToString())));
             }
             cmbMoiQuanHe.SelectedIndex       = 0;
             cmbTTSucKhoe.SelectedIndex       = 0;
             chkThongTinCoBanGDinh.IsChecked  = false;
             chkNguoiThuaKe.IsChecked         = false;
             chkNguoiDongTrachNhiem.IsChecked = false;
             txtSoGiayTo.Text            = "";
             raddtNgayCap.Value          = null;
             cmbLoaiGiayTo.SelectedIndex = lstSourceLoaiGiayTo.IndexOf(lstSourceLoaiGiayTo.FirstOrDefault(f => f.KeywordStrings.First().Equals(BusinessConstant.LOAI_GIAY_TO.CHUNG_MINH_ND.layGiaTri())));
             cmbNoiCap.SelectedIndex     = -1;
             txtTenKhachHang.Focus();
         }
     }
     catch (System.Exception ex)
     {
         if (ex.GetType() == typeof(CustomException))
         {
             new frmThongBaoLoi(ex.Message, ex.InnerException).ShowDialog();
         }
         else if (ex.InnerException.GetType() == typeof(CustomException))
         {
             new frmThongBaoLoi(ex.InnerException.Message, ex.InnerException).ShowDialog();
         }
         else
         {
             new frmThongBaoLoi("M.DungChung.LoiLoadDuLieu", ex).ShowDialog();
         }
         LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
     }
     finally
     {
         process = null;
     }
 }
        /// <summary>
        /// Extracts the characters from a string, beginning at a specified start position, and through the specified number of character
        /// </summary>
        /// <param name="target">The target value to apply this method on</param>
        /// <param name="from">Index where to start extraction</param>
        /// <param name="length">The number of characters to extract. If omitted, it extracts the rest of the string</param>
        /// <returns></returns>
        public string Substr(LString target, int from, int length = -1)
        {
            if (from < 0)
            {
                from = 0;
            }

            // Upto end of string.
            if (length == -1)
            {
                return(target.Value.Substring(from));
            }

            return(target.Value.Substring(from, length));
        }
Beispiel #5
0
        private static int SChar(Thread l)
        {
            var buf = LString.InternalAllocBuffer(l.StackTop);

            for (int i = LString.BufferDataOffset; i < buf.Length; i++)
            {
                var cch = (int)l[i - LString.BufferDataOffset + 1];
                if (cch < 0 || cch > 0xFF)
                {
                    throw new ArgumentException("value out of range");
                }
                buf[i] = (byte)cch;
            }
            return(l.SetReturnValues(LString.InternalFinishBuffer(buf)));
        }
Beispiel #6
0
    // Use this for initialization
    void Start()
    {
        m_translation = m_locaKey;
        m_textMesh    = this.GetComponent <TextMesh>();

        if (m_textMesh != null)
        {
            m_textMesh.text = m_translation;
        }

        if (guiText != null)
        {
            guiText.text = m_translation;
        }
    }
Beispiel #7
0
        private void Start()
        {
            LanguageEnum lang = LanguageEnum.unkonwn;

            Enum.TryParse(PlayerPrefsAES.GetString("lang"), true, out lang);//?????
            if (lang == LanguageEnum.unkonwn)
            {
                lang = Localization.SystemLang;
            }
            if (lang == LanguageEnum.unkonwn)
            {//默认英文
                lang = LanguageEnum.en;
            }
            Localization.Init(lang);
            LString.Load_UIString();
        }
Beispiel #8
0
 /// <summary>
 /// Kiểm tra các thông tin nhập vào trước khi lưu dữ liệu
 /// </summary>
 /// <returns></returns>
 private bool Validation()
 {
     if (LString.IsNullOrEmptyOrSpace(txtMaLoaiGD.Text))
     {
         LMessage.ShowMessage("Mã loại giao dịch không được để trống", LMessage.MessageBoxType.Warning);
         txtMaLoaiGD.Focus();
         return(false);
     }
     else if (LString.IsNullOrEmptyOrSpace(txtTenLoaiGD.Text))
     {
         LMessage.ShowMessage("M.DanhMuc.ucPhanHeGDCT.ThieuTenDonVi", LMessage.MessageBoxType.Warning);
         txtTenLoaiGD.Focus();
         return(false);
     }
     return(true);
 }
        private bool Validation()
        {
            if (string.IsNullOrEmpty(txtUsername.Text))
            {
                LMessage.ShowMessage("M.ZAMainApp.LoginWindow.ThieuTenDangNhap", LMessage.MessageBoxType.Warning);
                txtUsername.Focus();
                return(false);
            }

            else if (LString.IsNullOrEmptyOrSpace(txtPassword.Password))
            {
                LMessage.ShowMessage("M.ZAMainApp.LoginWindow.ThieuMatKhau", LMessage.MessageBoxType.Warning);
                txtPassword.Focus();
                return(false);
            }
            return(true);
        }
 private void FindData()
 {
     try
     {
         List <string> lst = new List <string>();
         foreach (RadTreeViewItem item in trvDonvi.CheckedItems)
         {
             if (!LString.IsNullOrEmptyOrSpace(item.Tag.ToString()))
             {
                 lst.Add(item.Tag.ToString());
             }
         }
         DataTable grdData = new DataTable("FIND_DATA");
         foreach (DataColumn col in dt.Columns)
         {
             grdData.Columns.Add(col.ColumnName, col.DataType);
         }
         grNhanSuDS.ItemsSource = null;
         if (lst.Count > 0)
         {
             foreach (DataRow row in dt.Rows)
             {
                 if (lst.Contains(row["MA_PHAN_HE"].ToString()))
                 {
                     grdData.ImportRow(row);
                     grdData.Rows[grdData.Rows.Count - 1]["STT"] = grdData.Rows.Count;
                 }
             }
             grNhanSuDS.ItemsSource = grdData;
             UpdateLayout();
             lblSum.Content = grdData.Rows.Count;
         }
         else
         {
             grNhanSuDS.ItemsSource = dt;
             lblSum.Content         = dt.Rows.Count;
         }
     }
     catch (System.Exception ex)
     {
         this.Cursor = Cursors.Arrow;
         CommonFunction.ThongBaoLoi(ex);
         LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
     }
 }
Beispiel #11
0
        /// <summary>
        /// Kiem tra du lieu truoc khi luu
        /// </summary>
        /// <returns></returns>
        private bool Validation()
        {
            if (LString.IsNullOrEmptyOrSpace(txtSoTaiKhoan.Text))
            {
                CommonFunction.ThongBaoTrong(lblSoTaiKhoan.Content.ToString());
                txtSoTaiKhoan.Focus();
                return(false);
            }

            else if (LString.IsNullOrEmptyOrSpace(txtTCTD.Text))
            {
                CommonFunction.ThongBaoTrong(lblTenTCTD.Content.ToString());
                txtTCTD.Focus();
                return(false);
            }

            return(true);
        }
Beispiel #12
0
        public void ManyEquals()
        {
            var strs = new List <LString>();

            for (int i = 0; i < 4096; i++)
            {
                strs.Add(new LString(string.Format("s:{0}", i)));
            }

            for (int i = 0; i < strs.Count; i++)
            {
                var so = strs[i];
                var sn = new LString(string.Format("s:{0}", i));

                Assert.AreEqual(so, sn);
                Assert.AreEqual(so.GetHashCode(), sn.GetHashCode());
            }
        }
        /// <summary>
        /// Extracts the characters from a string, between two specified indices
        /// </summary>
        /// <param name="target">The target value to apply this method on</param>
        /// <param name="from">Index where to start extraction</param>
        /// <param name="to">The index where to stop the extraction. If omitted, it extracts the rest of the string</param>
        /// <returns></returns>
        public string Substring(LString target, int from, int to = -1)
        {
            if (from < 0)
            {
                from = 0;
            }

            // Upto end of string.
            if (to == -1)
            {
                return(target.Value.Substring(from));
            }

            // Compute length for c# string method.
            int length = (to - from) + 1;

            return(target.Value.Substring(from, length));
        }
        private void btnKhachHang_Click(object sender, RoutedEventArgs e)
        {
            Window window = new Window();

            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            window.RenderSize            = new Size(1024, 768);
            ucPopupKhachHang uc = new ucPopupKhachHang();

            window.Content = uc;
            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            window.ShowDialog();
            if (!LString.IsNullOrEmptyOrSpace(uc.id))
            {
                txtMaKhachHang.Text     = uc.ma;
                lblTenKhachHang.Content = uc.ten;
            }
            uc = null;
        }
        /// <summary>
        /// Kiem tra du lieu truoc khi luu
        /// </summary>
        /// <returns></returns>
        private bool Validation()
        {
            AutoComboBox      au           = new AutoComboBox();
            AutoCompleteEntry loai_giay_to = au.getEntryByDisplayName(lstSourceLoaiGiayTo, ref cmbLoaiGiayTo);
            AutoCompleteEntry noi_cap      = au.getEntryByDisplayName(lstSourceNoiCap, ref cmbNoiCap);

            if (loai_giay_to == null)
            {
                CommonFunction.ThongBaoTrong(lblLoaiGiayTo.Content.ToString());
                cmbLoaiGiayTo.Focus();
                return(false);
            }
            else if (LString.IsNullOrEmptyOrSpace(txtSoGiayTo.Text))
            {
                CommonFunction.ThongBaoTrong(lblSoGiayTo.Content.ToString());
                txtSoGiayTo.Focus();
                return(false);
            }
            else if (raddtNgayCap.Value == null)
            {
                CommonFunction.ThongBaoTrong(lblNgayCap.Content.ToString());
                raddtNgayCap.Focus();
                return(false);
            }
            else if (noi_cap == null)
            {
                CommonFunction.ThongBaoTrong(lblNoiCap.Content.ToString());
                cmbNoiCap.Focus();
                return(false);
            }
            else if (raddtNgayHetHan.Value == null)
            {
                CommonFunction.ThongBaoTrong(lblNgayHetHan.Content.ToString());
                raddtNgayHetHan.Focus();
                return(false);
            }
            else if (Convert.ToDateTime(raddtNgayHetHan.Value) < Convert.ToDateTime(raddtNgayCap.Value))
            {
                LMessage.ShowMessage("M.KhachHang.Popup.ucThongTinCoBanHoGD.LoiNgayHetHan", LMessage.MessageBoxType.Warning);
                raddtNgayHetHan.Focus();
                return(false);
            }
            return(true);
        }
Beispiel #16
0
        private static int SLower(Thread l)
        {
            var str    = (LString)l[1];
            var strDat = str.InternalData;

            var ret = LString.InternalAllocBuffer(str.Length);

            for (int i = LString.BufferDataOffset; i < ret.Length; i++)
            {
                var ch = strDat[i];
                if (ch >= (byte)'A' && ch <= (byte)'Z')
                {
                    ch = (byte)((byte)'a' + (ch - (byte)'A'));
                }
                ret[i] = ch;
            }

            return(l.SetReturnValues(LString.InternalFinishBuffer(ret)));
        }
        /// <summary>
        /// Returns the position of the last found occurrence of a specified value in a string
        /// </summary>
        /// <param name="target">The target value to apply this method on</param>
        /// <param name="searchString">The text to search for</param>
        /// <param name="start">The position to start search</param>
        /// <returns></returns>
        public int LastIndexOf(LString target, string searchString, int start)
        {
            if (string.IsNullOrEmpty(target.Value))
            {
                return(-1);
            }
            if (string.IsNullOrEmpty(searchString))
            {
                return(-1);
            }
            if (start == -1)
            {
                return(target.Value.LastIndexOf(searchString));
            }

            var result = target.Value.LastIndexOf(searchString, start);

            return(result);
        }
        public void Can_Call_Execute()
        {
            var lsMethods = new LJSStringMethods();

            lsMethods.Init();
            var ls = new LString("fluent");

            Assert.AreEqual("u", lsMethods.ExecuteMethod(new LString("fluent"), "charAt", new object[] { 2 }));
            Assert.AreEqual("fluent_script", lsMethods.ExecuteMethod(new LString("fluent"), "concat", new object[] { "_", "script" }));
            Assert.AreEqual(6, lsMethods.ExecuteMethod(new LString("fluent_script"), "indexOf", new object[] { "_script", 0 }));
            Assert.AreEqual(6, lsMethods.ExecuteMethod(new LString("fluent_script"), "lastIndexOf", new object[] { "_script", -1 }));
            Assert.AreEqual(13, lsMethods.ExecuteMethod(new LString("fluent_script"), "length", null));
            Assert.AreEqual("fluent_fluent", lsMethods.ExecuteMethod(new LString("fluent_script"), "replace", new object[] { "script", "fluent" }));
            Assert.AreEqual(7, lsMethods.ExecuteMethod(new LString("fluent_script"), "search", new object[] { "script" }));
            Assert.AreEqual("_sc", lsMethods.ExecuteMethod(new LString("fluent_script"), "substr", new object[] { 6, 3 }));
            Assert.AreEqual("_sc", lsMethods.ExecuteMethod(new LString("fluent_script"), "substring", new object[] { 6, 8 }));
            Assert.AreEqual("fluent_script", lsMethods.ExecuteMethod(new LString("fluent_script"), "toLowerCase", null));
            Assert.AreEqual("FLUENT_SCRIPT", lsMethods.ExecuteMethod(new LString("fluent_script"), "toUpperCase", null));
        }
Beispiel #19
0
        /// <summary>
        /// Hiện popup khách hàng chưa phải là thành viên
        /// </summary>
        private void HienPopUpThanhVienGD()
        {
            Window window = new Window();

            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            window.RenderSize            = new Size(1024, 768);
            ucPopupKhachHang uc = new ucPopupKhachHang(false);

            window.Title   = "Danh sách khách hàng";
            window.Content = uc;
            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            window.ShowDialog();
            if (!LString.IsNullOrEmptyOrSpace(uc.id))
            {
                int idKhachHang = Convert.ToInt32(uc.id);
                SetFormThanhVienGD(idKhachHang);
            }
            uc = null;
        }
Beispiel #20
0
 private void txtLyDoChung_LostFocus(object sender, RoutedEventArgs e)
 {
     if (!LString.IsNullOrEmptyOrSpace(txtLyDoChung.Text))
     {
         foreach (DataRow dr in _dtGiaoDich.Rows)
         {
             if (KT_KS_LYDO == "RIENG")
             {
                 if (dr["LY_DO"] == null || LString.IsNullOrEmptyOrSpace(dr["LY_DO"].ToString()))
                 {
                     dr["LY_DO"] = txtLyDoChung.Text;
                 }
             }
             else
             {
                 dr["LY_DO"] = txtLyDoChung.Text;
             }
         }
     }
 }
        /// <summary>
        /// Kiem tra du lieu truoc khi luu
        /// </summary>
        /// <returns></returns>
        private bool Validation()
        {
            AutoComboBox au = new AutoComboBox();

            if (LString.IsNullOrEmptyOrSpace(txtMaKhachHang.Text))
            {
                CommonFunction.ThongBaoTrong(lblMaKhachHang.Content.ToString());
                txtMaKhachHang.Focus();
                return(false);
            }

            else if (au.getEntryByDisplayName(lstSourceMoiQuanHe, ref cmbMoiQuanHe) == null)
            {
                CommonFunction.ThongBaoTrong(lblMoiQuanHe.Content.ToString());
                cmbMoiQuanHe.Focus();
                return(false);
            }

            return(true);
        }
Beispiel #22
0
        public void DeepOpSelf()
        {
            var globals = new Table();

            Libs.BaseLib.SetBaseMethods(globals);

            globals["g__index"] = (Callable)(l =>
            {
                var t = (Table)l[1];
                var k = (LString)l[2];

                var kstr = k.ToString();
                kstr += "_";

                k = new LString(kstr);

                return(l.SetReturnValues(t[k]));
            });

            RunTestScriptWithGlobals("DeepOpSelf.lua", globals, 42);
        }
Beispiel #23
0
 private void txtMaPhanLoai_LostFocus(object sender, RoutedEventArgs e)
 {
     Presentation.Process.KeToanProcess ketoanProcess = new Presentation.Process.KeToanProcess();
     try
     {
         if (!LString.IsNullOrEmptyOrSpace(txtMaPhanLoai.Text))
         {
             DataTable dt = ketoanProcess.getThongTinMaPhanLoaiTheoMa(txtMaPhanLoai.Text);
             if (dt != null && dt.Rows.Count > 0)
             {
                 txtMaPhanLoai.Tag      = dt.Rows[0]["ID"].ToString();
                 txtMaPhanLoai.Text     = dt.Rows[0]["MA_PLOAI"].ToString();
                 lblTenPhanLoai.Content = dt.Rows[0]["TEN_PLOAI"].ToString();
             }
             else
             {
                 LMessage.ShowMessage("Không tồn tại mã phân loại tài khoản này", LMessage.MessageBoxType.Warning);
                 txtMaPhanLoai.Tag      = "";
                 txtMaPhanLoai.Text     = "";
                 lblTenPhanLoai.Content = "";
             }
         }
         else
         {
             txtMaPhanLoai.Tag      = "";
             txtMaPhanLoai.Text     = "";
             lblTenPhanLoai.Content = "";
         }
     }
     catch (System.Exception ex)
     {
         LMessage.ShowMessage("M.DungChung.LoiLoadDuLieu", LMessage.MessageBoxType.Error);
         LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
     }
     finally
     {
         ketoanProcess = null;
     }
 }
Beispiel #24
0
        /// <summary>
        /// Evaluates a math expression of 2 time spans.
        /// </summary>
        /// <param name="node">The AST node the evaluation is a part of.</param>
        /// <param name="lhs">The time on the left hand side</param>
        /// <param name="rhs">The time on the right hand side</param>
        /// <param name="op">The math operator.</param>
        /// <returns></returns>
        public static LBool CompareStrings(AstNode node, LString lhs, LString rhs, Operator op)
        {
            var left   = lhs.Value;
            var right  = rhs.Value;
            var result = false;

            if (op == Operator.EqualEqual)
            {
                result = left == right;
                return(new LBool(result));
            }
            else if (op == Operator.NotEqual)
            {
                result = left != right;
                return(new LBool(result));
            }

            var compareResult = string.Compare(left, right, StringComparison.InvariantCultureIgnoreCase);

            if (op == Operator.LessThan)
            {
                result = compareResult == -1;
            }
            else if (op == Operator.LessThanEqual)
            {
                result = compareResult != 1;
            }
            else if (op == Operator.MoreThan)
            {
                result = compareResult == 1;
            }
            else if (op == Operator.MoreThanEqual)
            {
                result = compareResult != -1;
            }
            return(new LBool(result));
        }
Beispiel #25
0
        private static bool HasPatternSpecials(LString pat)
        {
            var pDat = pat.InternalData;

            for (int i = LString.BufferDataOffset; i < pDat.Length; i++)
            {
                switch (pDat[i])
                {
                case (byte)'^':
                case (byte)'$':
                case (byte)'*':
                case (byte)'+':
                case (byte)'?':
                case (byte)'.':
                case (byte)'(':
                case (byte)'[':
                case (byte)'%':
                case (byte)'-':
                    return(true);
                }
            }

            return(false);
        }
Beispiel #26
0
        /// <summary>
        /// Su kien luu thong tin chi tiet xuong grid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tlbSaveThongTin_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (Validation())
                {
                    AutoComboBox au          = new AutoComboBox();
                    string       gioi_tinh   = au.getEntryByDisplayName(lstSourceGioiTinh, ref cmbGioiTinh).KeywordStrings[0];
                    string       suc_khoe    = au.getEntryByDisplayName(lstSourceSucKhoe, ref cmbTTSucKhoe).KeywordStrings[0];
                    string       moi_quan_he = au.getEntryByDisplayName(lstSourceMoiQuanHe, ref cmbMoiQuanHe).KeywordStrings[0];

                    DateTime    ngay_sinh = Convert.ToDateTime(raddtNgaySinh.Value);
                    int         tuoi      = LDateTime.CountYearBetweenDates(LDateTime.GetCurrentDate(), Convert.ToDateTime(raddtNgaySinh.Value));
                    DataRowView dr        = null;
                    if (!isUpdate)
                    {
                        DataRow drAdd = _dtSource.NewRow();
                        _dtSource.Rows.Add(drAdd);
                        dr             = _dtSource.DefaultView[_dtSource.Rows.Count - 1];
                        dr["CHON"]     = false;
                        dr["STT"]      = grThanhVienTrongGD.Items.Count;
                        dr["ID_KHANG"] = -1;
                        idTuSinh       = idTuSinh - 1;
                    }
                    else
                    {
                        dr = (DataRowView)grThanhVienTrongGD.SelectedItem;
                    }

                    if (dr == null)
                    {
                        DataRow drAdd = _dtSource.NewRow();
                        _dtSource.Rows.Add(drAdd);
                        dr             = _dtSource.DefaultView[_dtSource.Rows.Count - 1];
                        dr["CHON"]     = false;
                        dr["STT"]      = grThanhVienTrongGD.Items.Count;
                        dr["ID_KHANG"] = -1;
                        idTuSinh       = idTuSinh - 1;
                    }

                    dr["GD_HO_TEN"]            = txtTenKhachHang.Text.Trim();
                    dr["GD_NGAY_SINH"]         = ngay_sinh.ToString("yyyyMMdd");
                    dr["GD_NGAY_SINH_TEXT"]    = ngay_sinh.ToString(@"dd/MM/yyyy");
                    dr["GD_TUOI"]              = tuoi;
                    dr["GD_GIOI_TINH"]         = gioi_tinh;
                    dr["GD_GIOI_TINH_TEXT"]    = cmbGioiTinh.Text;
                    dr["GD_MOI_QUAN_HE"]       = moi_quan_he;
                    dr["GD_MOI_QUAN_HE_TEXT"]  = cmbMoiQuanHe.Text;
                    dr["GD_TTRANG_SKHOE"]      = suc_khoe;
                    dr["GD_TTRANG_SKHOE_TEXT"] = cmbTTSucKhoe.Text;
                    dr["GD_NGHE_NGHIEP"]       = chkCoViecLam.IsChecked;
                    dr["GD_NGUOI_TKE"]         = chkNguoiThuaKe.IsChecked;
                    dr["GD_NGUOI_DONG_TNHIEM"] = chkNguoiDongTrachNhiem.IsChecked;
                    if (!LString.IsNullOrEmptyOrSpace(txtMaThanhVienGD.Text))
                    {
                        dr["GD_MA_DONG_TNHIEM"] = txtMaThanhVienGD.Text;
                    }
                    else
                    {
                        dr["GD_MA_DONG_TNHIEM"] = "DTN" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    }

                    if (chkNguoiThuaKe.IsChecked == true || chkNguoiDongTrachNhiem.IsChecked == true)
                    {
                        AutoCompleteEntry auLoaiGiayTo = au.getEntryByDisplayName(lstSourceLoaiGiayTo, ref cmbLoaiGiayTo);
                        AutoCompleteEntry auNoiCap     = au.getEntryByDisplayName(lstSourceNoiCap, ref cmbNoiCap);

                        dr["GD_GTLQ_SO"] = txtSoGiayTo.Text;
                        if (!LObject.IsNullOrEmpty(auNoiCap))
                        {
                            dr["GD_GTLQ_NOI_CAP"] = auNoiCap.KeywordStrings[0];
                        }
                        dr["GD_GTLQ_NOI_CAP_TEXT"] = cmbNoiCap.Text;
                        if (!LObject.IsNullOrEmpty(auLoaiGiayTo))
                        {
                            dr["GD_GTLQ_LOAI"] = auLoaiGiayTo.KeywordStrings[0];
                        }
                        dr["GD_GTLQ_LOAI_TEXT"] = cmbLoaiGiayTo.Text;
                        if (!LObject.IsNullOrEmpty(raddtNgayCap.Value))
                        {
                            DateTime ngay_cap = Convert.ToDateTime(raddtNgayCap.Value);
                            dr["GD_GTLQ_NGAY_CAP"]      = ngay_cap.ToString("yyyyMMdd");
                            dr["GD_GTLQ_NGAY_CAP_TEXT"] = ngay_cap.ToString("dd/MM/yyyy");
                        }
                    }

                    ResetForm();
                }
            }
            catch (Exception ex)
            {
                LMessage.ShowMessage("M.DungChung.LoiChung", LMessage.MessageBoxType.Error);
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
            }
        }
Beispiel #27
0
        /// <summary>
        /// Extracts the characters from a string, between two specified indices
        /// </summary>
        /// <param name="target">The target value to apply this method on</param>
        /// <param name="from">Index where to start extraction</param>
        /// <param name="to">The index where to stop the extraction. If omitted, it extracts the rest of the string</param>
        /// <returns></returns>
        public string Substring(LString target, int from, int to = -1)
        {
            if (from < 0) from = 0; 

            // Upto end of string.
            if (to == -1) return target.Value.Substring(from);

            // Compute length for c# string method.
            int length = (to - from) + 1;
            return target.Value.Substring(from, length);
        }
Beispiel #28
0
 /// <summary>
 /// Searches for a match between a substring (or regular expression) and a string, and replaces the matched substring with a new substring
 /// </summary>
 /// <param name="target">The target value to apply this method on</param>
 /// <param name="substring">Required. A substring or a regular expression.</param>
 /// <param name="newString">Required. The string to replace the found value in parameter 1</param>
 /// <returns></returns>
 public string Replace(LString target, string substring, string newString)
 {
     return target.Value.Replace(substring, newString);
 }        
Beispiel #29
0
 /// <summary>
 /// Joins two or more strings, and returns a copy of the joined strings
 /// </summary>
 /// <param name="target">The target value to apply this method on</param>
 /// <param name="strings">The list of strings to join</param>
 /// <returns></returns>
 public string Concat(LString target, object[] strings)
 {
     var result = new StringBuilder();
     result.Append(target.Value);
     foreach (object str in strings)
         result.Append(str);
     return result.ToString();
 }
Beispiel #30
0
 /// <summary>
 /// Returns the position of the first found occurrence of a specified value in a string
 /// </summary>
 /// <param name="target">The target value to apply this method on</param>
 /// <param name="searchString">The string to search for</param>
 /// <param name="start">The starting position to start the search.</param>
 /// <returns></returns>
 public int IndexOf(LString target, string searchString, int start = 0)
 {
     if (string.IsNullOrEmpty(target.Value)) return -1;
     if (string.IsNullOrEmpty(searchString)) return -1;
     return target.Value.IndexOf(searchString, start);
 }
        public void Strings()
        {
            var a1 = new LString( "A" );
            var a2 = new LString( "A" );
            var b = new LString( "B" );

            Value va1 = a1;
            Value va2 = a2;
            Value vb = b;

            Assert.AreEqual( LValueType.String, va1.ValueType );
            Assert.AreEqual( LValueType.String, va2.ValueType );
            Assert.AreEqual( LValueType.String, vb.ValueType );

            Assert.IsTrue( va1.Equals( a1 ) );
            Assert.IsTrue( va1.Equals( a2 ) );
            Assert.IsFalse( va1.Equals( b ) );

            Assert.IsTrue( Value.Equals( va1, va2 ) );
            Assert.IsFalse( Value.Equals( va1, vb ) );

            Assert.IsTrue( va1.Equals( va2 ) );
            Assert.IsFalse( va1.Equals( vb ) );

            Assert.AreEqual( va1, va2 );
            Assert.AreNotEqual( va1, vb );

            Value nil = 4;
            Assert.AreEqual( 4, nil );
            nil.Set( new LString() );
            Assert.AreEqual( Value.Nil, nil );
            Assert.IsTrue( nil.IsNil );
        }
Beispiel #32
0
        /// <summary>
        /// Extracts the characters from a string, beginning at a specified start position, and through the specified number of character
        /// </summary>
        /// <param name="target">The target value to apply this method on</param>
        /// <param name="from">Index where to start extraction</param>
        /// <param name="length">The number of characters to extract. If omitted, it extracts the rest of the string</param>
        /// <returns></returns>
        public string Substr(LString target, int from, int length = -1)
        {
            if (from < 0) from = 0;

            // Upto end of string.
            if (length == -1) return target.Value.Substring(from);

            return target.Value.Substring(from, length);
        }
Beispiel #33
0
 /// <summary>
 /// Converts a string to lowercase letters
 /// </summary>
 /// <param name="target">The target value to apply this method on</param>
 /// <returns></returns>
 public string ToLowerCase(LString target)
 {
     return target.Value.ToLower();
 }
Beispiel #34
0
 /// <summary>
 /// Gets the length of the string
 /// </summary>
 /// <param name="target">The target value to apply this method on</param>
 /// <returns></returns>
 public int Length(LString target)
 {
     return target.Value.Length;
 }
Beispiel #35
0
 /// <summary>
 /// Returns the character at the specified index
 /// </summary>
 /// <param name="target">The target value to apply this method on</param>
 /// <param name="ndx">The index of the character to get</param>
 /// <returns></returns>
 public string CharAt(LString target, int ndx)
 {
     if (ndx < 0) return string.Empty;
     if (ndx >= target.Value.Length) return string.Empty;
     return target.Value[ndx].ToString();
 }
        public void ManyKeys()
        {
            var strs = new LString[256];
            for( int i = 0; i < strs.Length; i++ )
                strs[i] = new LString( string.Format( "str:{0}", i ) );

            var ta = new Table();

            ta[Math.E] = Math.PI;

            for( int n = 0; n < 4096 * 4; n++ )
            {
                int i = 1 + ((n * 17) % 13) * ((n * 13) % 17);
                ta[i] = ta[i].IsNil ? (Value)n : Value.Nil;

                int j = 1 + (((n - 5) * 17) % 13) * (((n + 3) * 13) % 17);

                var jKey = j * Math.PI;
                ta[jKey] = ta[jKey].IsNil ? (Value)n : Value.Nil;

                var sjKey = new LString( string.Format( "jKey:{0}", j ) );
                ta[sjKey] = ta[sjKey].IsNil ? (Value)n : Value.Nil;

                if( n % 10 == 0 )
                {
                    var s = strs[n % strs.Length];
                    ta[s] = ta[s].IsNil ? (Value)n : Value.Nil;
                }
            }

            Assert.AreEqual( Math.PI, ta[Math.E] );
        }
        private static int StrIdxArg( LString str, int idx )
        {
            if( idx == 0 )
                return -1;

            if( idx > 0 )
                idx--;
            else if( idx < 0 )
                idx += str.Length;

            if( idx < 0 )
                idx = 0;
            else if( idx > str.Length )
                idx = str.Length;

            return idx;
        }
        public void DeepOpSelf()
        {
            var globals = new Table();
            Libs.BaseLib.SetBaseMethods( globals );

            globals["g__index"] = (Callable)(l =>
            {
                var t = (Table)l[1];
                var k = (LString)l[2];

                var kstr = k.ToString();
                kstr += "_";

                k = new LString( kstr );

                return l.SetReturnValues( t[k] );
            });

            RunTestScriptWithGlobals( "DeepOpSelf.lua", globals, 42 );
        }
Beispiel #39
0
        /// <summary>
        /// Kiem tra du lieu truoc khi luu
        /// </summary>
        /// <returns></returns>
        private bool Validation()
        {
            AutoComboBox au = new AutoComboBox();

            if (LString.IsNullOrEmptyOrSpace(txtTenKhachHang.Text))
            {
                CommonFunction.ThongBaoTrong(lblHoTen.Content.ToString());
                txtTenKhachHang.Focus();
                return(false);
            }
            else if (raddtNgaySinh.Value == null)
            {
                CommonFunction.ThongBaoTrong(lblNgayThangNamSinh.Content.ToString());
                raddtNgaySinh.Focus();
                return(false);
            }
            else if (au.getEntryByDisplayName(lstSourceGioiTinh, ref cmbGioiTinh) == null)
            {
                CommonFunction.ThongBaoTrong(lblGioiTinh.Content.ToString());
                cmbGioiTinh.Focus();
                return(false);
            }
            else if (au.getEntryByDisplayName(lstSourceMoiQuanHe, ref cmbMoiQuanHe) == null)
            {
                CommonFunction.ThongBaoTrong(lblMoiQuanHe.Content.ToString());
                cmbMoiQuanHe.Focus();
                return(false);
            }
            else if (au.getEntryByDisplayName(lstSourceSucKhoe, ref cmbTTSucKhoe) == null)
            {
                CommonFunction.ThongBaoTrong(lblTTSucKhoe.Content.ToString());
                cmbTTSucKhoe.Focus();
                return(false);
            }
            else if (Convert.ToDateTime(raddtNgaySinh.Value) > LDateTime.GetCurrentDate())
            {
                LMessage.ShowMessage("M.KhachHang.Popup.ucThongTinCoBanHoGD.LoiNgaySinh", LMessage.MessageBoxType.Warning);
                raddtNgaySinh.Focus();
                return(false);
            }

            if (chkNguoiThuaKe.IsChecked == true || chkNguoiDongTrachNhiem.IsChecked == true)
            {
                AutoCompleteEntry loai_giay_to = au.getEntryByDisplayName(lstSourceLoaiGiayTo, ref cmbLoaiGiayTo);
                AutoCompleteEntry noi_cap      = au.getEntryByDisplayName(lstSourceNoiCap, ref cmbNoiCap);
                //if (loai_giay_to == null)
                //{
                //    CommonFunction.ThongBaoTrong(lblLoaiGiayTo.Content.ToString());
                //    cmbLoaiGiayTo.Focus();
                //    return false;
                //}
                //else if (LString.IsNullOrEmptyOrSpace(txtSoGiayTo.Text))
                //{
                //    CommonFunction.ThongBaoTrong(lblSoGiayTo.Content.ToString());
                //    txtSoGiayTo.Focus();
                //    return false;
                //}
                //else if (raddtNgayCap.Value == null)
                //{
                //    CommonFunction.ThongBaoTrong(lblNgayCap.Content.ToString());
                //    raddtNgayCap.Focus();
                //    return false;
                //}
                //else if (noi_cap == null)
                //{
                //    CommonFunction.ThongBaoTrong(lblNoiCap.Content.ToString());
                //    cmbNoiCap.Focus();
                //    return false;
                //}
            }
            return(true);
        }
        private static bool HasPatternSpecials( LString pat )
        {
            var pDat = pat.InternalData;
            for( int i = LString.BufferDataOffset; i < pDat.Length; i++ )
            {
                switch( pDat[i] )
                {
                case (byte)'^':
                case (byte)'$':
                case (byte)'*':
                case (byte)'+':
                case (byte)'?':
                case (byte)'.':
                case (byte)'(':
                case (byte)'[':
                case (byte)'%':
                case (byte)'-':
                    return true;
                }
            }

            return false;
        }
Beispiel #41
0
        /// <summary>
        /// Searches for a match between a regular expression and a string, and returns the position of the match
        /// </summary>
        /// <param name="target">The target value to apply this method on</param>
        /// <param name="regExp">Required. A regular expression.</param>
        /// <returns></returns>
        public int Search(LString target, string regExp)
        {
            Match match = Regex.Match(target.Value, regExp);
            if (!match.Success) return -1;

            return match.Index;
        }
Beispiel #42
0
        /// <summary>
        /// Returns the position of the last found occurrence of a specified value in a string
        /// </summary>
        /// <param name="target">The target value to apply this method on</param>
        /// <param name="searchString">The text to search for</param>
        /// <param name="start">The position to start search</param>
        /// <returns></returns>
        public int LastIndexOf(LString target, string searchString, int start)
        {
            if (string.IsNullOrEmpty(target.Value)) return -1;
            if (string.IsNullOrEmpty(searchString)) return -1;
            if (start == -1) return target.Value.LastIndexOf(searchString);

            var result = target.Value.LastIndexOf(searchString, start);
            return result;
        }
            public GMatcher( LString str, LString pat )
            {
                if( str.IsNil || pat.IsNil )
                    throw new ArgumentNullException();

                this.str = str.InternalData;
                this.pat = pat.InternalData;
            }
        private MatchResult CheckExpressionMatches(CompilerPlugin plugin, List <TokenMatch> matches, Dictionary <string, object> args, int peekCount, int matchCount)
        {
            var isMatch      = true;
            var token        = peekCount == 0 ? this.TokenIt.NextToken : this.TokenIt.Peek(peekCount);
            var totalMatched = matchCount;

            foreach (var match in matches)
            {
                var continueCheck  = false;
                var trackNamedArgs = true;
                var valueMatched   = false;

                // Termninators
                if (match.TokenType == "@exprTerminators" &&
                    (Terminators.ExpFlexibleEnd.ContainsKey(token.Token) || Terminators.ExpThenEnd.ContainsKey(token.Token))
                    )
                {
                    // Don't increment the peekcount
                    isMatch = totalMatched >= plugin.TotalRequiredMatches;
                    break;
                }
                // Check for ";" and EOF ( end of file/text )
                if (token.Token == Tokens.Semicolon || token.Token == Tokens.EndToken)
                {
                    isMatch = totalMatched >= plugin.TotalRequiredMatches;
                    break;
                }

                // Check 1: Group tokens ?
                if (match.IsGroup)
                {
                    var submatches = ((TokenGroup)match).Matches;
                    var result     = CheckExpressionMatches(plugin, submatches, args, peekCount, totalMatched);
                    if (match.IsRequired && !result.Success)
                    {
                        isMatch = false;
                        break;
                    }
                    if (result.Success)
                    {
                        peekCount = result.TokenCount;
                        if (match.IsRequired)
                        {
                            totalMatched += result.TotalMatched;
                        }
                    }
                }
                // Check 2: starttoken?
                else if (match.TokenType == "@starttoken")
                {
                    continueCheck = true;
                    totalMatched++;
                }
                // Check 2a: tokenmap1
                else if (match.TokenType == "@tokenmap1")
                {
                    if (plugin.TokenMap1 == null || !plugin.TokenMap1.ContainsKey(token.Token.Text))
                    {
                        isMatch = false;
                        break;
                    }
                    continueCheck = true;
                    totalMatched++;
                }
                else if (match.TokenType == "@tokenmap2")
                {
                    if (plugin.TokenMap2 == null || !plugin.TokenMap2.ContainsKey(token.Token.Text))
                    {
                        isMatch = false;
                        break;
                    }
                    continueCheck = true;
                    totalMatched++;
                }
                // Check 2c: "identSymbol" must exist
                else if (match.TokenType == "@identsymbol")
                {
                    var symbolExists = this.Symbols.Contains(token.Token.Text);
                    continueCheck = symbolExists;
                    if (!continueCheck)
                    {
                        isMatch = false;
                        break;
                    }
                    totalMatched++;
                }
                // Check 2c: "identSymbol" must exist
                else if (match.TokenType == "@singularsymbol")
                {
                    var plural       = token.Token.Text + "s";
                    var symbolExists = this.Symbols.Contains(plural);
                    continueCheck = symbolExists;
                    if (!continueCheck)
                    {
                        isMatch = false;
                        break;
                    }
                    totalMatched++;
                }
                // Check 2d: paramlist = @word ( , @word )* parameter names
                else if (match.TokenType == "@paramnames")
                {
                    var isvalidParamList = true;
                    var maxParams        = 10;
                    var totalParams      = 0;
                    var paramList        = new List <object>();

                    while (totalParams <= maxParams)
                    {
                        var token2 = this.TokenIt.Peek(peekCount, false);
                        if (token2.Token == Tokens.Comma)
                        {
                            peekCount++;
                        }
                        else if (token2.Token.Kind == TokenKind.Ident)
                        {
                            paramList.Add(token2.Token.Text);
                            peekCount++;
                        }
                        else
                        {
                            peekCount--;
                            break;
                        }
                        totalParams++;
                    }
                    isMatch       = isvalidParamList;
                    continueCheck = isMatch;
                    if (continueCheck)
                    {
                        trackNamedArgs = false;
                        if (!string.IsNullOrEmpty(match.Name))
                        {
                            args[match.Name]           = token;
                            args[match.Name + "Value"] = new LArray(paramList);
                        }
                        totalMatched++;
                    }
                    else
                    {
                        break;
                    }
                }
                // Check 3a: Optional words with text
                else if (!match.IsRequired && match.Text != null && match.Text != token.Token.Text)
                {
                    continueCheck = false;
                }
                // Check 3b: Optional words matched
                else if (!match.IsRequired && match.IsMatchingValue(token.Token))
                {
                    continueCheck = true;
                }
                // Check 4: Optional word not matched
                else if (!match.IsRequired && !match.IsMatchingValue(token.Token))
                {
                    continueCheck = false;
                }
                // Check 5a: Expected word
                else if (match.IsRequired && match.TokenType == null && match.Text == token.Token.Text)
                {
                    continueCheck = true;
                    totalMatched++;
                }
                // Check 5b: Expected word in list
                else if (match.IsRequired && match.TokenType == null && match.Values != null)
                {
                    if (!match.IsMatchingValue(token.Token))
                    {
                        isMatch = false;
                        break;
                    }
                    continueCheck = true;
                    valueMatched  = true;
                    totalMatched++;
                }
                // Check 6: check the type of n1
                else if (match.IsMatchingType(token.Token))
                {
                    continueCheck = true;
                    totalMatched++;
                }
                else
                {
                    isMatch = false;
                    break;
                }
                if (continueCheck)
                {
                    if (!string.IsNullOrEmpty(match.Name) && trackNamedArgs)
                    {
                        args[match.Name] = token;
                        if (match.TokenPropEnabled)
                        {
                            // 1. figure out which token map to use.
                            var lookupmap = plugin.StartTokenMap;

                            if (match.TokenType == "@tokenmap1")
                            {
                                lookupmap = plugin.TokenMap1;
                            }
                            else if (match.TokenType == "@tokenmap2")
                            {
                                lookupmap = plugin.TokenMap2;
                            }

                            // Case 1: Start token replacement value
                            if (match.TokenPropValue == "value")
                            {
                                var startToken = token.Token.Text;
                                args[match.Name + "Value"] = lookupmap[startToken];
                            }
                            // Case 2: Token value
                            else if (match.TokenPropValue == "tvalue")
                            {
                                LObject val = LObjects.Null;
                                if (match.TokenType == "@number")
                                {
                                    val = new LNumber((double)token.Token.Value);
                                }
                                else if (match.TokenType == "@time")
                                {
                                    val = new LTime((TimeSpan)token.Token.Value);
                                }
                                else if (match.TokenType == "@word")
                                {
                                    val = new LString((string)token.Token.Value);
                                }
                                else if (match.TokenType == "@starttoken")
                                {
                                    val = new LString(token.Token.Text);
                                }
                                args[match.Name + "Value"] = val;
                            }
                            // Case 2: Token value
                            else if (match.TokenPropValue == "tvaluestring")
                            {
                                LObject val = LObjects.Null;
                                if (match.TokenType == "@number")
                                {
                                    val = new LString(((double)token.Token.Value).ToString(CultureInfo.InvariantCulture));
                                }
                                else if (match.TokenType == "@time")
                                {
                                    val = new LString(((TimeSpan)token.Token.Value).ToString());
                                }
                                else if (match.TokenType == "@starttoken")
                                {
                                    val = new LString(token.Token.Text);
                                }
                                else if (match.TokenType == "@word")
                                {
                                    val = new LString(token.Token.Text);
                                }
                                else if (match.TokenType == "@singularsymbol")
                                {
                                    val = new LString(token.Token.Text);
                                }
                                args[match.Name + "Value"] = val;
                            }
                        }
                        // matching values
                        else if (valueMatched)
                        {
                            args[match.Name + "Value"] = token.Token.Text;
                        }
                    }
                    // Matched: increment.
                    peekCount++;
                    token = this.TokenIt.Peek(peekCount, false);
                }
            }
            var res = new MatchResult(isMatch, null, args);

            res.TotalMatched = totalMatched;
            res.TokenCount   = peekCount;
            return(res);
        }
 /// <summary>
 /// Gets the length of the string
 /// </summary>
 /// <param name="target">The target value to apply this method on</param>
 /// <returns></returns>
 public int Length(LString target)
 {
     return(target.Value.Length);
 }
 /// <summary>
 /// Searches for a match between a substring (or regular expression) and a string, and replaces the matched substring with a new substring
 /// </summary>
 /// <param name="target">The target value to apply this method on</param>
 /// <param name="substring">Required. A substring or a regular expression.</param>
 /// <param name="newString">Required. The string to replace the found value in parameter 1</param>
 /// <returns></returns>
 public string Replace(LString target, string substring, string newString)
 {
     return(target.Value.Replace(substring, newString));
 }
Beispiel #47
0
	  public LLocal(LString name, BInteger start, BInteger end)
	  {
		this.name = name;
		this.Start = start.asInt();
		this.end = end.asInt();
	  }
Beispiel #48
0
        private static LString ToStringCore( Value v, Thread l )
        {
            LString ret;

            switch( v.ValueType )
            {
            case LValueType.Nil:
                ret = Literals.Nil;
                break;

            case LValueType.Bool:
                ret = v.IsTrue ? Literals.True : Literals.False;
                break;

            case LValueType.Number:
                l.ConvertToString( ref v );
                goto case LValueType.String;

            case LValueType.String:
                ret = (LString)v;
                break;

            default:
                ret = new LString( v.ToString() );
                break;
            }

            return ret;
        }
 /// <summary>
 /// Converts a string to lowercase letters
 /// </summary>
 /// <param name="target">The target value to apply this method on</param>
 /// <returns></returns>
 public string ToLowerCase(LString target)
 {
     return(target.Value.ToLower());
 }