示例#1
0
文件: Test.asmx.cs 项目: tvctk5/MMO
        public string GetDataTable(string iTop)
        {
            try
            {
                DataTable objDataTable = new DataTable();

                objDataTable.Columns.Add("Column1");
                objDataTable.Columns.Add("Column2");
                //DataRow objDataRow = objDataTable.NewRow();
                //objDataRow[0] = "Giá trị số 1.1";
                //objDataRow[1] = "Giá trị số 1.2";
                //objDataTable.Rows.Add(objDataRow);

                //objDataRow = objDataTable.NewRow();
                //objDataRow[0] = "Giá trị số 2.1";
                //objDataRow[1] = "Giá trị số 2.2";
                //objDataTable.Rows.Add(objDataRow);

                //string ans = JsonConvert.SerializeObject(objDataTable, Formatting.Indented);

                //string script = "{\"DataRow\": " + ans + "}";
                ////script += "for(i = 0;i<employeeList.Employee.length;i++)";
                ////script += "{";
                ////script += "alert ('Name : ='+employeeList.Employee[i].Name+' Age : = '+employeeList.Employee[i].Age);";
                ////script += "}";

                ////JsonSerializerSettings objJsonSerializerSettings = new JsonSerializerSettings();
                ////DataTable tblGetData = (DataTable)JsonConvert.DeserializeObject(script);
                //return script;



                /////            test
                ModProduct_ManufacturerEntity objModProduct_Manufacturer = ModProduct_ManufacturerService.Instance.CreateQuery().OrderByAsc(p => p.ID).ToSingle();

                DataRow objDataRow = objDataTable.NewRow();
                objDataRow[0] = objModProduct_Manufacturer.ID;
                objDataRow[1] = objModProduct_Manufacturer.Name;
                objDataTable.Rows.Add(objDataRow);

                string ans    = JsonConvert.SerializeObject(objDataTable, Formatting.Indented);
                string script = "{\"DataRow\": " + ans + "}";
                return(script);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public void ActionAdd(ModProduct_ManufacturerModel model)
        {
            if (model.RecordID > 0)
            {
                item = ModProduct_ManufacturerService.Instance.GetByID(model.RecordID);

                // khoi tao gia tri mac dinh khi update
            }
            else
            {
                item = new ModProduct_ManufacturerEntity();

                // khoi tao gia tri mac dinh khi insert
                item.Activity   = CPViewPage.UserPermissions.Approve;
                item.CreateDate = DateTime.Now;
            }

            ViewBag.Data  = item;
            ViewBag.Model = model;
        }
        private string GetManufactureName(List <ModProduct_ManufacturerEntity> lstManufacturerEntity, int?iManufacturerID)
        {
            string sName = string.Empty;

            if (iManufacturerID == null || iManufacturerID <= 0)
            {
                return(sName);
            }

            if (lstManufacturerEntity == null || lstManufacturerEntity.Count <= 0)
            {
                return(sName);
            }

            ModProduct_ManufacturerEntity objModProduct_ManufacturerEntity = lstManufacturerEntity.Where(p => p.ID == iManufacturerID).SingleOrDefault();

            if (objModProduct_ManufacturerEntity == null)
            {
                return(sName);
            }

            sName = objModProduct_ManufacturerEntity.Name;
            return(sName);
        }