Esempio n. 1
0
        private void ToolStripButton_CopyTemplate_Click(object sender, EventArgs e)
        {
            StockTemplate template = GetSelectTemplate();

            if (template == null)
            {
                return;
            }

            string        templateName = string.Format("copy_{0}", template.TemplateName);
            StockTemplate temp         = new StockTemplate
            {
                TemplateName  = templateName,
                FutureCopies  = template.FutureCopies,
                MarketCapOpt  = template.MarketCapOpt,
                EReplaceType  = template.EReplaceType,
                EWeightType   = template.EWeightType,
                Benchmark     = template.Benchmark,
                CreatedUserId = template.CreatedUserId,
                EStatus       = template.EStatus,
                DCreatedDate  = DateTime.Now,
                CanEditUsers  = template.CanEditUsers,
                CanViewUsers  = template.CanViewUsers,
                Permissions   = template.Permissions,
            };

            StockTemplate newtemp = _templateBLL.CreateTemplate(temp);

            if (newtemp.TemplateId > 0)
            {
                _tempDataSource.Add(newtemp);
            }

            this.tempGridView.Invalidate();
        }
Esempio n. 2
0
        private StockTemplate SaveTemplateToDB(StockTemplate stockTemplate, TempChangeType type)
        {
            switch (type)
            {
            case TempChangeType.New:
            {
                var template = _templateBLL.CreateTemplate(stockTemplate);
                stockTemplate.TemplateId = template.TemplateId;
            }
            break;

            case TempChangeType.Update:
            {
                int tempid = _templateBLL.UpdateTemplate(stockTemplate);
                if (tempid > 0)
                {
                    stockTemplate.TemplateId = tempid;
                }
                else
                {
                    MessageDialog.Error(this, msgModifyFail);
                }
            }
            break;

            default:
                break;
            }
            return(stockTemplate);
        }