public JsonResult GetSummaryData(FormCollection fc) { var year = int.Parse(fc.Get("year")); var deptid = fc.Get("deptid"); var deptbll = new DepartmentBLL(); var teams = deptbll.GetSubDepartments(deptid, "班组"); var databll = new DataItemDetailBLL(); var dataitems = databll.GetDataItems("费用类型"); var budgetbll = new BudgetBLL(); var budget = budgetbll.GetBudgetSummary(year, teams.Select(x => x.DepartmentId).ToArray()); var costbll = new CostBLL(); var cost = costbll.GetCostSummary(year, teams.Select(x => x.DepartmentId).ToArray()); var result = new List <BudgetSummaryModel>(); result.AddRange(dataitems.GroupJoin(budget, x => x.ItemValue, y => y.Category, (x, y) => new BudgetSummaryModel { Category = x.ItemValue + "预算", Data = new decimal[] { y.Sum(z => z.Budget1), y.Sum(z => z.Budget2), y.Sum(z => z.Budget3), y.Sum(z => z.Budget4), y.Sum(z => z.Budget5), y.Sum(z => z.Budget6), y.Sum(z => z.Budget7), y.Sum(z => z.Budget8), y.Sum(z => z.Budget9), y.Sum(z => z.Budget10), y.Sum(z => z.Budget11), y.Sum(z => z.Budget12), } })); result.AddRange(dataitems.GroupJoin(cost, x => x.ItemValue, y => y.Category, (x, y) => new BudgetSummaryModel { Category = x.ItemValue + "支出", Data = new decimal[] { y.Where(z => z.Month == 1).Sum(z => z.Amount), y.Where(z => z.Month == 2).Sum(z => z.Amount), y.Where(z => z.Month == 3).Sum(z => z.Amount), y.Where(z => z.Month == 4).Sum(z => z.Amount), y.Where(z => z.Month == 5).Sum(z => z.Amount), y.Where(z => z.Month == 6).Sum(z => z.Amount), y.Where(z => z.Month == 7).Sum(z => z.Amount), y.Where(z => z.Month == 8).Sum(z => z.Amount), y.Where(z => z.Month == 9).Sum(z => z.Amount), y.Where(z => z.Month == 10).Sum(z => z.Amount), y.Where(z => z.Month == 11).Sum(z => z.Amount), y.Where(z => z.Month == 12).Sum(z => z.Amount), } })); result = result.OrderBy(x => x.Category).ToList(); return(Json(result)); }
public JsonResult Remove(string id) { var success = true; var message = "保存成功!"; try { var costbll = new CostBLL(); costbll.Remove(id); var filebll = new FileInfoBLL(); var files = filebll.DeleteByRecId(id); foreach (var item in files) { System.IO.File.Delete(Server.MapPath(item.FilePath)); } } catch (Exception e) { success = false; message = e.Message; } return(Json(new AjaxResult() { type = success ? ResultType.success : ResultType.error, message = message })); }
private void LoadTourCostDetailGraph(int Id, DateTime?StartDate = null, DateTime?EndDate = null) { //reset your chart series and legends chartCostDetail.Series.Clear(); chartCostDetail.Legends.Clear(); //Add a new Legend(if needed) and do some formating chartCostDetail.Legends.Add("LegendCostDetail"); chartCostDetail.Legends[0].LegendStyle = System.Windows.Forms.DataVisualization.Charting.LegendStyle.Table; // chartCostDetail.Legends[0].Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Bottom; // chartCostDetail.Legends[0].Alignment = StringAlignment.Center; chartCostDetail.Legends[0].Title = "Mục"; chartCostDetail.Legends[0].BorderColor = Color.Black; //Add a new chart-series string seriesname = "SeriesCostDetail"; chartCostDetail.Series.Add(seriesname); //set the chart-type to "Pie" chartCostDetail.Series[seriesname].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Doughnut; //Add some datapoints so the series. in this case you can pass the values to this method var costDetails = CostBLL.GetCostStatisticsByTourId(Id, StartDate, EndDate); foreach (var c in costDetails) { chartCostDetail.Series[seriesname].Points.AddXY(c.Name + "\n" + c.Price, c.Price); } }
public JsonResult Order_Deletes(string str) { BLL.OrderInfoBLL _BLL = new OrderInfoBLL(); retValue ret = new retValue(); string content = string.Empty; DataTable dt = str.ToTable(); string ids = ""; string costs = ""; foreach (DataRow item in dt.Rows) { if (!string.IsNullOrEmpty(item["ID"]._ToStrTrim())) { ids += item["ID"]._ToStrTrim() + ","; costs += item["CostID"]._ToStrTrim() + ","; } } ret = _BLL.DeleteByPK(ids.Remove(ids.Length - 1)); if (ret.result) { CostBLL costBLL = new CostBLL(); costBLL.DeleteByPK(costs); } content = ret.toJson(); var js = JsonConvert.SerializeObject(ret); return(Json(js, JsonRequestBehavior.AllowGet)); }
private void btnGroupCostAdd_Click(object sender, EventArgs e) { if (costMode != OperationType.Add) { costMode = OperationType.Add; btnGroupCostCancel.Visible = true; btnGroupCostAdd.Text = "Lưu"; btnGroupCostEdit.Visible = false; btnGroupCostDelete.Visible = false; cbGroupCostType.Enabled = true; tbGroupCostValue.Enabled = true; tbGroupCostNote.Enabled = true; } else { var rowIndex = dgvGroupList.SelectedRows[0].Index; var row = dgvGroupList.Rows[rowIndex]; var groupId = int.Parse(row.Cells["Id"].Value?.ToString()); int costTypeId = (int)cbGroupCostType.SelectedValue; var price = tbGroupCostValue.Text; var note = tbGroupCostNote.Text; try { CostBLL.CreateCost(groupId, costTypeId, price, note); Thread loadCostsThread = new Thread(() => LoadCosts(groupId)); loadCostsThread.Start(); } catch (Exception ex) { string message = ""; foreach (DictionaryEntry item in ex.Data) { message += item.Value?.ToString(); message += Environment.NewLine; } MessageBox.Show(message); return; } costMode = OperationType.View; btnGroupCostAdd.Text = "+ Thêm"; btnGroupCostEdit.Visible = true; btnGroupCostDelete.Visible = true; btnGroupCostCancel.Visible = false; cbGroupCostType.Enabled = false; tbGroupCostValue.Enabled = false; tbGroupCostNote.Enabled = false; } dgvGroupCostList.ClearSelection(); }
public ActionResult CostInfos(int page, int limit, string OrderNo, string OrderID, string State, string UnitName) { PageModel ret = new PageModel(); BLL.CostBLL _BLL = new CostBLL(); PMS.Models.UserModel userModel = Session["UserModel"] as PMS.Models.UserModel; PageModel pg = _BLL.GetCostRecords(0, State, OrderID._ToInt32(), OrderNo, UnitName, limit, page, userModel.OrgID); var js = JsonConvert.SerializeObject(pg); return(Content(js)); }
private void LoadCosts(int groupId, string type = null, string value = null) { //Back to main thread update UI if (InvokeRequired) { BeginInvoke(new Action(() => { dgvGroupCostList.ShowLoading(true); })); } //Fill DataTable var costs = CostBLL.ListCosts(groupId, type, value); var data = new BindingList <object>(); foreach (var cost in costs) { data.Add(new { cost.Id, Type = cost.CostType.Name, cost.Price, cost.Note, }); } //Back to main thread update UI if (InvokeRequired) { BeginInvoke(new Action(() => { //Clear loading column dgvGroupCostList.Columns.Clear(); dgvGroupCostList.Columns.Add("Id", "Mã"); dgvGroupCostList.Columns.Add("Type", "Loại"); dgvGroupCostList.Columns.Add("Price", "Giá"); dgvGroupCostList.Columns.Add("Note", "Ghi chú"); dgvGroupCostList.Columns["Price"].DefaultCellStyle.Format = "N0"; foreach (DataGridViewColumn column in dgvGroupCostList.Columns) { column.DataPropertyName = column.Name; } dgvGroupCostList.DataSource = data; })); } }
private void LoadCostTypes() { var costTypes = CostBLL.ListCostTypes(); //Back to main thread update UI if (InvokeRequired) { BeginInvoke(new Action(() => { cbGroupCostType.DataSource = costTypes; cbGroupCostType.DisplayMember = "Name"; cbGroupCostType.ValueMember = "Id"; })); } }
private void btnGroupCostDelete_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Bạn có chắc chắn muốn xóa??", "Xác nhận xóa!!", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { int id = int.Parse(tbGroupCostID.Text); CostBLL.RemoveCost(id); var rowIndex = dgvGroupList.SelectedRows[0].Index; var row = dgvGroupList.Rows[rowIndex]; var groupId = int.Parse(row.Cells["Id"].Value?.ToString()); Thread loadCostsThread = new Thread(() => LoadCosts(groupId)); loadCostsThread.Start(); } }
public JsonResult GetData(FormCollection fc) { var year = fc.Get("year"); var month = fc.Get("month"); var category = fc.Get("category"); var deptname = fc.Get("dept"); var page = int.Parse(fc.Get("page") ?? "1"); var rows = int.Parse(fc.Get("rows") ?? "20"); var costbll = new CostBLL(); var user = OperatorProvider.Provider.Current(); var total = 0; var costdept = Config.GetValue("CostDept"); var deptbll = new DepartmentBLL(); var dept = new DepartmentBLL().GetEntity(user.DeptId); var depts = default(List <DepartmentEntity>); if (dept == null || dept.FullName == costdept) { dept = deptbll.GetRootDepartment(); depts = deptbll.GetSubDepartments(dept.DepartmentId, null); } else { depts = deptbll.GetSubDepartments(dept.DepartmentId, null); depts.Add(dept); } var data = costbll.GetCostRecords(page, rows, out total, depts == null ? null : depts.Select(x => x.DepartmentId).ToArray(), year, month, category, deptname); var filebll = new FileInfoBLL(); foreach (var item in data) { var files = filebll.GetFileList(item.RecordId.ToString()); if (files.Count > 0) { item.FilePath = Url.Action("DownloadFile", new { area = "PublicInfoManage", controller = "ResourceFile", keyValue = files[0].FileId, filename = files[0].FileName, recId = files[0].RecId }); item.FileName = files[0].FileName; } } return(Json(new { rows = data, records = total, total = Math.Ceiling((double)total / rows), page })); }
public ActionResult Order_getCounts(string str) { retValue ret = new retValue(); PMS.Models.UserModel userModel = Session["UserModel"] as PMS.Models.UserModel; int userid = userModel._ID; BLL.CostBLL _BLL = new CostBLL(); JObject o = null; if (!string.IsNullOrEmpty(str)) { o = JObject.Parse(str); string OrderNo = o["OrderNo"]._ToStrTrim(); string OrderID = o["OrderID"]._ToStrTrim(); string State = o["CostState"]._ToStrTrim(); string UnitName = o["UnitName"]._ToStrTrim(); ret = _BLL.GetCostRecords(0, State, OrderID._ToInt32(), OrderNo, UnitName, userModel.OrgID); } var js = JsonConvert.SerializeObject(ret); return(Json(js, JsonRequestBehavior.AllowGet)); }
public JsonResult DoImport(CostRecordEntity record) { var success = true; var message = "保存成功!"; var user = OperatorProvider.Provider.Current(); if (this.Request.Files.Count > 0) { var book = default(Workbook); try { book = new Workbook(this.Request.Files[0].InputStream); } catch (Exception e) { return(Json(new AjaxResult() { type = ResultType.error, message = "无法识别的文件!" })); } try { var sheet = book.Worksheets[0]; var titleIndex = this.GetTitleRow(sheet, record.Category); var dataindex = this.GetDataIndex(sheet, titleIndex); var costbll = new CostBLL(); var costitems = this.GetCostData(sheet, titleIndex, dataindex); record.CostItems = costitems; record.RecordId = Guid.NewGuid(); costbll.AddCost(record); var filename = this.Request.Files[0].FileName; var path = Path.Combine(Server.MapPath("~/Resource"), "Budget"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var id = Guid.NewGuid().ToString(); this.Request.Files[0].SaveAs(Path.Combine(path, id + Path.GetExtension(filename))); var fileinfo = new FileInfoEntity() { FileId = id, FilePath = "~/Resource/Budget/" + id + Path.GetExtension(filename), FileName = filename, CreateDate = DateTime.Now, CreateUserId = user.UserId, CreateUserName = user.UserName, DeleteMark = 0, EnabledMark = 1, FileExtensions = Path.GetExtension(filename), FileSize = this.Request.Files[0].ContentLength.ToString(), ModifyDate = DateTime.Now, ModifyUserId = user.UserId, ModifyUserName = user.UserName, RecId = record.RecordId.ToString() }; var filebll = new FileInfoBLL(); filebll.SaveForm(null, fileinfo); } catch (Exception e) { success = false; message = e.Message; } } return(Json(new AjaxResult() { type = success ? ResultType.success : ResultType.error, message = message })); }
public ActionResult Order_AddEdits(string str) { retValue ret = new retValue(); PMS.Models.UserModel userModel = Session["UserModel"] as PMS.Models.UserModel; int userid = userModel._ID; BLL.OrderInfoBLL _BLL = new OrderInfoBLL(); JObject o = null; if (!string.IsNullOrEmpty(str)) { o = JObject.Parse(str); string ID = o["ID"]._ToStrTrim(); string NGUID = o["NGUID"]._ToStrTrim(); string CostID = o["CostID"]._ToStrTrim(); string Month = o["Month"]._ToStrTrim(); string OrderNum = o["OrderNumber"]._ToStrTrim(); string PersonID = o["OrderPeople"]._ToStrTrim(); string Poster = o["Poster"]._ToStrTrim(); string BKDH = o["NewspaperName"]._ToStrTrim(); string FullPrice = o["FullPrice"]._ToStrTrim(); string MoneyPayed = o["Pay"]._ToStrTrim(); string test1 = o["test1"]._ToStrTrim(); if (string.IsNullOrEmpty(ID)) { SqlHelp dbhelper = new SqlHelp(); SqlConnection conn = new SqlConnection(dbhelper.SqlConnectionString); conn.Open(); using (SqlTransaction tran = conn.BeginTransaction()) { try { ret = _BLL.Insert(tran, BKDH, PersonID._ToInt32(), OrderNum._ToInt32(), Month._ToInt32(), test1, userid._ToStr(), Poster._ToInt32(), FullPrice._ToDecimal()); tran.Commit(); } catch (Exception ex) { ret.result = false; ret.reason = ex.Message; tran.Rollback(); throw; } } } else { ret = _BLL.UpdateByPK(ID._ToInt32(), Month._ToInt32(), OrderNum._ToInt32(), BKDH, PersonID._ToInt32(), userid, Poster._ToInt32(), test1, NGUID); if (ret.result) { CostBLL costBLL = new CostBLL(); costBLL.UpdateByPK(CostID._ToInt32(), FullPrice._ToDecimal(), MoneyPayed._ToDecimal(), userid); } } } var js = JsonConvert.SerializeObject(ret); return(Json(js, JsonRequestBehavior.AllowGet)); }