예제 #1
0
        protected void SaveOrUpdate(object sender, EventArgs e)
        {
            int SmallId;

            if (!Int32.TryParse(Request["smallid"], out SmallId))
            {
                SmallId = 0;
            }
            string     Smallname  = Request["smallname"];
            int        Bigname    = Int32.Parse(Request["bigname"]);
            SmallClass smallclass = new SmallClass();

            smallclass.smallid   = SmallId;
            smallclass.smallname = Smallname;
            smallclass.bigid     = Bigname;
            if (smallclassService.SaveOrUpdate(smallclass))
            {
                Response.Write(true);
                Response.End();
            }
            else
            {
                Response.Write(false);
            }
        }
 public static RepetitiveReferenceIsNotLoop GetSampleInstance()
 {
     var singleRef = new SmallClass {N = 10};
     return new RepetitiveReferenceIsNotLoop
            {
                RefA = singleRef,
                RefB = singleRef
            };
 }
예제 #3
0
        public static SmallClass CreateInstance(bool isInitDefaultValue)
        {
            SmallClass model = new SmallClass();

            if (isInitDefaultValue)
            {
                model.SmallClassId = Guid.NewGuid();
            }
            return model;
        }
예제 #4
0
 ///添加还是修改操作,无id添加,有修改
 public bool SaveOrUpdate(SmallClass smallclass)
 {
     if (smallclass.smallid > 0)
     {
         return(dal.Update(smallclass));
     }
     else
     {
         return(dal.Add(smallclass) > 0 ? true : false);
     }
 }
        public static RepetitiveReferenceIsNotLoop GetSampleInstance()
        {
            var singleRef = new SmallClass {
                N = 10
            };

            return(new RepetitiveReferenceIsNotLoop
            {
                RefA = singleRef,
                RefB = singleRef
            });
        }
예제 #6
0
 public void Setup()
 {
     structs = new SmallStruct[items];
     classes = new SmallClass[items];
     for (int i = 0; i < items; i++)
     {
         structs[i] = new SmallStruct {
             Value1 = i
         };
         classes[i] = new SmallClass {
             Value1 = i
         };
     }
 }
예제 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //占位标签
            SearchBigId = Int32.Parse(Request["SearchBigId"]);
            BigClassService bigclassService = new BigClassService();
            BigClass        bigClass        = new BigClass();

            bigClass = bigclassService.GetModel(SearchBigId);
            nav      = bigClass.bigname;

            SearchSmallId = Int32.Parse(Request["SearchSmallId"]);
            if (SearchSmallId > 0)
            {
                SmallClassService smallclassService = new SmallClassService();
                SmallClass        smallClass        = new SmallClass();
                smallClass = smallclassService.GetModel(SearchSmallId);
                Code       = smallClass.smallname;

                NoticeService noticeService = new NoticeService();
                NoticeList = noticeService.GetModelList("");
                //分页
                int pageNumber = 1;
                if (!Int32.TryParse(Request["page"], out pageNumber))
                {
                    pageNumber = 1;
                }
                GoodsService goodsService = new GoodsService();
                //goodsList = goodsService.GetModelList("smallid=" +SearchSmallId);
                int maxPage     = 0;
                int recordCount = goodsService.GetRecordCount("smallid=" + SearchSmallId);
                if (recordCount % goodsService.pageCount == 0)
                {
                    maxPage = recordCount / goodsService.pageCount;
                }
                else
                {
                    maxPage = recordCount / goodsService.pageCount + 1;
                }
                if (pageNumber > maxPage)
                {
                    pageNumber = maxPage;
                }
                goodsList = goodsService.FindAllGoodsList(pageNumber, "smallid=" + SearchSmallId);
                pageCode  = PageUtil.genPagination("/goods/GoodsList.aspx", recordCount, pageNumber, goodsService.pageCount, "SearchSmallId=" + SearchSmallId.ToString() + "&SearchBigId=" + SearchBigId);
            }
            else
            {
            }
        }
