Example #1
0
        //冲账和取消冲账
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            if (base.zy_PatList == null || base.zy_PatList.PatType.Trim() == "3" || base.zy_PatList.PatType.Trim() == "4" || base.zy_PatList.PatType.Trim() == "5")
            {
                MessageBox.Show("已出院病人,不能再冲帐操作!");
                return;
            }
            if (this.dgFee.DataSource != null && ((DataTable)this.dgFee.DataSource).Rows.Count > 0)
            {
                DataTable tb = ((DataTable)this.dgFee.DataSource).DefaultView.ToTable();
                for (int i = 0; i < ((DataTable)this.dgFee.DataSource).Rows.Count; i++)
                {
                    if ((bool)this.dgFee[0, i].Value)
                    {
                        ZY_PresOrder zypresorder = new ZY_PresOrder();
                        zypresorder = (ZY_PresOrder)HIS.SYSTEM.PubicBaseClasses.ApiFunction.DataTableToObject(tb, i, zypresorder);
                        //取消冲账记录和已结算的记录都不能操作
                        if (zypresorder.Record_Flag == 2 || zypresorder.Cost_Flag == 1)
                        {
                            continue;
                        }
                        //[20100514.1.03]
                        if (currentDept.DeptID.ToString() != zypresorder.PresDeptCode)
                        {
                            MessageBox.Show("不是本科室记的账不允许操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            continue;
                        }
                        //取消冲账
                        if (zypresorder.OldID != 0)
                        {
                            if (MessageBox.Show("确定要对[" + this.dgFee[3, i].Value.ToString() + "]取消冲账吗?", "询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                            {
                                int presorderid = zypresorder.PresOrderID;

                                zypresorder.PresOrderID = 0;
                                zypresorder.Amount      = Convert.ToDecimal(0 - zypresorder.Amount);
                                zypresorder.Tolal_Fee   = Convert.ToDecimal(0 - zypresorder.Tolal_Fee);

                                int index = zypresorder.ItemName.IndexOf(" [");
                                if (index != -1)
                                {
                                    zypresorder.ItemName = zypresorder.ItemName.Substring(0, index);
                                }
                                //if (//zypresorder.PresType.Trim() == "3" ||
                                //    Convert.ToInt32(zypresorder.PresType) >= 4)
                                //{
                                //    zypresorder.Drug_Flag = 1;
                                //}
                                //else
                                //{
                                //    zypresorder.Drug_Flag = 0;
                                //}
                                zypresorder.Record_Flag = 2;
                                zypresorder.OldID       = presorderid;
                                zypresorder.PassID      = 0;
                                zypresorder.CostDate    = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime;
                                zyPresOrder.BackPres(presorderid, zypresorder);
                                MessageBox.Show("取消冲账成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else//对原始费用冲账
                        {
                            string value = GWMHIS.BussinessLogicLayer.Forms.DlgInputBoxStatic.InputBox("输入  [" + this.dgFee[3, i].Value.ToString() + "]  冲账的数量", "费用冲账", Convert.ToDecimal(this.dgFee[6, i].Value).ToString(), true);

                            value = Convert.ToDecimal(value).ToString();
                            //this.dgFee[i, 5] = Convert.ToDecimal(this.dgFee[i, 5]) - Convert.ToDecimal(value);
                            if (value != null && value != "0")
                            {
                                decimal Count = Convert.ToDecimal(value);
                                //decimal RCount = Count % Convert.ToDecimal(tb.Rows[i]["RELATIONNUM"]);

                                List <ZY_PresOrder> zy_PresOrderList = new List <ZY_PresOrder>();
                                zypresorder.OldID       = zypresorder.PresOrderID;
                                zypresorder.PresOrderID = 0;
                                zypresorder.Amount      = Convert.ToDecimal(0 - Convert.ToDecimal(value));
                                decimal fee = zyPresOrder.CalculateAllFee(Count, Convert.ToDecimal(tb.Rows[i]["RELATIONNUM"]), Convert.ToDecimal(tb.Rows[i]["Sell_PRICE"]));
                                zypresorder.Tolal_Fee   = Convert.ToDecimal(Convert.ToDecimal(0 - fee).ToString("0.00"));
                                zypresorder.Record_Flag = 1;
                                zypresorder.PassID      = 0;
                                zypresorder.CostDate    = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime;

                                int index = zypresorder.ItemName.IndexOf(" [");
                                if (index != -1)
                                {
                                    zypresorder.ItemName = zypresorder.ItemName.Substring(0, index);
                                }

                                decimal resultfee, arithmetical_compliment;
                                if (zypresorder.CheckBackPres(out resultfee, out arithmetical_compliment))
                                {
                                    if (arithmetical_compliment == 0)
                                    {
                                        zypresorder.Tolal_Fee = resultfee;
                                    }
                                    zy_PresOrderList.Add(zypresorder);
                                    zyPresOrder.BackPres(zy_PresOrderList);
                                    MessageBox.Show("冲账成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                                else
                                {
                                    MessageBox.Show(tb.Rows[i]["ItemName"].ToString() + "冲帐数量过多!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                        }
                    }
                }
                toolbrush_Click(null, null);
                //try
                //{
                //    //农合记账
                //    if (zy_PatList.PatientInfo.ACCOUNTTYPE.Trim() == "农合")
                //    {
                //        if (zy_PatList.PatientInfo.MediCard != null && zy_PatList.PatientInfo.MediCard.Trim() != "")
                //        {
                //            IZY_NccmInterface nccmInterface = NccmFactory.Create();
                //            if (nccmInterface != null)
                //            {
                //                nccmInterface.zy_Patlist = zy_PatList;
                //                DataTable dt = zyPresOrder.GetPresDataTable();
                //                nccmInterface.UploadZYPatFee(nccmInterface.ConvertFeeDetail(dt));
                //            }
                //        }
                //    }
                //}
                //catch (Exception err)
                //{
                //    MessageBox.Show(err.Message);
                //}
            }
        }