コード例 #1
0
ファイル: AutoSave.asmx.cs プロジェクト: tungdang130991/MyGit
        public ChuyenmucDetails[] BindDatatoDropdownChuyenmuc(object AnphamID)
        {
            _user = _NguoidungDAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name);
            DataTable dt = new DataTable();

            string _sql = string.Empty;

            _sql = "set dateformat dmy; SELECT Ma_ChuyenMuc,Ten_ChuyenMuc FROM T_ChuyenMuc where Hoatdong=1 and Ma_ChuyenMuc in (select Ma_ChuyenMuc from T_Nguoidung_Chuyenmuc where Ma_Nguoidung = " + _user.UserID.ToString() + ") and Ma_AnPham= " + AnphamID + " AND Ma_Chuyenmuc_Cha = 0 ";
            int Rank = 0;

            try
            {
                dt = ulti.ExecSqlDataSet(_sql).Tables[0];
                foreach (DataRow dtrow in dt.Rows)
                {
                    ChuyenmucDetails _listchuyenmuc = new ChuyenmucDetails();

                    _listchuyenmuc.Ma_ChuyenMuc  = Convert.ToInt32(dtrow["Ma_ChuyenMuc"].ToString());
                    _listchuyenmuc.Ten_ChuyenMuc = dtrow["Ten_ChuyenMuc"].ToString();
                    details.Add(_listchuyenmuc);
                    BinTreeCategorys(Rank, dtrow["Ma_ChuyenMuc"].ToString());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(details.ToArray());
        }
コード例 #2
0
ファイル: AutoSave.asmx.cs プロジェクト: tungdang130991/MyGit
        public void BinTreeCategorys(int Rank, string CategorysID)
        {
            Rank++;
            string    _sqlChild = string.Empty;
            DataTable _dtchild  = new DataTable();

            if (HPCBusinessLogic.UltilFunc.GetLatestID("T_ChuyenMuc", "Ma_Chuyenmuc_Cha", "WHERE Ma_Chuyenmuc_Cha=" + CategorysID) > 0)
            {
                _sqlChild = "set dateformat dmy; SELECT Ma_ChuyenMuc,Ten_ChuyenMuc FROM T_ChuyenMuc WHERE  Ma_Chuyenmuc_Cha= " + CategorysID + " ORDER BY Ma_ChuyenMuc";

                try
                {
                    _dtchild = ulti.ExecSqlDataSet(_sqlChild).Tables[0];

                    if (_dtchild != null && _dtchild.Rows.Count > 0)
                    {
                        foreach (DataRow dtrow in _dtchild.Rows)
                        {
                            string blank = "";
                            for (int k = 0; k < Rank; k++)
                            {
                                blank = "&nbsp;&nbsp;&nbsp;&nbsp;" + blank;
                            }
                            ChuyenmucDetails _listchuyenmuc = new ChuyenmucDetails();
                            _listchuyenmuc.Ma_ChuyenMuc  = Convert.ToInt32(dtrow["Ma_ChuyenMuc"].ToString());
                            _listchuyenmuc.Ten_ChuyenMuc = HttpUtility.HtmlDecode(blank) + dtrow["Ten_ChuyenMuc"].ToString();
                            details.Add(_listchuyenmuc);
                            BinTreeCategorys(Rank, dtrow["Ma_ChuyenMuc"].ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            Rank--;
        }