예제 #8
0
        private void Initialize()
        {
            TreeNode parent = node.Parent;

            if (node.Level == 0)
            {
                parent = node;
            }

            if (action == OperationEnum.Edit)
            {
                skinTextBoxName.Text = parent.FullPath;
                this.Text            = "修改类别";
                skinTextBoxID.Text   = node.Text;
                if (node.Tag is CostumeClassInfo)
                {
                    CostumeClassInfo info = node.Tag as CostumeClassInfo;
                    costumeTextBoxSort.Value = info.OrderNo;
                    skinTextBoxCode.Text     = info.ClassCode;
                }
                else if (node.Tag is SmallClass)
                {
                    SmallClass info = node.Tag as SmallClass;
                    costumeTextBoxSort.Value = info.OrderNo;
                    skinTextBoxCode.Text     = info.ClassCode;
                }
                else if (node.Tag is SubSmallClass)
                {
                    SubSmallClass info = node.Tag as SubSmallClass;
                    costumeTextBoxSort.Value = info.OrderNo;
                    skinTextBoxCode.Text     = info.ClassCode;
                }
            }
            else
            {
                skinTextBoxName.Text     = node.FullPath;
                this.Text                = "新增类别";
                skinTextBoxCode.Text     = String.Empty;
                costumeTextBoxSort.Value = 100;
            }
        }
예제 #9
0
        private void Form_ItemSelected(TreeNode node, EventArgs t2)
        {
            Costume costume = new Costume();

            costume.ClassID    = -1;
            costume.BigClassID = -1;
            if (node.Tag is CostumeClassInfo)
            {
                CostumeClassInfo info = node.Tag as CostumeClassInfo;
                costume.BigClass   = info.BigClass;
                costume.BigClassID = info.ID;
                costume.ClassID    = info.ID;
            }
            else if (node.Tag is SmallClass)
            {
                CostumeClassInfo infoParent = node.Parent.Tag as CostumeClassInfo;
                SmallClass       info       = node.Tag as SmallClass;
                costume.BigClass   = info.BigClass;
                costume.SmallClass = info.SmallClassStr;
                costume.BigClassID = infoParent.ID;
                costume.ClassID    = info.ID;
            }
            else if (node.Tag is SubSmallClass)
            {
                CostumeClassInfo infoBig = node.Parent.Parent.Tag as CostumeClassInfo;
                SubSmallClass    info    = node.Tag as SubSmallClass;
                costume.BigClass      = info.BigClass;
                costume.SmallClass    = info.SmallClass;
                costume.SubSmallClass = info.SubSmallClassStr;
                costume.BigClassID    = infoBig.ID;
                costume.ClassID       = info.ID;
            }

            SelectedValue = costume;
            ItemSelected?.Invoke(costume);
        }
예제 #10
0
 public static bool Update(SmallClass smallClass)
 {
     CommonDataProvider dp = CommonDataProvider.Instance();
     return dp.UpdateSmallClass(smallClass);
 }
예제 #11
0
 public abstract bool UpdateSmallClass(SmallClass smallClass);
예제 #12
0
 public abstract bool CreateSmallClass(SmallClass smallClass);
예제 #13
0
        public SmallClass PopulateSmallClassFromIDataReader(IDataReader dr)
        {
            SmallClass model = null;

            if (dr != null)
            {
                model = new SmallClass();

                if (dr["SmallClassId"] is System.DBNull)
                    model.SmallClassId = null;
                else
                    model.SmallClassId = (Guid)dr["SmallClassId"];

                if (dr["BigClassId"] is System.DBNull)
                    model.BigClassId = null;
                else
                    model.BigClassId = (Guid)dr["BigClassId"];

                model.SmallClassName = dr["SmallClassName"].ToString();
            }
            return model;
        }
