Exemplo n.º 1
0
        private void sb_ok_Click(object sender, EventArgs e)
        {
            if (!gridView1.PostEditor())
            {
                return;
            }
            if (!gridView1.UpdateCurrentRow())
            {
                return;
            }
            if (!SaveCheck())
            {
                return;                            //数据合法性校验!!!
            }
            string s_billno = string.Empty;

            //0.再次判断寄存号位 是否占用
            if (RegAction.GetBitStatus(regionId, i_bi005, bitDesc) != "9")
            {
                XtraMessageBox.Show("当前号位无效或已被占用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            //1.生成寄存记录
            int i_months = Convert.ToInt32(comboBox1.Text);

            rc01 = new RC01(unitOfWork1);
            if (s_source == "1" /*外来寄存*/)
            {
                rc01.RC001 = MiscAction.GetEntityPK("RC01");
            }
            else if (s_source == "0" || s_source == "8")
            {
                rc01.RC001 = txtEdit_rc001.Text;
            }

            rc01.RC002 = rg_rc002.EditValue.ToString();              //逝者性别
            rc01.RC202 = rg_rc202.EditValue.ToString();              //逝者性别2
            rc01.RC003 = txtEdit_rc003.Text;                         //逝者姓名
            rc01.RC303 = txtEdit_rc303.Text;                         //逝者姓名2
            rc01.RC004 = Convert.ToInt32(txtEdit_rc004.EditValue);   //逝者年龄
            rc01.RC404 = txtEdit_rc404.EditValue == null ? 0 : Convert.ToInt32(txtEdit_rc404.EditValue);
            rc01.RC014 = txtedit_rc014.Text;                         //身份证号
            rc01.RC050 = txtEdit_rc050.Text;                         //联系人
            rc01.RC051 = txtEdit_rc051.Text;                         //联系电话
            rc01.RC052 = lookUp_rc052.EditValue.ToString();          //与逝者关系
            rc01.RC055 = txtEdit_ac055.Text;                         //联系地址
            rc01.RC099 = mem_rc099.Text;                             //备注
            rc01.RC109 = RegAction.GenRegisterNo(s_source == "2" ? "1" : "0");

            if (s_source == "0" || s_source == "8")
            {
                rc01.SOURCE = "0";                                       //本馆火化
            }
            else if (s_source == "1")
            {
                rc01.SOURCE = "1";
            }

            //状态
            if (s_source == "8")
            {
                rc01.STATUS = "8";
            }
            else
            {
                rc01.STATUS = "1";
            }

            rc01.RC110 = RegAction.GetRoomIdByBitId(bitId);               //寄存室编号
            rc01.RC120 = regionId;                                        //寄存架号
            rc01.RC130 = bitId;                                           //寄存号位
            rc01.RC140 = MiscAction.GetServerTime();                      //寄存日期
            rc01.RC150 = rc01.RC140.AddMonths(i_months);                  //寄存到期日期
            rc01.RC100 = Envior.cur_user.UC001;                           //经办人
            rc01.RC200 = MiscAction.GetServerTime();


            ///2.寄存费缴费记录表
            string s_fa001 = MiscAction.GetEntityPK("FA01");

            if (s_source == "0" || s_source == "1")              //本馆火化 或外来寄存
            {
                RC04 rc04 = new RC04(unitOfWork1);
                rc04.RC001  = rc01.RC001;
                rc04.RC010  = s_fa001;                                      //结算流水号
                rc04.RC020  = MiscAction.GetServerTime();                   //缴费开始时间
                rc04.RC022  = rc01.RC150;                                   //缴费截至时间
                rc04.PRICE  = bitPrice;                                     //单价
                rc04.NUMS   = Convert.ToInt32(comboBox1.Text);              //缴费期限
                rc04.RC030  = rc04.PRICE * rc04.NUMS;                       //寄存费金额
                rc04.RC031  = "1";                                          //0-原始登记 1-正常交费
                rc04.RC100  = Envior.cur_user.UC001;                        //经办人
                rc04.RC200  = MiscAction.GetServerTime();
                rc04.STATUS = "1";
            }

            ///3.插入销售表
            SA01 sa01 = new SA01(unitOfWork1);

            sa01.SA001  = MiscAction.GetEntityPK("SA01");
            sa01.SA002  = "08";                    //项目类别 08-寄存费
            sa01.AC001  = rc01.RC001;              //逝者编号
            sa01.SA003  = "寄存费";
            sa01.SA004  = bitId;
            sa01.SA005  = "2";                     //销售业务类型 2-骨灰寄存
            sa01.PRICE  = bitPrice;
            sa01.NUMS   = Convert.ToInt32(comboBox1.Text);
            sa01.SA007  = sa01.PRICE * sa01.NUMS;
            sa01.SA006  = bitPrice;
            sa01.SA008  = s_source == "8" ? "0" : "1";
            sa01.SA010  = s_source == "8" ? "" : s_fa001;
            sa01.SA100  = Envior.cur_user.UC001;                    //经办人
            sa01.SA200  = MiscAction.GetServerTime();
            sa01.STATUS = "1";

            ///4.处理附件销售.
            foreach (SA01 s in xpCollection_sa01)
            {
                s.SA001  = MiscAction.GetEntityPK("SA01");
                s.SA002  = "13";
                s.AC001  = rc01.RC001;
                s.SA003  = FireAction.Mapper_Item(s.SA004);
                s.SA005  = "2";                                              // 销售类别 0 - 火化业务 1 - 临时性销售 2骨灰寄存
                s.SA008  = s_source == "8" ? "0" : "1";
                s.SA010  = s_source == "8" ? "" : s_fa001;
                s.SA100  = Envior.cur_user.UC001;                        //经办人
                s.SA200  = MiscAction.GetServerTime();
                s.STATUS = "1";
            }

            ////5. 处理财务结算表
            if (s_source == "0" || s_source == "1")
            {
                FA01 fa01 = new FA01(unitOfWork1);
                fa01.FA001  = s_fa001;
                fa01.FA002  = "2";                            //收费业务类型 2-寄存
                fa01.FA003  = rc01.RC003;
                fa01.FA004  = regfee + fpfee;
                fa01.FA100  = Envior.cur_user.UC001;
                fa01.FA200  = MiscAction.GetServerTime();
                fa01.FA099  = s_billno;
                fa01.WS001  = Envior.workstationId;
                fa01.AC001  = rc01.RC001;
                fa01.STATUS = "1";
            }
            ////6. 处理号位表
            BI01 bi01 = unitOfWork1.GetObjectByKey <BI01>(bitId);

            bi01.BI010 = rc01.RC001;
            if (s_source == "0" || s_source == "1")
            {
                bi01.STATUS = "1";
            }
            else if (s_source == "8")
            {
                bi01.STATUS = "8";
            }

            try
            {
                unitOfWork1.CommitChanges();
                string s_tip = string.Empty;
                if (s_source == "0" || s_source == "1")
                {
                    s_tip = "办理成功,现在打印【收据】";
                }
                else
                {
                    s_tip = "办理成功!";
                }

                XtraMessageBox.Show(s_tip, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ////打印收据
                if (s_source == "0" || s_source == "1")
                {
                    //Frm_InputBill frm_bill = new Frm_InputBill();
                    //if (frm_bill.ShowDialog() == DialogResult.OK)
                    //{
                    //	s_billno = frm_bill.swapdata["billno"].ToString();
                    //}
                    //frm_bill.Dispose();
                    //if (!string.IsNullOrEmpty(s_billno))
                    //{
                    PrintAction.Print_Skpz1(s_fa001);
                    //MiscAction.SetFinanceBill(s_fa001, s_billno);
                    //}
                }

                ////todo 2.打印寄存证
                if (s_source == "0" || s_source == "1" || s_source == "2")
                {
                    XtraMessageBox.Show("现在准备打印【寄存证】!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    PrintAction.Print_RegCardBase(rc01.RC001);
                }
                if (XtraMessageBox.Show("现在打印【骨灰安放卡】吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    PrintAction.Print_RegSettle(rc01.RC001);
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ee)
            {
                unitOfWork1.RollbackTransaction();
                LogUtils.Error(ee.Message);
                XtraMessageBox.Show(ee.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }