private void exportToolStripMenuItem_Click(object sender, EventArgs e) { tProject project = db.Get <tProject>(projectCode); saveFileDialog1.FileName = string.Format("{0}.mdb", project.ProjectName); DialogResult dlgResult = saveFileDialog1.ShowDialog(); if (dlgResult == DialogResult.OK) { string fileName = saveFileDialog1.FileName; List <string> sqlScripts = new List <string>() { }; List <tScript> scripts = db.GetAll <tScript>().Where(x => x.tProjectCode == projectCode).OrderBy(x => x.scriptId).ToList(); foreach (tScript script in scripts) { sqlScripts.Add(string.Format("\nINSERT INTO [tScript] ([scriptId], [sql], [tProjectCode]) VALUES({0}, '{1}', '{2}');", script.scriptId, dbFactoryStatic.escapeQuery(script.sql), script.tProjectCode)); } bool exportResult = db.exportFile(sqlScripts, fileName); if (exportResult) { MessageBox.Show("Exported"); } else { MessageBox.Show("Can't Export File!!! There is some error!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public ActionResult edit(int id) { tProject prod = db.tProject.First(p => p.fid == id); if (prod == null) { return(RedirectToAction("List")); } return(View(prod)); }
public string Create(tProject target) { //------新增專案-----------// tProject prj = new tProject(); prj.fProjectId = target.fProjectId; prj.fProjectName = target.fProjectName; prj.fClient = target.fClient; prj.fPrice = target.fPrice; prj.fCreatdDate = target.fCreatdDate; prj.fDateline = target.fDateline; prj.fEmployeeId = target.fEmployeeId; prj.fProgress = 0; prj.fPaymentStatus = "未收款"; db.tProjects.Add(prj); db.SaveChanges(); //------新增專案預算書------// tBudget budget = new tBudget(); budget.fProjectId = target.fProjectId; db.tBudgets.Add(budget); db.SaveChanges(); //---------新增階段表------// //預設為三階段// //todo:讓使用者自訂階段數量及名稱 tLevel level1 = new tLevel(); level1.fProjectId = prj.fProjectId; level1.fLevelName = "規劃"; level1.fEstimateTime = 0; tLevel level2 = new tLevel(); level2.fProjectId = prj.fProjectId; level2.fLevelName = "開發"; level2.fEstimateTime = 0; tLevel level3 = new tLevel(); level3.fProjectId = prj.fProjectId; level3.fLevelName = "測試"; level3.fEstimateTime = 0; db.tLevels.Add(level1); db.tLevels.Add(level2); db.tLevels.Add(level3); db.SaveChanges(); return("success"); }
public ActionResult Edit(int?fPRJId, tProject target) { var project = db.tProjects.Where(p => p.fProjectId == fPRJId).FirstOrDefault(); project.fPrice = target.fPrice; project.fCreatdDate = target.fCreatdDate; project.fDateline = target.fDateline; project.fEmployeeId = target.fEmployeeId; db.SaveChanges(); return(View(project)); }
public ActionResult edit(tProject p) { tProject prod = db.tProject.First(m => m.fid == p.fid); if (prod == null) { return(RedirectToAction("List")); } prod.fname = p.fname; prod.fprice = p.fprice; prod.fQty = p.fQty; prod.fcost = p.fcost; db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult New(tProject p) { if (p.productphoto != null) { string name = Guid.NewGuid().ToString() + Path.GetExtension(p.productphoto.FileName); var photopath = Path.Combine(Server.MapPath("~/Content"), name); p.productphoto.SaveAs(photopath); p.fPhoto = "../Content/" + name; } db.tProject.Add(p); db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult add(tShoppingCar item) { int prodID = Convert.ToInt32(item.fProduct); tProject t = db.tProject.FirstOrDefault(p => p.fid == prodID); if (t != null) { item.fDate = DateTime.Now.ToString("yyyyMMddHHmmss"); item.fCustomer = "cthulu"; item.fPrice = t.fprice; db.tShoppingCar.Add(item); db.SaveChanges(); } return(RedirectToAction("List")); }
public ActionResult addsession(tShoppingCar item) { int prodID = Convert.ToInt32(item.fProduct); tProject t = db.tProject.FirstOrDefault(p => p.fid == prodID); if (t != null) { List <CShoppingCartItem> list = (List <CShoppingCartItem>)Session[CDictionary.SK_PURCHASED_IN_SHOPPINGCART]; if (list == null) { list = new List <CShoppingCartItem>(); Session[CDictionary.SK_PURCHASED_IN_SHOPPINGCART] = list; } CShoppingCartItem x = new CShoppingCartItem(); x.price = Convert.ToDouble(t.fprice); x.productID = t.fid; x.productname = t.fname; x.count = (int)item.fCount; list.Add(x); } return(RedirectToAction("List")); }
private void bindInfo() { tProject project = db.Get <tProject>(projectCode); bindScripts(projectCode); }
static void SyncProject(string username) { //вывожу ее отдельно, так как здесь немного другая логика работы using (var db = new ApplicationDbContext()) { var t = db.tModerator.First(a => a.tUsers.UserName == username); if (t != null) { var fc = new FbConnectionStringBuilder { UserID = t.tModerator_userId, Password = t.tModerator_password, Database = t.tModerator_database, Charset = "win1251", Pooling = false, Role = "R_ADMIN" }; using (var fb = new FbConnection(fc.ConnectionString)) { try { fb.Open(); using (var ft = fb.BeginTransaction()) { using ( var fcon = new FbCommand( "select p.ID_PROJECTS, p.MNEMO from PROJECTS p order by 1", fb, ft)) { using (var fr = fcon.ExecuteReader()) { while (fr.Read()) { //Добавляем проект if (db.tProject.Find(fr[0]) != null) { var m = db.tProject.Find(fr[0]); m.tProject_name = fr[1].ToString(); db.Entry(m).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } else { var m = new tProject { Id = (int)fr[0], tProject_name = fr[1].ToString() }; db.tProject.Add(m); db.SaveChanges(); } //теперь добавим подсистему using ( var fconSub = new FbCommand( "select s.ID_SUBSYSTEM, s.MNEMO from SUBSYSTEMS s where s.ID_PROJECTS = @id order by 1", fb, ft)) { fconSub.Parameters.AddWithValue("@id", (int)fr[0]); using (var frSub = fconSub.ExecuteReader()) { while (frSub.Read()) { if (db.tSubsystem.Find(frSub[0]) != null) { var sub = db.tSubsystem.Find(frSub[0]); sub.tSubsystem_name = frSub[1].ToString(); db.Entry(sub).State = System.Data.Entity.EntityState.Modified; } else { var sub = new tSubsystem { Id = (int)frSub[0], tSubsystem_name = frSub[1].ToString(), tproject = db.tProject.Find(fr[0]) }; db.tSubsystem.Add(sub); db.SaveChanges(); } } frSub.Dispose(); } fconSub.Dispose(); } //Релизы проектов using ( var fconSub = new FbCommand( "select pr.ID_RELEASE_PROJECTS, pr.MNEMO from RELEASE_PROJECTS pr where pr.ID_PROJECTS = @id order by pr.MNEMO", fb, ft)) { fconSub.Parameters.AddWithValue("@id", (int)fr[0]); using (var frSub = fconSub.ExecuteReader()) { while (frSub.Read()) { if (db.tReleaseProject.Find(frSub[0]) != null) { var sub = db.tReleaseProject.Find(frSub[0]); sub.tReleaseProject_name = frSub[1].ToString(); db.Entry(sub).State = System.Data.Entity.EntityState.Modified; } else { var sub = new tReleaseProject { Id = (int)frSub[0], tReleaseProject_name = frSub[1].ToString(), tproject = db.tProject.Find(fr[0]) }; db.tReleaseProject.Add(sub); db.SaveChanges(); } } frSub.Dispose(); } fconSub.Dispose(); } } fr.Dispose(); } fcon.Dispose(); } ft.Commit(); ft.Dispose(); } } catch {} finally { fb.Close(); } fb.Dispose(); } } db.Dispose(); } }
public string Create(tProject target) { //------新增專案-----------// tProject prj = new tProject(); prj.fProjectId = target.fProjectId; prj.fProjectName = target.fProjectName; prj.fClient = target.fClient; prj.fPrice = target.fPrice; prj.fCreatdDate = target.fCreatdDate; prj.fDateline = target.fDateline; prj.fDepartment = target.fDepartment; prj.fEmployeeId = target.fEmployeeId; prj.fProgress = 0; prj.fStatus = "進行中"; db.tProjects.Add(prj); db.SaveChanges(); //------新增專案預算書------// tBudget budget = new tBudget(); budget.fProjectId = target.fProjectId; budget.fManagementFeePct = 0.2; budget.fSalaryHour = 200; budget.fagree = "未申請"; budget.fBudget = 0; db.tBudgets.Add(budget); db.SaveChanges(); //---------新增階段表------// //預設為三階段// //todo:讓使用者自訂階段數量及名稱 tLevel level1 = new tLevel(); level1.fProjectId = prj.fProjectId; level1.fLevelName = "規劃"; level1.fEstimateTime = 0; level1.fSpendCost = 0; tLevel level2 = new tLevel(); level2.fProjectId = prj.fProjectId; level2.fLevelName = "開發"; level2.fEstimateTime = 0; level2.fSpendCost = 0; tLevel level3 = new tLevel(); level3.fProjectId = prj.fProjectId; level3.fLevelName = "測試"; level3.fEstimateTime = 0; level3.fSpendCost = 0; db.tLevels.Add(level1); db.tLevels.Add(level2); db.tLevels.Add(level3); db.SaveChanges(); return("success"); }