Exemple #1
0
        public ActionResult Save(System.Int32 id, string tag)
        {
            T_RKMXModels model = new T_RKMXModels();

            model.DataModel = new T_RKMX();
            Int32 did = id;

            if (tag != "Add")
            {
                model.DataModel = T_RKMXDomain.GetInstance().GetModelById(id);
                did             = model.DataModel.CKID;
            }

            //加载仓库列表
            T_CKModels ckmode = new T_CKModels();

            ckmode.DataModel = ckmode.DataModel ?? new T_CK();

            ckmode.DataList = T_CKDomain.GetInstance().GetAllT_CK(ckmode.DataModel);

            ViewData["CK"] = new SelectList(ckmode.DataList, "CKID", "CKMC");

            //加载产品列表
            T_YLCPModels ylcpQymode = new T_YLCPModels();

            ylcpQymode.DataModel = ylcpQymode.DataModel ?? new T_YLCP();

            ylcpQymode.DataList = T_YLCPDomain.GetInstance().GetAllT_YLCP(ylcpQymode.DataModel).Where(p => p.CPStatus == Convert.ToInt32("1")).ToList();

            ViewData["YLCP"] = new SelectList(ylcpQymode.DataList, "CPID", "CPMC");

            //加载入库单列表
            T_RKDModels rkdQymode = new T_RKDModels();

            rkdQymode.DataModel = rkdQymode.DataModel ?? new T_RKD();
            T_RKD rkd = T_RKDDomain.GetInstance().GetModelById(did);

            rkdQymode.DataList = new List <T_RKD>();
            rkdQymode.DataList.Add(rkd);
            ViewData["RKD"] = new SelectList(rkdQymode.DataList, "RKID", "RKMC");



            //if (id != 0)
            //{
            //    model.DataModel = T_RKMXDomain.GetInstance().GetModelById(id);
            //}
            model.Tag = tag;
            return(View("~/Views/T_RKMX/Save.cshtml", model));
        }
