public static DataTable GetTreeDonVi(string pv_strUserName, string pv_strMaDonVi)
        {
            DataTable   v_dt     = null;
            string      v_strRet = "ERROR|" + ErrorDef.SYSTEM_ERROR.ToString();
            XmlDocument v_objDoc = LXMLMessage.InitXmlMessageTemplate();

            LXMLMessage.SetAttribute(ref v_objDoc, LXMLAttribute.FunctionName, "BusinessServices.TruyVan.BS_TruyVan.TruyVanXML");
            DataTable v_dtParam = LXMLMessage.InitRequestParamTable();

            v_dtParam.Rows.Add(new string[] { "OBJECTNAME", "INQ.DS.CUM" });
            v_dtParam.Rows.Add(new string[] { "INQUIRYNAME", "TREE_01" });
            v_dtParam.Rows.Add(new string[] { "USER_NAME", pv_strUserName });
            v_dtParam.Rows.Add(new string[] { "MA_DVI_QLY", pv_strMaDonVi });
            try
            {
                v_objDoc.DocumentElement.SelectSingleNode("RequestInfo").InnerXml = "<![CDATA[" + LXMLMessage.ConvertDataTableToXml(v_dtParam) + "]]>";

                string v_strDocument = LXMLMessage.ConvertDocumentToString(v_objDoc);
                v_strRet = WebProcess.Instance().SendMessage(v_strDocument);
            }
            catch (Exception ex)
            {
                v_strRet = "ERROR|" + ErrorDef.SYSTEM_ERROR.ToString();
            }

            if (v_strRet.StartsWith("OK|"))
            {
                v_dt = LXMLMessage.ConvertXmlToDataTable(v_strRet.Substring(3));
            }

            return(v_dt);
        }
        public static DataTable GetDSBaoCao(string pv_strMaDM)
        {
            DataTable   v_dt     = null;
            string      v_strRet = "ERROR|" + ErrorDef.SYSTEM_ERROR.ToString();
            XmlDocument v_objDoc = LXMLMessage.InitXmlMessageTemplate();

            LXMLMessage.SetAttribute(ref v_objDoc, LXMLAttribute.FunctionName, "BusinessServices.BaoCao.BS_BaoCao.ProcessXML");
            DataTable v_dtParam = LXMLMessage.InitRequestParamTable();

            v_dtParam.Rows.Add(new string[] { "FUNCTIONNAME", "GetDSBaoCao" });
            v_dtParam.Rows.Add(new string[] { "MADM", pv_strMaDM });

            try
            {
                v_objDoc.DocumentElement.SelectSingleNode("RequestInfo").InnerXml = "<![CDATA[" + LXMLMessage.ConvertDataTableToXml(v_dtParam) + "]]>";

                string v_strDocument = LXMLMessage.ConvertDocumentToString(v_objDoc);
                v_strRet = WebProcess.Instance().SendMessage(v_strDocument);
            }
            catch (Exception ex)
            {
                v_strRet = "ERROR|" + ErrorDef.SYSTEM_ERROR.ToString();
            }

            if (v_strRet.StartsWith("OK|"))
            {
                v_dt = LXMLMessage.ConvertXmlToDataTable(v_strRet.Substring(3));
            }

            return(v_dt);
        }
        public static DataTable GetPopupData(string pv_strMaTruyVan, List <string> pv_lstDieuKien)
        {
            DataTable v_dtRet = null;

            string      v_strRet = "ERROR|" + ErrorDef.SYSTEM_ERROR.ToString();
            XmlDocument v_objDoc = LXMLMessage.InitXmlMessageTemplate();

            LXMLMessage.SetAttribute(ref v_objDoc, LXMLAttribute.FunctionName, "BusinessServices.Popup.BS_Popup.ProcessXML");
            DataTable v_dtParam = LXMLMessage.InitRequestParamTable();

            v_dtParam.Rows.Add(new string[] { "FUNCTIONNAME", "Popup" });
            v_dtParam.Rows.Add(new string[] { "MATRUYVAN", pv_strMaTruyVan });

            try
            {
                if (null != pv_lstDieuKien)
                {
                    foreach (string v_strItem in pv_lstDieuKien)
                    {
                        v_dtParam.Rows.Add(new string[] { "DIEUKIEN", v_strItem });
                    }
                }
                v_objDoc.DocumentElement.SelectSingleNode("RequestInfo").InnerXml = "<![CDATA[" + LXMLMessage.ConvertDataTableToXml(v_dtParam) + "]]>";

                string v_strDocument = LXMLMessage.ConvertDocumentToString(v_objDoc);


                v_strRet = WebProcess.Instance().SendMessage(v_strDocument);
            }
            catch (Exception ex)
            {
                v_strRet = "ERROR|" + ErrorDef.SYSTEM_ERROR.ToString();
            }

            if (v_strRet.StartsWith("OK|"))
            {
                v_objDoc.LoadXml("<root>" + v_strRet.Substring(3) + "</root>");

                v_dtRet = LXMLMessage.ConvertXmlToDataTable(v_objDoc.DocumentElement.SelectSingleNode("PopupData").InnerXml);
                DataRow v_dr = v_dtRet.NewRow();

                string[] v_arrHeader = v_objDoc.DocumentElement.SelectSingleNode("PopupHeader").InnerXml.Split("#".ToCharArray());
                for (int i = 0; i < v_arrHeader.GetLength(0); i++)
                {
                    string[] v_arrCol = v_arrHeader[i].Split('|');
                    v_dtRet.Columns[i].Caption = v_arrCol[0];
                    v_dtRet.Columns[i].ExtendedProperties.Add("width", v_arrCol[1]);
                }
            }

            return(v_dtRet);
        }
        public static DataTable GetComboSource(string pv_strMaTruyVan, List <String> pv_lstDieuKien)
        {
            DataTable   v_dtRet  = null;
            string      v_strRet = "ERROR|" + ErrorDef.SYSTEM_ERROR.ToString();
            XmlDocument v_objDoc = LXMLMessage.InitXmlMessageTemplate();

            LXMLMessage.SetAttribute(ref v_objDoc, LXMLAttribute.FunctionName, "BusinessServices.TruyVan.BS_TruyVan.TruyVanXML");
            DataTable v_dtParam = LXMLMessage.InitRequestParamTable();

            v_dtParam.Rows.Add(new string[] { "OBJECTNAME", "INQ.COMBOBOX" });
            v_dtParam.Rows.Add(new string[] { "INQUIRYNAME", pv_strMaTruyVan });

            try
            {
                if (null != pv_lstDieuKien)
                {
                    for (int i = 0; i < pv_lstDieuKien.Count; i++)
                    {
                        v_dtParam.Rows.Add(new string[] { pv_lstDieuKien[i], pv_lstDieuKien[i] });
                    }
                }

                v_objDoc.DocumentElement.SelectSingleNode("RequestInfo").InnerXml = "<![CDATA[" + LXMLMessage.ConvertDataTableToXml(v_dtParam) + "]]>";

                string v_strDocument = LXMLMessage.ConvertDocumentToString(v_objDoc);


                v_strRet = WebProcess.Instance().SendMessage(v_strDocument);
            }
            catch (Exception ex)
            {
                v_strRet = "ERROR|" + ErrorDef.SYSTEM_ERROR.ToString();
            }

            if (v_strRet.StartsWith("OK|"))
            {
                v_dtRet = LXMLMessage.ConvertXmlToDataTable(v_strRet.Substring(3));
            }

            return(v_dtRet);
        }
        protected void cmdLogin_Click(object sender, EventArgs e)
        {
            lblErrorDesc.Text = "";
            long v_lngErrorCode = ErrorDef.SYSTEM_SUCESS;

            if (ValidateForm())
            {
                string v_strUser      = txtUserName.Text.Trim().ToUpper();
                string v_strPass      = LSecurity.MD5Encrypt(txtPass.Text.Trim());
                string v_strSessionId = "";

                string v_strResult = UserController.LoginRequest(v_strUser, v_strPass, ref v_strSessionId);
                if (v_strResult.StartsWith("OK"))
                {
                    XmlDocument v_objDoc = new XmlDocument();
                    v_objDoc.LoadXml(v_strResult.Substring(3));
                    UserInfo v_objUser = new UserInfo();
                    v_objUser.SessionID       = v_strSessionId;
                    v_objUser.UserName        = v_strUser;
                    v_objUser.IDNguoiSuDung   = Convert.ToInt32(v_objDoc.DocumentElement.SelectSingleNode("IDNguoiSuDung").InnerText);
                    v_objUser.LoaiNguoiSuDung = v_objDoc.DocumentElement.SelectSingleNode("LoaiNguoiSuDung").InnerText;
                    v_objUser.FullName        = v_objDoc.DocumentElement.SelectSingleNode("FullName").InnerText;
                    v_objUser.MaDonVi         = v_objDoc.DocumentElement.SelectSingleNode("MaDonVi").InnerText;
                    v_objUser.TenDonVi        = v_objDoc.DocumentElement.SelectSingleNode("TenDonVi").InnerText;

                    v_objUser.MaDonViQuanLy    = v_objDoc.DocumentElement.SelectSingleNode("MaDonVi").InnerText;
                    v_objUser.TenDonViQuanLy   = v_objDoc.DocumentElement.SelectSingleNode("TenDonVi").InnerText;
                    v_objUser.MaDonViGiaoDich  = v_objDoc.DocumentElement.SelectSingleNode("MaDonVi").InnerText + "00";
                    v_objUser.TenDonViGiaoDich = "TenDonViGiaoDich";
                    //v_objUser.MaDonViQuanLy = v_objDoc.DocumentElement.SelectSingleNode("MaDonViQuanLy").InnerText;
                    //v_objUser.TenDonViQuanLy = v_objDoc.DocumentElement.SelectSingleNode("TenDonViQuanLy").InnerText;
                    //v_objUser.MaDonViGiaoDich = v_objDoc.DocumentElement.SelectSingleNode("MaDonViGiaoDich").InnerText;
                    //v_objUser.TenDonViGiaoDich = v_objDoc.DocumentElement.SelectSingleNode("TenDonViGiaoDich").InnerText;

                    v_objUser.NgayLamViecTruoc   = v_objDoc.DocumentElement.SelectSingleNode("NgayLamViecTruoc").InnerText;
                    v_objUser.NgayLamViecHienTai = v_objDoc.DocumentElement.SelectSingleNode("NgayLamViecHienTai").InnerText;
                    v_objUser.NgayLamViecSau     = v_objDoc.DocumentElement.SelectSingleNode("NgayLamViecSau").InnerText;
                    v_objUser.MaDongNoiTe        = v_objDoc.DocumentElement.SelectSingleNode("MaDongNoiTe").InnerText;
                    v_objUser.CayMenu            = LXMLMessage.ConvertXmlToDataTable(v_objDoc.DocumentElement.SelectSingleNode("CayMenu").InnerXml.Replace("<![CDATA[", "").Replace("]]>", ""));
                    v_objUser.DSDonVi            = LXMLMessage.ConvertXmlToDataTable(v_objDoc.DocumentElement.SelectSingleNode("ListDonVi").InnerXml.Replace("<![CDATA[", "").Replace("]]>", ""));

                    AppConfig.LoginedUser = v_objUser;

                    //Them doan nay de co the goi cac service khac
                    UserInformation userInfo = new UserInformation();
                    //userInfo.SessionId = HttpContext.Current.Session["LoginedUser"].GetHashCode().ToString();
                    userInfo.SessionId          = v_strSessionId;
                    userInfo.TenDangNhap        = AppConfig.LoginedUser.UserName;
                    userInfo.ListChucNang       = null;
                    userInfo.IdNguoiSuDung      = AppConfig.LoginedUser.IDNguoiSuDung;
                    userInfo.HoTen              = AppConfig.LoginedUser.FullName;
                    userInfo.MaDonVi            = AppConfig.LoginedUser.MaDonVi;
                    userInfo.TenDonVi           = AppConfig.LoginedUser.TenDonVi;
                    userInfo.MaDonViQuanLy      = AppConfig.LoginedUser.MaDonViQuanLy;
                    userInfo.TenDonViQuanLy     = AppConfig.LoginedUser.TenDonViQuanLy;
                    userInfo.MaDonViGiaoDich    = AppConfig.LoginedUser.MaDonViGiaoDich;
                    userInfo.TenDonViGiaoDich   = AppConfig.LoginedUser.TenDonViGiaoDich;
                    userInfo.LoaiNguoiSuDung    = AppConfig.LoginedUser.LoaiNguoiSuDung;
                    userInfo.NgayLamViecTruoc   = AppConfig.LoginedUser.NgayLamViecTruoc;
                    userInfo.NgayLamViecHienTai = AppConfig.LoginedUser.NgayLamViecHienTai;
                    userInfo.NgayLamViecSau     = AppConfig.LoginedUser.NgayLamViecSau;
                    userInfo.MaDongNoiTe        = AppConfig.LoginedUser.MaDongNoiTe;
                    userInfo.MacAddress         = "";
                    HttpContext.Current.Session["UserInformation"] = userInfo;

                    //Add cookie
                    if (chkRemember.Checked)
                    {
                        v_objUser.SaveCookie();
                    }

                    Response.Redirect("~/Default.aspx");
                }
                else
                {
                    v_lngErrorCode = Convert.ToInt64(v_strResult.Replace("ERROR|", ""));

                    lblErrorDesc.Text = CacheService.Instance().GetErrorDef(v_lngErrorCode);
                    txtUserName.Focus();
                }
            }
        }