需求描述:
此购进单的基本信息,购进单位,入库单位,入库时间……
此购进单批号,产品名称,生产企业,等基本信息。
实现能够循环加载打印。
本单金额小计,整单金额合计计算。
技术需求:
界面设计,循环加载数据
实现函数:根据产品编号查询产品生产企业
实现函数:根据产品查询产品规格
实现函数:根据产品查询产品单位
实现金额数字转换大写
金额大小写转换的类:
namespace CommTool { /// <summary> /// 字符串处理相关 /// </summary> public class StringHandler { /// <summary> /// author:sunliyuan /// sunliyuan:2011年12月4日 /// 转换人民币大小金额 /// </summary> /// <param name="num">金额</param> /// <returns>返回大写形式</returns> public static string CmycurD(decimal num) { string str1 = "零壹贰叁肆伍陆柒捌玖"; //0-9所对应的汉字 string str2 = "万仟佰拾亿仟佰拾万仟佰拾元角分"; //数字位所对应的汉字 string str3 = ""; //从原num值中取出的值 string str4 = ""; //数字的字符串形式 string str5 = ""; //人民币大写金额形式 int i; //循环变量 int j; //num的值乘以100的字符串长度 string ch1 = ""; //数字的汉语读法 string ch2 = ""; //数字位的汉字读法 int nzero = 0; //用来计算连续的零值是几个 int temp; //从原num值中取出的值 num = Math.Round(Math.Abs(num), 2); //将num取绝对值并四舍五入取2位小数 str4 = ((long)(num * 100)).ToString(); //将num乘100并转换成字符串形式 j = str4.Length; //找出最高位 if (j > 15) { return "溢出"; } str2 = str2.Substring(15 - j); //取出对应位数的str2的值。如:200.55,j为5所以str2=佰拾元角分 //循环取出每一位需要转换的值 for (i = 0; i < j; i++) { str3 = str4.Substring(i, 1); //取出需转换的某一位的值 temp = Convert.ToInt32(str3); //转换为数字 if (i != (j - 3) && i != (j - 7) && i != (j - 11) && i != (j - 15)) { //当所取位数不为元、万、亿、万亿上的数字时 if (str3 == "0") { ch1 = ""; ch2 = ""; nzero = nzero + 1; } else { if (str3 != "0" && nzero != 0) { ch1 = "零" + str1.Substring(temp * 1, 1); ch2 = str2.Substring(i, 1); nzero = 0; } else { ch1 = str1.Substring(temp * 1, 1); ch2 = str2.Substring(i, 1); nzero = 0; } } } else { //该位是万亿,亿,万,元位等关键位 if (str3 != "0" && nzero != 0) { ch1 = "零" + str1.Substring(temp * 1, 1); ch2 = str2.Substring(i, 1); nzero = 0; } else { if (str3 != "0" && nzero == 0) { ch1 = str1.Substring(temp * 1, 1); ch2 = str2.Substring(i, 1); nzero = 0; } else { if (str3 == "0" && nzero >= 3) { ch1 = ""; ch2 = ""; nzero = nzero + 1; } else { if (j >= 11) { ch1 = ""; nzero = nzero + 1; } else { ch1 = ""; ch2 = str2.Substring(i, 1); nzero = nzero + 1; } } } } } if (i == (j - 11) || i == (j - 3)) { //如果该位是亿位或元位,则必须写上 ch2 = str2.Substring(i, 1); } str5 = str5 + ch1 + ch2; if (i == j - 1 && str3 == "0") { //最后一位(分)为0时,加上“整” str5 = str5 + ‘整‘; } } if (num == 0) { str5 = "零元整"; } return str5; } /// <summary> /// author:sunliyuan /// 2011年12月4日 /// 转换人民币大小金额 (一个重载,将字符串先转换成数字在调用CmycurD) /// </summary> /// <param name="num">用户输入的金额,字符串形式未转成decimal</param> /// <returns></returns> public static string CmycurD(string numstr) { try { decimal num = Convert.ToDecimal(numstr); return CmycurD(num); } catch { return "非数字形式!"; } } } }
根据产品编号查询产品的生产企业
-- Description: 根据产品编号查询产品的生产企业 -- ============================================= CREATE FUNCTION [dbo].[FN_getMadeEnterpriseByProID] ( @ProID INT ) RETURNS NVARCHAR(100) AS BEGIN DECLARE @MadeEnterprise NVARCHAR(100) SELECT @MadeEnterprise=MadeEnterprise FROM dbo.BiotbProduct WHERE [email protected] RETURN @MadeEnterprise END
根据产品编号查询产品规格:
-- Description: 根据产品编号查询产品规格 -- ============================================= CREATE FUNCTION [dbo].[FN_getProSpecbyProID] ( @ProID INT ) RETURNS NVARCHAR(100) AS BEGIN -- Declare the return variable here DECLARE @Spec NVARCHAR(100) -- Add the T-SQL statements to compute the return value here SELECT @Spec=spec FROM BiotbProduct WHERE [email protected] -- Return the result of the function RETURN @Spec END
根据产品编号查询产品单位:
-- Description: 根据产品编号查询产品单位 -- ============================================= CREATE FUNCTION [dbo].[FN_getProUnitbyProID] ( @proID INT ) RETURNS NVARCHAR(50) AS BEGIN -- Declare the return variable here DECLARE @Unit NVARCHAR(50) -- Add the T-SQL statements to compute the return value here SELECT @Unit=Unit FROM dbo.BiotbProduct WHERE [email protected] -- Return the result of the function RETURN @Unit END
构建查询打印的视图数据:
CREATE VIEW [dbo].[View_PurchaseInfoPrint] AS SELECT SendComName=dbo.getCompanyNameByCompanyID(SendComID), AppUserName=dbo.getUserNameByUserID(AppUserID), AuditingUser=dbo.getUserNameByUserID(AcceptUserid), stockUserName=dbo.getUserNameByUserID(Stockuserid), StockName=dbo.FN_getStockNameByStockID(StockID), StockDate=dbo.Fn_getSotckTimeByPurchaseID(PurchaseID), * FROM dbo.BioPurchaseAppInfo CREATE VIEW [dbo].[View_PurchaseBatchInfoPrint]ASSELECT ProName, Spec=dbo.FN_getProSpecbyProID(ProID), MadeEnterprise=dbo.FN_getMadeEnterpriseByProID(ProID), Unit=dbo.FN_getProUnitbyProID(ProID), ProCount, ProPrice, ProBatchPriceTotal=(ProPrice*realityProCount), InvoicePrice, PurchaseProID, PurchaseID, ProID, makeDate, batchNum, expirationDate, ProBatchID, stockDate, boxNum, BatchProCount, realityProCount FROM View_PurchaseProBatchInfo
根据仓库编号查询仓库名称:
-- Description: 根据仓库编号查询仓库名称 -- ============================================= CREATE FUNCTION [dbo].[FN_getStockNameByStockID] ( -- Add the parameters for the function here @stockID INT ) RETURNS NVARCHAR(100) AS BEGIN DECLARE @StockName NVARCHAR(100) SELECT @StockName=StockName FROM dbo.BioErpStockTable WHERE [email protected] RETURN @StockName END
时间: 2024-10-01 00:05:30