예제 #14
0
        private void Add()
        {
            InteractResult result = null;

            if (node.Level == 0)
            {
                InsertCostumeClassPara para = new InsertCostumeClassPara()
                {
                    BigClass  = skinTextBoxID.Text,
                    OrderNo   = Decimal.ToInt32(costumeTextBoxSort.Value),
                    ClassCode = skinTextBoxCode.Text
                };
                CostumeClassInfo subSmallClass = new CostumeClassInfo()
                {
                    BigClass   = skinTextBoxID.Text,
                    SmallClass = new List <SmallClass>(),
                    OrderNo    = Decimal.ToInt32(costumeTextBoxSort.Value),
                    ClassCode  = skinTextBoxCode.Text
                };


                result = GlobalCache.ServerProxy.InsertBigCostumeClass(para);
                switch (result.ExeResult)
                {
                case ExeResult.Error:
                    GlobalMessageBox.Show(result.Msg);
                    break;

                case ExeResult.Success:
                    subSmallClass.ID = Int32.Parse(result.Msg);
                    TreeNode newNode = new TreeNode(subSmallClass.BigClass);
                    newNode.Tag = subSmallClass;
                    node.Nodes.Add(newNode);
                    this.DialogResult = DialogResult.OK;
                    break;

                default:
                    break;
                }
            }
            else if (node.Level == 1)
            {
                InsertSmallClassPara para = new InsertSmallClassPara()
                {
                    ParentAutoID = (node.Tag as CostumeClassInfo).ID,
                    SmallClass   = skinTextBoxID.Text,
                    OrderNo      = Decimal.ToInt32(costumeTextBoxSort.Value),
                    ClassCode    = skinTextBoxCode.Text
                };

                SmallClass subSmallClass = new SmallClass()
                {
                    SubSmallClass = new List <SubSmallClass>(),
                    BigClass      = node.Text,
                    SmallClassStr = skinTextBoxID.Text,
                    OrderNo       = Decimal.ToInt32(costumeTextBoxSort.Value),
                    ClassCode     = skinTextBoxCode.Text
                };

                result = GlobalCache.ServerProxy.InsertSmallClass(para);
                switch (result.ExeResult)
                {
                case ExeResult.Error:
                    GlobalMessageBox.Show(result.Msg);
                    break;

                case ExeResult.Success:
                    subSmallClass.ID = Int32.Parse(result.Msg);
                    TreeNode newNode = new TreeNode(subSmallClass.SmallClassStr);
                    newNode.Tag = subSmallClass;
                    node.Nodes.Add(newNode);
                    this.DialogResult = DialogResult.OK;
                    break;

                default:
                    break;
                }
            }
            else if (node.Level == 2)
            {
                InsertSubSmallClassPara para = new InsertSubSmallClassPara()
                {
                    ParentAutoID = (node.Tag as  SmallClass).ID,
                    //BigClass = node.Parent.Text,
                    //SmallClass = node.Text,
                    SubSmallClass = skinTextBoxID.Text,
                    OrderNo       = Decimal.ToInt32(costumeTextBoxSort.Value),
                    ClassCode     = skinTextBoxCode.Text
                };

                SubSmallClass subSmallClass = new SubSmallClass()
                {
                    BigClass         = node.Parent.Text,
                    SmallClass       = node.Text,
                    SubSmallClassStr = skinTextBoxID.Text,
                    OrderNo          = Decimal.ToInt32(costumeTextBoxSort.Value),
                    ClassCode        = skinTextBoxCode.Text
                };

                result = GlobalCache.ServerProxy.InsertSubSmallClass(para);
                switch (result.ExeResult)
                {
                case ExeResult.Error:
                    GlobalMessageBox.Show(result.Msg);
                    break;

                case ExeResult.Success:
                    subSmallClass.ID = Int32.Parse(result.Msg);
                    TreeNode newNode = new TreeNode(subSmallClass.SubSmallClassStr);
                    newNode.Tag = subSmallClass;
                    node.Nodes.Add(newNode);
                    SmallClass smallClass = node.Tag as SmallClass;
                    if (smallClass.SubSmallClass != null)
                    {
                        smallClass.SubSmallClass.Add(subSmallClass);
                    }
                    this.DialogResult = DialogResult.OK;
                    break;

                default:
                    break;
                }
            }
        }
예제 #15
0
        public override bool CreateSmallClass(SmallClass smallClass)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("Insert Into SmallClass(");
            strSql.Append("SmallClassId,BigClassId,SmallClassName");
            strSql.Append(") Values (");
            strSql.Append("@SmallClassId,@BigClassId,@SmallClassName");
            strSql.Append(")");

            SqlParameter[] parameters = {
                new SqlParameter("@SmallClassId", SqlDbType.UniqueIdentifier),
                new SqlParameter("@BigClassId", SqlDbType.UniqueIdentifier),
                new SqlParameter("@SmallClassName", SqlDbType.NVarChar)
            };
            parameters[0].Value = smallClass.SmallClassId;
            parameters[1].Value = smallClass.BigClassId;
            parameters[2].Value = smallClass.SmallClassName;

            int rows;

            try
            {
                rows = DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
            }
            catch (SqlException ex)
            {
                throw ex;
            }

            return (rows > 0);
        }
 int Get(SmallClass @class)
 {
     return @class.Val;
 }
