public static UIOutPatient ConvertPatient(OutPatient p) { string name = ""; UIOutPatient pat = new UIOutPatient( ); Age age = new Age( ); age.AgeNum = p.Age; foreach (object obj in Enum.GetValues(typeof(AgeUnit))) { if (obj.ToString( ) == p.HpGrade) { age.Unit = (AgeUnit)obj; break; } } pat.BordDay = XcDate.AgeToDate(age); pat.CardNo = p.HisCardNo; //name = PublicDataReader.GetDeptNameById( Convert.ToInt32( p.CureDeptCode == "" ? "0" : p.CureDeptCode ) ); name = BaseDataController.GetName(BaseDataCatalog.科室列表, Convert.ToInt32(p.CureDeptCode == "" ? "0" : p.CureDeptCode)); pat.CureDepartment = new BindValue(p.CureDeptCode, name); //name = PublicDataReader.GetEmployeeNameById( Convert.ToInt32( p.CureEmpCode == "" ? "0" : p.CureEmpCode ) ); name = BaseDataController.GetName(BaseDataCatalog.人员列表, Convert.ToInt32(p.CureEmpCode == "" ? "0" : p.CureEmpCode)); pat.CureDoctor = new BindValue(p.CureEmpCode, name); pat.Disease = new BindValue(p.DiseaseCode, p.DiseaseName); pat.OutPatientNo = p.VisitNo; pat.PatId = Convert.ToInt32(p.PatID); pat.PatientName = p.PatientName; //pat.PatientType = new BindValue( p.MediType , PublicDataReader.GetPatientTypeNameByCode( p.MediType ) ); pat.PatientType = new BindValue(p.MediType, BaseDataController.GetName(BaseDataCatalog.病人类型列表, p.MediType)); pat.PatListId = p.PatListID; pat.RegDate = p.CureDate; pat.RegDepartment = pat.CureDepartment; pat.Sex = p.Sex; pat.WorkUnit = new BindValue(p.HpCode, GetWorkUnitNameByCode(p.HpCode)); return(pat); }
private void ShowPatientList(List <BasePatient> lstPatient) { dgvPatList.Rows.Clear( ); foreach (BasePatient p in lstPatient) { OutPatient patient = (OutPatient)p; int row = dgvPatList.Rows.Add( ); dgvPatList[COL_PATLISTID.Name, row].Value = patient.PatListID; dgvPatList[COL_VISITNO.Name, row].Value = patient.VisitNo; dgvPatList[COL_PATNAME.Name, row].Value = patient.PatientName; dgvPatList[COL_SEX.Name, row].Value = patient.Sex; dgvPatList[COL_AGE.Name, row].Value = patient.Age; dgvPatList[COL_PATTYPE.Name, row].Value = BaseDataController.GetName(BaseDataCatalog.病人类型列表, patient.MediType.Trim()); //PublicDataReader.GetPatientTypeNameByCode( patient.MediType.Trim()); dgvPatList[COL_DOCTOR.Name, row].Value = BaseDataController.GetName(BaseDataCatalog.人员列表, Convert.ToInt32(patient.CureEmpCode == "" ? "0" : patient.CureEmpCode)); //PublicDataReader.GetEmployeeNameById( Convert.ToInt32( patient.CureEmpCode == "" ? "0" : patient.CureEmpCode ) ); dgvPatList[COL_DEPT.Name, row].Value = BaseDataController.GetName(BaseDataCatalog.科室列表, Convert.ToInt32(patient.CureDeptCode == "" ? "0" : patient.CureDeptCode)); //PublicDataReader.GetDeptNameById( Convert.ToInt32( patient.CureDeptCode == "" ? "0" : patient.CureDeptCode ) ); dgvPatList[COL_CURDATE.Name, row].Value = patient.CureDate; dgvPatList.Rows[row].Tag = patient; } dgvPatList.CurrentCell = null; }
/// <summary> /// 获取挂号统计报表(NAME,DATE,NUM) /// </summary> /// <param name="ViewType">0-按医生 1-按科室</param> /// <param name="beginDate"></param> /// <param name="endDate"></param> /// <returns></returns> private DataSet GetRegisterReport(int ViewType, DateTime beginDate, DateTime endDate) { DataTable tbReg = GetRegisterData(beginDate, endDate); DataTable tbResultByName = new DataTable(); tbResultByName.TableName = "TB_A"; tbResultByName.Columns.Add("CODE", Type.GetType("System.String")); tbResultByName.Columns.Add("NAME", Type.GetType("System.String")); tbResultByName.Columns.Add("NUM", Type.GetType("System.Int32")); tbResultByName.Columns.Add("MONEY", Type.GetType("System.Decimal")); DataTable tbResultByDate = new DataTable(); tbResultByDate.TableName = "TB_B"; tbResultByDate.Columns.Add("DATE", Type.GetType("System.String")); tbResultByDate.Columns.Add("NUM", Type.GetType("System.Int32")); string fileName = ""; if (ViewType == 0) { fileName = "PRESDOCCODE"; } else { fileName = "PRESDEPTCODE"; } for (int i = 0; i < tbReg.Rows.Count; i++) { string code = tbReg.Rows[i][fileName].ToString().Trim(); DataRow[] drs = tbResultByName.Select("CODE='" + code + "'"); if (drs.Length == 0) { DataRow dr = tbResultByName.NewRow(); dr["CODE"] = code; if (ViewType == 0) { dr["NAME"] = code == "" ? "未指定" : BaseDataController.GetName(BaseDataCatalog.人员列表, Convert.ToInt32(code)); //PublicDataReader.GetEmployeeNameById( Convert.ToInt32( code ) ); } else { dr["NAME"] = code == "" ? "未指定" : BaseDataController.GetName(BaseDataCatalog.科室列表, Convert.ToInt32(code)); //PublicDataReader.GetDeptNameById( Convert.ToInt32( code ) ); } dr["NUM"] = tbReg.Rows[i]["REGNUM"]; //dr["MONEY"] = tbReg.Rows[i]["MONEY"]; tbResultByName.Rows.Add(dr); } else { drs[0]["NUM"] = Convert.ToInt32(tbReg.Rows[i]["REGNUM"]) + (Convert.IsDBNull(drs[0]["NUM"]) ? 0 : Convert.ToInt32(drs[0]["NUM"])); //drs[0]["MONEY"] = Convert.ToInt32( tbReg.Rows[i]["REGNUM"] ) + ( Convert.IsDBNull( drs[0]["MONEY"] ) ? 0 : Convert.ToDecimal( drs[0]["MONEY"] ) ); } //日期 drs = tbResultByDate.Select("DATE='" + Convert.ToDateTime(tbReg.Rows[i]["PRESDATE"]).ToString("yyyy-MM-dd") + "'"); if (drs.Length == 0) { DataRow dr = tbResultByDate.NewRow(); dr["DATE"] = Convert.ToDateTime(tbReg.Rows[i]["PRESDATE"]).ToString("yyyy-MM-dd"); dr["NUM"] = tbReg.Rows[i]["REGNUM"]; tbResultByDate.Rows.Add(dr); } else { int num = Convert.IsDBNull(drs[0]["NUM"]) ? 0 : Convert.ToInt32(drs[0]["NUM"]); int num1 = Convert.IsDBNull(tbReg.Rows[i]["REGNUM"]) ? 0 : Convert.ToInt32(tbReg.Rows[i]["REGNUM"]); num = num + num1; drs[0]["NUM"] = num; } } DataSet dsResult = new DataSet(); dsResult.Tables.Add(tbResultByName); dsResult.Tables.Add(tbResultByDate); return(dsResult); }
/// <summary> /// 显示处方 /// </summary> /// <param name="Prescriptions"></param> private void ShowPrescriptions(Prescription[] Prescriptions) { dgvPresc.Rows.Clear( ); for (int i = 0; i < Prescriptions.Length; i++) { Color bkColor = Color.White; if (i % 2 == 0) { bkColor = Color.WhiteSmoke; } decimal presSubTotal = 0; Color forceColor = Color.Blue; if (Prescriptions[i].Record_Flag != 0) { forceColor = Color.Red; } for (int j = 0; j < Prescriptions[i].PresDetails.Length; j++) { dgvPresc.Rows.Add( ); int row = dgvPresc.Rows.Count - 1; dgvPresc["PresID", row].Value = Prescriptions[i].PrescriptionID; if (j == 0) { dgvPresc["NO", row].Value = Convert.ToString(i + 1); //dgvPresc["PresID" , row].Value = Prescriptions[i].PrescriptionID; dgvPresc["InvoiceNo", row].Value = Prescriptions[i].TicketNum; dgvPresc["PatName", row].Value = Prescriptions[i].PatientName; dgvPresc["VisitNo", row].Value = Prescriptions[i].VisitNo; //dgvPresc[DoctorName.Name , row].Value = Prescriptions[i].PresDocCode.Trim( ) == "" ? "" : PublicDataReader.GetEmployeeNameById( Convert.ToInt32( Prescriptions[i].PresDocCode ) ); dgvPresc[DoctorName.Name, row].Value = Prescriptions[i].PresDocCode.Trim() == "" ? "" : BaseDataController.GetName(BaseDataCatalog.人员列表, Convert.ToInt32(Prescriptions[i].PresDocCode)); } dgvPresc["Item_Name", row].Value = Prescriptions[i].PresDetails[j].Itemname; dgvPresc["Standard", row].Value = Prescriptions[i].PresDetails[j].Standard; dgvPresc["Price", row].Value = Prescriptions[i].PresDetails[j].Sell_price; dgvPresc["PACK_Unit", row].Value = Prescriptions[i].PresDetails[j].Unit; if (Prescriptions[i].PresDetails[j].BigitemCode == "01" || Prescriptions[i].PresDetails[j].BigitemCode == "02" || Prescriptions[i].PresDetails[j].BigitemCode == "03") { decimal baseNum = Prescriptions[i].PresDetails[j].Amount % Prescriptions[i].PresDetails[j].RelationNum; decimal packNum = (Prescriptions[i].PresDetails[j].Amount - baseNum) / Prescriptions[i].PresDetails[j].RelationNum; dgvPresc["PACK_NUM", row].Value = packNum; dgvPresc["BASE_NUM", row].Value = baseNum; } else { dgvPresc["PACK_NUM", row].Value = 0; dgvPresc["BASE_NUM", row].Value = Prescriptions[i].PresDetails[j].Amount; } dgvPresc["PresAmount", row].Value = Prescriptions[i].PresDetails[j].PresAmount; dgvPresc["TotalCost", row].Value = Prescriptions[i].PresDetails[j].Tolal_Fee; presSubTotal += Prescriptions[i].PresDetails[j].Tolal_Fee; //if ( Prescriptions[i].Record_Flag == 0 ) //{ if (Prescriptions[i].Charge_Flag != 0) { dgvPresc["RECORD_FLAG", row].Value = "√"; } else { dgvPresc["RECORD_FLAG", row].Value = ""; } //} //else //{ // dgvPresc["RECORD_FLAG", row].Value = ""; //退费的用红字显示 //} if (Prescriptions[i].PresDetails[j].BigitemCode == "01" || Prescriptions[i].PresDetails[j].BigitemCode == "02" || Prescriptions[i].PresDetails[j].BigitemCode == "03") { if (Prescriptions[i].Drug_Flag == 1) { dgvPresc["Drug_Flag", row].Value = "√"; } else { dgvPresc["Drug_Flag", row].Value = ""; } } //颜色 for (int r = 0; r < dgvPresc.Columns.Count; r++) { dgvPresc.Rows[row].Cells[r].Style.ForeColor = forceColor; dgvPresc.Rows[row].Cells[r].Style.BackColor = bkColor; } } //小计 dgvPresc.Rows.Add( ); dgvPresc["Standard", dgvPresc.Rows.Count - 1].Value = "小 计:"; Hashtable htBigItem; decimal roundMoney; //presSubTotal = BaseDataController.CalculatePrescriptionTotalFee( Prescriptions[i] , out htBigItem , out roundMoney ); List <IPresDetail> lstDetail = new List <IPresDetail>(); for (int detailIndex = 0; detailIndex < Prescriptions[i].PresDetails.Length; detailIndex++) { lstDetail.Add(Prescriptions[i].PresDetails[detailIndex]); } presSubTotal = (new PrescMoneyCalculate()).GetPrescriptionTotalMoney(lstDetail, out htBigItem, out roundMoney); dgvPresc["TotalCost", dgvPresc.Rows.Count - 1].Value = Decimal.Round(presSubTotal, 1); for (int m = 0; m < dgvPresc.Columns.Count; m++) { dgvPresc[m, dgvPresc.Rows.Count - 1].Style.ForeColor = forceColor; dgvPresc[m, dgvPresc.Rows.Count - 1].Style.BackColor = bkColor; dgvPresc[m, dgvPresc.Rows.Count - 1].ReadOnly = true; } } }
private void CreateTreeList() { int selectedchargeUserId = 0; if (chkChargeUser.Checked) { selectedchargeUserId = Convert.ToInt32(cboChargeUser.SelectedValue); } tvwAccountList.Nodes.Clear( ); DataTable tbHandIn = AccountBookController.GetAccountList(dtpFrom.Value, dtpTo.Value); TreeNode tdHandIn = new TreeNode( ); tdHandIn.Text = "已交款"; List <PrivyAccountBook> lstAllBooks = new List <PrivyAccountBook>( ); #region 构造交款员树 for (int i = 0; i < tbHandIn.Rows.Count; i++) { int chargeUserId = Convert.ToInt32(tbHandIn.Rows[i]["AccountCode"]); if (chkChargeUser.Checked && chargeUserId != selectedchargeUserId) { continue; } if (tdHandIn.Nodes.Count == 0) { TreeNode ndUser = new TreeNode( ); ndUser.Text = BaseDataController.GetName(BaseDataCatalog.人员列表, chargeUserId); ndUser.Tag = chargeUserId; tdHandIn.Nodes.Add(ndUser); } else { bool hasIntree = false; foreach (TreeNode nd in tdHandIn.Nodes) { if (Convert.ToInt32(nd.Tag) == chargeUserId) { hasIntree = true; break; } } if (!hasIntree) { TreeNode ndUser = new TreeNode( ); ndUser.Text = BaseDataController.GetName(BaseDataCatalog.人员列表, chargeUserId); ndUser.Tag = chargeUserId; tdHandIn.Nodes.Add(ndUser); } } } #endregion #region 生成账单明细,并合并 foreach (TreeNode ndUser in tdHandIn.Nodes) { int chargeUserId = Convert.ToInt32(ndUser.Tag); DataRow[] drsAccount = tbHandIn.Select("ACCOUNTCODE=" + chargeUserId, "ACCOUNTDATE asc"); int[] accountIdList = new int[drsAccount.Length]; for (int i = 0; i < drsAccount.Length; i++) { accountIdList[i] = Convert.ToInt32(drsAccount[i]["ACCOUNTID"]); } DataTable tbInvoice; DataTable tbInvoiceDetail; AccountBookController.GetAccountData(chargeUserId, accountIdList, out tbInvoice, out tbInvoiceDetail); //个人所有账单 List <PrivyAccountBook> lstBook = new List <PrivyAccountBook>( ); for (int i = 0; i < drsAccount.Length; i++) { TreeNode ndDate = new TreeNode( ); ndDate.Text = Convert.ToDateTime(drsAccount[i]["ACCOUNTDATE"]).ToString("yyyy-MM-dd HH:mm:ss"); int accountId = Convert.ToInt32(drsAccount[i]["ACCOUNTID"]); PrivyAccountBook book = AccountBookController.GetPrivyAccountBook(chargeUserId, accountId, tbInvoice, tbInvoiceDetail, tbHandIn); ndDate.Tag = book; ndUser.Nodes.Add(ndDate); lstBook.Add(book); } //PrivyAccountBook totalBook = AccountBookController.CollectPrivyAccountBook( lstBook ); ndUser.Tag = new PrivyAccountBook(); //lstAllBooks.Add( totalBook ); } #endregion tvwAccountList.Nodes.Add(tdHandIn); //CollectAccountBook allBook = AccountBookController.CollectAllAccountBook( lstAllBooks ); tdHandIn.Tag = new PrivyAccountBook(); DataTable tbUnHandIn = AccountBookController.GetNotHandInAccountUser( ); TreeNode ndUnHandIn = new TreeNode( ); List <PrivyAccountBook> lstAllnothandBook = new List <PrivyAccountBook>( ); ndUnHandIn.Text = "未交款"; for (int i = 0; i < tbUnHandIn.Rows.Count; i++) { TreeNode ndUnhandInUser = new TreeNode( ); ndUnhandInUser.Text = tbUnHandIn.Rows[i]["CHARGENAME"].ToString().Trim(); int chargeUserId = Convert.ToInt32(tbUnHandIn.Rows[i]["CHARGECODE"]); if (chkChargeUser.Checked && chargeUserId != selectedchargeUserId) { continue; } //PrivyAccountBook book = AccountBookController.GetPrivyAccountBook( chargeUserId , 0 ); ndUnhandInUser.Tag = new PrivyAccountBook(); ndUnHandIn.Nodes.Add(ndUnhandInUser); // lstAllnothandBook.Add( book ); } tvwAccountList.Nodes.Add(ndUnHandIn); //CollectAccountBook notHandBook = AccountBookController.CollectAllAccountBook( lstAllnothandBook ); ndUnHandIn.Tag = new PrivyAccountBook(); tvwAccountList.ExpandAll( ); }
private void btnStat_Click(object sender, EventArgs e) { SetControlEnable(false); DateTime beginDate; DateTime endDate; BaseReport report = null; string accountIdList; string patTypeCode = ""; int statDay = Convert.ToInt32(txtDay.Text); StatDateType dateType = StatDateType.统计日; OPDBillKind invoiceType = OPDBillKind.所有发票; #region 统计条件 foreach (object obj in Enum.GetValues(typeof(StatDateType))) { if (obj.ToString( ) == cboDateType.Text) { dateType = (StatDateType)obj; break; } } foreach (object obj in Enum.GetValues(typeof(OPDBillKind))) { if (obj.ToString( ) == cboInvoiceType.Text) { invoiceType = (OPDBillKind)obj; break; } } if (chkPatType.Checked) { patTypeCode = cboPatType.SelectedValue.ToString( ); } #endregion ReportController.GetReportBeginDateAndEndDate(dateType, statDay, dtpFrom.Value, dtpEnd.Value, out beginDate, out endDate, out accountIdList); lblDate.Text = beginDate.ToString("yyyy-MM-dd HH:mm:ss") + "--" + endDate.ToString("yyyy-MM-dd HH:mm:ss"); try { report = new PatientFeeReport( ); report.BeginDate = beginDate; report.EndDate = endDate; ((PatientFeeReport)report).PatientTypeCode = patTypeCode; ((PatientFeeReport)report).InvoiceType = invoiceType; ((PatientFeeReport)report).CurDocName = chkCureDoc.Checked ? cboDoc.Text : ""; ((PatientFeeReport)report).CurDeptName = chkDept.Checked ? cboDept.Text : ""; ((PatientFeeReport)report).ChargeName = chkSfy.Checked ? cboCharge.Text : ""; report.StatDateType = dateType; report.AccountIdList = accountIdList; report.ReportTitle = "门诊病人费用统计表"; report.Lister = BaseDataController.GetName(BaseDataCatalog.人员列表, employeeId); //PublicDataReader.GetEmployeeNameById( employeeId ); ReportController.FillReport(report); dgvReport.DataSource = report.DataResult; dgvReport.Tag = report; for (int i = 0; i < dgvReport.Columns.Count; i++) { if (i >= 7) { dgvReport.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgvReport.Columns[i].Width = 80; } if (i < 8) { dgvReport.Columns[i].Frozen = true; } } } catch { MessageBox.Show("统计发生错误!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { SetControlEnable(true); } }
private void btnStat_Click(object sender, EventArgs e) { DateTime beginDate; DateTime endDate; BaseReport report = null; string accountIdList; StatDateType dateType = StatDateType.自定义时间; StatClassType statType = StatClassType.门诊发票分类; ReportStyle style = ReportStyle.科目为标题列; foreach (object obj in Enum.GetValues(typeof(StatClassType))) { if (obj.ToString() == cboStatType.Text) { statType = (StatClassType)obj; break; } } foreach (object obj in Enum.GetValues(typeof(ReportStyle))) { if (obj.ToString() == cboStyle.Text) { style = (ReportStyle)obj; break; } } StatObjctType statObjectType = StatObjctType.收费员; try { Cursor = GWMHIS.BussinessLogicLayer.Classes.PublicStaticFun.WaitCursor(); ReportController.GetReportBeginDateAndEndDate(dateType, 15, dtpFrom.Value, dtpEnd.Value, out beginDate, out endDate, out accountIdList); report = new TollerIncomeReport(); report.BeginDate = dtpFrom.Value; report.EndDate = dtpEnd.Value; report.StatType = statType; report.Reportstyle = style; report.StatDateType = dateType; // report.AccountIdList = accountIdList; report.StatObjectType = statObjectType; report.ReportTitle = "门诊收费员工作量统计报表"; report.Lister = BaseDataController.GetName(BaseDataCatalog.人员列表, currentEmployeeId); ReportController.FillReport(report, dtpFrom.Value, dtpEnd.Value); dgvReport.DataSource = report.DataResult; dgvReport.Tag = report; for (int i = 1; i < dgvReport.Columns.Count; i++) { dgvReport.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgvReport.Columns[i].Width = 80; } dgvReport.Columns[0].Frozen = true; dgvReport.Columns[1].Frozen = true; } catch (OperatorException oe) { MessageBox.Show(oe.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception err) { ErrorWriter.WriteLog(err.Message); MessageBox.Show("统计报表中发生错误!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor = Cursors.Default; } }
private void btnStat_Click(object sender, EventArgs e) { DateTime beginDate; DateTime endDate; BaseReport report = null; string accountIdList; int statDay = Convert.ToInt32(txtDay.Text); StatDateType dateType = StatDateType.统计日; StatClassType statType = StatClassType.门诊发票分类; StatObjctType statObjectType = StatObjctType.医生; ReportStyle style = ReportStyle.科目为标题列; #region 统计条件 foreach (object obj in Enum.GetValues(typeof(StatDateType))) { if (obj.ToString( ) == cboDateType.Text) { dateType = (StatDateType)obj; break; } } foreach (object obj in Enum.GetValues(typeof(StatClassType))) { if (obj.ToString( ) == cboStatType.Text) { statType = (StatClassType)obj; break; } } foreach (object obj in Enum.GetValues(typeof(ReportStyle))) { if (obj.ToString( ) == cboStyle.Text) { style = (ReportStyle)obj; break; } } foreach (object obj in Enum.GetValues(typeof(StatObjctType))) { if (obj.ToString( ) == cboType.Text) { statObjectType = (StatObjctType)obj; break; } } #endregion try { Cursor = GWMHIS.BussinessLogicLayer.Classes.PublicStaticFun.WaitCursor( ); SetButtonEnable(false); ReportController.GetReportBeginDateAndEndDate(dateType, statDay, dtpFrom.Value, dtpEnd.Value, out beginDate, out endDate, out accountIdList); lblDate.Text = beginDate.ToString("yyyy-MM-dd HH:mm:ss") + " —— " + endDate.ToString("yyyy-MM-dd HH:mm:ss"); switch (statObjectType) { case StatObjctType.医生: report = new DoctorIncomeReport( ); break; case StatObjctType.科室: report = new DepartmentIncomeReport( ); break; case StatObjctType.收费员: report = new TollerIncomeReport( ); break; case StatObjctType.病人类型: report = new PatientTypeIncomReport( ); break; } report.BeginDate = beginDate; report.EndDate = endDate; report.StatType = statType; report.Reportstyle = style; report.StatDateType = dateType; report.AccountIdList = accountIdList; report.StatObjectType = statObjectType; report.ReportTitle = "门诊" + cboType.Text + "收入报表"; //report.Lister = PublicDataReader.GetEmployeeNameById( currentEmployeeId ); report.Lister = BaseDataController.GetName(BaseDataCatalog.人员列表, currentEmployeeId); ReportController.FillReport(report); dgvReport.DataSource = report.DataResult; dgvReport.Tag = report; for (int i = 1; i < dgvReport.Columns.Count; i++) { dgvReport.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgvReport.Columns[i].Width = 80; } dgvReport.Columns[0].Frozen = true; dgvReport.Columns[1].Frozen = true; if (chkChargeTotalInfo.Checked) { StatTotalInfo(); } else { dgvTotalInfo.DataSource = null; } } catch (OperatorException oe) { MessageBox.Show(oe.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception err) { ErrorWriter.WriteLog(err.Message); MessageBox.Show("统计报表中发生错误!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { SetButtonEnable(true); Cursor = Cursors.Default; } }
private void FormatData(DataTable tbData) { DataTable tbResult = new DataTable( ); tbResult.Columns.Add("统计项目", Type.GetType("System.String")); tbResult.Columns.Add("合计", Type.GetType("System.Decimal")); for (int i = 0; i < tbData.Rows.Count; i++) { //string deptId = PublicDataReader.GetDeptNameById( Convert.ToInt32( tbData.Rows[i]["ID"] )) ; string deptId = BaseDataController.GetName(BaseDataCatalog.科室列表, Convert.ToInt32(tbData.Rows[i]["ID"])); if (!tbResult.Columns.Contains(deptId)) { DataColumn col = new DataColumn(deptId, Type.GetType("System.Decimal")); //col.Caption = PublicDataReader.GetDeptNameById( Convert.ToInt32( tbData.Rows[i]["ID"] ) ); col.Caption = BaseDataController.GetName(BaseDataCatalog.科室列表, Convert.ToInt32(tbData.Rows[i]["ID"])); tbResult.Columns.Add(col); } } for (int i = 0; i < tbData.Rows.Count; i++) { //string deptId = PublicDataReader.GetDeptNameById( Convert.ToInt32( tbData.Rows[i]["ID"] ) ); string deptId = BaseDataController.GetName(BaseDataCatalog.科室列表, Convert.ToInt32(tbData.Rows[i]["ID"])); string code = tbData.Rows[i]["CODE"].ToString( ).Trim( ); decimal total_fee = Convert.ToDecimal(tbData.Rows[i]["Total_Fee"]); if (tbResult.Select("统计项目='" + code + "'").Length == 0) { DataRow drNew = tbResult.NewRow( ); drNew["统计项目"] = code; drNew[deptId] = total_fee; drNew["合计"] = total_fee; tbResult.Rows.Add(drNew); } else { DataRow[] drs = tbResult.Select("统计项目='" + code + "'"); decimal fee = Convert.IsDBNull(drs[0][deptId]) ? 0 : Convert.ToDecimal(drs[0]["total_fee"]); drs[0][deptId] = total_fee + fee; drs[0]["合计"] = Convert.ToDecimal(drs[0]["合计"]) + Convert.ToDecimal(drs[0][deptId]); } } for (int i = 0; i < tbResult.Rows.Count; i++) { //DataRow[] drs = PublicDataReader.StatItemList.Select( "STAT_CODE='" + tbResult.Rows[i]["统计项目"].ToString( ).Trim( ) + "'" ); DataRow[] drs = BaseDataController.BaseDataSet[BaseDataCatalog.基本分类与各分类对应表].Select("STAT_CODE='" + tbResult.Rows[i]["统计项目"].ToString().Trim() + "'"); string item_name = drs[0]["STAT_NAME"].ToString().Trim(); tbResult.Rows[i]["统计项目"] = item_name; } DataRow drTotal = tbResult.NewRow( ); drTotal["统计项目"] = "合计"; for (int i = 0; i < tbResult.Columns.Count; i++) { if (tbResult.Columns[i].ColumnName == "统计项目") { continue; } string fieldname = tbResult.Columns[i].ColumnName; object obj = tbResult.Compute("SUM(" + fieldname + ")", ""); if (obj != null && !Convert.IsDBNull(obj)) { drTotal[fieldname] = obj; } } tbResult.Rows.Add(drTotal); dgvStatItem.DataSource = tbResult; for (int i = 1; i < dgvStatItem.Columns.Count; i++) { dgvStatItem.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } dgvStatItem.Columns[1].Frozen = true; for (int i = 0; i < tbData.Rows.Count; i++) { //DataRow[] drs = PublicDataReader.StatItemList.Select( "STAT_CODE='" + tbData.Rows[i]["CODE"].ToString( ).Trim( ) + "'" ); DataRow[] drs = BaseDataController.BaseDataSet[BaseDataCatalog.基本分类与各分类对应表].Select("STAT_CODE='" + tbData.Rows[i]["CODE"].ToString().Trim() + "'"); string item_name = drs[0]["STAT_NAME"].ToString( ).Trim( ); //string dept_name = PublicDataReader.GetDeptNameById( Convert.ToInt32( tbData.Rows[i]["ID"] ) ); string dept_name = BaseDataController.GetName(BaseDataCatalog.科室列表, Convert.ToInt32(tbData.Rows[i]["ID"])); tbData.Rows[i]["ID"] = dept_name; tbData.Rows[i]["CODE"] = item_name; } dgvStatItem.Tag = tbData; }
private void txtInvoiceNo_KeyPress(object sender, KeyPressEventArgs e) { if ((int)e.KeyChar == 13) { if (txtInvoiceNo.Text.Trim( ) == "") { MessageBox.Show("请输入要退费的发票号", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { try { string invoiceNo = Convert.ToInt32(txtInvoiceNo.Text).ToString(); txtInvoiceNo.Text = HIS.MZ_BLL.InvoiceManager.FormatInvoiceNo(invoiceNo); currentPatient = new HIS.MZ_BLL.OutPatient(invoiceNo, OPDBillKind.门诊收费发票); txtPatientName.Text = currentPatient.PatientName; //lblFeeType.Text = PublicDataReader.GetPatientTypeNameByCode( currentPatient.MediType ); lblFeeType.Text = BaseDataController.GetName(BaseDataCatalog.病人类型列表, currentPatient.MediType); currentInvoice = new HIS.MZ_BLL.Invoice(txtPerfChar.Text.Trim(), invoiceNo, OPDBillKind.门诊收费发票); if (currentInvoice.RecordFlag != 0) { MessageBox.Show("该发票已经退费,请确认输入的发票号是否正确!"); txtInvoiceNo.Focus(); return; } lstRetYP = PublicDataReader.GetDrugReturnValueList(currentInvoice.InvoiceNo); ShowPrescriptions(currentInvoice.Prescription, lstRetYP); lblInvoiceNo.Text = currentInvoice.PerfChar + txtInvoiceNo.Text; lblTotal.Text = currentInvoice.TotalPay.ToString("0.00"); lblCash.Text = currentInvoice.CashPay.ToString("0.00"); lblPOS.Text = currentInvoice.PosPay.ToString("0.00"); lblChargeUp.Text = currentInvoice.VillagePay.ToString("0.00"); lblFover.Text = currentInvoice.FavorPay.ToString("0.00"); lblSelfTally.Text = currentInvoice.SelfTally.ToString("0.00"); // if (Convert.ToInt32(HIS.MZ_BLL.OPDParamter.Parameters["016"]) == 0) { btnAll.Enabled = false; dgvPresc.ReadOnly = true; btnAll_Click(null, null); return; } } catch (Exception err) { MessageBox.Show(err.Message + "\r\n1、确认发票号是否输入正确。\r\n2、确认是否输入了发票前缀字母。", "", MessageBoxButtons.OK, MessageBoxIcon.Error); txtInvoiceNo.Focus(); txtInvoiceNo.Text = ""; txtPatientName.Text = ""; lblFeeType.Text = ""; dgvPresc.Rows.Clear(); lblCash.Text = "0.00"; lblChargeUp.Text = "0.00"; lblFover.Text = "0.00"; lblPOS.Text = "0.00"; lblTotal.Text = "0.00"; } //add zenghao this.btnAll.Enabled = true; dgvPresc.Focus( ); } } }
/// <summary> /// 显示处方 /// </summary> /// <param name="Prescriptions"></param> /// <param name="ReturnDrugDetailList"></param> private void ShowPrescriptions(Prescription[] Prescriptions, List <PrescriptionDetail> ReturnDrugDetailList) { dgvPresc.Rows.Clear( ); loadPresc = true; for (int i = 0; i < Prescriptions.Length; i++) { for (int j = 0; j < Prescriptions[i].PresDetails.Length; j++) { dgvPresc.Rows.Add( ); int row = dgvPresc.Rows.Count - 1; dgvPresc["PrescID", row].Value = Prescriptions[i].PrescriptionID; dgvPresc["DetailID", row].Value = Prescriptions[i].PresDetails[j].DetailId; dgvPresc["NO1", row].Value = Convert.ToString(i + 1); if (j == 0) { dgvPresc["NO2", row].Value = Convert.ToString(i + 1); } dgvPresc["Item_Name", row].Value = Prescriptions[i].PresDetails[j].Itemname; dgvPresc["Standard", row].Value = Prescriptions[i].PresDetails[j].Standard; dgvPresc["Price", row].Value = Prescriptions[i].PresDetails[j].Sell_price; dgvPresc["Item_Unit", row].Value = Prescriptions[i].PresDetails[j].Unit; //大单位 dgvPresc["PACK_Unit", row].Value = Prescriptions[i].PresDetails[j].Unit; //大单位 string base_unit = ""; DataRow[] drBaseItem = dtbChargeItems.Select("isdrug = 1 and item_id=" + Prescriptions[i].PresDetails[j].ItemId.ToString( )); if (drBaseItem.Length > 0) { base_unit = drBaseItem[0]["base_unit"].ToString( ).Trim( ); } else { base_unit = Prescriptions[i].PresDetails[j].Unit; } dgvPresc["Base_Unit", row].Value = base_unit; //小单位 if (Prescriptions[i].PresDetails[j].BigitemCode == "01" || Prescriptions[i].PresDetails[j].BigitemCode == "02" || Prescriptions[i].PresDetails[j].BigitemCode == "03") { decimal baseNum = 0; decimal packNum = 0; GetPackNumAndBaseNum(Prescriptions[i].PresDetails[j].Amount, Prescriptions[i].PresDetails[j].RelationNum, out packNum, out baseNum); decimal retBaseNum = 0; decimal retPackNum = 0; GetPackNumAndBaseNum(Prescriptions[i].PresDetails[j].DetailId, Prescriptions[i].PresDetails[j].ItemId, ReturnDrugDetailList, out retPackNum, out retBaseNum); dgvPresc["PACK_NUM", row].Value = packNum; dgvPresc["ReturnPackNum", row].Value = retPackNum; dgvPresc["BASE_NUM", row].Value = baseNum; dgvPresc["ReturnBaseNum", row].Value = retBaseNum; //add zenghao if (retPackNum > 0 || retBaseNum > 0) { this.btnAll.Enabled = false; } } else { dgvPresc["PACK_NUM", row].Value = 0; dgvPresc["ReturnPackNum", row].Value = 0; dgvPresc["BASE_NUM", row].Value = Prescriptions[i].PresDetails[j].Amount; dgvPresc["ReturnBaseNum", row].Value = 0; } dgvPresc["PresAmount", row].Value = Prescriptions[i].PresDetails[j].PresAmount; //dgvPresc["EXEC_DEPT" , row].Value = PublicDataReader.GetDeptNameById( Convert.ToInt32(Prescriptions[i].ExecDeptCode) ); dgvPresc["EXEC_DEPT", row].Value = BaseDataController.GetName(BaseDataCatalog.科室列表, Convert.ToInt32(Prescriptions[i].ExecDeptCode)); dgvPresc["EXEC_DEPT", row].Tag = Prescriptions[i].ExecDeptCode; dgvPresc["TotalCost", row].Value = Prescriptions[i].PresDetails[j].Tolal_Fee; dgvPresc["Item_ID", row].Value = Prescriptions[i].PresDetails[j].ItemId; dgvPresc["STATITEM_CODE", row].Value = Prescriptions[i].PresDetails[j].BigitemCode; dgvPresc["Complex_Id", row].Value = Prescriptions[i].PresDetails[j].ComplexId; dgvPresc["HJXS", row].Value = Prescriptions[i].PresDetails[j].RelationNum; dgvPresc["PrescDoctor", row].Value = Prescriptions[i].PresDocCode; dgvPresc["PrescDept", row].Value = Prescriptions[i].PresDeptCode; dgvPresc["Selected", row].Value = (short)1; dgvPresc["Modified", row].Value = 0; dgvPresc["DRUG_FLAG", row].Value = Prescriptions[i].Drug_Flag; dgvPresc[DocPresId.Name, row].Value = Prescriptions[i].DocPresId; //颜色 for (int r = 0; r < dgvPresc.Columns.Count; r++) { dgvPresc.Rows[row].Cells[r].Style.ForeColor = Color.Blue; } dgvPresc_CellEndEdit(this, new DataGridViewCellEventArgs(dgvPresc.Columns["ReturnBaseNum"].Index, row)); } dgvPresc.Rows.Add( ); WriteSubTotalRow(dgvPresc.Rows.Count - 1); } if (dgvPresc.Rows.Count > 0) { dgvPresc.CurrentCell = dgvPresc["BASE_NUM", dgvPresc.Rows.Count - 1]; } loadPresc = false; }
/// <summary> /// 填充选择卡选中行的数据到指定的行 /// </summary> /// <param name="SelectedRow">从选项卡选择的行记录</param> /// <param name="rowIndex">当前要填充的行</param> private void _fillSelectedRowData(DataRow SelectedRow, int rowIndex) { DataTable tbPresc = (DataTable)formView.Prescriptions; DataRow dr = tbPresc.Rows[rowIndex]; dr[COL_KEYWORD] = SelectedRow["CODE"].ToString( ).Trim( ); dr[COL_ITEM_NAME] = SelectedRow["CHEM_NAME"].ToString( ).Trim( ); dr[COL_ITEM_UNIT] = SelectedRow["ITEM_UNIT"].ToString( ).Trim( ); dr[COL_STANDARD] = SelectedRow["STANDARD"].ToString( ).Trim( ); dr[COL_SELL_PRICE] = Convert.ToDecimal(SelectedRow["PRICE"]); dr[COL_PACK_NUM] = 0; dr[COL_PACK_UNIT] = SelectedRow["ITEM_UNIT"].ToString( ).Trim( ); dr[COL_BASE_NUM] = 0; dr[COL_BASE_UNIT] = SelectedRow["BASE_UNIT"].ToString( ).Trim( ); dr[COL_PRES_DOSAGE] = 1; dr[COL_PRES_DOC_NAME] = BaseDataController.GetName(BaseDataCatalog.人员列表, formView.PrescDoctorId); dr[COL_PRESDETAIL_ID] = 0; dr[COL_TOTAL_FEE] = 0; dr[COL_SELECTED_FLAG] = true; dr[COL_PRESC_TYPE] = ""; dr[COL_ITEM_ID] = Convert.ToInt32(SelectedRow["ITEM_ID"]); dr[COL_COMPLEX_ID] = Convert.ToInt32(SelectedRow["COMPLEX_ID"]); dr[COL_BUY_PRICE] = dr[COL_SELL_PRICE]; dr[COL_RELATION_NUM] = Convert.ToDecimal(SelectedRow["HJXS"]); //查找当前行所在的处方的医生、处方ID, #region ................. int start, end, subTotalRow; GetPrescriptionSectionStartRow(rowIndex, out start, out end, out subTotalRow); if (subTotalRow == -1) { if (start == end) { //如果是新开处方的第一行,处方医生和科室取当前选择的医生和科室 dr[COL_PRES_DOC_ID] = formView.PrescDoctorId; dr[COL_PRES_DEPT_ID] = formView.DoctorDeptId; dr[COL_PRESMASTER_ID] = 0; } else { //取其他行的医生和科室 for (int i = start; i <= end; i++) { if (!Convert.IsDBNull(tbPresc.Rows[i][COL_PRES_DOC_ID]) && tbPresc.Rows[i][COL_PRES_DOC_ID].ToString( ).Trim( ) != "") { dr[COL_PRES_DOC_ID] = tbPresc.Rows[i][COL_PRES_DOC_ID]; dr[COL_PRES_DEPT_ID] = tbPresc.Rows[i][COL_PRES_DEPT_ID]; dr[COL_PRESMASTER_ID] = tbPresc.Rows[i][COL_PRESMASTER_ID]; break; } } } } else { //取其他行的医生和科室 for (int i = start; i <= end; i++) { if (!Convert.IsDBNull(tbPresc.Rows[i][COL_PRES_DOC_ID]) && tbPresc.Rows[i][COL_PRES_DOC_ID].ToString( ).Trim( ) != "") { dr[COL_PRES_DOC_ID] = tbPresc.Rows[i][COL_PRES_DOC_ID]; dr[COL_PRES_DEPT_ID] = tbPresc.Rows[i][COL_PRES_DEPT_ID]; dr[COL_PRESMASTER_ID] = tbPresc.Rows[i][COL_PRESMASTER_ID]; break; } } } #endregion if (SelectedRow["EXEC_DEPT_CODE"].ToString() == "0") { //dr[COL_EXEC_DEPT_NAME] = PublicDataReader.GetDeptNameById(formView.DoctorDeptId); dr[COL_EXEC_DEPT_NAME] = BaseDataController.GetName(BaseDataCatalog.科室列表, formView.DoctorDeptId); dr[COL_EXEC_DEPT_ID] = formView.DoctorDeptId; } else { dr[COL_EXEC_DEPT_NAME] = SelectedRow["EXEC_DEPT_NAME"].ToString().Trim(); dr[COL_EXEC_DEPT_ID] = SelectedRow["EXEC_DEPT_CODE"].ToString().Trim(); } dr[COL_DOC_PRESMASTER_ID] = 0; dr[COL_DOC_PRESDETAIL_ID] = 0; dr[COL_BIGITEMCODE] = SelectedRow["STATITEM_CODE"].ToString( ).Trim( ); dr[COL_MODIFY_FLAG] = 1; dr[COL_SUB_TOTAL_FLAG] = 0; }
/// <summary> /// 填充处方数据 /// </summary> /// <param name="prescriptions">要填充的处方,Prescription[]类型的数组</param> /// <param name="descTable">填充的目标数据表</param> private void FillPrescData(Prescription[] prescriptions, DataTable descTable) { descTable.Rows.Clear( ); for (int presIndex = 0; presIndex < prescriptions.Length; presIndex++) { PrescriptionDetail[] details = prescriptions[presIndex].PresDetails; for (int detailIndex = 0; detailIndex < details.Length; detailIndex++) { DataRow dr = descTable.NewRow( ); #region 增加明细行 if (detailIndex == 0) { dr[COL_PRESNO] = presIndex + 1; } decimal pack_num = 0; string pack_unit = ""; decimal base_num = details[detailIndex].Amount; string base_unit = details[detailIndex].Unit.Trim(); if (details[detailIndex].BigitemCode == "01" || details[detailIndex].BigitemCode == "02" || details[detailIndex].BigitemCode == "03") { pack_num = 0; pack_unit = ""; base_num = 0; base_unit = ""; ConvertDrugAmountToPackNumAndBaseNum(Convert.ToInt32(details[detailIndex].ItemId), details[detailIndex].Amount, details[detailIndex].RelationNum, out pack_num, out pack_unit, out base_num, out base_unit); } dr[COL_KEYWORD] = ""; dr[COL_ITEM_NAME] = details[detailIndex].Itemname.Trim(); dr[COL_ITEM_UNIT] = details[detailIndex].Unit.Trim(); dr[COL_STANDARD] = details[detailIndex].Standard.Trim(); dr[COL_SELL_PRICE] = details[detailIndex].Sell_price; dr[COL_PACK_NUM] = pack_num; dr[COL_PACK_UNIT] = pack_unit; dr[COL_BASE_NUM] = base_num; dr[COL_BASE_UNIT] = base_unit; dr[COL_PRES_DOSAGE] = details[detailIndex].PresAmount; dr[COL_PRES_DOC_NAME] = BaseDataController.GetName(BaseDataCatalog.人员列表, Convert.ToInt32(prescriptions[presIndex].PresDocCode)); dr[COL_EXEC_DEPT_NAME] = BaseDataController.GetName(BaseDataCatalog.科室列表, Convert.ToInt32(prescriptions[presIndex].ExecDeptCode)); dr[COL_TOTAL_FEE] = details[detailIndex].Tolal_Fee; dr[COL_SELECTED_FLAG] = prescriptions[presIndex].Selected; dr[COL_PRESMASTER_ID] = prescriptions[presIndex].PrescriptionID; dr[COL_PRESDETAIL_ID] = details[detailIndex].DetailId; dr[COL_PRESC_TYPE] = prescriptions[presIndex].PrescType; dr[COL_ITEM_ID] = details[detailIndex].ItemId; dr[COL_COMPLEX_ID] = details[detailIndex].ComplexId; dr[COL_BUY_PRICE] = details[detailIndex].Buy_price; dr[COL_RELATION_NUM] = details[detailIndex].RelationNum; dr[COL_PRES_DOC_ID] = prescriptions[presIndex].PresDocCode; dr[COL_PRES_DEPT_ID] = prescriptions[presIndex].PresDeptCode; dr[COL_EXEC_DEPT_ID] = prescriptions[presIndex].ExecDeptCode; dr[COL_DOC_PRESMASTER_ID] = prescriptions[presIndex].DocPresId; dr[COL_DOC_PRESDETAIL_ID] = details[detailIndex].DocPrescDetailId; dr[COL_BIGITEMCODE] = details[detailIndex].BigitemCode; dr[COL_MODIFY_FLAG] = (short)0; dr[COL_SUB_TOTAL_FLAG] = (short)0; dr[COL_PRESC_AMBIT] = presIndex + 1; #endregion descTable.Rows.Add(dr); } #region 增加小计行 DataRow drSubTotal = descTable.NewRow( ); drSubTotal[COL_EXEC_DEPT_NAME] = "小 计"; drSubTotal[COL_SELL_PRICE] = DBNull.Value; drSubTotal[COL_PACK_NUM] = DBNull.Value; drSubTotal[COL_BASE_NUM] = DBNull.Value; drSubTotal[COL_SELECTED_FLAG] = prescriptions[presIndex].Selected; drSubTotal[COL_SUB_TOTAL_FLAG] = (short)1; drSubTotal[COL_PRESC_AMBIT] = presIndex + 1; drSubTotal[COL_TOTAL_FEE] = prescriptions[presIndex].Total_Fee; descTable.Rows.Add(drSubTotal); drSubTotal[COL_TOTAL_FEE] = _calculatePrescriptionFee(descTable.Rows.IndexOf(drSubTotal)); #endregion } }