private void Btn_Charge_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TOTALCHARGE.Text.Trim()))
            {
                mes.Show("请选择收费项目!");
                return;
            }

            if (CHARGETYPEID.SelectedValue == null || CHARGETYPEID.SelectedValue == DBNull.Value)
            {
                mes.Show("收款方式不能为空!");
                CHARGETYPEID.Focus();
                return;
            }
            else
            {
                if (CHARGETYPEID.SelectedValue.ToString() == "2")
                {
                    if (POSRUNNINGNO.Text.Trim() == "")
                    {
                        mes.Show("请输入POS机收费的交易流水号!");
                        POSRUNNINGNO.Focus();
                        return;
                    }
                }
            }

            if (_BCSS > 0m)
            {
                if (Approve_Finance())
                {
                    mes.Show("收费成功!");
                    BindDepartmentFee();
                    TOTALCHARGE.Text = "";
                    CHARGEBCSS.Text  = "";
                }
            }
            else
            {
                mes.Show("未检测到收费信息!");
            }
        }
예제 #2
0
        private void Btn_Print_Click(object sender, EventArgs e)
        {
            if (RECEIPTNO.Text.Trim() == "")
            {
                mes.Show("请输入收据号!");
                RECEIPTNO.Focus();
                return;
            }
            if (!Information.IsNumeric(RECEIPTNO.Text))
            {
                mes.Show("收据号只能由数字组成!");
                RECEIPTNO.SelectAll();
                return;
            }
            RECEIPTNO.Text = RECEIPTNO.Text.PadLeft(8, '0');
            if (BLLWATERFEECHARGE.IsExistReceiptNO(RECEIPTNO.Text))
            {
                if (mes.ShowQ("系统检测到号码为'" + RECEIPTNO.Text + "'的收据已使用,确定使用此号码吗?") != DialogResult.OK)
                {
                    RECEIPTNO.SelectAll();
                    return;
                }
            }
            if (CHARGETYPEID.SelectedValue == null || CHARGETYPEID.SelectedValue == DBNull.Value)
            {
                mes.Show("收款方式不能为空!");
                CHARGETYPEID.Focus();
                return;
            }
            else
            {
                if (CHARGETYPEID.SelectedValue.ToString() == "2")
                {
                    if (POSRUNNINGNO.Text.Trim() == "")
                    {
                        mes.Show("请输入POS机收费的交易流水号!");
                        POSRUNNINGNO.Focus();
                        return;
                    }
                }
            }

            if (_BCSS > 0m)
            {
                if (Approve_Finance())
                {
                    //===================================ByRen201610170956===================================================打印收据
                    #region
                    FastReport.Report report1 = new FastReport.Report();
                    try
                    {
                        string   strWaterUserName = "", strAddress = "", strFeeName = "";
                        DateTime dtNow     = mes.GetDatetimeNow(); //获取收据打印时间
                        decimal  decDepSum = 0;

                        object objMes = htBaseMes["WATERUSERNAME"];
                        if (objMes != null && objMes != DBNull.Value)
                        {
                            strWaterUserName = objMes.ToString();
                        }

                        objMes = htBaseMes["WATERUSERADDRESS"];
                        if (objMes != null && objMes != DBNull.Value)
                        {
                            strAddress = objMes.ToString();
                        }

                        for (int i = 0; i < dtFeeItems.Rows.Count; i++)
                        {
                            string  strFeeNameSingle = "";
                            decimal decFeeSingle     = 0;

                            object obj = dtFeeItems.Rows[i]["FeeItem"];
                            if (obj != null && obj != DBNull.Value)
                            {
                                strFeeNameSingle = obj.ToString();
                            }

                            obj = dtFeeItems.Rows[i]["Fee"];
                            if (Information.IsNumeric(obj))
                            {
                                decFeeSingle = Convert.ToDecimal(obj);
                            }

                            if (strFeeName == "")
                            {
                                strFeeName = strFeeNameSingle + ":" + decFeeSingle.ToString("F2");
                            }
                            else
                            {
                                strFeeName += "\r\n" + strFeeNameSingle + ":" + decFeeSingle.ToString("F2");
                            }

                            decDepSum += decFeeSingle;
                        }

                        report1.Load(Application.StartupPath + @"\PRINTModel\收据模板\报装预算收据.frx");

                        (report1.FindObject("CellWaterUserName") as FastReport.Table.TableCell).Text    = strWaterUserName;
                        (report1.FindObject("CellWaterUserAddress") as FastReport.Table.TableCell).Text = strAddress;

                        (report1.FindObject("txtBCSS") as FastReport.TextObject).Text             = "本次实收: " + _BCSS.ToString("F2");
                        (report1.FindObject("txtYSZJ") as FastReport.TextObject).Text             = "预算总计: " + _BCSS.ToString("F2");
                        (report1.FindObject("txtFeeDetailSummery") as FastReport.TextObject).Text = strFeeDepartMent + "预算明细: ";
                        (report1.FindObject("txtFeeDetail") as FastReport.TextObject).Text        = strFeeName;

                        (report1.FindObject("txtChargeWorkerName") as FastReport.TextObject).Text = strRealName;
                        (report1.FindObject("txtReceiptNO") as FastReport.TextObject).Text        = "NO." + RECEIPTNO.Text.PadLeft(8, '0');

                        string strCapMoney = RMBToCapMoney.CmycurD(_BCSS.ToString("F2"));
                        if (CHARGETYPEID.SelectedValue.ToString() == "2")
                        {
                            (report1.FindObject("txtCapMoney") as FastReport.TextObject).Text = "金额大写:" + strCapMoney + "   " + "交易流水号:" + POSRUNNINGNO.Text;
                        }
                        else
                        {
                            (report1.FindObject("txtCapMoney") as FastReport.TextObject).Text = "金额大写:" + strCapMoney;
                        }

                        report1.PrintSettings.ShowDialog = false;
                        report1.Prepare();
                        report1.Print();

                        //获取新的收据号码,8位收据号
                        if (Information.IsNumeric(RECEIPTNO.Text))
                        {
                            RECEIPTNO.Text = (Convert.ToInt64(RECEIPTNO.Text) + 1).ToString().PadLeft(8, '0');
                        }
                    }
                    catch (Exception exx)
                    {
                        MessageBox.Show(exx.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        // free resources used by report
                        report1.Dispose();
                    }
                    #endregion
                    //=========================================================================

                    mes.Show("收费成功!");
                    BindDepartmentFee();
                    TOTALCHARGE.Text = "";
                    CHARGEBCSS.Text  = "";
                }
            }
            else
            {
                mes.Show("未检测到收费信息!");
            }
        }