예제 #17
0
 public int c(SmallClass d)
 {
     return(5);
 }
예제 #18
0
        public override bool UpdateSmallClass(SmallClass smallClass)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("Update SmallClass Set ");
            strSql.Append(@"BigClassId = @BigClassId,
                            SmallClassName = @SmallClassName");
            strSql.Append(" Where SmallClassId = @SmallClassId");

            SqlParameter[] paramArray = {
                new SqlParameter("@SmallClassId", SqlDbType.UniqueIdentifier),
                new SqlParameter("@BigClassId", SqlDbType.UniqueIdentifier),
                new SqlParameter("@SmallClassName", SqlDbType.NVarChar)
            };
            paramArray[0].Value = smallClass.SmallClassId;
            paramArray[1].Value = smallClass.BigClassId;
            paramArray[2].Value = smallClass.SmallClassName;

            List<SqlParameter> parameters = new List<SqlParameter>();
            parameters.AddRange(paramArray);

            int rows;

            try
            {
                rows = DbHelperSQL.ExecuteSql(strSql.ToString(),parameters.ToArray());
            }
            catch (SqlException ex)
            {
                throw ex;
            }

            return (rows > 0);
        }
예제 #19
0
        static void Main(string[] args)
        {
            //var user = new User();
            //user.MyProperty.Add(new SmallClass
            //{
            //    MyProperty = 1
            //});

            //var user1 = new User();
            //user1.MyProperty.Add(new SmallClass
            //{
            //    MyProperty = 111
            //});
            //user1.MyProperty.Add(new SmallClass
            //{
            //    MyProperty = 222
            //});

            var bigClass = new BigClass
            {
                One   = 1,
                Two   = 1.0M,
                Three = "1",
                Four  = 0,
                Five  = 2,
            };

            var smallClass = new SmallClass
            {
                MyProperty = 1
            };

            var anonObject = new AnonymousObjectsExample();
            var dtoObject1 = new DataTransferObject
            {
                Value = bigClass.Two,
                Type  = bigClass.GetType(),
            };
            var dtoObject2 = new DataTransferObject
            {
                Value = smallClass.MyProperty,
                Type  = smallClass.GetType(),
            };

            // Огромные вычисления :)
            var anonObject3 = new
            {
                Value = bigClass.Two,
                Type  = bigClass.GetType(),
            };
            var dtoObject3ByAnonObject = new DataTransferObject
            {
                Value = anonObject3.Value,
                Type  = anonObject3.Type,
            };

            Console.WriteLine(anonObject3.GetType());
            Console.WriteLine(dtoObject3ByAnonObject.GetType());

            anonObject.Show(dtoObject3ByAnonObject);
            anonObject.Show(dtoObject1);
            anonObject.Show(dtoObject2);

            var listWithValues = new List <int>
            {
                0,
                1,
                2,
                3,
                0,
                4,
                0,
                5,
                0,
            };

            var resultValue1 = new List <ResultObject>();
            var resultValue2 = new List <ResultObject>();
            var resultValue3 = new List <ResultObject>();

            foreach (var item in listWithValues)
            {
                var newTempObject = new ResultObject
                {
                    Value  = item,
                    Result = CheckUp(item)
                };

                resultValue1.Add(newTempObject);
            }
예제 #20
0
        private void 刪除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (GlobalMessageBox.Show("确定删除该条数据?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                TreeNode node = skinTreeViewClass.SelectedNode;
                if (node.Level == 1)
                {
                    CostumeClassInfo info   = node.Tag as CostumeClassInfo;
                    InteractResult   result = GlobalCache.ServerProxy.DeleteBigCostumeClass(info.ID);
                    switch (result.ExeResult)
                    {
                    case ExeResult.Success:
                        allNodes.Remove(node);
                        node.Remove();
                        break;

                    case ExeResult.Error:
                        GlobalMessageBox.Show(result.Msg);
                        break;

                    default:
                        break;
                    }
                }
                else if (node.Level == 2)
                {
                    SmallClass     info   = node.Tag as SmallClass;
                    InteractResult result = GlobalCache.ServerProxy.DeleteSmallClass(info.ID);
                    switch (result.ExeResult)
                    {
                    case ExeResult.Success:
                        allNodes.Remove(node);
                        node.Remove();
                        break;

                    case ExeResult.Error:
                        GlobalMessageBox.Show(result.Msg);
                        break;

                    default:
                        break;
                    }
                }
                else if (node.Level == 3)
                {
                    SubSmallClass  info   = node.Tag as SubSmallClass;
                    InteractResult result = GlobalCache.ServerProxy.DeleteSubSmallClass(info.ID);
                    switch (result.ExeResult)
                    {
                    case ExeResult.Success:
                        allNodes.Remove(node);
                        node.Remove();
                        break;

                    case ExeResult.Error:
                        GlobalMessageBox.Show(result.Msg);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
예제 #21
0
        private void Save()
        {
            InteractResult result = null;

            //subSmallClass.ID = Int32.Parse(result.Msg);
            //TreeNode newNode = new TreeNode(subSmallClass.BigClass);
            //newNode.Tag = subSmallClass;
            //node.Nodes.Add(newNode);

            if (node.Level == 1)
            {
                CostumeClassInfo   bigClass = node.Tag as CostumeClassInfo;
                UpdateBigClassPara para     = new UpdateBigClassPara()
                {
                    ID        = bigClass.ID,
                    NewClass  = skinTextBoxID.Text,
                    OrderNo   = Decimal.ToInt32(costumeTextBoxSort.Value),
                    ClassCode = skinTextBoxCode.Text
                };

                result = GlobalCache.ServerProxy.UpdateBigCostumeClass(para);
                switch (result.ExeResult)
                {
                case ExeResult.Error:
                    GlobalMessageBox.Show(result.Msg);
                    break;

                case ExeResult.Success:
                    bigClass.BigClass  = para.NewClass;
                    bigClass.ClassCode = para.ClassCode;
                    bigClass.OrderNo   = para.OrderNo;
                    node.Text          = para.NewClass;
                    node.Tag           = bigClass;
                    this.DialogResult  = DialogResult.OK;
                    break;

                default:
                    break;
                }
            }
            else if (node.Level == 2)
            {
                SmallClass           subSmallClass = node.Tag as SmallClass;
                UpdateSmallClassPara para          = new UpdateSmallClassPara()
                {
                    ID        = subSmallClass.ID,
                    NewClass  = skinTextBoxID.Text,
                    OrderNo   = Decimal.ToInt32(costumeTextBoxSort.Value),
                    ClassCode = skinTextBoxCode.Text
                };
                result = GlobalCache.ServerProxy.UpdateSmallClass(para);
                switch (result.ExeResult)
                {
                case ExeResult.Error:
                    GlobalMessageBox.Show(result.Msg);
                    break;

                case ExeResult.Success:
                    subSmallClass.BigClass      = node.Parent.Text;
                    subSmallClass.ClassCode     = para.ClassCode;
                    subSmallClass.OrderNo       = para.OrderNo;
                    subSmallClass.SmallClassStr = para.NewClass;
                    node.Text         = para.NewClass;
                    node.Tag          = subSmallClass;
                    this.DialogResult = DialogResult.OK;

                    break;

                default:
                    break;
                }
            }
            else if (node.Level == 3)
            {
                SubSmallClass           subSmallClass = node.Tag as SubSmallClass;
                UpdateSubSmallClassPara para          = new UpdateSubSmallClassPara()
                {
                    ID        = subSmallClass.ID,
                    NewClass  = skinTextBoxID.Text,
                    OrderNo   = Decimal.ToInt32(costumeTextBoxSort.Value),
                    ClassCode = skinTextBoxCode.Text
                };

                result = GlobalCache.ServerProxy.UpdateSubSmallClass(para);
                switch (result.ExeResult)
                {
                case ExeResult.Error:
                    GlobalMessageBox.Show(result.Msg);
                    break;

                case ExeResult.Success:
                    subSmallClass.ID               = para.ID;
                    subSmallClass.ClassCode        = para.ClassCode;
                    subSmallClass.OrderNo          = para.OrderNo;
                    subSmallClass.SubSmallClassStr = para.NewClass;
                    node.Text         = para.NewClass;
                    node.Tag          = subSmallClass;
                    this.DialogResult = DialogResult.OK;
                    break;

                default:
                    break;
                }
            }
        }