| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using CoreFS.CA06;using Pur.Entity;
- using Pur.Entity.balanceEntity;
- using Core.Mes.Client.Comm.Control;
- using System.Collections;
- using Pur.Entity.configureEntity;
- using Core.Mes.Client.Comm.Tool;
- using com.hnshituo.pur.vo;
- using Infragistics.Win;
- namespace Pur.balance
- {
- public partial class FrmPop_BalanceRegM : FrmPmsBase
- {
- public FrmPop_BalanceRegM(ArrayList al_BalanceId, OpeBase ob)
- {
- InitializeComponent();
- GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], "Check");
- this.ob = ob;
- getBalanceM(al_BalanceId);// 获取结算单信息
- }
- /// <summary>
- /// 获取结算单信息
- /// </summary>
- private void getBalanceM(ArrayList al)
- {
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.balance.service.BalanceBillMService", "getBalanceMToBalanceRegM", new object[] { al });
- //按创建时间降序
- dt.DefaultView.Sort = "CREATETIME DESC";
- dt = dt.DefaultView.ToTable();
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);//结算信息
- }
- /// <summary>
- /// 获取含税总金额
- /// </summary>
- private void getBalanceAmtTax()
- {
- double summer = 0;//含税总金额
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if ((Boolean)ultraGrid1.Rows[i].Cells["Check"].Value)
- {
- if (ultraGrid1.Rows[i].Cells["TOTALWITHAMTTAX"].Value.ToString().Trim() != "")
- {
- double d = 0;
- double.TryParse(ultraGrid1.Rows[i].Cells["TOTALWITHAMTTAX"].Value.ToString(), out d);
- summer += d;
- }
- }
- }
- txt_BALANCE_AMT_TAX.Text = summer.ToString();//含税总金额
- }
- /// <summary>
- /// 新增报销登记单
- /// </summary>
- private void addBalanceRegM()
- {
- if (txt_INVOICE_CODE.Text.Trim() == "")
- {
- MessageUtil.ShowTips("请填写发票号");
- return;
- }
- PurBalanceRegMEntity pbrmEntity = new PurBalanceRegMEntity();
- //报销单主表
- pbrmEntity.RegmId = Guid.NewGuid().ToString();//-
- pbrmEntity.Status = "1";//状态
- pbrmEntity.InvoiceCode = txt_INVOICE_CODE.Text;//发票编号
- pbrmEntity.InvoiceAmt = double.Parse(txt_BALANCE_AMT_TAX.Text);//发票总金额
- pbrmEntity.InvoiceDate = System.DateTime.Now;//发票开票日期-
- if (txt_BALANCE_AMT_TAX.Text != "")
- {
- pbrmEntity.RegAmt = double.Parse(txt_BALANCE_AMT_TAX.Text);//申报总金额
- }
- else
- {
- pbrmEntity.RegAmt = 0;
- }
- pbrmEntity.RegAmtUpCase = smallLettersTocapitalLetters(txt_BALANCE_AMT_TAX.Text);//申报总金额大写
- pbrmEntity.ConfirmUserid = UserInfo.GetUserID();
- pbrmEntity.ConfirmUsername = UserInfo.GetUserName();
- pbrmEntity.ConfirmDate = System.DateTime.Now;//票据确认日期-
- pbrmEntity.Validflag = "1";
- pbrmEntity.SuppCode = ultraGrid1.ActiveRow.Cells["SUPPCODE"].Value.ToString();
- pbrmEntity.SuppName = ultraGrid1.ActiveRow.Cells["SUPPNAME"].Value.ToString();
- pbrmEntity.CreateUserid = UserInfo.GetUserID();
- pbrmEntity.CreateName = UserInfo.GetUserName();
- //报销单行
- ArrayList albrc = new ArrayList();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if ((Boolean)ultraGrid1.Rows[i].Cells["Check"].Value)
- {
- PurBalanceRegCEntity pbrCEntity = new PurBalanceRegCEntity();
- pbrCEntity.Id = Guid.NewGuid().ToString();
- pbrCEntity.BalanceId = ultraGrid1.Rows[i].Cells["BALANCEID"].Value.ToString();//结算单号
- pbrCEntity.Validflag = "1";
- pbrCEntity.CreateUserid = UserInfo.GetUserID();
- pbrCEntity.CreateName = UserInfo.GetUserName();
- albrc.Add(pbrCEntity);
- }
- }
- if (albrc.Count < 1)
- {
- MessageUtil.ShowTips("请选择结算单");
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.balance.service.BalanceRegMService", "addBalanceRegM", new object[] { pbrmEntity, albrc });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("报销单生成失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("报销单(" + crt.Resultmsg+ ")生成成功!");
- }
- /// <summary>
- /// 选择结算单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- if (e.Cell.Column.Key == "Check")
- {
- getBalanceAmtTax();
- }
- }
- private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- ultraGrid1.UpdateData();
- }
- /// <summary>
- /// 按钮控件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void barsManagerButon_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key.ToString())
- {
- case "Query":
- {
- }
- break;
- case "conFirmation":
- {
- addBalanceRegM();
- }
- break;
- case "ESC":
- {
- this.Close();
- }
- break;
- }
- }
- //小写转换为大写
- private string smallLettersTocapitalLetters(string strSmallLetter)
- {
- string strCapitalLetters = "";//保存转化结果
- string[] strCapital = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };//大写汉字
- string[] strUionIntger = { "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千", "万", "十", "百", "千"};//大写单位
- string[] strUionfloat = { "角", "分", "厘", "毫" };
- char[] c_IntgerSmallLetter = null;//传入数字整数部分
- char[] c_floatSmallLetter = null;//传入数字小数部分
- //获取整数部分和小数部分
- if (strSmallLetter.IndexOf('.') != -1)
- {
- c_IntgerSmallLetter = strSmallLetter.Substring(0, strSmallLetter.IndexOf('.')).ToCharArray();
- c_floatSmallLetter = strSmallLetter.Substring(strSmallLetter.IndexOf('.') + 1).ToCharArray();
- }
- else
- {
- c_IntgerSmallLetter = strSmallLetter.ToCharArray();
- }
- //转化整数部分
- for (int i = 0; i < c_IntgerSmallLetter.Length; i++)
- {
- int c = int.Parse(c_IntgerSmallLetter[i].ToString());
- if (strCapital[c] != "零")
- {
- strCapitalLetters += strCapital[c];
- if (i != c_IntgerSmallLetter.Length - 1)
- {
- strCapitalLetters += strUionIntger[c_IntgerSmallLetter.Length - 1 - 1 - i];
- }
- }
- else//如果数字为零
- {
- strCapitalLetters += "零零";
- }
- }
- strCapitalLetters += "元";//加上单位
- //转化小数部分
- if (c_floatSmallLetter != null)
- {
- for (int i = 0; i < c_floatSmallLetter.Length; i++)
- {
- int c = int.Parse(c_floatSmallLetter[i].ToString());
- if (strCapital[c] != "零")
- {
- strCapitalLetters += strCapital[c];
- strCapitalLetters += strUionfloat[i];
- }
- else//如果数字为零
- {
- strCapitalLetters += "零零";
- }
- }
- }
- //将有两个零的都替换成一个零
- while (strCapitalLetters.Contains("零零"))
- {
- strCapitalLetters = strCapitalLetters.Replace("零零", "零");
- }
- if (c_IntgerSmallLetter.Length > 1)//如果整数长度大于1,那么最后一位不能为零
- {
- if (strCapitalLetters.Substring(strCapitalLetters.IndexOf("元") - 1, 1) == "零")
- {
- strCapitalLetters = strCapitalLetters.Remove(strCapitalLetters.IndexOf("元") - 1, 1);
- }
- }
- if (strCapitalLetters.Substring(strCapitalLetters.Length - 1) == "零")//最后一位不能为零
- {
- strCapitalLetters = strCapitalLetters.Remove((strCapitalLetters.Length - 1));
- }
- //转化小数部分
- return strCapitalLetters;
- }
- }
- }
|