Exemple #2
0
        public string ExportExcelPR(System.Int32 id)
        {
            //接收需要导出的数据
            T_RKD ckdinfo = new T_RKD();

            List <T_RKD> list = T_RKDDomain.GetInstance().GetListModelById(id);

            if (list.Count > 0)
            {
                ckdinfo = list[0];
            }

            //采购单名称
            string xsqyName = ckdinfo.YSDH;

            List <T_RKMX> ckmxList = T_RKMXDomain.GetInstance().GetListModelById(id);

            //命名导出表格的StringBuilder变量
            StringBuilder sHtml = new StringBuilder(string.Empty);

            //打印表头
            sHtml.Append("<table border=\"0\" width=\"100%\">");
            sHtml.Append("<tr height=\"40\"><td colspan=\"10\" align=\"center\" style='font-size:24px'><b>入库单" + "</b></td></tr>");
            sHtml.Append("<tr height=\"40\"><td colspan=\"8\" align=\"left\">购买单位:" + xsqyName + "</td><td align=\"right\">日期:" + DateTime.Now.ToString("yyyy-MM-dd") + "</td><td align=\"right\">单据编号:" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + "</td></tr>");
            sHtml.Append("</table>");
            sHtml.Append("<table border=\"1\" width=\"100%\">");
            //sHtml.Append("<tr height=\"40\"><td colspan=\"10\" align=\"center\" style='font-size:24px'><b>出库单" + "</b></td></tr>");
            //sHtml.Append("<tr height=\"40\"><td colspan=\"8\" align=\"left\">&nbsp;购买单位:" + xsqyName + "</td><td align=\"right\">日期:" + DateTime.Now.ToString("yyyy-MM-dd") + "</td><td align=\"right\">单据编号:" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + "</td></tr>");
            //打印列名
            sHtml.Append("<tr height=\"30\" align=\"center\" ><td>商品名称</td><td>规格</td><td>生产厂家</td><td>单位</td><td>数量</td><td>单价</td>"
                         + "<td>金额</td><td>批号</td><td>生产日期</td><td>注册证号</td></tr>");

            //合计
            double total = 0.0;

            for (int i = 0; i < ckmxList.Count; i++)
            {
                T_RKMX ckmx = ckmxList[i];
                //产品名称
                string cpName = ckmx.T_YLCP.CPMC;
                //规格
                string cpGg = ckmx.T_YLCP.CPGG ?? "";
                //单位
                string cpDw = ckmx.T_YLCP.CPDW ?? "";
                //数量
                double cpDj = ckmx.CPNUM ?? 0;
                //生成批号
                string scPh = ckmx.T_YLCP.CPPH ?? "";
                //生产日期
                string scRq = "";
                if (ckmx.T_YLCP.CPSCSJ != null)
                {
                    scRq = ckmx.T_YLCP.CPSCSJ.Value.ToLongDateString();
                }

                //生产企业
                string cpScqy = ckmx.T_YLCP.CPSCQY ?? "";
                //单价
                double cpPrice = ckmx.T_YLCP.CPPrice ?? 0.0;
                //产品总价
                double rowTotal = cpDj * cpPrice;

                total = total + rowTotal;
                //注册证号
                string cpzczh = ckmx.T_YLCP.CPZCZ;

                sHtml.Append("<tr height=\"30\" align=\"center\"><td>" + cpName
                             + "</td><td>" + cpGg + "</td><td>" + cpScqy
                             + "</td><td>" + cpDw + "</td><td>" + cpDj.ToString()
                             + "</td><td>" + cpPrice.ToString() + "</td><td>" + rowTotal.ToString() + "</td><td>" + scPh + "</td><td>" + scRq
                             + "</td><td>" + cpzczh
                             + "</td></tr>");
            }
            //循环读取List集合
            for (int i = 0; i < list.Count; i++)
            {
            }
            //打印表尾
            sHtml.Append("<tr height=\"40\" align=\"center\"><td>合计:</td><td colspan=\"9\">" + total + "</td></tr>");
            sHtml.Append("</table>");
            sHtml.Append("<table  border=\"0\" width=\"100%\">");
            sHtml.Append("<tr height=\"40\" align=\"center\"><td colspan=\"7\" align=\"left\">制单人:&nbsp;&nbsp</td><td align=\"right\">审核人:&nbsp;&nbsp</td><td align=\"right\">采购员:&nbsp;&nbsp</td><td align=\"center\">质检员:&nbsp;&nbsp</td></tr>");
            sHtml.Append("</table>");
            //调用输出Excel表的方法
            return(sHtml.ToString());
            //ExportToExcel("application/vnd.ms-excel", "出库单.xls", sHtml.ToString());
        }
