/// <summary>
        /// 更新费用数据
        /// </summary>
        /// <param name="head">费用主数据</param>
        /// <param name="list">费用明细数据</param>
        /// <returns></returns>
        public string UpdTaxProvisionRecord(T_IERecord form)
        {
            bool   result = false;
            string msg    = string.Empty;

            form.C_GUID     = Session["CurrentCompanyGuid"].ToString();
            form.Creator    = base.userData.LoginFullName;
            form.CreateDate = GetNowDate();
            if (form.IEGroup == "ac23eded-9c74-4781-8d14-797a5bccdc79" || form.IEGroup == "234218e9-87c5-4854-814a-7d5671bf1fd9" || form.IEGroup == "8e777b91-f3f9-4907-ba1a-2e0842967500")
            {
                form.Profit_GUID = "51BFDD3E-2253-4FBF-A946-19C18C25C6FC";
            }
            if (form.IEGroup == "d136bf9c-c3a3-4f33-ab1e-820526dcbc24")
            {
                form.Profit_GUID = "082CD9EB-9947-43C4-A7C6-F2B7FAB6EE54";
            }
            result = new IESvc().UpdExpenseRecord(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 UpdWageCostsRecord(string id, string rper, decimal money, decimal money1, decimal money2, decimal money3, string invtype, string remark, string currency, string addstyle, DateTime date)
        {
            bool       result = false;
            string     msg    = string.Empty;
            T_IERecord Record = new T_IERecord();

            Record.Creator        = base.userData.LoginFullName;
            Record.C_GUID         = Session["CurrentCompany"].ToString();
            Record.IE_GUID        = id;
            Record.RPer           = rper;
            Record.AffirmDate     = date;
            Record.Date           = date;
            Record.SumAmount      = money;
            Record.InvType        = invtype;
            Record.IEGroup        = "1544d862-b1ab-42b8-9e97-9c2e1704665c";//工资类别guid
            Record.Remark         = remark;
            Record.Currency       = currency;
            Record.CreateDate     = DateTime.Now;
            Record.TaxationAmount = 0;
            Record.TaxationType   = "";
            Record.State          = "应付";
            Record.Profit_GUID    = "51BFDD3E-2253-4FBF-A946-19C18C25C6FC";

            T_WageCost WageCostRecord = new T_WageCost();

            WageCostRecord.W_GUID         = id;
            WageCostRecord.C_GUID         = Session["CurrentCompany"].ToString();
            WageCostRecord.Date           = date;
            WageCostRecord.Employee       = remark;
            WageCostRecord.Cash           = money1;
            WageCostRecord.PersonalTaxes  = money2;
            WageCostRecord.SocialSecurity = money3;
            WageCostRecord.Total          = money1 + money2 + money3;
            new IESvc().UpdWageCost(WageCostRecord);

            DateTime EditThreshold = DateTime.Parse(Session["EditThreshold"].ToString());

            if (Record.Date <= DateTime.Now && Record.Date >= EditThreshold)
            {
                result = new IESvc().UpdExpenseRecord(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));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新收入纪录
        /// </summary>
        /// <param name="head">收入主数据</param>
        /// <param name="list">收入明细数据</param>
        /// <returns></returns>
        public string UpdIncomeRecord(T_IERecord form)
        {
            bool   result = false;
            string msg    = string.Empty;

            form.C_GUID  = Session["CurrentCompanyGuid"].ToString();
            form.Creator = base.userData.LoginFullName;

            if (form.InvType == "主营业务收入")
            {
                form.Profit_Name = "主营业务收入";
            }
            if (form.InvType == "其他业务收入")
            {
                form.Profit_Name   = "其他业务收入";
                form.DetailInvtype = form.DetailInvtype1;
            }
            if (form.InvType == "营业外收入")
            {
                form.Profit_Name   = "营业外收入";
                form.DetailInvtype = form.DetailInvtype1;
            }
            if (form.InvType == "投资收益")
            {
                form.Profit_Name = "投资收益";
            }

            if (form.Pagename == "DirectMaterialPurchasingQuery/Index")
            {
                result = new IESvc().UpdIncomeRecord(form);
            }
            else
            {
                result = new IESvc().UpdIncomeRecord(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 UpdExpenseRecord(T_IERecord form)
        {
            bool   result = false;
            string msg    = string.Empty;

            form.C_GUID  = Session["CurrentCompanyGuid"].ToString();
            form.Creator = base.userData.LoginFullName;
            result       = new IESvc().UpdExpenseRecord(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));
        }
Exemplo n.º 5
0
        public bool UpdV(T_IERecord rec) {
            DBHelper dh = new DBHelper();
            dh.BeginTran();
            try
            {
                dh.strCmd = "SP_UpdReceivablesDeclareCustomer";
                dh.AddPare("@GUID", SqlDbType.NVarChar, 40, rec.IE_GUID);
                dh.AddPare("@VoucherNo", SqlDbType.NVarChar, 40, rec.InvNo);
                dh.AddPare("@Business_GUID", SqlDbType.NVarChar, 40, rec.Business_GUID);
                dh.AddPare("@SubBusiness_GUID", SqlDbType.NVarChar, 40, rec.SubBusiness_GUID);
                dh.AddPare("@InvType", SqlDbType.NVarChar, 40, rec.InvType);
                dh.AddPare("@RPer", SqlDbType.NVarChar, 40, rec.RPer);
                dh.AddPare("@Date", SqlDbType.DateTime, 0, rec.Date);
                dh.AddPare("@Amount", SqlDbType.Decimal, 0, rec.SumAmount);
                dh.AddPare("@Remark", SqlDbType.NVarChar, 200, rec.Remark);
                dh.AddPare("@Currency", SqlDbType.NVarChar, 20, rec.Currency);
                dh.AddPare("@Profit_Name", SqlDbType.NVarChar, 40, rec.Profit_Name);
                dh.AddPare("@State", SqlDbType.NVarChar, 40, rec.State);
                if (rec.InvType == "短期借款" || rec.InvType == "长期借款")
                {
                    dh.AddPare("@Record", SqlDbType.NVarChar, 40, "未还款");
                }
                else
                {
                    dh.AddPare("@Record", SqlDbType.NVarChar, 40, "未记录");
                }

                dh.AddPare("@C_GUID", SqlDbType.NVarChar, 40, rec.C_GUID);
                dh.AddPare("@Summary", SqlDbType.NVarChar, 40, rec.Summary);
                dh.NonQuery();
                dh.CleanPara();
                dh.CommitTran();
                return true;
            }
            catch
            {
                dh.RollBackTran();
                return false;
            }
        
        }
Exemplo n.º 6
0
        /// <summary>
        /// 更新费用数据
        /// </summary>
        /// <param name="head">费用主数据</param>
        /// <param name="list">费用明细数据</param>
        /// <returns></returns>
        public string UpdExpenseRecord(T_IERecord form)
        {
            bool       result = false;
            ExceResult res    = new ExceResult();
            string     msg    = string.Empty;

            form.C_GUID  = Session["CurrentCompanyGuid"].ToString();
            form.Creator = base.userData.LoginFullName;
            result       = new IESvc().UpdExpenseRecord(form);
            if (result)
            {
                res.success = true;
                msg         = General.Resource.Common.Success;
            }
            else
            {
                res.success = false;
                msg         = General.Resource.Common.Failed;
            }
            return(JsonConvert.SerializeObject(res));
        }
        public bool UpdV(T_IERecord rec)
        {
            DBHelper dh = new DBHelper();

            dh.BeginTran();
            try
            {
                dh.strCmd = "SP_UpdPaymentDeclareCostSpending";
                dh.AddPare("@GUID", SqlDbType.NVarChar, 40, rec.IE_GUID);
                dh.AddPare("@InvType", SqlDbType.NVarChar, 40, rec.InvType);
                dh.AddPare("@RPer", SqlDbType.NVarChar, 40, rec.RPer);
                //if (!rec.Date.Equals(DateTime.MinValue))
                //{
                //    dh.AddPare("@Date", SqlDbType.DateTime, 0, rec.Date);
                //}
                dh.AddPare("@Date", SqlDbType.DateTime, 0, rec.Date);
                dh.AddPare("@Business_GUID", SqlDbType.NVarChar, 40, rec.Business_GUID);
                dh.AddPare("@SubBusiness_GUID", SqlDbType.NVarChar, 40, rec.SubBusiness_GUID);
                dh.AddPare("@Amount", SqlDbType.Decimal, 0, rec.SumAmount);
                dh.AddPare("@Remark", SqlDbType.NVarChar, 200, rec.Remark);
                dh.AddPare("@Currency", SqlDbType.NVarChar, 20, rec.Currency);
                dh.AddPare("@State", SqlDbType.NVarChar, 40, rec.State);
                dh.AddPare("@Record", SqlDbType.NVarChar, 40, rec.Record);
                dh.AddPare("@C_GUID", SqlDbType.NVarChar, 40, rec.C_GUID);
                dh.AddPare("@voucherNo", SqlDbType.NVarChar, 40, rec.InvNo);
                dh.AddPare("@Profit_Name", SqlDbType.NVarChar, 40, rec.Profit_Name);
                dh.AddPare("@Summary", SqlDbType.NVarChar, 40, rec.Summary);
                dh.NonQuery();
                dh.CleanPara();
                dh.CommitTran();
                return(true);
            }
            catch
            {
                dh.RollBackTran();
                return(false);
            }
        }
        /// <summary>
        /// 批量导入excel数据
        /// </summary>
        /// 20180514修改对应新的职工薪酬模板
        public ActionResult Upexcel(FormCollection from)
        {
            ExceResult res = new ExceResult();

            res.success = true;
            HttpPostedFileBase file       = Request.Files["upload"];
            string             result     = string.Empty;
            string             strVouchID = Guid.NewGuid().ToString();

            if (file == null || file.ContentLength <= 0)
            {
                res.success = false;
                res.msg     = "无有效文件";
            }
            else
            {
                try
                {
                    List <T_DetailedAccount> rec = new AccountSvc().GetLAccountByName("职工薪酬", Session["CurrentCompanyGuid"].ToString());
                    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)
                    {
                        res.success = false;
                        result      = "Excel表为空!请重新导入!"; //当Excel表为空时,对用户进行提示
                    }
                    //数据表一共多少行!
                    DataRow[] dr = tab.Select();
                    T_GeneralLedgerAccount gen = new AccountSvc().GetLAByName("银行存款", Session["CurrentCompanyGuid"].ToString());
                    string RpTypeID            = string.Empty;
                    if (gen != null)
                    {
                        RpTypeID = gen.LA_GUID;
                    }
                    //按行进行数据存储操作!
                    for (int i = 3; i < dr.Length; i++)
                    {
                        T_WageCost WageCostRecord = new T_WageCost();
                        WageCostRecord.W_GUID           = Guid.NewGuid().ToString();
                        WageCostRecord.C_GUID           = Session["CurrentCompanyGuid"].ToString();
                        WageCostRecord.State            = "未付";
                        WageCostRecord.PayType          = RpTypeID;
                        WageCostRecord.Date             = Convert.ToDateTime(dr[i][1].ToString());
                        WageCostRecord.Profit_Name      = dr[i][2].ToString();
                        WageCostRecord.Employee         = dr[i][0].ToString();
                        WageCostRecord.Cash             = Convert.ToDecimal(GetValue(dr[i][4].ToString())) + Convert.ToDecimal(GetValue(dr[i][5].ToString())) - Convert.ToDecimal(GetValue(dr[i][6].ToString()));
                        WageCostRecord.Total            = Convert.ToDecimal(GetValue(dr[i][23].ToString()));
                        WageCostRecord.PersonalTaxes    = Convert.ToDecimal(GetValue(dr[i][12].ToString()));
                        WageCostRecord.BonusAllowance   = Convert.ToDecimal(GetValue(dr[i][7].ToString())) + Convert.ToDecimal(GetValue(dr[i][8].ToString())) + Convert.ToDecimal(GetValue(dr[i][9].ToString()));
                        WageCostRecord.EmployeeWelfare  = Convert.ToDecimal(GetValue(dr[i][10].ToString()));
                        WageCostRecord.SocialSecurity   = Convert.ToDecimal(GetValue(dr[i][16].ToString()));
                        WageCostRecord.HousingProvident = Convert.ToDecimal(GetValue(dr[i][19].ToString()));
                        WageCostRecord.NonCurrency      = Convert.ToDecimal(GetValue(dr[i][22].ToString()));
                        WageCostRecord.StaffEducation   = Convert.ToDecimal(GetValue(dr[i][21].ToString()));
                        WageCostRecord.TradeUnion       = Convert.ToDecimal(GetValue(dr[i][20].ToString()));
                        WageCostRecord.DismissWelfare   = Convert.ToDecimal(GetValue(dr[i][11].ToString()));

                        T_IERecord Record = new T_IERecord();
                        Record.Creator    = base.userData.LoginFullName;
                        Record.C_GUID     = Session["CurrentCompanyGuid"].ToString();
                        Record.IE_GUID    = WageCostRecord.W_GUID;
                        Record.RPer       = "e5e38321-4549-4c24-9f3a-3cd70ee1d591";
                        Record.AffirmDate = WageCostRecord.Date;
                        Record.Date       = WageCostRecord.Date;
                        Record.SumAmount  = WageCostRecord.Total;
                        Record.InvType    = WageCostRecord.Profit_Name;
                        if (WageCostRecord.Profit_Name == "营业成本")
                        {
                            WageCostRecord.Profit_Name = "主营业务成本";
                        }
                        var query = rec.Where(p => p.ParentName == WageCostRecord.Profit_Name);
                        if (query.Any())
                        {
                            Record.IEGroup = query.FirstOrDefault().DA_GUID;//工资类别guid
                        }
                        Record.Remark      = WageCostRecord.Employee;
                        Record.Currency    = dr[i][3].ToString();
                        Record.Amount      = WageCostRecord.Total - WageCostRecord.PersonalTaxes;
                        Record.CreateDate  = GetNowDate();
                        Record.Profit_Name = WageCostRecord.Profit_Name;

                        Record.TaxationAmount = 0;
                        Record.TaxationType   = "";
                        Record.IE_Flag        = "SA";
                        Record.State          = "应付";

                        if (WageCostRecord.Date.CompareTo(Convert.ToDateTime(GetNowDate())) > 0)
                        {
                            result = "导入失败,时间错误";
                            break;
                        }
                        if (WageCostRecord.Date == null)
                        {
                            result = "导入失败,excel表第二列第" + dr[i] + "行时间没有填写";
                            break;
                        }
                        if (WageCostRecord.Employee == null)
                        {
                            result = "导入失败,excel表第一列第" + dr[i] + "行姓名没有填写";
                            break;
                        }
                        try
                        {
                            string currency = (new CurrencySvc().GetCurrency(dr[i][3].ToString())).ToString();
                            WageCostRecord.Currency = currency;
                        }
                        catch (Exception)
                        {
                            result = "导入失败,无此货币";
                            break;
                        }

                        if (dr[i][2].ToString() != "营业成本" && dr[i][2].ToString() != "销售费用" && dr[i][2].ToString() != "管理费用")
                        {
                            result = "导入失败,类别错误";
                            break;
                        }


                        bool TorF = new IESvc().UpdWageCost(WageCostRecord, strVouchID);

                        if (TorF)
                        {
                            DateTime EditThreshold = DateTime.Parse(Session["EditThreshold"].ToString());
                            if (Record.Date <= DateTime.Now && Record.Date >= EditThreshold)
                            {
                                bool ExpR = new IESvc().UpdExpenseInfo(Record, strVouchID);
                                if (ExpR)
                                {
                                    result = "导入成功!";
                                }
                                else
                                {
                                    result = General.Resource.Common.Failed;
                                }
                            }
                            else
                            {
                                result = FMS.Resource.Finance.Finance.DateError;
                            }
                        }
                        else
                        {
                            result = "导入失败!";
                        }
                    }
                }
                catch (Exception)
                {
                    result = "导入失败,请检查EXCEL格式是否错误!";
                }
            }
            JsonResult json = new JsonResult();

            json.Data = result;
            return(json);
        }
        public string UpdWageCostsRecord(List <T_WageCost> payList, string addstyle)
        {
            bool   result     = false;
            string msg        = string.Empty;
            string strVouchID = Guid.NewGuid().ToString();

            List <T_DetailedAccount> rec = new AccountSvc().GetLAccountByName("职工薪酬", Session["CurrentCompanyGuid"].ToString());

            foreach (T_WageCost wag in payList)
            {
                var query = rec.Where(p => p.ParentName == wag.Profit_Name);
                wag.C_GUID = Session["CurrentCompanyGuid"].ToString();
                T_IERecord Record = new T_IERecord();
                Record.Creator    = base.userData.LoginFullName;
                Record.C_GUID     = Session["CurrentCompanyGuid"].ToString();
                Record.IE_GUID    = wag.W_GUID;
                Record.RPer       = "e5e38321-4549-4c24-9f3a-3cd70ee1d591";
                Record.AffirmDate = wag.Date;
                Record.Date       = wag.Date;
                Record.SumAmount  = wag.Total;
                Record.InvType    = wag.InvType;
                if (query.Any())
                {
                    Record.IEGroup = query.FirstOrDefault().DA_GUID;
                }
                Record.Remark         = wag.Employee;
                Record.Currency       = wag.Currency;
                Record.Amount         = wag.Total - wag.PersonalTaxes;
                Record.CreateDate     = GetNowDate();
                Record.Profit_Name    = wag.Profit_Name;
                Record.TaxationAmount = 0;
                Record.TaxationType   = "";
                Record.IE_Flag        = "SA";
                //T_GeneralLedgerAccount rec = new AccountSvc().GetLAccount(Record.IEGroup, Session["CurrentCompanyGuid"].ToString(), Record.Profit_Name);
                //Record.IEGroup = rec.Where(p => p.ParentName == wag.Profit_Name).FirstOrDefault().DA_GUID;
                if (addstyle == "1")
                {
                    Record.State = "已付";
                }
                else
                {
                    Record.State = "应付";
                }
                result = new IESvc().UpdWageCost(wag, strVouchID);
                if (result)
                {
                    DateTime EditThreshold = DateTime.Parse(Session["EditThreshold"].ToString());
                    if (Record.Date <= DateTime.Now && Record.Date >= EditThreshold)
                    {
                        new IESvc().UpdExpenseInfo(Record, strVouchID);
                        if (result)
                        {
                            msg = General.Resource.Common.Success;
                        }
                        else
                        {
                            msg = General.Resource.Common.Failed;
                        }
                    }
                    else
                    {
                        result = false;
                        msg    = FMS.Resource.Finance.Finance.DateError;
                    }
                }
                else
                {
                    msg = General.Resource.Common.Failed;
                }
            }
            return(string.Format("{{\"Result\":{0},\"Msg\":\"{1}\"}}"
                                 , result.ToString().ToLower(), msg));
        }
Exemplo n.º 10
0
        /// <summary>
        /// 更新收入/费用纪录
        /// </summary>
        /// <param name="head">概要</param>
        /// <param name="list">明细</param>
        /// <returns></returns>
        private bool UpdIERecord(T_IERecord rec)
        {
            DBHelper dh = new DBHelper();

            dh.BeginTran();
            try {
                dh.strCmd = "SP_UpdIERecord";
                dh.AddPare("@IE_GUID", SqlDbType.NVarChar, 40, rec.IE_GUID);
                dh.AddPare("@IE_Flag", SqlDbType.NVarChar, 1, rec.IE_Flag);
                dh.AddPare("@InvType", SqlDbType.NVarChar, 40, rec.InvType);
                dh.AddPare("@IEGroup", SqlDbType.NVarChar, 40, rec.IEGroup);
                dh.AddPare("@IEDescription", SqlDbType.NVarChar, 40, rec.IEDescription);
                dh.AddPare("@InvNo", SqlDbType.NVarChar, 20, rec.InvNo);
                dh.AddPare("@RPer", SqlDbType.NVarChar, 40, rec.RPer);
                dh.AddPare("@Creator", SqlDbType.NVarChar, 40, rec.Creator);
                dh.AddPare("@CreateDate", SqlDbType.DateTime, 0, rec.CreateDate);
                dh.AddPare("@C_GUID", SqlDbType.NVarChar, 40, rec.C_GUID);
                if (!rec.AffirmDate.Equals(DateTime.MinValue))
                {
                    dh.AddPare("@AffirmDate", SqlDbType.DateTime, 0, rec.AffirmDate);
                }
                if (!rec.Date.Equals(DateTime.MinValue))
                {
                    dh.AddPare("@Date", SqlDbType.DateTime, 0, rec.Date);
                }
                dh.AddPare("@Amount", SqlDbType.Decimal, 0, rec.Amount);
                dh.AddPare("@TaxationAmount", SqlDbType.Decimal, 0, rec.TaxationAmount);
                dh.AddPare("@TaxationType", SqlDbType.NVarChar, 40, rec.TaxationType);
                dh.AddPare("@SumAmount", SqlDbType.Decimal, 0, rec.SumAmount == 0 ? (rec.TaxationAmount + rec.Amount) : rec.SumAmount);
                dh.AddPare("@Remark", SqlDbType.NVarChar, 200, rec.Remark);
                dh.AddPare("@Currency", SqlDbType.NVarChar, 20, rec.Currency);
                dh.AddPare("@B_GUID", SqlDbType.NVarChar, 40, rec.B_GUID);
                dh.AddPare("@BA_GUID", SqlDbType.NVarChar, 40, rec.BA_GUID);
                dh.AddPare("@Profit_GUID", SqlDbType.NVarChar, 40, rec.Profit_GUID);
                dh.AddPare("@State", SqlDbType.NVarChar, 40, rec.State);
                dh.NonQuery();
                dh.CleanPara();
                if (rec.IE_Flag == "I")
                {
                    dh.strCmd = "SP_UpdReceivables";
                    dh.AddPare("@R_GUID", SqlDbType.NVarChar, 40, rec.IE_GUID);
                    dh.AddPare("@C_GUID", SqlDbType.NVarChar, 40, rec.C_GUID);
                    dh.AddPare("@Payer", SqlDbType.NVarChar, 40, rec.RPer);
                    if (!rec.AffirmDate.Equals(DateTime.MinValue))
                    {
                        dh.AddPare("@Date", SqlDbType.DateTime, 0, rec.AffirmDate);
                    }
                    dh.AddPare("@InvType", SqlDbType.NVarChar, 40, rec.InvType);
                    dh.AddPare("@InvNo", SqlDbType.NVarChar, 40, rec.InvNo);
                    dh.AddPare("@B_GUID", SqlDbType.NVarChar, 40, rec.B_GUID);
                    dh.AddPare("@BA_GUID", SqlDbType.NVarChar, 40, rec.BA_GUID);
                    dh.AddPare("@Money", SqlDbType.Decimal, 0, rec.Amount + rec.TaxationAmount);
                    dh.AddPare("@Currency", SqlDbType.NVarChar, 5, rec.Currency);
                    dh.NonQuery();
                }
                else if (rec.IE_Flag == "E")
                {
                    dh.strCmd = "SP_UpdPayable";
                    dh.AddPare("@R_GUID", SqlDbType.NVarChar, 40, rec.IE_GUID);
                    dh.AddPare("@C_GUID", SqlDbType.NVarChar, 40, rec.C_GUID);
                    dh.AddPare("@Payee", SqlDbType.NVarChar, 40, rec.RPer);
                    if (!rec.AffirmDate.Equals(DateTime.MinValue))
                    {
                        dh.AddPare("@Date", SqlDbType.DateTime, 0, rec.AffirmDate);
                    }
                    dh.AddPare("@InvType", SqlDbType.NVarChar, 40, rec.InvType);
                    dh.AddPare("@InvNo", SqlDbType.NVarChar, 40, rec.InvNo);
                    dh.AddPare("@B_GUID", SqlDbType.NVarChar, 40, rec.B_GUID);
                    dh.AddPare("@BA_GUID", SqlDbType.NVarChar, 40, rec.BA_GUID);
                    dh.AddPare("@Money", SqlDbType.Decimal, 0, rec.Amount + rec.TaxationAmount);
                    dh.AddPare("@Currency", SqlDbType.NVarChar, 5, rec.Currency);
                    dh.NonQuery();
                }
                dh.CommitTran();
                return(true);
            }

            catch
            {
                dh.RollBackTran();
                return(false);
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// 更新费用纪录
 /// </summary>
 /// <param name="head">费用概要</param>
 /// <param name="list">费用明细</param>
 /// <returns></returns>
 public bool UpdExpenseRecord(T_IERecord form)
 {
     form.IE_Flag = "E";
     return(UpdIERecord(form));
 }
Exemplo n.º 12
0
 /// <summary>
 /// 更新收入纪录
 /// </summary>
 /// <param name="head">收入概要</param>
 /// <param name="list">收入明细</param>
 /// <returns></returns>
 public bool UpdIncomeRecord(T_IERecord form)
 {
     form.IE_Flag = "I";
     return(UpdIERecord(form));
 }
        ///   <summary>
        /// 产品核销
        /// </summary>

        /// <param name="productGuid">产品ID</param>
        /// <param name="saledCount">核销产品数量</param>
        /// <param name="ieGuidList">核销的收入ID</param>
        /// <param name="ieDetail">收入明细(新增收入时传入)</param>
        /// <returns></returns>
        public string ProductSales(string productGuid, string stockAmount, string saledCount, List <string> ieGuidList, string ieDetail)
        {
            ExceResult res    = new ExceResult();
            string     C_GUID = Session["CurrentCompanyGuid"].ToString();


            decimal count;

            if (!decimal.TryParse(saledCount, out count) || count <= 0)
            {
                res.success = false;
                res.msg     = "核销数量异常";
                return(JsonConvert.SerializeObject(res));
            }
            decimal stockcount;

            if (!decimal.TryParse(stockAmount, out stockcount) || stockcount <= 0)
            {
                res.success = false;
                res.msg     = "核销数量异常";
                return(JsonConvert.SerializeObject(res));
            }

            if (string.IsNullOrEmpty(productGuid))
            {
                res.success = false;
                res.msg     = "核销产品异常";
                return(JsonConvert.SerializeObject(res));
            }

            if ((ieGuidList == null || ieGuidList.Count == 0) && string.IsNullOrEmpty(ieDetail))
            {
                res.success = false;
                res.msg     = "收入数据异常";
                return(JsonConvert.SerializeObject(res));
            }

            var        ieGuid   = string.Empty;
            T_IERecord ieRecord = new T_IERecord();

            ieRecord.AffirmDate = DateTime.Now;
            ieRecord.Date       = DateTime.Now;

            if (ieGuidList != null && ieGuidList.Count > 0)
            {
                //核销现有收入,用逗号链接
                ieGuid = string.Join(",", ieGuidList.ToArray());
            }
            else
            {
                string[] temp = ieDetail.Split(new char[] { ',' });
                ////客户,收入确认日期,账期截止日期,货币,收入金额,税种企业所得税,税费金额,含税总收入,备注,Business_GUID,SubBusiness_GUID
                //传入参数必须包含以上9个项目
                if (temp.Count() != 11)
                {
                    res.success = false;
                    res.msg     = "收入数据异常";
                    return(JsonConvert.SerializeObject(res));
                }
                else
                {
                    DateTime affirmDate;
                    DateTime endDate;
                    if (!DateTime.TryParse(temp[1], out affirmDate))
                    {
                        res.success = false;
                        res.msg     = "收入确认日期异常";
                        return(JsonConvert.SerializeObject(res));
                    }

                    if (!DateTime.TryParse(temp[2], out endDate))
                    {
                        res.success = false;
                        res.msg     = "账期截止日期异常";
                        return(JsonConvert.SerializeObject(res));
                    }
                    ieRecord.Creator = base.userData.LoginFullName;

                    ieRecord.RPer = temp[0];

                    ieRecord.AffirmDate       = affirmDate;
                    ieRecord.Date             = endDate;
                    ieRecord.Currency         = temp[3];
                    ieRecord.Amount           = Convert.ToDecimal(temp[4]);
                    ieRecord.TaxationType     = temp[5];
                    ieRecord.TaxationAmount   = Convert.ToDecimal(temp[6]);
                    ieRecord.SumAmount        = Convert.ToDecimal(temp[7]);
                    ieRecord.Remark           = temp[8];
                    ieRecord.Business_GUID    = temp[9];
                    ieRecord.SubBusiness_GUID = temp[10];
                }
            }


            bool result = ProductSvc.SalesProduct(productGuid, ieGuid, count, C_GUID, ieRecord, stockcount);

            if (result)
            {
                res.success = true;
                res.msg     = "";
            }
            else
            {
                res.success = false;
                res.msg     = "不是该公司产品不可核销";
            }

            return(JsonConvert.SerializeObject(res));
        }
        /// <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++)
                    {
                        T_WageCost WageCostRecord = new T_WageCost();
                        WageCostRecord.W_GUID         = Guid.NewGuid().ToString();
                        WageCostRecord.C_GUID         = Session["CurrentCompany"].ToString();
                        WageCostRecord.Date           = Convert.ToDateTime(dr[i][1].ToString());
                        WageCostRecord.Employee       = dr[i][0].ToString();;
                        WageCostRecord.Cash           = Convert.ToDecimal(dr[i][2].ToString());
                        WageCostRecord.PersonalTaxes  = Convert.ToDecimal(dr[i][3].ToString());
                        WageCostRecord.SocialSecurity = Convert.ToDecimal(dr[i][4].ToString());
                        WageCostRecord.Total          = Convert.ToDecimal(dr[i][2].ToString()) + Convert.ToDecimal(dr[i][3].ToString()) + Convert.ToDecimal(dr[i][4].ToString());;
                        new IESvc().UpdWageCost(WageCostRecord);
                        //RPer,B_Guid,BA_Guid数据需要比对!
                        string rper = "b73f1802-4ba4-4873-b423-86ea3d9b723f";

                        T_IERecord record = new T_IERecord();
                        record.IE_GUID = Guid.NewGuid().ToString();
                        record.RPer    = rper;

                        DateTime           dt;
                        DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
                        dtFormat.ShortDatePattern = "yyyy/MM/dd";
                        dt = Convert.ToDateTime(dr[i][1].ToString(), dtFormat);
                        record.AffirmDate     = dt;
                        record.Date           = Convert.ToDateTime(dr[i][1].ToString());
                        record.State          = "应付";
                        record.SumAmount      = Convert.ToDecimal(dr[i][2].ToString()) + Convert.ToDecimal(dr[i][3].ToString()) + Convert.ToDecimal(dr[i][4].ToString());
                        record.C_GUID         = Session["CurrentCompany"].ToString();
                        record.Creator        = base.userData.LoginFullName;
                        record.CreateDate     = DateTime.Now;
                        record.Currency       = dr[i][6].ToString();
                        record.InvType        = dr[i][7].ToString();
                        record.IEGroup        = "1544d862-b1ab-42b8-9e97-9c2e1704665c";
                        record.Remark         = dr[i][0].ToString();
                        record.TaxationAmount = 0;
                        record.TaxationType   = "";
                        bool TorF = new IESvc().UpdExpenseRecord(record);
                        if (TorF)
                        {
                            result = "导入成功!";
                        }
                        else
                        {
                            result = "导入失败!";
                        }
                    }
                }
                catch (Exception)
                {
                    result = "导入失败,请检查EXCEL格式是否错误!";
                }
            }
            JsonResult json = new JsonResult();

            json.Data = result;
            return(json);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 核销产品
        /// </summary>
        /// <param name="guid">要核销的产品</param>
        /// <param name="ieGuid">收入GUID(多个用逗号)</param>
        /// <param name="saledAmount">核销金额</param>
        /// <param name="companyId">当前公司GUID</param>
        /// <param name="ieDetail">收入明细</param>
        /// <returns></returns>
        public static bool SalesProduct(string guid, string ieGuid, decimal saledAmount, string companyId, T_IERecord rec, decimal stockcount)
        {
            DBHelper dh = new DBHelper();

            dh.BeginTran();
            try
            {
                dh.strCmd = "SP_SalesProduct";
                dh.AddPare("@p_guid", SqlDbType.VarChar, 40, guid);
                dh.AddPare("@c_guid", SqlDbType.VarChar, 40, companyId);
                dh.AddPare("@saled_count", SqlDbType.Decimal, 18, saledAmount);
                dh.AddPare("@ie_guid", SqlDbType.VarChar, int.MaxValue, ieGuid);

                dh.AddPare("@RPer", SqlDbType.VarChar, 40, rec.RPer);
                dh.AddPare("@Creator", SqlDbType.VarChar, 40, rec.Creator);
                dh.AddPare("@AffirmDate", SqlDbType.VarChar, 40, rec.AffirmDate);
                dh.AddPare("@end_date", SqlDbType.VarChar, 40, rec.Date);
                dh.AddPare("@Amount", SqlDbType.VarChar, 40, rec.Amount);
                dh.AddPare("@TaxationAmount", SqlDbType.VarChar, 40, rec.TaxationAmount);
                dh.AddPare("@TaxationType", SqlDbType.VarChar, 40, rec.TaxationType);
                dh.AddPare("@SumAmount", SqlDbType.VarChar, 40, rec.SumAmount);
                dh.AddPare("@Remark", SqlDbType.VarChar, 40, rec.Remark);
                dh.AddPare("@Currency", SqlDbType.VarChar, 40, rec.Currency);
                dh.AddPare("@Business_GUID", SqlDbType.VarChar, 40, rec.Business_GUID);
                dh.AddPare("@SubBusiness_GUID", SqlDbType.VarChar, 40, rec.SubBusiness_GUID);


                dh.AddPare("@result", SqlDbType.Int, ParameterDirection.Output, 0, null);

                dh.NonQuery();
                dh.CleanPara();

                dh.strCmd = "SP_GetProductBatch";
                dh.AddPare("@c_id", SqlDbType.VarChar, 40, companyId);
                dh.AddPare("@pid", SqlDbType.VarChar, 40, guid);
                List <T_AIDRecord> result = new List <T_AIDRecord>();
                result = dh.Reader <T_AIDRecord>();
                dh.CleanPara();

                for (int j = 0; j < result.Count; j++)
                {
                    dh.strCmd = "SP_UpdProductBatch";
                    dh.AddPare("@Amount", SqlDbType.VarChar, 40, (saledAmount / stockcount) * result[j].Amount);
                    dh.AddPare("@GUID", SqlDbType.VarChar, 40, result[j].GUID);
                    dh.NonQuery();
                    dh.CleanPara();
                }
                dh.CommitTran();
                return(true);
            }
            catch (System.Exception e)
            {
                dh.RollBackTran();
                return(false);
            }
        }