public ActionResult DisplayDeals(int crmid) { CompanyRelationship crm = CH.GetDataById <CompanyRelationship>(crmid); var ds = from d in crm.Deals select new AjaxViewDeal { CompanyNameEN = d.CompanyRelationship.Company.Name_EN, CompanyNameCH = d.CompanyRelationship.Company.Name_CH, DealCode = d.DealCode, Abandoned = d.Abandoned, AbandonReason = d.AbandonReason, ActualPaymentDate = d.ActualPaymentDate, Committer = d.Committer, CommitterContect = d.Committer, CommitterEmail = d.CommitterEmail, ExpectedPaymentDate = d.ExpectedPaymentDate, ID = d.ID, Income = d.Income, IsClosed = d.IsClosed, PackageNameCH = d.Package.Name_CH, PackageNameEN = d.Package.Name_EN, Payment = d.Payment, Currency = d.Currencytype.Name, PaymentDetail = d.PaymentDetail, Sales = d.Sales, ProjectCode = d.Project.ProjectCode, SignDate = d.SignDate, TicketDescription = d.TicketDescription, IsConfirm = (d.IsConfirm == true ? "是" : "否") }; return(PartialView("Deal", ds.ToList())); }
public ActionResult AddCompany(Company item, int?projectid, int[] checkedCategorys) { projectid = this.TrySetProjectIDForUser(projectid); ViewBag.ProjectID = projectid; this.AddAddErrorStateIfOneOfNameExist <Company>(item.Name_EN, item.Name_CH); this.AddErrorIfAllNamesEmpty(item); if (ModelState.IsValid) { List <Category> lc = new List <Category>(); if (checkedCategorys != null) { lc = CH.GetAllData <Category>(i => checkedCategorys.Contains(i.ID)); } var p = CH.GetDataById <Project>(projectid); CH.Create <Company>(item); var ms = new List <Member>(); ms.Add(p.GetMemberInProjectByName(Employee.CurrentUserName)); var cr = new CompanyRelationship() { CompanyID = item.ID, ProjectID = projectid, Importancy = 1, Members = ms, Categorys = lc }; CH.Create <CompanyRelationship>(cr); return(RedirectToAction("CompanyRelationshipIndex", "productinterface", new { projectid = projectid })); } else { return(View()); } }
public ActionResult Edit(CompanyRelationship item, int[] checkedCategorys, string enname, string chname) { //如何保存多对多关系中 引用变化的例子 if (ModelState.IsValid) { var com = CH.GetDataById <Company>(item.CompanyID); if (com.Name_CH != chname || com.Name_EN != enname) { com.Name_CH = chname; com.Name_EN = enname; CH.Edit <Company>(com); } CH.Edit <CompanyRelationship>(item); if (checkedCategorys != null) { item = CH.GetDataById <CompanyRelationship>(item.ID); item.Categorys.Clear(); var ck = CH.GetAllData <Category>(c => checkedCategorys.Any(cc => cc == c.ID)); ck.ForEach(c => { item.Categorys.Add(c); }); string categorystring = string.Empty; ck.ForEach(l => { if (string.IsNullOrEmpty(categorystring)) { categorystring = l.Name; } else { categorystring += "," + l.Name; } }); item.CategoryString = categorystring; CH.Edit <CompanyRelationship>(item); CH.DB.SaveChanges(); } else { item = CH.GetDataById <CompanyRelationship>(item.ID); item.Categorys.Clear(); CH.DB.SaveChanges(); } if (Employee.EqualToProductInterface()) { return(RedirectToAction("companyrelationshipindex", "productinterface", new { id = item.ProjectID })); } else { return(RedirectToAction("management", "project", new { id = item.ProjectID, tabindex = 3 })); } } ViewBag.ProjectID = item.ProjectID; return(View(item)); }
public ActionResult DeleteConfirmed(int id) { CompanyRelationship companyRelationship = db.CompanyRelationships.Find(id); db.CompanyRelationships.Remove(companyRelationship); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "CompanyRelationshipId,CompanyRelationshipTypeId,FromCompany,ToCompany")] CompanyRelationship companyRelationship) { if (ModelState.IsValid) { db.Entry(companyRelationship).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FromCompany = new SelectList(db.GameCompanies, "GameCompanyId", "GameCompanyName", companyRelationship.FromCompany); ViewBag.ToCompany = new SelectList(db.GameCompanies, "GameCompanyId", "GameCompanyName", companyRelationship.ToCompany); ViewBag.CompanyRelationshipTypeId = new SelectList(db.CompanyRelationshipTypes, "CompanyRelationshipTypeId", "CompanyRelationshipTypeName", companyRelationship.CompanyRelationshipTypeId); return(View(companyRelationship)); }
public ActionResult Create(string enname, string chname, CompanyRelationship item, int[] checkedCategorys) { this.AddErrorIfAllNamesEmpty(enname, chname); this.AddAddErrorStateIfOneOfNameExist <Company>(enname, chname); if (ModelState.IsValid) { var company = new Company() { Name_EN = enname, Name_CH = chname, Creator = Employee.CurrentUserName, From = Employee.GetCurrentProfile("Department").ToString() }; CH.Create <Company>(company); if (ModelState.IsValid) { string categorystring = string.Empty; if (checkedCategorys != null) { var ck = CH.GetAllData <Category>(i => checkedCategorys.Contains(i.ID)); item.Categorys = ck; ck.ForEach(l => { if (string.IsNullOrEmpty(categorystring)) { categorystring = l.Name; } else { categorystring += "|" + l.Name; } }); item.CategoryString = categorystring; } item.CompanyID = company.ID; CH.Create <CompanyRelationship>(item); if (Employee.EqualToProductInterface()) { return(RedirectToAction("companyrelationshipindex", "productinterface", new { id = item.ProjectID })); } else { return(RedirectToAction("management", "project", new { id = item.ProjectID, tabindex = 3 })); } } } ViewBag.ProjectID = item.ProjectID; return(View()); }
// GET: CompanyRelationships/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CompanyRelationship companyRelationship = db.CompanyRelationships.Find(id); if (companyRelationship == null) { return(HttpNotFound()); } return(View(companyRelationship)); }
public ActionResult GetLeadsJson(int crmid) { CompanyRelationship crm = CH.GetDataById <CompanyRelationship>(crmid); var leads = from c in crm.Company.Leads.Where(w => w.Deleted == false) select new { LeadID = c.ID, LeadNameCH = c.Name_CH, LeadNameEN = c.Name_EN, LeadTitle = c.Title, LeadMobile = c.Mobile, LeadContact = c.Contact }; return(Json(leads.ToList())); }
// GET: CompanyRelationships/Delete/5 public ActionResult Delete(int?id) { if (this.User.Identity.IsAuthenticated) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CompanyRelationship companyRelationship = db.CompanyRelationships.Find(id); if (companyRelationship == null) { return(HttpNotFound()); } return(View(companyRelationship)); } else { return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized)); } }
// GET: CompanyRelationships/Edit/5 public ActionResult Edit(int?id) { if (this.User.Identity.IsAuthenticated) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CompanyRelationship companyRelationship = db.CompanyRelationships.Find(id); if (companyRelationship == null) { return(HttpNotFound()); } ViewBag.FromCompany = new SelectList(db.GameCompanies, "GameCompanyId", "GameCompanyName", companyRelationship.FromCompany); ViewBag.ToCompany = new SelectList(db.GameCompanies, "GameCompanyId", "GameCompanyName", companyRelationship.ToCompany); ViewBag.CompanyRelationshipTypeId = new SelectList(db.CompanyRelationshipTypes, "CompanyRelationshipTypeId", "CompanyRelationshipTypeName", companyRelationship.CompanyRelationshipTypeId); return(View(companyRelationship)); } else { return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized)); } }
public ActionResult MergeCompay(AjaxMergeCompany mergecompany) { var maincrmid = mergecompany.company.CRMID; CompanyRelationship crm = CH.GetDataById <CompanyRelationship>(mergecompany.company.CRMID); crm.Company.Address = mergecompany.company.Address; crm.Company.AreaID = mergecompany.company.AreaID; crm.Company.Business = mergecompany.company.Business; crm.Company.CompanyTypeID = mergecompany.company.CompanyTypeID; crm.Company.Contact = mergecompany.company.Contact == null?mergecompany.company.Contact:mergecompany.company.Contact.Trim(); crm.Company.ModifiedDate = DateTime.Now; crm.Company.ModifiedUser = Employee.CurrentUserName; crm.Company.Address_EN = mergecompany.company.Address_EN; crm.Company.Province = mergecompany.company.Province; crm.Company.City = mergecompany.company.City; crm.Company.Scale = mergecompany.company.Scale; crm.Company.AnnualSales = mergecompany.company.AnnualSales; crm.Company.MainProduct = mergecompany.company.MainProduct; crm.Company.MainClient = mergecompany.company.MainClient; crm.Company.Description = mergecompany.company.Description; crm.Company.DistrictNumberID = mergecompany.company.DistrictNumberID; crm.Company.Fax = mergecompany.company.Fax; crm.Company.Name_CH = mergecompany.company.Name_CH == null?mergecompany.company.Name_CH:mergecompany.company.Name_CH.Trim(); crm.Company.Name_EN = mergecompany.company.Name_EN == null?mergecompany.company.Name_EN:mergecompany.company.Name_EN.Trim(); crm.Company.WebSite = mergecompany.company.WebSite; crm.Company.ZIP = mergecompany.company.ZIP; crm.Company.Customers = mergecompany.company.Customers; crm.Company.Competitor = mergecompany.company.Competitor; var maincompanyid = crm.CompanyID; List <int> crmids = mergecompany.ids.Where(w => w != maincrmid).ToList(); List <Category> othercates = new List <Category>(); //crm.Company.Leads.AddRange(otherleads); foreach (int i in crmids) { CompanyRelationship othercrm = CH.GetDataById <CompanyRelationship>(i); othercates.AddRange(othercrm.Categorys); } crm.Categorys.AddRange(othercates); CH.Edit <CompanyRelationship>(crm); List <int> oldcompanyids = new List <int>(); foreach (int i in crmids) { CompanyRelationship othercrm = CH.GetDataById <CompanyRelationship>(i); othercrm.Deleted = true; CH.Edit <CompanyRelationship>(othercrm); //判断是否有其他crm指向次公司 var hasothercrm = CH.DB.CompanyRelationships.Any(w => w.CompanyID == othercrm.CompanyID && !crmids.Contains(w.ID)); if (!hasothercrm) { Company com = CH.GetDataById <Company>(othercrm.CompanyID); com.Deleted = true; CH.Edit <Company>(com); oldcompanyids.Add((int)othercrm.CompanyID); } } CompanyMergeTrack _track = new CompanyMergeTrack(); _track.TableName = "Company"; _track.OldID = maincompanyid.ToString(); _track.NewID = string.Join(";", oldcompanyids.ToArray()); CH.Create <CompanyMergeTrack>(_track); _track = new CompanyMergeTrack(); _track.TableName = "CompanyRelationship"; _track.OldID = maincrmid.ToString(); _track.NewID = string.Join(";", crmids.ToArray()); CH.Create <CompanyMergeTrack>(_track); List <int> companyids = CH.DB.CompanyRelationships.Where(w => crmids.Contains((int)w.ID)).Select(w => (int)w.CompanyID).ToList(); List <Lead> otherleads = CH.DB.Leads.Where(w => companyids.Contains((int)w.CompanyID)).ToList(); List <int> oldleadids = new List <int>(); List <int> newleadids = new List <int>(); List <int> oldcallids = new List <int>(); List <int> newcallids = new List <int>(); foreach (Lead lead in otherleads) { oldleadids.Add(lead.ID); lead.Deleted = true; CH.Edit <Lead>(lead); int leadid = lead.ID; lead.CompanyID = crm.Company.ID; lead.Deleted = false; CH.DB.Set <Lead>().Add(lead); CH.DB.SaveChanges(); //CH.Create<Lead>(lead); newleadids.Add(lead.ID); List <LeadCall> othercalls = CH.DB.LeadCalls.Where(w => w.LeadID == leadid).ToList(); foreach (LeadCall call in othercalls) { oldcallids.Add(call.ID); call.Deleted = true; CH.Edit <LeadCall>(call); call.LeadID = lead.ID; call.CompanyRelationshipID = maincrmid; call.Deleted = false; CH.Create <LeadCall>(call); newcallids.Add(call.ID); } } if (otherleads.Count > 0) { _track = new CompanyMergeTrack(); _track.TableName = "Lead"; _track.OldID = string.Join(";", oldleadids.ToArray()); _track.NewID = string.Join(";", newleadids.ToArray()); CH.Create <CompanyMergeTrack>(_track); } if (oldcallids.Count > 0) { _track = new CompanyMergeTrack(); _track.TableName = "LeadCall"; _track.OldID = string.Join(";", oldcallids.ToArray()); _track.NewID = string.Join(";", newcallids.ToArray()); CH.Create <CompanyMergeTrack>(_track); } List <Deal> otherdeals = CH.DB.Deals.Where(w => crmids.Contains((int)w.CompanyRelationshipID)).ToList(); List <int> newdealids = new List <int>(); foreach (Deal deal in otherdeals) { deal.Deleted = true; CH.Edit <Deal>(deal); deal.CompanyRelationshipID = maincrmid; deal.Deleted = false; CH.Create <Deal>(deal); newdealids.Add(deal.ID); } if (otherdeals.Count > 0) { _track = new CompanyMergeTrack(); _track.TableName = "Deal"; _track.OldID = string.Join(";", otherdeals.Select(w => w.ID).ToArray()); _track.NewID = string.Join(";", newdealids.ToArray()); CH.Create <CompanyMergeTrack>(_track); } List <Comment> othercomments = CH.DB.Comments.Where(w => crmids.Contains((int)w.CompanyRelationshipID)).ToList(); List <int> newcommentids = new List <int>(); foreach (Comment comment in othercomments) { comment.Deleted = true; CH.Edit <Comment>(comment); comment.CompanyRelationshipID = maincrmid; comment.Deleted = false; CH.Create <Comment>(comment); newcommentids.Add(comment.ID); } if (othercomments.Count > 0) { _track = new CompanyMergeTrack(); _track.TableName = "Comment"; _track.OldID = string.Join(";", othercomments.Select(w => w.ID).ToArray()); _track.NewID = string.Join(";", newcommentids.ToArray()); CH.Create <CompanyMergeTrack>(_track); } return(Json(new { crmid = crm.ID })); }
public ActionResult DisplayComments(int crmid) { CompanyRelationship crm = CH.GetDataById <CompanyRelationship>(crmid); return(PartialView("Comment", crm.Comments)); }
public ActionResult DisplayCategories(int crmid) { CompanyRelationship crm = CH.GetDataById <CompanyRelationship>(crmid); return(PartialView("Category", crm.Categorys)); }
public ActionResult DisplayLeadCalls(int crmid) { CompanyRelationship crm = CH.GetDataById <CompanyRelationship>(crmid); return(PartialView("LeadCall", crm.LeadCalls)); }
private void FakeData(DB context) { context.Roles.Add(new Role() { Name = "高层", Level = 1000, ID = 1 }); context.Roles.Add(new Role() { Name = "版块负责人", Level = 500, ID = 2 }); context.Roles.Add(new Role() { Name = "销售经理", Level = 100, ID = 3 }); context.Roles.Add(new Role() { Name = "销售专员", Level = 10, ID = 4 }); context.Roles.Add(new Role() { Name = "产品部接口人", Level = 5, ID = 5 }); context.Roles.Add(new Role() { Name = "会务部部接口人", Level = 3, ID = 6 }); context.Roles.Add(new Role() { Name = "市场部接口人", Level = 1, ID = 7 }); context.CompanyTypes.Add(new CompanyType { Name = "外企独资企业", ID = 1 }); context.CompanyTypes.Add(new CompanyType { Name = "外企办事处", ID = 2 }); context.CompanyTypes.Add(new CompanyType { Name = "合资企业", ID = 3 }); context.CompanyTypes.Add(new CompanyType { Name = "国有企业", ID = 4 }); context.CompanyTypes.Add(new CompanyType { Name = "合资企业", ID = 5 }); context.CompanyTypes.Add(new CompanyType { Name = "民营企业", ID = 6 }); context.CompanyTypes.Add(new CompanyType { Name = "事业单位", ID = 7 }); context.Areas.Add(new Area() { Name_EN = "", Name_CH = "航天", ID = 1 }); context.Areas.Add(new Area() { Name_EN = "", Name_CH = "石油", ID = 2 }); context.Areas.Add(new Area() { Name_EN = "", Name_CH = "化工", ID = 3 }); context.Areas.Add(new Area() { Name_EN = "", Name_CH = "医疗", ID = 4 }); context.Areas.Add(new Area() { Name_EN = "Publishing", Name_CH = "出版行业", ID = 5 }); context.OnPhoneBlockTypes.Add(new OnPhoneBlockType() { Name = "没有预算", Code = 1 }); context.OnPhoneBlockTypes.Add(new OnPhoneBlockType() { Name = "无战略规划", Code = 2 }); context.OnPhoneBlockTypes.Add(new OnPhoneBlockType() { Name = "请假", Code = 3 }); context.OnPhoneBlockTypes.Add(new OnPhoneBlockType() { Name = "无人接听", Code = 4 }); context.OnPhoneBlockTypes.Add(new OnPhoneBlockType() { Name = "不是决策人", Code = 5 }); context.LeadCallTypes.Add(new LeadCallType() { Name = "Others", Code = 10, ID = 1 }); context.LeadCallTypes.Add(new LeadCallType() { Name = "Blowed", Code = 20, ID = 2 }); context.LeadCallTypes.Add(new LeadCallType() { Name = "Not Pitched", Code = 30, ID = 3 }); context.LeadCallTypes.Add(new LeadCallType() { Name = "Pitched", Code = 40, ID = 4 }); context.LeadCallTypes.Add(new LeadCallType() { Name = "Full Pitched", Code = 50, ID = 5 }); context.LeadCallTypes.Add(new LeadCallType() { Name = "Call-Backed", Code = 60, ID = 6 }); context.LeadCallTypes.Add(new LeadCallType() { Name = "Waiting for Approval", Code = 70, ID = 7 }); context.LeadCallTypes.Add(new LeadCallType() { Name = "Qualified Decision", Code = 80, ID = 8 }); context.LeadCallTypes.Add(new LeadCallType() { Name = "Closed", Code = 90, ID = 9 }); context.DistrictNumbers.Add(new DistrictNumber() { Country = "kuwait", Number = 965, TimeDifference = -5, ID = 1 }); context.DistrictNumbers.Add(new DistrictNumber() { Country = "Australia", Number = 61, TimeDifference = 2, ID = 2 }); context.DistrictNumbers.Add(new DistrictNumber() { Country = "India", Number = 91, TimeDifference = -2.3, ID = 3 }); context.CurrencyTypes.Add(new CurrencyType() { Name = "RMB", ID = 1 }); context.CurrencyTypes.Add(new CurrencyType() { Name = "$", ID = 2 }); context.SalesTypes.Add(new SalesType() { Name = "基础销售", ID = 1 }); context.SalesTypes.Add(new SalesType() { Name = "客户经理", ID = 2 }); context.PaymentTypes.Add(new PaymentType() { Name = "现金" }); context.PaymentTypes.Add(new PaymentType() { Name = "刷卡" }); context.PaymentTypes.Add(new PaymentType() { Name = "汇款" }); context.PaymentTypes.Add(new PaymentType() { Name = "其他" }); context.PackageTypes.Add(new PackageType() { Name_EN = "PLATINUM", ID = 1 }); context.PackageTypes.Add(new PackageType() { Name_EN = "GLOD", ID = 2 }); context.PackageTypes.Add(new PackageType() { Name_EN = "SILVER", ID = 3 }); context.PackageTypes.Add(new PackageType() { Name_EN = "BRONZE", ID = 4 }); context.PackageTypes.Add(new PackageType() { Name_EN = "ASSOCIATE", ID = 5 }); context.ParticipantTypes.Add(new ParticipantType() { Name_EN = "Sponsor", ID = 1 }); context.ParticipantTypes.Add(new ParticipantType() { Name_EN = "Delegate", ID = 2 }); context.ParticipantTypes.Add(new ParticipantType() { Name_EN = "VIP", ID = 3 }); context.ParticipantTypes.Add(new ParticipantType() { Name_EN = "Others", ID = 4 }); context.Packages.Add(new Package { Name_CH = "黄金展商", Name_EN = "30 minutes speechs", Prize = 20000, PackageTypeID = 1, ParticipantTypeID = 1, ID = 1, SubName = "" }); var c1 = new Company() { AreaID = 1, CompanyTypeID = 1, Cerator = "sean", Creator = "karen", Contact = "2100000", DistrictNumberID = 1, From = "销售部", ID = 1, Name_CH = "天空之星", Name_EN = "Sky Start", Fax = "213000" }; context.Companys.Add(c1); var c2 = new Company() { AreaID = 2, CompanyTypeID = 1, Cerator = "sean", Contact = "214545400", Creator = "karen", DistrictNumberID = 1, From = "销售部", ID = 2, Name_CH = "火箭之家", Name_EN = "Rocket Me", Fax = "214500" }; context.Companys.Add(c2); var c3 = new Company() { AreaID = 3, CompanyTypeID = 1, Cerator = "susie", Contact = "21566500", Creator = "karen", DistrictNumberID = 1, From = "销售部", ID = 3, Name_CH = "高精行空油业", Name_EN = "Elite Sky Oil", Fax = "563000" }; context.Companys.Add(c3); var l1 = new Lead() { ID = 1, Name_CH = "马克", Name_EN = "Mike", Fax = "213000", CompanyID = 1, Contact = "23422232", Mobile = "1243323233", Title = "CEO", Gender = "Mr", EMail = "*****@*****.**" }; context.Leads.Add(l1); var l2 = new Lead() { ID = 2, Name_CH = "艾利克斯", Name_EN = "Alex", Fax = "214500", CompanyID = 1, Contact = "23422232", Mobile = "1248903233", Title = "CFO", Gender = "Mr", EMail = "*****@*****.**" }; context.Leads.Add(l2); var l3 = new Lead() { ID = 3, Name_CH = "马丁", Name_EN = "Martin", Fax = "254000", CompanyID = 2, Contact = "2342752", Mobile = "1343323233", Title = "Sales Director", Gender = "Mr", EMail = "*****@*****.**" }; context.Leads.Add(l3); var l4 = new Lead() { ID = 4, Name_CH = "汤玛斯", Name_EN = "Tomas", Fax = "563000", CompanyID = 3, Contact = "23674232", Mobile = "1256423233", Title = "CTO", Gender = "Mr", EMail = "*****@*****.**" }; context.Leads.Add(l4); var p1 = new Project() { ID = 1, EndDate = DateTime.Now.AddYears(1), ConferenceStartDate = new DateTime(2012, 12, 6), ConferenceEndDate = new DateTime(2012, 12, 7), StartDate = DateTime.Now.AddYears(-1), Target = 50000000, IsActived = true, TeamLeader = "sean", Manager = "mike", Name_CH = "CTC 航空峰会", ProjectCode = "ACYY", Market = "amy", Product = "flora" }; p1.CompanyRelationships = new List <CompanyRelationship>(); var cr1 = new CompanyRelationship() { ID = 1, ProjectID = 1, CompanyID = 1, Importancy = 6 }; var cr2 = new CompanyRelationship() { ID = 2, ProjectID = 1, CompanyID = 2, Importancy = 3 }; context.CompanyRelationships.Add(cr1); context.CompanyRelationships.Add(cr2); p1.CompanyRelationships.Add(cr1); p1.CompanyRelationships.Add(cr2); var tm1 = new TargetOfMonth() { ID = 1, BaseDeal = 50000, CheckIn = 50000, Deal = 70000, StartDate = DateTime.Now.StartOfMonth(), EndDate = DateTime.Now.EndOfMonth() }; context.TargetOfMonths.Add(tm1); p1.TargetOfMonths = new List <TargetOfMonth>(); p1.TargetOfMonths.Add(tm1); var tw1 = new TargetOfWeek() { ID = 1, Member = "sean", TargetOfMonthID = 1, ProjectID = 1, CheckIn = 10000, Deal = 12000, EndDate = DateTime.Now.EndOfWeek(), StartDate = DateTime.Now.StartOfWeek() }; context.TargetOfWeeks.Add(tw1); var tw2 = new TargetOfWeek() { ID = 2, Member = "sean", TargetOfMonthID = 1, ProjectID = 1, CheckIn = 10300, Deal = 15000, EndDate = DateTime.Now.EndOfWeek().AddDays(7), StartDate = DateTime.Now.StartOfWeek().AddDays(7) }; context.TargetOfWeeks.Add(tw2); var tw3 = new TargetOfWeek() { ID = 3, Member = "susie", TargetOfMonthID = 1, ProjectID = 1, CheckIn = 8500, Deal = 11000, EndDate = DateTime.Now.EndOfWeek(), StartDate = DateTime.Now.StartOfWeek() }; context.TargetOfWeeks.Add(tw3); var tw4 = new TargetOfWeek() { ID = 4, Member = "tina", TargetOfMonthID = 1, ProjectID = 1, CheckIn = 7000, Deal = 6000, EndDate = DateTime.Now.EndOfWeek(), StartDate = DateTime.Now.StartOfWeek() }; context.TargetOfWeeks.Add(tw4); var d1 = new Deal() { ExpectedPaymentDate = DateTime.Now.AddDays(-2), SignDate = DateTime.Now.AddDays(-5), ActualPaymentDate = DateTime.Now, ID = 1, Income = 12000, Payment = 12000, PackageID = 1, CompanyRelationshipID = 1, Sales = "sean", IsClosed = true }; var d2 = new Deal() { ExpectedPaymentDate = DateTime.Now.AddDays(-1), SignDate = DateTime.Now.AddDays(-3), ActualPaymentDate = DateTime.Now, ID = 2, Income = 5000, Payment = 5000, PackageID = 1, CompanyRelationshipID = 1, Sales = "tina", IsClosed = true }; var d4 = new Deal() { ExpectedPaymentDate = DateTime.Now.AddDays(-3), SignDate = DateTime.Now.AddDays(-6), ActualPaymentDate = DateTime.Now, ID = 4, Income = 7500, Payment = 7500, PackageID = 1, CompanyRelationshipID = 2, Sales = "sean", IsClosed = true }; var d3 = new Deal() { ExpectedPaymentDate = DateTime.Now.AddDays(7), SignDate = DateTime.Now.AddDays(-2), ID = 3, Income = 0, Payment = 60000, PackageID = 1, CompanyRelationshipID = 1, Sales = "sean", IsClosed = false }; context.Deals.Add(d1); context.Deals.Add(d2); context.Deals.Add(d3); context.Deals.Add(d4); var lc1 = new LeadCall() { ID = 1, CreatedDate = DateTime.Now.AddDays(-5), CallDate = DateTime.Now.AddDays(-5), Creator = "sean", MemberID = 1, LeadCallTypeID = 3, LeadID = 1, CompanyRelationshipID = 1 }; var lc2 = new LeadCall() { ID = 2, CreatedDate = DateTime.Now.AddDays(-4), CallDate = DateTime.Now.AddDays(-4), Creator = "sean", MemberID = 1, LeadCallTypeID = 4, LeadID = 1, CompanyRelationshipID = 1 }; var lc3 = new LeadCall() { ID = 3, CreatedDate = DateTime.Now.AddDays(-3), CallDate = DateTime.Now.AddDays(-4), Creator = "sean", MemberID = 1, LeadCallTypeID = 5, LeadID = 1, CompanyRelationshipID = 1 }; var lc5 = new LeadCall() { ID = 4, CreatedDate = DateTime.Now.AddDays(-2), CallDate = DateTime.Now.AddDays(-4), Creator = "sean", MemberID = 1, LeadCallTypeID = 6, CallBackDate = DateTime.Now.AddDays(1), LeadID = 2, CompanyRelationshipID = 1 }; var lc6 = new LeadCall() { ID = 5, CreatedDate = DateTime.Now.AddDays(-1), CallDate = DateTime.Now.AddDays(-4), Creator = "sean", MemberID = 1, LeadCallTypeID = 6, CallBackDate = DateTime.Now.AddDays(2), LeadID = 1, CompanyRelationshipID = 1 }; var lc7 = new LeadCall() { ID = 6, CreatedDate = DateTime.Now.AddDays(-3), CallDate = DateTime.Now.AddDays(-4), Creator = "susie", MemberID = 3, LeadCallTypeID = 2, LeadID = 3, CompanyRelationshipID = 2 }; var lc4 = new LeadCall() { ID = 7, CreatedDate = DateTime.Now.AddDays(-1), CallDate = DateTime.Now.AddDays(-4), Creator = "susie", MemberID = 3, LeadCallTypeID = 2, LeadID = 3, CompanyRelationshipID = 2 }; context.LeadCalls.Add(lc1); context.LeadCalls.Add(lc2); context.LeadCalls.Add(lc3); context.LeadCalls.Add(lc4); context.LeadCalls.Add(lc5); context.LeadCalls.Add(lc6); context.LeadCalls.Add(lc7); context.Projects.Add(p1); var p2 = new Project() { ID = 2, EndDate = DateTime.Now, StartDate = DateTime.Now, ConferenceStartDate = new DateTime(2012, 12, 6), ConferenceEndDate = new DateTime(2012, 12, 7), Target = 30000000, IsActived = true, TeamLeader = "stone", Manager = "mike", Name_CH = "万国博览会", ProjectCode = "BTEC" }; context.Projects.Add(p2); var p3 = new Project() { ID = 3, EndDate = new DateTime(2012, 12, 6), StartDate = new DateTime(2012, 7, 16), ConferenceStartDate = new DateTime(2012, 12, 6), ConferenceEndDate = new DateTime(2012, 12, 7), Target = 900000, IsActived = true, TeamLeader = "stone", Manager = "mike", Name_CH = "2012亚洲数字出版高峰论坛暨颁奖盛典", Name_EN = "Asia Digital Publishing Summit & Awards 2012", ProjectCode = "ADPSA2012", }; context.Projects.Add(p3); context.Members.Add(new Member() { ID = 1, ProjectID = 1, Name = "sean", Characters = "R|S", SalesTypeID = 2 }); context.Members.Add(new Member() { ID = 2, ProjectID = 1, Name = "susie", SalesTypeID = 1 }); context.Members.Add(new Member() { ID = 3, ProjectID = 1, Name = "tina", SalesTypeID = 1 }); context.Members.Add(new Member() { ID = 4, ProjectID = 2, Name = "stone", SalesTypeID = 2 }); context.Members.Add(new Member() { ID = 5, ProjectID = 2, Name = "john", SalesTypeID = 1 }); context.Members.Add(new Member() { ID = 6, ProjectID = 2, Name = "lucas", SalesTypeID = 1 }); context.Members.Add(new Member() { ID = 7, ProjectID = 2, Name = "tina", SalesTypeID = 1 }); context.Members.Add(new Member() { ID = 8, ProjectID = 3, Name = "rachel", SalesTypeID = 1 }); }