Exemple #3
0
        public string ExportExcelPR(System.Int32 id)
        {
            //获取需要打印的数据
            T_RKD ckdinfo = new T_RKD();

            List <T_RKD> list = T_RKDDomain.GetInstance().GetListModelById(id);

            if (list.Count > 0)
            {
                ckdinfo = list[0];
            }

            //验收单号
            string rkysdh = ckdinfo.YSDH;

            //供货企业名称
            T_RKMX        rkdinfo  = new T_RKMX();
            List <T_RKMX> rkmxList = T_RKMXDomain.GetInstance().GetListModelById(id);

            if (rkmxList.Count > 0)
            {
                rkdinfo = rkmxList[0];
            }
            string ghqy = rkdinfo.T_SupQY == null ? "" : rkdinfo.T_SupQY.SupMC;


            //命名导出表格的StringBuilder变量
            StringBuilder sHtml = new StringBuilder(string.Empty);

            //打印表头
            sHtml.Append("<table border=\"0\" width=\"100%\">"); //
            sHtml.Append("<tr height=\"40\"><td colspan=\"12\" align=\"center\" style='font-size:24px'><b>入库单" + "</b></td></tr>");
            sHtml.Append("<tr height=\"40\"><td colspan=\"6\" align=\"left\">供货企业:" + ghqy + "</td><td align=\"center\" colspan=\"4\">日期:" + DateTime.Now.ToString("yyyy-MM-dd") + "</td><td align=\"right\"  colspan=\"2\">入库单号:" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + "</td></tr>");
            sHtml.Append("</table>");
            sHtml.Append("<table border=\"1\" width=\"100%\"  style='border-collapse:collapse;border:1px solid black;'>"); // width=\"100%\"
            sHtml.Append("<tr height=\"30\" align=\"center\" ><td>产品名称</td><td>产品规格</td><td>生产厂家</td><td>生产日期</td><td>单位</td><td>数量</td><td>单价</td>"
                         + "<td>金额</td><td>产品批号</td><td>产品有效期</td><td>经营许可证号</td><td>注册证号</td></tr>");

            //合计
            double total = 0.0;

            for (int i = 0; i < rkmxList.Count; i++)
            {
                T_RKMX rkmx = rkmxList[i];
                //产品名称
                string cpName = rkmx.T_YLCP.CPMC;
                //规格
                string cpGg = rkmx.T_YLCP.CPGG ?? "";
                //单位
                string cpDw = rkmx.T_YLCP.CPDW ?? "";
                //数量
                double cpDj = rkmx.CPNUM ?? 0;
                //产品批号
                string scPh = rkmx.CPPH ?? "";
                //产品有效期
                string yxq = "";
                if (rkmx.CPYXQ != null)
                {
                    yxq = rkmx.CPYXQ.Value.ToString("yyyyMMdd");
                }
                var scrq = "";
                if (rkmx.CPSCRQ != null)
                {
                    scrq = rkmx.CPSCRQ.Value.ToString("yyyyMMdd");
                }

                //生产企业
                string cpScqy = rkdinfo.T_SupQY1 == null ? "" : rkdinfo.T_SupQY1.SupMC;
                //单价
                double cpPrice = Math.Round(rkmx.T_YLCP.CPPrice ?? 0.0, 2);
                //产品总价
                double rowTotal = Math.Round(cpDj * cpPrice, 2);

                total = total + rowTotal;
                //注册证号
                string cpzczh = rkmx.T_YLCP.CPZCZ;
                //经营许可证号
                string xkzbh = rkmx.T_SupQY.SupXKZBH;
                sHtml.Append("<tr height=\"30\" align=\"center\"><td>" + cpName
                             + "</td><td>" + cpGg + "</td><td>" + cpScqy
                             + "</td><td>" + scrq
                             + "</td><td>" + cpDw + "</td><td>" + cpDj.ToString()
                             + "</td><td>" + cpPrice.ToString("0.00") + "</td><td>" + rowTotal.ToString("0.00") + "</td><td>" + scPh + "</td><td>" + yxq
                             + "</td><td>" + xkzbh
                             + "</td><td>" + cpzczh
                             + "</td></tr>");
            }
            //打印表尾
            sHtml.Append("<tr height=\"40\" align=\"center\"><td colspan=\"5\">合计金额:(大写)" + MoneySmallToBig(total.ToString()) + "</td><td colspan=\"7\">(小写)" + total.ToString("0.00") + "</td></tr>");
            sHtml.Append("</table>");
            sHtml.Append("<table  border=\"0\" width=\"100%\">"); // width =\"100%\"
            Expression <Func <T_YSD, bool> > where = p => p.YSDH == ckdinfo.YSDH;
            var ysd      = T_YSDDomain.GetInstance().GetAllModels <int>(where).FirstOrDefault();
            var cgdModel = new T_CGD();

            if (ysd != null && ysd.YSID != 0 && !string.IsNullOrEmpty(ysd.CGDH))
            {
                Expression <Func <T_CGD, bool> > where1 = p => p.CGDH == ysd.CGDH;
                cgdModel = T_CGDDomain.GetInstance().GetAllModels <int>(where1).FirstOrDefault();
            }

            sHtml.Append("<tr height=\"40\" align=\"center\"><td colspan=\"2\" align=\"left\">制单人:&nbsp;" + ckdinfo.RKCJR + "</td><td align=\"left\" colspan=\"4\">审核人:&nbsp;" + cgdModel.SHR + "</td><td align=\"left\" colspan=\"3\">采购员:&nbsp;" + cgdModel.CGPERSON + "</td><td align=\"left\" colspan=\"3\">质检员:&nbsp;</td></tr>");
            sHtml.Append("</table>");
            return(sHtml.ToString());
        }