/// <summary> /// 从界面获取出库信息 /// </summary> /// <param name="p_lngMainSeq"></param> /// <returns></returns> private clsMS_StorageGrossForOut[] m_objGetOutValue(long[] p_lngMainSeq) { if (p_lngMainSeq == null || p_lngMainSeq.Length == 0) { return(null); } clsMS_StorageGrossForOut[] objSubArr = null; List <clsMS_StorageGrossForOut> lisDetail = new List <clsMS_StorageGrossForOut>(); long lngRes = 0; DataTable dtbDetail = null; clsDcl_OutStorage objDSDomain = new clsDcl_OutStorage(); for (int iSEQ = 0; iSEQ < p_lngMainSeq.Length; iSEQ++) { lngRes = objDSDomain.m_lngGetOutStorageDetail(p_lngMainSeq[iSEQ], out dtbDetail); objSubArr = m_objGetDetail(dtbDetail); if (objSubArr != null && objSubArr.Length > 0) { lisDetail.AddRange(objSubArr); } } objDSDomain = null; if (lisDetail.Count > 0) { objSubArr = lisDetail.ToArray(); } return(objSubArr); }
/// <summary> /// 获取子表内容 /// </summary> /// <param name="p_lngMainSEQ">主表序列号</param> /// <param name="p_dtbValue">子表内容</param> internal void m_mthGetOutStorageDetail(long p_lngMainSEQ, out DataTable p_dtbValue) { clsDcl_OutStorage objOSDomain = new clsDcl_OutStorage(); long lngRes = objOSDomain.m_lngGetOutStorageDetail(p_lngMainSEQ, out p_dtbValue); objOSDomain = null; }
/// <summary> /// 获取指定日期内的金额 /// </summary> internal void m_mthGetAllMoney() { m_objViewer.m_lblBuyInMoney.Text = string.Empty; m_objViewer.m_lblRetailMoney.Text = string.Empty; DateTime dtmBegin = Convert.ToDateTime(Convert.ToDateTime(m_objViewer.m_dtpBeginDatePage1.Text).ToString("yyyy-MM-dd 00:00:00")); DateTime dtmEnd = Convert.ToDateTime(Convert.ToDateTime(m_objViewer.m_dtpEndDatePage1.Text).ToString("yyyy-MM-dd 23:59:59")); clsDcl_OutStorage objOSDomain = new clsDcl_OutStorage(); if (m_objViewer.m_dtbAllMoney == null) { long lngRes = objOSDomain.m_lngGetAllInMoney(dtmBegin, dtmEnd, m_objViewer.m_strStorageID, 4, out m_objViewer.m_dtbAllMoney); } if (m_objViewer.m_dtbAllMoney != null && m_objViewer.m_dtbAllMoney.Rows.Count == 0) { m_objViewer.m_dtbAllMoney = null; } if (m_objViewer.m_dtbAllMoney != null && m_objViewer.m_dtvCurrentMainVienPage1 != null) { //StringBuilder stbFilter = new StringBuilder(100); //int intRowsCount = m_objViewer.m_dtvCurrentMainVienPage1.Count; //for (int iRow = 0; iRow < intRowsCount; iRow++) //{ // stbFilter.Append(" seriesid_int ="); // stbFilter.Append(m_objViewer.m_dtvCurrentMainVienPage1[iRow]["SERIESID_INT"].ToString()); // if (iRow < intRowsCount - 1) // { // stbFilter.Append(" or "); // } //} string strFilterResult = m_strMainFilter(); //if (!string.IsNullOrEmpty(strFilterResult)) //{ DataRow[] drAllMoney = m_objViewer.m_dtbAllMoney.Select(strFilterResult); if (drAllMoney != null && drAllMoney.Length > 0) { decimal dcmBuyIn = 0m; decimal dcmRetailSale = 0m; for (int iM = 0; iM < drAllMoney.Length; iM++) { dcmBuyIn += Convert.ToDecimal(drAllMoney[iM]["BuyInMoney"]); dcmRetailSale += Convert.ToDecimal(drAllMoney[iM]["RetailPrice"]); } m_objViewer.m_lblBuyInMoney.Text = dcmBuyIn.ToString("0.0000"); m_objViewer.m_lblRetailMoney.Text = dcmRetailSale.ToString("0.0000"); } //} } }
/// <summary> /// 获取指定日期内的金额 /// </summary> internal void m_mthGetAllMoney() { m_objViewer.m_lblBuyInMoney.Text = string.Empty; m_objViewer.m_lblRetailMoney.Text = string.Empty; DateTime dtmBegin = Convert.ToDateTime(Convert.ToDateTime(m_objViewer.m_dtpSearchBeginDate.Text).ToString("yyyy-MM-dd 00:00:00")); DateTime dtmEnd = Convert.ToDateTime(Convert.ToDateTime(m_objViewer.m_dtpSearchEndDate.Text).ToString("yyyy-MM-dd 23:59:59")); clsDcl_OutStorage objOSDomain = new clsDcl_OutStorage(); if (m_objViewer.m_dtbAllMoney == null) { long lngRes = objOSDomain.m_lngGetAllInMoney(dtmBegin, dtmEnd, m_objViewer.m_strStorageID, 2, out m_objViewer.m_dtbAllMoney); } if (m_objViewer.m_dtbAllMoney != null && m_objViewer.m_dtbAllMoney.Rows.Count == 0) { m_objViewer.m_dtbAllMoney = null; } if (m_objViewer.m_dtbAllMoney != null && m_objViewer.m_dtvCurrentMainView != null) { //StringBuilder stbFilter = new StringBuilder(100); int intRowsCount = m_objViewer.m_dtvCurrentMainView.Count; System.Collections.Hashtable hstMedicine = new System.Collections.Hashtable(); for (int iRow = 0; iRow < intRowsCount; iRow++) { hstMedicine.Add(Convert.ToInt64(m_objViewer.m_dtvCurrentMainView[iRow]["seriesid_int"]), m_objViewer.m_dtvCurrentMainView[iRow]["outstorageid_vchr"].ToString()); } string strFilterResult = m_strMainFilter(); //if (!string.IsNullOrEmpty(strFilterResult)) //{ DataRow[] drAllMoney = m_objViewer.m_dtbAllMoney.Select(strFilterResult); if (drAllMoney != null && drAllMoney.Length > 0) { decimal dcmBuyIn = 0m; decimal dcmRetailSale = 0m; for (int iM = 0; iM < drAllMoney.Length; iM++) { if (!hstMedicine.Contains(Convert.ToInt64(drAllMoney[iM]["seriesid_int"]))) { continue; } dcmBuyIn += Convert.ToDecimal(drAllMoney[iM]["BuyInMoney"]); dcmRetailSale += Convert.ToDecimal(drAllMoney[iM]["RetailPrice"]); } m_objViewer.m_lblBuyInMoney.Text = dcmBuyIn.ToString("0.0000"); m_objViewer.m_lblRetailMoney.Text = dcmRetailSale.ToString("0.0000"); } //} } }
/// <summary> /// 入帐 /// </summary> internal void m_mthInAccount() { if (!m_objViewer.m_blnIsAdmin) { MessageBox.Show("当前用户没有药库管理权限,不能入帐", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } List <DataRow> lstCheckRow = new List <DataRow>(); List <long> lstSeq = new List <long>(); //主表序列 List <string> lstOutStorageID = new List <string>(); //出库单据号 for (int iSe = 0; iSe < m_objViewer.m_dgvMainInfo.Rows.Count; iSe++) { if (Convert.ToBoolean(m_objViewer.m_dgvMainInfo.Rows[iSe].Cells[0].Value)) { DataRow drCheck = m_objViewer.m_dtvCurrentMainVienPage1[iSe].Row; if (drCheck["STATUS"].ToString() == "2") { lstCheckRow.Add(drCheck); lstSeq.Add(Convert.ToInt64(drCheck["SERIESID_INT"])); lstOutStorageID.Add(drCheck["OUTSTORAGEID_VCHR"].ToString()); } } } if (lstCheckRow.Count == 0) { MessageBox.Show("请先选择需入帐的药品出库信息", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } DataRow[] drCommit = lstCheckRow.ToArray(); if (drCommit == null || drCommit.Length == 0) { MessageBox.Show("没有符合入帐条件的药品出库信息", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } DateTime dtmNow = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); clsDcl_OutStorage objODomain = new clsDcl_OutStorage(); long lngRes = objODomain.m_lngInAccount(lstOutStorageID.ToArray(), lstSeq.ToArray(), m_objViewer.m_strStorageID, m_objViewer.LoginInfo.m_strEmpID, dtmNow); if (lngRes > 0) { foreach (DataRow dr in drCommit) { dr["INACCOUNTID_CHR"] = m_objViewer.LoginInfo.m_strEmpID; dr["STATUS"] = 3; dr["INACCOUNTDATE_DAT"] = dtmNow; dr["statusdesc"] = "入帐"; } MessageBox.Show("入帐成功", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("入帐失败", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 退审 /// </summary> internal void m_mthUnCommitOutStorage() { if (!m_objViewer.m_blnIsAdmin) { MessageBox.Show("当前用户没有药库管理权限,不能退审", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } List <DataRow> lstCheckRow = new List <DataRow>(); for (int iSe = 0; iSe < m_objViewer.m_dgvMainInfo.Rows.Count; iSe++) { if (Convert.ToBoolean(m_objViewer.m_dgvMainInfo.Rows[iSe].Cells[0].Value)) { DataRow drCheck = m_objViewer.m_dtvCurrentMainVienPage1[iSe].Row; if (drCheck["STATUS"].ToString() == "2") { lstCheckRow.Add(drCheck); } } } if (lstCheckRow.Count == 0) { MessageBox.Show("请先选择需退审的药品出库信息", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } DataRow[] drCommit = lstCheckRow.ToArray(); if (drCommit == null || drCommit.Length == 0) { MessageBox.Show("没有符合退审条件的药品出库信息", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } long[] lngMainSEQ = new long[drCommit.Length]; for (int iRow = 0; iRow < drCommit.Length; iRow++) { lngMainSEQ[iRow] = Convert.ToInt64(drCommit[iRow]["SERIESID_INT"]); } clsDcl_OutStorage objOSDomain = new clsDcl_OutStorage(); //long lngRes = objOSDomain.m_lngUnCommit(lngMainSEQ); long lngRes = 0; clsMS_StorageGrossForOut[] objSubArr = null; //List<clsMS_StorageGrossForOut> lisDetail = new List<clsMS_StorageGrossForOut>(); DataTable dtbDetail = null; for (int iSEQ = 0; iSEQ < lngMainSEQ.Length; iSEQ++) { lngRes = objOSDomain.m_lngGetOutStorageDetail(lngMainSEQ[iSEQ], out dtbDetail); objSubArr = m_objGetDetail(dtbDetail); if (objSubArr != null && objSubArr.Length > 0) { lngRes = objOSDomain.m_lngUnCommitOutStorage(objSubArr, lngMainSEQ[iSEQ], drCommit[iSEQ]["OUTSTORAGEID_VCHR"].ToString(), m_objViewer.m_strStorageID); if (lngRes > 0) { m_mthUpdateUIAfterUnCommit(drCommit[iSEQ]); } } } objOSDomain = null; if (lngRes > 0) { //m_mthUpdateUIAfterUnCommit(drCommit); if (m_objViewer.m_dgvMainInfo.Rows.Count > 0) { m_objViewer.m_dgvMainInfo.Rows[0].Selected = true; } else { if (m_objViewer.m_dtbSubDataPage1 != null) { m_objViewer.m_dtbSubDataPage1.Rows.Clear(); } } System.Windows.Forms.MessageBox.Show("退审完成", "药品出库", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { System.Windows.Forms.MessageBox.Show("退审失败", "药品出库", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } }
/// <summary> /// 审核出库 /// </summary> /// <param name="p_drCommit">审核的行</param> internal void m_mthCommitOutStorage() { if (!m_objViewer.m_blnIsAdmin) { MessageBox.Show("当前用户没有药库管理权限,不能审核", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } List <DataRow> lstCheck = new List <DataRow>(); bool blnNewState = false; for (int iSe = 0; iSe < m_objViewer.m_dgvMainInfo.Rows.Count; iSe++) { if (Convert.ToBoolean(m_objViewer.m_dgvMainInfo.Rows[iSe].Cells[0].Value)) { DataRow drCheck = m_objViewer.m_dtvCurrentMainVienPage1[iSe].Row; clsDcl_Purchase_Detail clsDcl = new clsDcl_Purchase_Detail(); clsDcl.m_lngCheckBillState(2, drCheck["OUTSTORAGEID_VCHR"].ToString(), out blnNewState); if (!blnNewState) { MessageBox.Show("已选中的出库单,包含不是新制状态的单据,请刷新后重试", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } if (drCheck["STATUS"].ToString() == "1") { lstCheck.Add(drCheck); } } } if (lstCheck.Count == 0) { MessageBox.Show("请先选择需审核的药品出库信息", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } DataRow[] drNew = lstCheck.ToArray(); if (drNew == null || drNew.Length == 0) { MessageBox.Show("没有需审核的药品出库信息", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } string strCurrentOutStorageID = string.Empty; try { long[] lngMainSEQ = new long[drNew.Length]; for (int iMSeq = 0; iMSeq < drNew.Length; iMSeq++) { lngMainSEQ[iMSeq] = Convert.ToInt64(drNew[iMSeq]["SERIESID_INT"]); } clsMS_StorageGrossForOut[] objSubArr = null; //List<clsMS_StorageGrossForOut> lisDetail = new List<clsMS_StorageGrossForOut>(); long lngRes = 0; DataTable dtbDetail = null; clsDcl_OutStorage objOSDomain = new clsDcl_OutStorage(); clsMS_AccountDetail_VO[] objAccount = null; for (int iSEQ = 0; iSEQ < lngMainSEQ.Length; iSEQ++) { strCurrentOutStorageID = drNew[iSEQ]["OUTSTORAGEID_VCHR"].ToString(); lngRes = objOSDomain.m_lngGetOutStorageDetail(lngMainSEQ[iSEQ], out dtbDetail); objSubArr = m_objGetDetail(dtbDetail); if (objSubArr != null && objSubArr.Length > 0) { objAccount = m_objAccountDetailArr(dtbDetail, Convert.ToInt32(drNew[iSEQ]["FORMTYPE"]), strCurrentOutStorageID); lngRes = objOSDomain.m_lngCommitOutStorage(objSubArr, objAccount, m_objViewer.LoginInfo.m_strEmpID, lngMainSEQ[iSEQ], m_objViewer.m_blnIsImmAccount); if (lngRes > 0) { m_mthUpdateUIAfterCommit(drNew[iSEQ]); } } } //if (lisDetail.Count > 0) //{ // clsDcl_Storage objSTDomain = new clsDcl_Storage(); // lngRes = objSTDomain.m_lngSubStorageDetailRealGross(lisDetail.ToArray()); // for (int iList = 0; iList < lisDetail.Count; iList++) // { // lngRes = objSTDomain.m_lngSubStorageGross(lisDetail[iList]); // } // if (lngRes > 0) // { // lngRes = objOSDomain.m_lngSetCommitUser(m_objViewer.LoginInfo.m_strEmpID, lngMainSEQ); // } // if (lngRes > 0) // { // p_drCommit = drNew; // } //} objOSDomain = null; if (lngRes > 0) { MessageBox.Show("审核完成", "药品出库", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { MessageBox.Show("审核失败", "药品出库", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } catch (Exception objEx) { com.digitalwave.Utility.clsLogText objLogger = new com.digitalwave.Utility.clsLogText(); bool blnRes = objLogger.LogError(objEx); } }
/// <summary> /// 删除出库药品信息 /// </summary> internal void m_mthDeleteOutStorage() { List <long> lngCheckRowIndex = new List <long>(); List <long> lngWrongRowIndex = new List <long>(); bool blnNewState = false; for (int iSe = 0; iSe < m_objViewer.m_dgvMainInfo.Rows.Count; iSe++) { if (Convert.ToBoolean(m_objViewer.m_dgvMainInfo.Rows[iSe].Cells[0].Value)) { clsDcl_Purchase_Detail clsDcl = new clsDcl_Purchase_Detail(); clsDcl.m_lngCheckBillState(2, m_objViewer.m_dtvCurrentMainVienPage1[iSe]["OUTSTORAGEID_VCHR"].ToString(), out blnNewState); if (!blnNewState) { MessageBox.Show("已选中的出库单,包含不是新制状态的单据,请刷新后重试", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } int intState = Convert.ToInt32(m_objViewer.m_dtvCurrentMainVienPage1[iSe]["STATUS"]); if (intState == 2 || intState == 3)//已审核或已入帐 { lngWrongRowIndex.Add(Convert.ToInt64(m_objViewer.m_dtvCurrentMainVienPage1[iSe]["SERIESID_INT"])); continue; } lngCheckRowIndex.Add(Convert.ToInt64(m_objViewer.m_dtvCurrentMainVienPage1[iSe]["SERIESID_INT"])); } } if (lngWrongRowIndex.Count > 0) { DialogResult drResultQ = MessageBox.Show("部分已选择记录已审核或已入账,将不能删除,是否继续?", "药品出库", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (drResultQ == DialogResult.No) { return; } } if (lngCheckRowIndex.Count == 0) { MessageBox.Show("请先选择一条新制药品入库信息", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DialogResult drResult = MessageBox.Show("是否删除选中记录?", "药品出库", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (drResult == DialogResult.No) { return; } clsMS_StorageGrossForOut[] objGetOutValue = m_objGetOutValue(lngCheckRowIndex.ToArray()); clsDcl_OutStorage objOSDomain = new clsDcl_OutStorage(); long lngRes = objOSDomain.m_lngDeleteMainOutStorage(lngCheckRowIndex.ToArray()); objOSDomain = null; if (lngRes > 0) { m_mthAddAvailaGross(objGetOutValue); MessageBox.Show("删除成功", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Information); StringBuilder stbFilter = new StringBuilder(50); for (int iSer = 0; iSer < lngCheckRowIndex.Count; iSer++) { stbFilter.Append(" SERIESID_INT = '"); stbFilter.Append(lngCheckRowIndex[iSer]); stbFilter.Append("'"); if (iSer < lngCheckRowIndex.Count - 1) { stbFilter.Append(" or "); } } DataRow[] drRemove = m_objViewer.m_dtbMainDataPage1.Select(stbFilter.ToString()); if (drRemove != null && drRemove.Length > 0) { for (int iRev = 0; iRev < drRemove.Length; iRev++) { m_objViewer.m_dtbMainDataPage1.Rows.Remove(drRemove[iRev]); } } DataView dtvSub = m_objViewer.m_dgvSubInfo.DataSource as DataView; if (m_objViewer.m_dtvCurrentMainVienPage1.Count == 0 && dtvSub != null) { dtvSub.Table.Rows.Clear(); } } else { MessageBox.Show("删除失败", "药品出库", MessageBoxButtons.OK, MessageBoxIcon.Error); } }