首页 > 代码库 > 交款功能代码
交款功能代码
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 WeifenLuo.WinFormsUI.Docking;using System.Drawing.Printing;using System.IO;namespace DBzd{ public partial class FeesFrm : DockContent { private MainFrm mf; //交款方式 private string jkfs; //图片信息 private byte[] byteZhiPiaoA = null; private byte[] byteZhiPiaoB = null; private byte[] byteHuiKuanA = null; private byte[] byteHuiKuanB = null; private byte[] byteQianTiaoA = null; private double trueprice; public FeesFrm() { InitializeComponent(); } public FeesFrm(MainFrm f) { InitializeComponent(); mf = f; } private void FeesFrm_Load(object sender, EventArgs e) { #region 年度列表 toolStripComboBox1.Items.Clear(); var q = from p in mf.DS.UnitPaperTask orderby p.year descending group p by p.year into g select new { year = g.Key, g }; foreach (var it in q) { toolStripComboBox1.Items.Add(it.year); } toolStripComboBox1.SelectedIndex = 0; #endregion #region 加载单位类别 toolStripComboBox3.Items.Clear(); var q1 = from k in mf.DS.Unit // orderby k.kind descending group k by k.kind into g select new { kind = g.Key, g }; foreach (var i in q1) { toolStripComboBox3.Items.Add(i.kind); } toolStripComboBox3.SelectedIndex = 0; #endregion combSKFS.SelectedIndex = 0; btnSave.Enabled = false; } #region 工具栏 //工具栏 单位类别 下拉列表变换 private void toolStripComboBox3_SelectedIndexChanged(object sender, EventArgs e) { combJKDW.Items.Clear(); var q5 = from p in mf.DS.Unit.AsEnumerable() where p.kind == toolStripComboBox3.SelectedItem.ToString().Trim() && p.Istake == "是" select p; foreach (var i in q5) { Unit un = new Unit(); un.unitid = i.unitid; un.shortname = i.shortname; un.tel = i.Tel; un.allname = i.allname; combJKDW.Items.Add(un); } combJKDW.DisplayMember = "shortname"; if (combJKDW.Items.Count > 0) { combJKDW.SelectedIndex = 0; } } //搜索单位 private void tsTxtSearch_TextChanged(object sender, EventArgs e) { combJKDW.Items.Clear(); string upper = tsTxtSearch.Text.ToUpper(); var q5 = from p in mf.DS.Unit.AsEnumerable() where p.Istake == "是" select p; foreach (var i in q5) { string namecode = PinYin.GetCodstring(i.shortname); if (namecode.StartsWith(upper)) { Unit un = new Unit(); un.unitid = i.unitid; un.allname = i.allname; un.shortname = i.shortname; un.tel = i.Tel; combJKDW.Items.Add(un); } } combJKDW.DisplayMember = "shortname"; if (combJKDW.Items.Count > 0) { combJKDW.SelectedIndex = 0; } } #endregion //显示计划金额及企业任务 private void PlantMoney() { //txtTruePrice.Text = ""; txtPlantMoeny.Text = ""; Unit un = combJKDW.SelectedItem as Unit; List<string> qflag = (from p in mf.DS.Fees.AsEnumerable() where p.unitid == un.unitid && p.year == toolStripComboBox1.SelectedItem.ToString().Trim() select p.flag).ToList<string>(); if (qflag.Count > 0) { var qplantprices = from p in mf.DS.UnitMoneyTask.AsEnumerable() where p.unitid == un.unitid select p; foreach (var i in qplantprices) { txtPlantMoeny.Text = i.totalMoney.ToString(); // txtCompTask.Text = i.compprices.ToString(); txtUnitTel.Text = un.tel; } //查询计划金额表,是否有该单位的计划金额?有:无 if (qplantprices.Count() > 0) { if (txtCompTask.Text != "0") { txtTruePrice.Text = txtTotalMoney.Text = (double.Parse(txtPlantMoeny.Text) + double.Parse(txtCompTask.Text) + double.Parse(txtZiDingMoney.Text.Trim())).ToString(); } else { txtTruePrice.Text = txtTotalMoney.Text = (double.Parse(txtPlantMoeny.Text) + double.Parse(txtZiDingMoney.Text.Trim())).ToString(); } } else { txtPlantMoeny.Text = labTal.Text; } var q = from p in mf.DS.Fees.AsEnumerable() where p.unitid == un.unitid select p; foreach (var i in q) { txtDrawee.Text = i.drawee; txtDraweeTel.Text = i.draweetel; txtTruePrice.Text = i.tureprice.ToString(); combSKR.Text = i.payee; dateTimePicker1.Value = i.paytime; switch (i.flag) { case "完成": rabOver.Checked = true; break; case "部分": rabPat.Checked = true; break; case "未交": rabNot.Checked = true; break; } txtbz.Text = i.bz; } txtDrawee.Enabled = txtDraweeTel.Enabled = txtTruePrice.Enabled = combSKR.Enabled = btnSave.Enabled = dateTimePicker1.Enabled = btnEdit.Enabled = false; } else { txtDrawee.Enabled = txtDraweeTel.Enabled = txtTruePrice.Enabled = combSKR.Enabled = btnSave.Enabled = dateTimePicker1.Enabled = btnEdit.Enabled = true; txtDrawee.Text = txtDraweeTel.Text = ""; txtPlantMoeny.Text = labTal.Text; if (txtPlantMoeny.Text == "") { txtPlantMoeny.Text = "0"; } if (txtCompTask.Text != "0") { txtTruePrice.Text = txtTotalMoney.Text = (double.Parse(txtPlantMoeny.Text.Trim()) + double.Parse(txtCompTask.Text.Trim()) + double.Parse(txtZiDingMoney.Text.Trim())).ToString(); } else { txtTruePrice.Text = txtTotalMoney.Text = (double.Parse(txtPlantMoeny.Text.Trim()) + double.Parse(txtZiDingMoney.Text.Trim())).ToString(); } rabNot.Checked = true; btnSave.Text = "保存"; } } //显示计划任务列表 private void ShowPlantTask() { listView1.Items.Clear(); //实现了视图功能 Unit un = combJKDW.SelectedItem as Unit; var pt = from p in mf.DS.Paper.AsEnumerable() from ut in mf.DS.UnitPaperTask.AsEnumerable() where ut.unitid == un.unitid && ut.paperid == p.paperid && ut.year == toolStripComboBox1.SelectedItem.ToString().Trim() select new { id = ut.id, paperid = p.paperid, bk = p.name, nm = ut.plantnum, // tnm = ut.truenum, price = p.price, bt = p.subsidy, ye = ut.year }; foreach (var i in pt) { //ListViewItem lv = new ListViewItem(new string[] { i.bk, i.nm.ToString(), i.tnm.ToString(), (i.price - i.bt).ToString(), i.ye }); ListViewItem lv = new ListViewItem(new string[] { i.bk, i.nm.ToString(), (i.price - i.bt).ToString(), i.ye }); lv.Tag = i.id; listView1.Items.Add(lv); } } //计算、显示总金额 private void CalListViewMoney() { double money = 0; foreach (ListViewItem item in listView1.Items) { int fensu = Int32.Parse(item.SubItems[2].Text.Trim()); double danjia = double.Parse(item.SubItems[3].Text.Trim()); money += fensu * danjia; } labTal.Text = money.ToString(); } //选择单位 private void combJKDW_SelectedIndexChanged(object sender, EventArgs e) { //显示自订报刊金额 getZidinbBaoKan(); //显示计划金额 PlantMoney(); //显示实际订刊数 ShowPlantTask(); //计算实际金额 CalListViewMoney(); //显示不同交款方式 ShowJiaoKuanFanShi(); //显示不同交款方式页 // showTabControlPt(); //显示批复 getPiFu(); txtbaokan.Text = txtNumber.Text = ""; combJKDW.Focus(); } //todo:是否要重新设计?有了计划任务的单位,单位计划金额应即时程序算出来,不应从库取; //而只有计划金额无任务的单位才从,库在取(只包括几个乡镇!他们是为完成总任务做备份金用的) private void ShowJiaoKuanFanShi() { Unit un = combJKDW.SelectedItem as Unit; var q = from p in mf.DS.Fees.AsEnumerable() where p.unitid == un.unitid select p; foreach (var i in q) { switch (i.paykind) { case "现金": combSKFS.SelectedIndex = 0; //tabControl1.SelectedIndex = 0; break; case "支票": combSKFS.SelectedIndex = 1; combBank.Text = i.bank; txtSbgetMoeny.Text = i.getpaysb; rabMoney.Checked = (i.checkkind == "现金支票") ? true : false; rabZhip.Checked = (i.checkkind == "转账支票") ? true : false; dateTimePickerMoney.Value = i.getpaytime; // tabControl1.SelectedIndex = 1; break; case "汇款": combSKFS.SelectedIndex = 2; txtPayAccount.Text = i.getpayaccount; dateTimePicker5.Value = i.getpaytime; // tabControl1.SelectedIndex = 2; break; case "欠条": combSKFS.SelectedIndex = 3; //txtPayAccount.Text = i.getpayaccount; //dateTimePicker5.Value = http://www.mamicode.com/i.getpaytime;>// tabControl1.SelectedIndex = 3; break; } } } //显示自订报刊金额 private void getZidinbBaoKan() { //得到单位ID Unit u = combJKDW.SelectedItem as Unit; //得到非党刊id; List<string> Arid = (from p in mf.DS.UnitPaperTask.AsEnumerable() where p.unitid == u.unitid select p.paperid).ToList<string>(); List<string> dkid = (from p in mf.DS.Paper.AsEnumerable() where p.IsDanKan == "否" select p.paperid).ToList<string>(); int caljg = 0; txtZiDingMoney.Text = "0"; foreach (var i in dkid) { if (Arid.Contains(i)) { int m = 0; var q = from p in mf.DS.Paper.AsEnumerable() from upt in mf.DS.UnitPaperTask.AsEnumerable() where upt.unitid == u.unitid && p.paperid == i select new { price = p.price, subprice = p.subsidy, numb = upt.plantnum }; foreach (var im in q) { m = Convert.ToInt32(im.price - im.subprice) * im.numb; } caljg += m; } } txtZiDingMoney.Text = caljg.ToString(); } //双击列表要修改数量 private void listView1_MouseDoubleClick(object sender, MouseEventArgs e) { if (listView1.SelectedItems.Count > 0) { txtNumber.Text = ""; txtbaokan.Text = listView1.SelectedItems[0].Text; txtNumber.Text = listView1.SelectedItems[0].SubItems[2].Text; } } //编辑数量 private void btnEdit_Click(object sender, EventArgs e) { foreach (ListViewItem item in listView1.Items) { if (item.Text == txtbaokan.Text) { item.SubItems[2].Text = txtNumber.Text.Trim(); } } txtbaokan.Text = ""; txtNumber.Text = ""; CalListViewMoney(); //保存实际订刊数 SaveTruePaperNumb(); } //todo:计划金额列表中,无单位计划金额,需要新查询计算。1、单位,2、分任务或分金额。如有任务无金额?有金额无任务? //保存按键 private void btnSave_Click(object sender, EventArgs e) { Fees fees = new Fees(); Unit un = combJKDW.SelectedItem as Unit; fees.unitid = un.unitid;//单位代码 fees.paykind = jkfs;//交款方式 fees.plantprrice = double.Parse(txtTotalMoney.Text.Trim());//计划总额 fees.tureprice = double.Parse(txtTruePrice.Text.Trim());//实收金额 fees.drawee = txtDrawee.Text;//交款人 fees.draweetel = txtDraweeTel.Text;//交款人电话 fees.payee = combSKR.SelectedItem.ToString();//收款人 fees.paytime = dateTimePicker1.Value;//交款时间 string flag = ""; foreach (RadioButton rb in gBoxFlag.Controls) { if (rb.Checked == true) { flag = rb.Text; } } fees.flay = flag;//进度标注(完成,部分,未交 fees.bz = txtbz.Text; //todo:系统的配置年度设置 fees.year = toolStripComboBox1.SelectedItem.ToString().Trim(); //判断 switch (jkfs) { case "现金": //判断是新增还是修改 if (btnSave.Text == "保存") { BKDataSet.FeesRow fr = mf.DS.Fees.AddFeesRow(fees.unitid, fees.paykind, fees.plantprrice, fees.tureprice, fees.drawee, fees.draweetel, fees.payee, fees.paytime, fees.flay, fees.bz, fees.year, "", "", "", DateTime.Now, null, null, ""); int zed = mf.feesTap.Update(mf.DS.Fees); if (zed > 0) { MessageBox.Show("已保存!"); } if (combJKDW.SelectedIndex < combJKDW.Items.Count - 1) { combJKDW.SelectedIndex = combJKDW.SelectedIndex + 1; } } if (btnSave.Text == "修改") { int id = (from p in mf.DS.Fees.AsEnumerable() orderby p.id descending where p.unitid == un.unitid && p.flag == "完成" && p.year == toolStripComboBox1.SelectedItem.ToString().Trim() select p.id).SingleOrDefault(); BKDataSet.FeesRow fr = mf.DS.Fees.FindByid(id); fr.tureprice = double.Parse(txtTruePrice.Text.Trim()); fr.drawee = txtDrawee.Text; fr.draweetel = txtDraweeTel.Text; fr.paykind = jkfs; fr.payee = combSKR.SelectedItem.ToString(); fr.year = toolStripComboBox1.SelectedItem.ToString().Trim(); fr.flag = flag; fr.bz = txtbz.Text; fr.paytime = dateTimePicker1.Value; int zed = mf.feesTap.Update(mf.DS.Fees); if (zed > 0) { MessageBox.Show("已修改!"); } if (combJKDW.SelectedIndex < combJKDW.Items.Count - 1) { combJKDW.SelectedIndex = combJKDW.SelectedIndex + 1; } } break; case "支票": //判断是新增还是修改 if (btnSave.Text == "保存") { string checkkind = (rabMoney.Checked == true) ? "现金支票" : "转账支票"; BKDataSet.FeesRow fr = mf.DS.Fees.AddFeesRow(fees.unitid, fees.paykind, fees.plantprrice, fees.tureprice, fees.drawee, fees.draweetel, fees.payee, fees.paytime, fees.flay, fees.bz, fees.year, checkkind, combBank.Text, txtSbgetMoeny.Text, DateTime.Now, byteZhiPiaoA, byteZhiPiaoB, ""); int zed = mf.feesTap.Update(mf.DS.Fees); if (zed > 0) { MessageBox.Show("已保存!"); } if (combJKDW.SelectedIndex < combJKDW.Items.Count - 1) { combJKDW.SelectedIndex = combJKDW.SelectedIndex + 1; } } if (btnSave.Text == "修改") { int id = (from p in mf.DS.Fees.AsEnumerable() orderby p.id descending where p.unitid == un.unitid && p.flag == "完成" && p.year == toolStripComboBox1.SelectedItem.ToString().Trim() select p.id).SingleOrDefault(); BKDataSet.FeesRow fr = mf.DS.Fees.FindByid(id); fr.tureprice = double.Parse(txtTruePrice.Text.Trim()); fr.drawee = txtDrawee.Text; fr.draweetel = txtDraweeTel.Text; fr.paykind = jkfs; fr.payee = combSKR.SelectedItem.ToString(); fr.year = toolStripComboBox1.SelectedItem.ToString().Trim(); fr.flag = flag; fr.bz = txtbz.Text; fr.getpaytime = dateTimePickerMoney.Value; fr.getpaysb = txtSbgetMoeny.Text; fr.bank = combBank.Text; int zed = mf.feesTap.Update(mf.DS.Fees); if (zed > 0) { MessageBox.Show("已修改!"); } if (combJKDW.SelectedIndex < combJKDW.Items.Count - 1) { combJKDW.SelectedIndex = combJKDW.SelectedIndex + 1; } } break; case "汇款": //判断是新增还是修改 if (btnSave.Text == "保存") { BKDataSet.FeesRow fr = mf.DS.Fees.AddFeesRow(fees.unitid, fees.paykind, fees.plantprrice, fees.tureprice, fees.drawee, fees.draweetel, fees.payee, fees.paytime, fees.flay, fees.bz, fees.year, "", "", "", DateTime.Now, byteHuiKuanA, byteHuiKuanB, txtPayAccount.Text); int zed = mf.feesTap.Update(mf.DS.Fees); if (zed > 0) { MessageBox.Show("已保存!"); } if (combJKDW.SelectedIndex < combJKDW.Items.Count - 1) { combJKDW.SelectedIndex = combJKDW.SelectedIndex + 1; } } if (btnSave.Text == "修改") { int id = (from p in mf.DS.Fees.AsEnumerable() orderby p.id descending where p.unitid == un.unitid && p.flag == "完成" && p.year == toolStripComboBox1.SelectedItem.ToString().Trim() select p.id).SingleOrDefault(); BKDataSet.FeesRow fr = mf.DS.Fees.FindByid(id); fr.tureprice = double.Parse(txtTruePrice.Text.Trim()); fr.drawee = txtDrawee.Text; fr.draweetel = txtDraweeTel.Text; fr.paykind = jkfs; fr.payee = combSKR.SelectedItem.ToString(); fr.year = toolStripComboBox1.SelectedItem.ToString().Trim(); fr.flag = flag; fr.bz = txtbz.Text; fr.paytime = dateTimePicker1.Value; fr.getpaytime = dateTimePicker5.Value; fr.getpayaccount = txtPayAccount.Text; int zed = mf.feesTap.Update(mf.DS.Fees); if (zed > 0) { MessageBox.Show("已修改!"); } if (combJKDW.SelectedIndex < combJKDW.Items.Count - 1) { combJKDW.SelectedIndex = combJKDW.SelectedIndex + 1; } } break; case "欠条": //判断是新增还是修改 if (btnSave.Text == "保存") { BKDataSet.FeesRow fr = mf.DS.Fees.AddFeesRow(fees.unitid, fees.paykind, fees.plantprrice, fees.tureprice, fees.drawee, fees.draweetel, fees.payee, fees.paytime, fees.flay, fees.bz, fees.year, "", "", "", DateTime.Now, null, null, ""); int zed = mf.feesTap.Update(mf.DS.Fees); if (zed > 0) { MessageBox.Show("已保存!"); } if (combJKDW.SelectedIndex < combJKDW.Items.Count - 1) { combJKDW.SelectedIndex = combJKDW.SelectedIndex + 1; } } if (btnSave.Text == "修改") { int id = (from p in mf.DS.Fees.AsEnumerable() orderby p.id descending where p.unitid == un.unitid && p.year == toolStripComboBox1.SelectedItem.ToString().Trim() select p.id).SingleOrDefault(); BKDataSet.FeesRow fr = mf.DS.Fees.FindByid(id); fr.tureprice = double.Parse(txtTruePrice.Text.Trim()); fr.drawee = txtDrawee.Text; fr.draweetel = txtDraweeTel.Text; fr.paykind = jkfs; fr.payee = combSKR.SelectedItem.ToString(); fr.year = toolStripComboBox1.SelectedItem.ToString().Trim(); fr.flag = flag; fr.bz = txtbz.Text; fr.paytime = dateTimePicker1.Value; int zed = mf.feesTap.Update(mf.DS.Fees); if (zed > 0) { MessageBox.Show("已修改!"); } if (combJKDW.SelectedIndex < combJKDW.Items.Count - 1) { combJKDW.SelectedIndex = combJKDW.SelectedIndex + 1; } } break; } } //保存实际订刊数 private void SaveTruePaperNumb() { for (int i = 0; i < listView1.Items.Count; i++) { int u = Int32.Parse(listView1.Items[i].Tag.ToString()); BKDataSet.UnitPaperTaskRow rw = mf.DS.UnitPaperTask.FindByid(u); string j = listView1.Items[i].SubItems[2].Text.Trim(); // rw.truenum = Int32.Parse(j); } mf.unitpapertaskTap.Update(mf.DS.UnitPaperTask); } //大写金额 private void txtTotalMoney_TextChanged(object sender, EventArgs e) { labRMB.Text = "人民币(大写):"; if (txtTruePrice.Text != "") { labRMB.Text += RMBCapitalization.RMBAmount(double.Parse(txtTruePrice.Text)); } } //清除文本 private static void clearTXT(BKDataSet.FeesRow fr) { fr.unitid = ""; fr.plantprice = 0; fr.tureprice = 0; fr.drawee = ""; fr.draweetel = ""; fr.paykind = ""; fr.paytime = DateTime.Now; fr.payee = ""; fr.bank = ""; fr.getpayaccount = ""; fr.getpaysb = ""; fr.getpaytime = DateTime.Now; fr.year = ""; fr.flag = ""; fr.bz = ""; } //交款实际金额变动 private void txtTruePrice_TextChanged(object sender, EventArgs e) { if (!System.Text.RegularExpressions.Regex.IsMatch(txtTruePrice.Text, @"^([0-9]*)\.?[0-9]*$")) { MessageBox.Show("请输入正确的金额!"); return; } // double caizhi = Convert.ToDouble(txtTotalMoney.Text.Trim()) - Convert.ToDouble(txtTruePrice.Text.Trim()); //if (caizhi > 0) //{ // labCaZhi.Text = "少收金额:"; // txtChazhi.Text = caizhi.ToString("0.00"); //} //else //{ // labCaZhi.Text = "多收金额:"; // txtChazhi.Text = (-caizhi).ToString("0.00"); //} loadPrintText(); } //交款方式 private void combSKFS_SelectedIndexChanged(object sender, EventArgs e) { jkfs = combSKFS.SelectedItem.ToString().Trim(); for (int i = 0; i < tabControl1.TabPages.Count; i++) { if (tabControl1.TabPages[i].Text == jkfs) { tabControl1.SelectedTab = tabControl1.TabPages[i]; if (tabControl1.SelectedTab.Text == "欠条") { loadPrintText(); } } } } //支票正面图片 private void pictureBox1_DoubleClick(object sender, EventArgs e) { if (DialogResult.OK == openFileDialog1.ShowDialog()) { try { // 读成二进制 byteZhiPiaoA = File.ReadAllBytes(openFileDialog1.FileName); // 直接返这个存储到数据就行了 cmd.Parameters.Add("@image", SqlDbType.Image).Value = http://www.mamicode.com/bytes;>// 输出二进制 在这里把数据中取到的值放在这里byte[] bytes=(byte[])model.image; pictureBox1.Image = System.Drawing.Image.FromStream(new MemoryStream(byteZhiPiaoA)); this.pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; // 如果保存成文件:File.WriteAllBytes(@"d:\text.jpg", bytes); } catch { } } } //支票反面图片 private void pictureBox2_DoubleClick(object sender, EventArgs e) { //经过实践,我们可以通过FileStream 来打开文件,这样就可以实现不锁定Image文件,到时可以让多用户同时访问Image文件。具体文件实现如下: //FileStream fs = File.OpenRead(Path); //OpenRead //int filelength = 0; //filelength = (int)fs.Length; //获得文件长度 //Byte[] image = new Byte[filelength]; //建立一个字节数组 //fs.Read(image, 0, filelength); //按字节流读取 //System.Drawing.Image result = System.Drawing.Image.FromStream(fs); //fs.Close(); if (DialogResult.OK == openFileDialog1.ShowDialog()) { try { // 读成二进制 byteZhiPiaoB = File.ReadAllBytes(openFileDialog1.FileName); // 直接返这个存储到数据就行了 cmd.Parameters.Add("@image", SqlDbType.Image).Value = http://www.mamicode.com/bytes;>// 输出二进制 在这里把数据中取到的值放在这里byte[] bytes=(byte[])model.image; pictureBox2.Image = System.Drawing.Image.FromStream(new MemoryStream(byteZhiPiaoB)); this.pictureBox2.SizeMode = PictureBoxSizeMode.Zoom; // 如果保存成文件:File.WriteAllBytes(@"d:\text.jpg", bytes); } catch { } } } //欠条图片 private void pictureBox3_DoubleClick(object sender, EventArgs e) { if (DialogResult.OK == openFileDialog1.ShowDialog()) { try { // 读成二进制 byteQianTiaoA = File.ReadAllBytes(openFileDialog1.FileName); // 直接返这个存储到数据就行了 cmd.Parameters.Add("@image", SqlDbType.Image).Value = http://www.mamicode.com/bytes;>// 输出二进制 在这里把数据中取到的值放在这里byte[] bytes=(byte[])model.image; pictureBox3.Image = System.Drawing.Image.FromStream(new MemoryStream(byteQianTiaoA)); this.pictureBox3.SizeMode = PictureBoxSizeMode.Zoom; // 如果保存成文件:File.WriteAllBytes(@"d:\text.jpg", bytes); } catch { } } } //汇款正面 private void pictureBox5_DoubleClick(object sender, EventArgs e) { if (DialogResult.OK == openFileDialog1.ShowDialog()) { try { // 读成二进制 byteHuiKuanA = File.ReadAllBytes(openFileDialog1.FileName); // 直接返这个存储到数据就行了 cmd.Parameters.Add("@image", SqlDbType.Image).Value = http://www.mamicode.com/bytes;>// 输出二进制 在这里把数据中取到的值放在这里byte[] bytes=(byte[])model.image; pictureBox5.Image = System.Drawing.Image.FromStream(new MemoryStream(byteHuiKuanA)); this.pictureBox5.SizeMode = PictureBoxSizeMode.Zoom; // 如果保存成文件:File.WriteAllBytes(@"d:\text.jpg", bytes); } catch { } } } //汇款反面 private void pictureBox6_DoubleClick(object sender, EventArgs e) { if (DialogResult.OK == openFileDialog1.ShowDialog()) { try { // 读成二进制 byteHuiKuanB = File.ReadAllBytes(openFileDialog1.FileName); // 直接返这个存储到数据就行了 cmd.Parameters.Add("@image", SqlDbType.Image).Value = http://www.mamicode.com/bytes;>// 输出二进制 在这里把数据中取到的值放在这里byte[] bytes=(byte[])model.image; pictureBox6.Image = System.Drawing.Image.FromStream(new MemoryStream(byteHuiKuanB)); this.pictureBox6.SizeMode = PictureBoxSizeMode.Zoom; // 如果保存成文件:File.WriteAllBytes(@"d:\text.jpg", bytes); } catch { } } } private void tsbEdit_Click(object sender, EventArgs e) { if (txtDrawee.Enabled == txtDraweeTel.Enabled == txtTruePrice.Enabled == combSKR.Enabled == btnSave.Enabled == dateTimePicker1.Enabled == btnEdit.Enabled == false) { txtDrawee.Enabled = txtDraweeTel.Enabled = txtTruePrice.Enabled = combSKR.Enabled = btnSave.Enabled = dateTimePicker1.Enabled = btnEdit.Enabled = true; btnSave.Text = "修改"; } else { txtDrawee.Enabled = txtDraweeTel.Enabled = txtTruePrice.Enabled = combSKR.Enabled = btnSave.Enabled = dateTimePicker1.Enabled = btnEdit.Enabled = false; btnSave.Text = "保存"; } } private void rabOver_CheckedChanged(object sender, EventArgs e) { BtnSaveEnabled(); } private void BtnSaveEnabled() { if (rabOver.Checked || rabPat.Checked) { btnSave.Enabled = true; } else { btnSave.Enabled = false; } } private void rabPat_CheckedChanged(object sender, EventArgs e) { BtnSaveEnabled(); } private void btnUp_Click(object sender, EventArgs e) { if (txtTruePrice.Text != "") { if (btnUp.Text == "↑") { trueprice = double.Parse(txtTotalMoney.Text.Trim()); txtTruePrice.Text = Math.Ceiling(trueprice).ToString("0"); btnUp.Text = "↓"; } else { trueprice = double.Parse(txtTotalMoney.Text.Trim()); txtTruePrice.Text = Math.Floor(trueprice).ToString("0"); btnUp.Text = "↑"; } } } #region 功能区 #region 打印内容设置 #region 欠条 private void loadPrintText() { Unit u = combJKDW.SelectedItem as Unit; rtbDoc.Font = new Font("仿宋", 16, FontStyle.Regular); rtbDoc.Text = " 欠 条" + "\n"; rtbDoc.Text += "\n"; //rtbDoc.Text += " 今欠宣传部" + mf.configbk.YEAR + "年度,党报党刊款(小写):¥" + txtTruePrice.Text + "元。\n" + "大写人民币:" + RMBCapitalization.RMBAmount(double.Parse(txtTruePrice.Text)) + "。"; rtbDoc.Text += "\n\n"; rtbDoc.Text += "\n 欠款单位:" + u.allname; rtbDoc.Text += "\n 打欠条人:" + " "; rtbDoc.Text += "\n 电 话:" + txtDraweeTel.Text; rtbDoc.Text += "\n 日 期:" + System.DateTime.Now.ToString("yyyy年MM月dd日"); } #endregion #region 批复 private void getPiFu() { Unit u = combJKDW.SelectedItem as Unit; rtbDoc.Font = new Font("仿宋", 16, FontStyle.Regular); //todo:编号设置 rtbDocPF.Font = new Font("仿宋", 16, FontStyle.Regular); rtbDocPF.Text = "第 号" + "\n"; rtbDocPF.Text += "\n"; //rtbDocPF.Text += " 关于提取" + mf.configbk.YEAR + "年度重点党报党刊征订奖金的批复"; rtbDocPF.Text += "\n"; rtbDocPF.Text += "\n"; rtbDocPF.Text += u.allname + ":"; rtbDocPF.Text += "\n"; rtbDocPF.Text += "\n"; //rtbDocPF.Text += " 经研究同意,对按时完成" + mf.configbk.YEAR + "年度重点党报党刊征订任务的单位给予奖励,奖金为报款总额的10%,资金自筹。\n"; //rtbDocPF.Text += " 你单位按要求完成了任务,报款总额为:¥" + txtTotalMoney.Text + "元,大写:" + labRMB.Text.ToString() + ",奖金为" + double.Parse(txtTotalMoney.Text) * .1 + "人民币(大写):" + RMBCapitalization.RMBAmount(double.Parse(txtTotalMoney.Text) * .1) + "。\n"; rtbDocPF.Text += "\n"; rtbDocPF.Text += "\n 中共滦县县委宣传部"; rtbDocPF.Text += "\n"; rtbDocPF.Text += "\n"; rtbDocPF.Text += " " + System.DateTime.Now.ToString("yyyy年MM月dd日"); rtbDocPF.Text += "\n"; rtbDocPF.Text += "…………………………………………………………………………"; rtbDocPF.AppendText("\n"); rtbDocPF.AppendText("第 号" + "\n"); rtbDocPF.AppendText("\n"); //rtbDocPF.AppendText(" 关于提取" + mf.configbk.YEAR + "年度重点党报党刊征订奖金的批复"); rtbDocPF.AppendText("\n"); rtbDocPF.AppendText("\n"); rtbDocPF.AppendText(u.allname + ":"); rtbDocPF.AppendText("\n"); rtbDocPF.AppendText("\n"); //rtbDocPF.AppendText(" 经研究同意,对按时完成" + mf.configbk.YEAR + "年度重点党报党刊征订任务的单位给予奖励,奖金为报款总额的10%,资金自筹。\n"); //rtbDocPF.AppendText(" 你单位按要求完成了任务,报款总额为:¥" + txtTotalMoney.Text + "元,大写:" + labRMB.Text.ToString() + ",奖金为" + double.Parse(txtTotalMoney.Text) * .1 + "人民币(大写):" + RMBCapitalization.RMBAmount(double.Parse(txtTotalMoney.Text) * .1) + "。\n"); rtbDocPF.AppendText("\n"); rtbDocPF.AppendText("\n 中共滦县县委宣传部"); rtbDocPF.AppendText("\n"); rtbDocPF.AppendText("\n"); rtbDocPF.AppendText(" " + System.DateTime.Now.ToString("yyyy年MM月dd日")); rtbDocPF.AppendText("\n"); } #endregion #endregion #region Printing private int checkPrint; private void PrintDocument1_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e) { checkPrint = 0; } private void PrintDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { if (tabControl1.SelectedTab.Text == "欠条") { checkPrint = rtbDoc.Print(checkPrint, rtbDoc.TextLength, e); if (checkPrint < rtbDoc.TextLength) { e.HasMorePages = true; } else { e.HasMorePages = false; } } if (tabControl1.SelectedTab.Text == "批复") { checkPrint = rtbDocPF.Print(checkPrint, rtbDocPF.TextLength, e); if (checkPrint < rtbDocPF.TextLength) { e.HasMorePages = true; } else { e.HasMorePages = false; } } } private void tsbtnPrintSetup_Click(object sender, EventArgs e) { this.pageSetupDialog1.ShowDialog(); } private void tsbtnPrintView_Click(object sender, EventArgs e) { this.printPreviewDialog1.ShowDialog(); } private void tsbtnPrint_Click(object sender, EventArgs e) { if (this.printDialog1.ShowDialog() == DialogResult.OK) { this.printDocument1.Print(); } } #endregion #region 文字编辑设置 private void tsbtnLeft_Click(object sender, EventArgs e) { if (tabControl1.SelectedTab.Text == "欠条") { if (this.rtbDoc.SelectionAlignment == HorizontalAlignment.Left) this.rtbDoc.SelectionAlignment = HorizontalAlignment.Center; else this.rtbDoc.SelectionAlignment = HorizontalAlignment.Left; this.rtbDoc.Focus(); } if (tabControl1.SelectedTab.Text == "批复") { if (this.rtbDocPF.SelectionAlignment == HorizontalAlignment.Left) this.rtbDocPF.SelectionAlignment = HorizontalAlignment.Center; else this.rtbDocPF.SelectionAlignment = HorizontalAlignment.Left; this.rtbDocPF.Focus(); } } private void tsbtnCenter_Click(object sender, EventArgs e) { if (tabControl1.SelectedTab.Text == "欠条") { if (this.rtbDoc.SelectionAlignment == HorizontalAlignment.Center) this.rtbDoc.SelectionAlignment = HorizontalAlignment.Left; else this.rtbDoc.SelectionAlignment = HorizontalAlignment.Center; this.rtbDoc.Focus(); } if (tabControl1.SelectedTab.Text == "批复") { if (this.rtbDocPF.SelectionAlignment == HorizontalAlignment.Center) this.rtbDocPF.SelectionAlignment = HorizontalAlignment.Left; else this.rtbDocPF.SelectionAlignment = HorizontalAlignment.Center; this.rtbDocPF.Focus(); } } private void tsbtnRight_Click(object sender, EventArgs e) { if (tabControl1.SelectedTab.Text == "欠条") { if (this.rtbDoc.SelectionAlignment == HorizontalAlignment.Right) this.rtbDoc.SelectionAlignment = HorizontalAlignment.Left; else this.rtbDoc.SelectionAlignment = HorizontalAlignment.Right; this.rtbDoc.Focus(); } if (tabControl1.SelectedTab.Text == "批复") { if (this.rtbDocPF.SelectionAlignment == HorizontalAlignment.Right) this.rtbDocPF.SelectionAlignment = HorizontalAlignment.Left; else this.rtbDocPF.SelectionAlignment = HorizontalAlignment.Right; this.rtbDocPF.Focus(); } } private void tsbtnUnderline_Click(object sender, EventArgs e) { if (tabControl1.SelectedTab.Text == "欠条") { Font oldFont = this.rtbDoc.SelectionFont; Font newFont; if (oldFont.Underline) newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Underline); else newFont = new Font(oldFont, oldFont.Style | FontStyle.Underline); this.rtbDoc.SelectionFont = newFont; this.rtbDoc.Focus(); } if (tabControl1.SelectedTab.Text == "批复") { Font oldFont = this.rtbDocPF.SelectionFont; Font newFont; if (oldFont.Underline) newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Underline); else newFont = new Font(oldFont, oldFont.Style | FontStyle.Underline); this.rtbDocPF.SelectionFont = newFont; this.rtbDocPF.Focus(); } } private void tsbtnBold_Click(object sender, EventArgs e) { if (tabControl1.SelectedTab.Text == "欠条") { Font oldFont = this.rtbDoc.SelectionFont; Font newFont; if (oldFont.Bold) newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Bold); else newFont = new Font(oldFont, oldFont.Style | FontStyle.Bold); this.rtbDoc.SelectionFont = newFont; this.rtbDoc.Focus(); } if (tabControl1.SelectedTab.Text == "批复") { Font oldFont = this.rtbDocPF.SelectionFont; Font newFont; if (oldFont.Bold) newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Bold); else newFont = new Font(oldFont, oldFont.Style | FontStyle.Bold); this.rtbDocPF.SelectionFont = newFont; this.rtbDocPF.Focus(); } } private void tsbtnFont_Click(object sender, EventArgs e) { if (tabControl1.SelectedTab.Text == "欠条") { try { if (!(rtbDoc.SelectionFont == null)) { fontDialog1.Font = rtbDoc.SelectionFont; } else { fontDialog1.Font = null; } fontDialog1.ShowApply = true; if (fontDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { rtbDoc.SelectionFont = fontDialog1.Font; } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Error"); } } if (tabControl1.SelectedTab.Text == "批复") { try { if (!(rtbDocPF.SelectionFont == null)) { fontDialog1.Font = rtbDocPF.SelectionFont; } else { fontDialog1.Font = null; } fontDialog1.ShowApply = true; if (fontDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { rtbDocPF.SelectionFont = fontDialog1.Font; } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Error"); } } } #endregion #endregion }}
交款功能代码
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。