/// <summary> /// 资产信息 /// </summary> /// <param name="id">GUID</param> /// <returns></returns> public ActionResult IndexEdit(string id) { string C_GUID = Session["CurrentCompanyGuid"].ToString(); StringBuilder strJson = new StringBuilder(); T_AIDRecord record = new T_AIDRecord(); record = new AIDSvc().GetAIDRecord(id, C_GUID); strJson.Append(new JavaScriptSerializer().Serialize(record)); return(View()); }
/// <summary> /// 记录营业外收入的资产信息 /// </summary> /// <param">hdy.16.11.7</param> /// <returns></returns> public string GetAIDRecordBusinessPartner(string id) { string C_GUID = Session["CurrentCompanyGuid"].ToString(); StringBuilder strJson = new StringBuilder(); T_AIDRecord record = new T_AIDRecord(); record = new AIDSvc().GetAIDRecordBusinessPartner(id, C_GUID); strJson.Append(new JavaScriptSerializer().Serialize(record)); return(strJson.ToString()); }
/// <summary> /// 更新间接物品采购纪录 /// </summary> /// <param name="head">收入主数据</param> /// <param name="list">收入明细数据</param> /// <returns></returns> public string UpdDirectMaterialPurchasingRecord(T_AIDRecord form) { bool result = false; string msg = string.Empty; form.C_GUID = Session["CurrentCompany"].ToString(); result = new AIDSvc().UpdDirectMaterialPurchasingRecord(form); if (result) { msg = General.Resource.Common.Success; } else { msg = General.Resource.Common.Failed; } return(string.Format("{{\"Result\":{0},\"Msg\":\"{1}\"}}" , result.ToString().ToLower(), msg)); }
/// <summary> /// 更新费用纪录(转售) /// </summary> /// <param name="head">费用主数据</param> /// <param name="list">费用明细数据</param> /// <returns></returns> public string UpdResaleExpenseRecord(T_AIDRecord form) { bool result = false; string msg = string.Empty; form.C_GUID = Session["CurrentCompanyGuid"].ToString(); //当前用户 form.Creator = base.userData.LoginFullName; result = new AIDSvc().UpdResaleIndirectMaterialPurchasingRecord(form); if (result) { msg = General.Resource.Common.Success; } else { msg = General.Resource.Common.Failed; } return(string.Format("{{\"Result\":{0},\"Msg\":\"{1}\"}}" , result.ToString().ToLower(), msg)); }
public string UpdAssetPurchaseRecord(string id, string rper, decimal amount, string invtype, string remark, string currency, string addstyle, DateTime date, int depreciationperiod, string description, decimal surplusvalue, string state) { bool result = false; string msg = string.Empty; T_AIDRecord Record = new T_AIDRecord(); Record.C_GUID = Session["CurrentCompany"].ToString(); Record.GUID = id; Record.RPer = rper; Record.Date = date; Record.Amount = amount; Record.InvType = invtype; Record.Remark = remark; Record.Currency = currency; Record.Description = description; Record.DepreciationPeriod = depreciationperiod; Record.SurplusValue = surplusvalue; Record.State = state; DateTime EditThreshold = DateTime.Parse(Session["EditThreshold"].ToString()); if (Record.Date <= DateTime.Now && Record.Date >= EditThreshold) { result = new AIDSvc().UpdAssetPurchaseRecord(Record); if (result) { msg = General.Resource.Common.Success; } else { msg = General.Resource.Common.Failed; } } else { result = false; msg = FMS.Resource.Finance.Finance.DateError; } return(string.Format("{{\"Result\":{0},\"Msg\":\"{1}\"}}" , result.ToString().ToLower(), msg)); }
/// <summary> /// 更新采购记录 /// </summary> /// <param name="rec"></param> /// <returns></returns> private bool UpdAIDRecord(T_AIDRecord rec) { DBHelper dh = new DBHelper(); dh.BeginTran(); try { dh.strCmd = "SP_UpdAIDRecord"; dh.AddPare("@GUID", SqlDbType.NVarChar, 40, rec.GUID); dh.AddPare("@AID_Flag", SqlDbType.NVarChar, 1, rec.AID_Flag); dh.AddPare("@InvType", SqlDbType.NVarChar, 40, rec.InvType); dh.AddPare("@Description", SqlDbType.NVarChar, 40, rec.Description); dh.AddPare("@DepreciationPeriod", SqlDbType.Int, 40, rec.DepreciationPeriod); dh.AddPare("@RPer", SqlDbType.NVarChar, 40, rec.RPer); dh.AddPare("@C_GUID", SqlDbType.NVarChar, 40, rec.C_GUID); if (!rec.Date.Equals(DateTime.MinValue)) { dh.AddPare("@Date", SqlDbType.DateTime, 0, rec.Date); } dh.AddPare("@Amount", SqlDbType.Decimal, 0, rec.Amount); dh.AddPare("@SurplusValue", SqlDbType.Decimal, 0, rec.SurplusValue); dh.AddPare("@Remark", SqlDbType.NVarChar, 200, rec.Remark); dh.AddPare("@Currency", SqlDbType.NVarChar, 20, rec.Currency); dh.AddPare("@State", SqlDbType.NVarChar, 20, rec.State); dh.NonQuery(); dh.CleanPara(); if (rec.AID_Flag == "A") { dh.strCmd = "SP_UpdPaymentDeclareCostSpending"; dh.AddPare("@GUID", SqlDbType.NVarChar, 40, rec.GUID); dh.AddPare("@InvType", SqlDbType.NVarChar, 40, "资产采购"); dh.AddPare("@RPer", SqlDbType.NVarChar, 40, rec.RPer); if (!rec.Date.Equals(DateTime.MinValue)) { dh.AddPare("@Date", SqlDbType.DateTime, 0, rec.Date); } dh.AddPare("@Amount", SqlDbType.Decimal, 0, rec.Amount); dh.AddPare("@Remark", SqlDbType.NVarChar, 200, rec.Remark); dh.AddPare("@Currency", SqlDbType.NVarChar, 20, rec.Currency); dh.AddPare("@State", SqlDbType.NVarChar, 40, "未付"); dh.AddPare("@C_GUID", SqlDbType.NVarChar, 40, rec.C_GUID); dh.NonQuery(); } else if (rec.AID_Flag == "D") { dh.strCmd = "SP_UpdPaymentDeclareCostSpending"; dh.AddPare("@GUID", SqlDbType.NVarChar, 40, rec.GUID); dh.AddPare("@InvType", SqlDbType.NVarChar, 40, "直接物料采购"); dh.AddPare("@RPer", SqlDbType.NVarChar, 40, rec.RPer); if (!rec.Date.Equals(DateTime.MinValue)) { dh.AddPare("@Date", SqlDbType.DateTime, 0, rec.Date); } dh.AddPare("@Amount", SqlDbType.Decimal, 0, rec.Amount); dh.AddPare("@Remark", SqlDbType.NVarChar, 200, rec.Remark); dh.AddPare("@Currency", SqlDbType.NVarChar, 20, rec.Currency); dh.AddPare("@State", SqlDbType.NVarChar, 40, "未付"); dh.AddPare("@C_GUID", SqlDbType.NVarChar, 40, rec.C_GUID); dh.NonQuery(); } else if (rec.AID_Flag == "I") { dh.strCmd = "SP_UpdPaymentDeclareCostSpending"; dh.AddPare("@GUID", SqlDbType.NVarChar, 40, rec.GUID); dh.AddPare("@InvType", SqlDbType.NVarChar, 40, "间接物料采购"); dh.AddPare("@RPer", SqlDbType.NVarChar, 40, rec.RPer); if (!rec.Date.Equals(DateTime.MinValue)) { dh.AddPare("@Date", SqlDbType.DateTime, 0, rec.Date); } dh.AddPare("@Amount", SqlDbType.Decimal, 0, rec.Amount); dh.AddPare("@Remark", SqlDbType.NVarChar, 200, rec.Remark); dh.AddPare("@Currency", SqlDbType.NVarChar, 20, rec.Currency); dh.AddPare("@State", SqlDbType.NVarChar, 40, "未付"); dh.AddPare("@C_GUID", SqlDbType.NVarChar, 40, rec.C_GUID); dh.NonQuery(); } dh.CommitTran(); return(true); } catch { dh.RollBackTran(); return(false); } }
public bool UpdTemporyRecord(T_AIDRecord form) { form.AID_Flag = "T"; return(UpdAIDRecord(form)); }
/// <summary> /// 更新间接物料采购记录 /// </summary> /// <param name="form"></param> /// <returns></returns> public bool UpdIndirectMaterialPurchasingRecord(T_AIDRecord form) { form.AID_Flag = "I"; return(UpdAIDRecord(form)); }
/// <summary> /// 更新资产采购记录 /// </summary> /// <param name="form"></param> /// <returns></returns> public bool UpdAssetPurchaseRecord(T_AIDRecord form) { form.AID_Flag = "A"; return(UpdAIDRecord(form)); }
/// <summary> /// 批量导入excel数据 /// </summary> public ActionResult Upexcel(FormCollection from) { HttpPostedFileBase file = Request.Files["upload"]; string result = string.Empty; if (file == null || file.ContentLength <= 0) { } else { try { Workbook workbook = new Workbook(file.InputStream); Cells cells = workbook.Worksheets[0].Cells; DataTable tab = cells.ExportDataTable(0, 0, cells.Rows.Count, cells.MaxDisplayRange.ColumnCount); int rowsnum = tab.Rows.Count; if (rowsnum == 0) { result = "Excel表为空!请重新导入!"; //当Excel表为空时,对用户进行提示 } //数据表一共多少行! DataRow[] dr = tab.Select(); //按行进行数据存储操作! for (int i = 1; i < dr.Length; i++) { //RPer,B_Guid,BA_Guid数据需要比对! string rper = (new BusinessPartnerSvc().GetPartnersDts(Session["CurrentCompanyGuid"].ToString(), dr[i][3].ToString())).ToString(); T_AIDRecord record = new T_AIDRecord(); record.C_GUID = Session["CurrentCompanyGuid"].ToString(); record.GUID = Guid.NewGuid().ToString(); record.Date = dr[i][0].ToString(); record.Amount = Convert.ToDecimal(dr[i][1].ToString()); record.Currency = dr[i][2].ToString(); record.RPer = rper; record.InvType = dr[i][4].ToString(); record.Description = dr[i][5].ToString(); record.DepreciationPeriod = Convert.ToInt32(dr[i][6].ToString()); record.Remark = dr[i][7].ToString(); record.SurplusValue = Convert.ToDecimal(dr[i][1].ToString()); record.State = "折旧中"; bool TorF = new AIDSvc().UpdAssetPurchaseRecord(record); if (TorF) { result = "导入成功!"; } else { result = "导入失败!"; } } } catch (Exception) { result = "导入失败,请检查EXCEL格式是否错误!"; } } JsonResult json = new JsonResult(); json.Data = result; return(json); }
public ActionResult ImportExcel() { ExceResult res = new ExceResult(); res.success = true; var file = Request.Files; string result = string.Empty; if (file == null || file.Count <= 0) { res.success = false; res.msg = "无有效文件"; } else { try { Workbook workbook = new Workbook(file[0].InputStream); Cells cells = workbook.Worksheets[0].Cells; DataTable tab = cells.ExportDataTable(0, 0, cells.Rows.Count, cells.MaxDisplayRange.ColumnCount); int rowsnum = tab.Rows.Count; if (rowsnum == 0) { res.success = false; result = "Excel表为空!请重新导入!"; //当Excel表为空时,对用户进行提示 } //数据表一共多少行! DataRow[] dr = tab.Select(); //按行进行数据存储操作! for (int i = 1; i < dr.Length; i++) { T_AIDRecord record = new T_AIDRecord(); record.C_GUID = Session["CurrentCompanyGuid"].ToString(); record.GUID = Guid.NewGuid().ToString(); record.Date = dr[i][0].ToString(); record.Amount = Convert.ToDecimal(dr[i][1].ToString()); if (record.Date.CompareTo(GetNowDate()) > 0) { result = "导入失败,购入日期错误"; break; } try { string currency = (new CurrencySvc().GetCurrency(dr[i][2].ToString())).ToString(); record.Currency = currency; } catch (Exception) { result = "导入失败,无此货币"; break; } try { string rper = (new BusinessPartnerSvc().GetPartnersDts(Session["CurrentCompanyGuid"].ToString(), dr[i][3].ToString())).ToString(); record.RPer = rper; } catch (Exception) { result = "导入失败,无此供应商"; break; } record.AssetType = dr[i][4].ToString(); if (record.AssetType != "固定资产" && record.AssetType != "无形资产") { result = "导入失败,无此资产分类"; break; } try { string InvType = (new AIDSvc().GetAssetTypeCatId(Session["CurrentCompanyGuid"].ToString(), dr[i][4].ToString(), dr[i][5].ToString())).ToString(); record.InvType = InvType; } catch (Exception) { result = "导入失败,无此资产类别"; break; } try { string SonInvType = (new AIDSvc().GetSubTypeCatId(Session["CurrentCompanyGuid"].ToString(), dr[i][6].ToString(), dr[i][5].ToString())).ToString(); record.SonInvType = SonInvType; } catch (Exception) { result = "导入失败,无此资产子类别"; break; } //record.DepreciationPeriod = int.Parse(dr[i][6].ToString()); //record.Remark = ""; record.State = "折旧中"; bool TorF = new AIDSvc().UpdAssetPurchaseRecord(record); if (TorF) { result = "导入成功!"; } else { result = "导入失败!"; } } } catch (Exception) { result = "导入失败,请检查EXCEL格式是否错误!"; } } JsonResult json = new JsonResult(); json.Data = result; return(json); }
/// <summary> /// 转售直接物料采购记录 /// </summary> /// <param name="form"></param> /// <returns></returns> public bool UpdResaleDirectMaterialPurchasingRecord(T_AIDRecord form) { form.AID_Flag = "D"; return(UpdResaleAIDRecord(form)); }
/// <summary> /// 转售采购记录 /// </summary> /// <param name="rec"></param> /// <returns></returns> private bool UpdResaleAIDRecord(T_AIDRecord rec) { DBHelper dh = new DBHelper(); dh.BeginTran(); try { dh.strCmd = "SP_UpdResaleAIDRecord"; dh.AddPare("@GUID", SqlDbType.NVarChar, 40, rec.GUID); dh.AddPare("@C_GUID", SqlDbType.NVarChar, 40, rec.C_GUID); //转售的实际金额(收入金额) dh.AddPare("@ResaleActualAmount", SqlDbType.Decimal, 0, rec.ResaleActualAmount); //这里的AID——Flag是指IE_Record表中的IE_Flag dh.AddPare("@AID_Flag", SqlDbType.NVarChar, 1, "I"); dh.AddPare("@InvType", SqlDbType.NVarChar, 40, rec.InvType); dh.AddPare("@RPer", SqlDbType.NVarChar, 40, rec.RPer); //当库存金额等于使用金额的时候状态修改为已使用 dh.AddPare("@Amount", SqlDbType.Decimal, 0, rec.Amount); //使用金额 dh.AddPare("@InventoryAmount", SqlDbType.Decimal, 0, rec.InventoryAmount); //库存金额 dh.AddPare("@Business_GUID", SqlDbType.NVarChar, 40, rec.Business_GUID); dh.AddPare("@SubBusiness_GUID", SqlDbType.NVarChar, 40, rec.SubBusiness_GUID); if (rec.Amount >= rec.InventoryAmount) { dh.AddPare("@State", SqlDbType.NVarChar, 40, "已转售"); } else { dh.AddPare("@State", SqlDbType.NVarChar, 40, "库存"); } string GUIDTW = Guid.NewGuid().ToString(); dh.AddPare("@GUIDTW", SqlDbType.NVarChar, 40, GUIDTW); dh.AddPare("@ResaleNumber", SqlDbType.NVarChar, 40, rec.ResaleNumber); //dh.AddPare("@IE_GUID", SqlDbType.NVarChar, 40, rec.IE_GUID); dh.AddPare("@Inventory_Number", SqlDbType.NVarChar, 40, rec.Inventory_Number); dh.AddPare("@Creator", SqlDbType.NVarChar, 40, rec.Creator); dh.AddPare("@AffirmDate", SqlDbType.DateTime, 0, rec.AffirmDate); //收入确认日期 dh.AddPare("@Date", SqlDbType.DateTime, 0, rec.Date); //收入截止日期 dh.AddPare("@Pnumber", SqlDbType.NVarChar, 40, rec.Pnumber); dh.AddPare("@Currency", SqlDbType.NVarChar, 40, rec.Currency); dh.AddPare("@OriginalAmount", SqlDbType.Decimal, 0, rec.OriginalAmount); dh.AddPare("@TaxationType", SqlDbType.NVarChar, 40, rec.TaxationType); dh.AddPare("@TaxationAmount", SqlDbType.Decimal, 0, rec.TaxationAmount); dh.AddPare("@SumAmount", SqlDbType.Decimal, 0, rec.ResaleActualAmount + rec.TaxationAmount); dh.AddPare("@Remark", SqlDbType.NVarChar, 200, rec.Remark); dh.AddPare("@Description", SqlDbType.NVarChar, 100, rec.Description); dh.AddPare("@States", SqlDbType.NVarChar, 40, rec.StateIE); dh.AddPare("@CostType", SqlDbType.VarChar, 1, rec.CostType); dh.AddPare("@Detailed_Categories", SqlDbType.NVarChar, 40, rec.Detailed_Categories); dh.NonQuery(); dh.CleanPara(); dh.CommitTran(); return(true); } catch { dh.RollBackTran(); return(false); } }
/// <summary> /// 更新采购记录 /// </summary> /// <param name="rec"></param> /// <returns></returns> private bool UpdAIDRecord(T_AIDRecord rec) { DBHelper dh = new DBHelper(); dh.BeginTran(); try { dh.strCmd = "SP_UpdAIDRecord"; dh.AddPare("@GUID", SqlDbType.NVarChar, 40, rec.GUID); dh.AddPare("@Description", SqlDbType.NVarChar, 100, rec.Description); //dh.AddPare("@DepreciationPeriod", SqlDbType.Int, 40, rec.DepreciationPeriod); dh.AddPare("@RPer", SqlDbType.NVarChar, 40, rec.RPer); //添加资产分类和物料类别的子类别 dh.AddPare("@InvType", SqlDbType.VarChar, 50, rec.InvType); //类别 dh.AddPare("@SonInvType", SqlDbType.VarChar, 50, rec.SonInvType); //子类别 dh.AddPare("@MaterielManage", SqlDbType.VarChar, 50, rec.MaterielManage); //子类别 dh.AddPare("@C_GUID", SqlDbType.NVarChar, 40, rec.C_GUID); if (!rec.Date.Equals(DateTime.MinValue)) { dh.AddPare("@Date", SqlDbType.DateTime, 0, rec.Date); } dh.AddPare("@Amount", SqlDbType.Decimal, 0, rec.Amount); dh.AddPare("@MaterialNumber", SqlDbType.NVarChar, 40, rec.MaterialNumber); dh.AddPare("@SurplusValue", SqlDbType.Decimal, 0, rec.SurplusValue); dh.AddPare("@Remark", SqlDbType.NVarChar, 200, rec.Remark); dh.AddPare("@Currency", SqlDbType.NVarChar, 40, rec.Currency); dh.AddPare("@State", SqlDbType.NVarChar, 40, rec.State); dh.AddPare("@CostType", SqlDbType.VarChar, 1, rec.CostType); dh.AddPare("@Business_GUID", SqlDbType.NVarChar, 40, rec.Business_GUID); dh.AddPare("@SubBusiness_GUID", SqlDbType.NVarChar, 40, rec.SubBusiness_GUID); dh.NonQuery(); dh.CleanPara(); if (rec.AID_Flag == "A") { dh.strCmd = "SP_UpdPaymentDeclareCostSpending"; dh.AddPare("@GUID", SqlDbType.NVarChar, 40, rec.GUID); dh.AddPare("@InvType", SqlDbType.NVarChar, 40, "资产采购"); dh.AddPare("@RPer", SqlDbType.NVarChar, 40, rec.RPer); if (!rec.Date.Equals(DateTime.MinValue)) { dh.AddPare("@Date", SqlDbType.DateTime, 0, rec.Date); } dh.AddPare("@Amount", SqlDbType.Decimal, 0, rec.Amount); dh.AddPare("@Remark", SqlDbType.NVarChar, 200, rec.Remark); dh.AddPare("@Currency", SqlDbType.NVarChar, 20, rec.Currency); dh.AddPare("@State", SqlDbType.NVarChar, 40, "未付"); dh.AddPare("@Record", SqlDbType.NVarChar, 40, "未记录"); dh.AddPare("@C_GUID", SqlDbType.NVarChar, 40, rec.C_GUID); dh.AddPare("@Profit_GUID", SqlDbType.NVarChar, 40, "B1F44906-51D6-47F4-B6EC-7B678B5E7CD5"); dh.AddPare("@Business_GUID", SqlDbType.NVarChar, 40, rec.Business_GUID); dh.AddPare("@SubBusiness_GUID", SqlDbType.NVarChar, 40, rec.SubBusiness_GUID); dh.NonQuery(); } else if (rec.AID_Flag == "D") { dh.strCmd = "SP_UpdPaymentDeclareCostSpending"; dh.AddPare("@GUID", SqlDbType.NVarChar, 40, rec.GUID); dh.AddPare("@InvType", SqlDbType.NVarChar, 40, "物料采购"); dh.AddPare("@RPer", SqlDbType.NVarChar, 40, rec.RPer); if (!rec.Date.Equals(DateTime.MinValue)) { dh.AddPare("@Date", SqlDbType.DateTime, 0, rec.Date); } dh.AddPare("@Amount", SqlDbType.Decimal, 0, rec.Amount); dh.AddPare("@Remark", SqlDbType.NVarChar, 200, rec.Remark); dh.AddPare("@Currency", SqlDbType.NVarChar, 20, rec.Currency); dh.AddPare("@State", SqlDbType.NVarChar, 40, "未付"); dh.AddPare("@Record", SqlDbType.NVarChar, 40, "未记录"); dh.AddPare("@C_GUID", SqlDbType.NVarChar, 40, rec.C_GUID); dh.AddPare("@voucherNo", SqlDbType.NVarChar, 40, rec.Remark); dh.AddPare("@Profit_GUID", SqlDbType.NVarChar, 40, "41C968F2-7D51-4F9F-83B6-EC0F4381ECD0"); dh.AddPare("@Business_GUID", SqlDbType.NVarChar, 40, rec.Business_GUID); dh.AddPare("@SubBusiness_GUID", SqlDbType.NVarChar, 40, rec.SubBusiness_GUID); dh.NonQuery(); } else if (rec.AID_Flag == "I") { dh.strCmd = "SP_UpdPaymentDeclareCostSpending"; dh.AddPare("@GUID", SqlDbType.NVarChar, 40, rec.GUID); dh.AddPare("@InvType", SqlDbType.NVarChar, 40, "物料采购"); dh.AddPare("@RPer", SqlDbType.NVarChar, 40, rec.RPer); if (!rec.Date.Equals(DateTime.MinValue)) { dh.AddPare("@Date", SqlDbType.DateTime, 0, rec.Date); } dh.AddPare("@Amount", SqlDbType.Decimal, 0, rec.Amount); dh.AddPare("@Remark", SqlDbType.NVarChar, 200, rec.Remark); dh.AddPare("@Currency", SqlDbType.NVarChar, 20, rec.Currency); dh.AddPare("@State", SqlDbType.NVarChar, 40, "未付"); dh.AddPare("@Record", SqlDbType.NVarChar, 40, "未记录"); dh.AddPare("@C_GUID", SqlDbType.NVarChar, 40, rec.C_GUID); dh.AddPare("@Profit_GUID", SqlDbType.NVarChar, 40, "41C968F2-7D51-4F9F-83B6-EC0F4381ECD0"); dh.AddPare("@Business_GUID", SqlDbType.NVarChar, 40, rec.Business_GUID); dh.AddPare("@SubBusiness_GUID", SqlDbType.NVarChar, 40, rec.SubBusiness_GUID); dh.NonQuery(); } dh.CommitTran(); return(true); } catch { dh.RollBackTran(); return(false); } }