private void m_cmdModify_Click(object sender, EventArgs e) { clsMS_StockPlan_VO objMain = null; clsMS_StockPlan_Detail_VO[] objSubArr = null; ((clsCtl_StockPlan)objController).m_mthModifySelected(out objMain, out objSubArr); if (objMain == null) { return; } int intSelectedSubRow = 0; if (m_dgvSubInfo.SelectedRows != null && m_dgvSubInfo.SelectedRows.Count > 0) { intSelectedSubRow = m_dgvSubInfo.SelectedRows[0].Index; } frmStockPlan_Detail frmspd = new frmStockPlan_Detail(m_strStorageID, objMain, objSubArr, intSelectedSubRow); frmspd.FormClosed += new FormClosedEventHandler(frmspd_FormClosed); frmspd.ShowDialog(); frmspd.m_txtProviderName.Focus(); }
/// <summary> /// 插入主表和明细表数据 /// </summary> /// <param name="m_objMainVo"></param> /// <param name="m_objDetailArr"></param> /// <returns></returns> public long m_lngAddNewPlanMedInfo(int m_intCommit, ref clsMS_StockPlan_VO m_objMainVo, ref clsMS_StockPlan_Detail_VO[] m_objDetailArr) { long lngRes = 0; com.digitalwave.iCare.middletier.MedicineStoreService.clsStockPlanSVC objSvc = (com.digitalwave.iCare.middletier.MedicineStoreService.clsStockPlanSVC)com.digitalwave.iCare.common.clsObjectGenerator.objCreatorObjectByType(typeof(com.digitalwave.iCare.middletier.MedicineStoreService.clsStockPlanSVC)); lngRes = objSvc.m_lngAddNewPlanMedInfo(objPrincipal, m_intCommit, ref m_objMainVo, ref m_objDetailArr); return(lngRes); }
/// <summary> /// 获取主表VO /// </summary> /// <returns></returns> private clsMS_StockPlan_VO m_objGetMainISVO() { if (m_objCurrentMain == null) { m_objCurrentMain = new clsMS_StockPlan_VO(); m_objCurrentMain.m_datNEWORDER_DAT = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); m_objCurrentMain.m_lngSTATE_INT = 1; } m_objCurrentMain.m_lngSERIESID_INT = m_objViewer.m_lngMainSEQ; m_objCurrentMain.m_strSTOCKPLANID_VCHR = m_objViewer.m_txtBillNumber.Text; m_objCurrentMain.m_strVENDORID_CHR = m_objViewer.m_txtProviderName.Tag.ToString(); m_objCurrentMain.m_strVENDORNAME_VCHR = m_objViewer.m_txtProviderName.Text; m_objCurrentMain.m_datSTOCKPLAN_DAT = Convert.ToDateTime(m_objViewer.m_dtpPlanDate.Text); m_objCurrentMain.m_datNEWORDER_DAT = Convert.ToDateTime(m_objViewer.m_dtpNewOrderDate.Text); m_objCurrentMain.m_strMAKERID_CHR = m_objViewer.m_txtMakeBillPerson.Tag.ToString(); m_objCurrentMain.m_strVENDORID_CHR = m_objViewer.m_txtProviderName.Tag.ToString(); m_objCurrentMain.m_strCOMMENT_VCHR = m_objViewer.m_txtRemark.Text; m_objCurrentMain.m_strSTORAGEID_CHR = m_objViewer.m_strStorageID; return(m_objCurrentMain); }
/// <summary> /// 修改选定的入库单 /// </summary> /// <param name="p_objMain">主表</param> /// <param name="p_objSubVO">子表</param> internal void m_mthModifySelected(out clsMS_StockPlan_VO p_objMain, out clsMS_StockPlan_Detail_VO[] p_objSubVO) { p_objMain = null; p_objSubVO = null; #region 主表VO clsMS_StockPlan_VO objMain = null; if (m_objViewer.m_dgvMainInfo.SelectedRows.Count == 1) { DataRowView drvMain = m_objViewer.m_dtvMainView[m_objViewer.m_dgvMainInfo.SelectedRows[0].Index]; //int intState = Convert.ToInt32(drvMain["STATE_INT"]); //if (intState != 1) //{ // MessageBox.Show("非新制表单不能修改", "采购计划", MessageBoxButtons.OK, MessageBoxIcon.Error); // return; //} objMain = new clsMS_StockPlan_VO(); objMain.m_lngSERIESID_INT = Convert.ToInt64(drvMain["SERIESID_INT"]); objMain.m_strSTOCKPLANID_VCHR = drvMain["STOCKPLANID_VCHR"].ToString(); //objMain.m_strSTORAGENAME_VCHR = drvMain["STORAGENAME_VCHR"].ToString(); objMain.m_lngSTATE_INT = Convert.ToInt32(drvMain["STATE_INT"]); objMain.m_strVENDORID_CHR = drvMain["VENDORID_CHR"].ToString(); objMain.m_strVENDORNAME_VCHR = drvMain["vendorname_vchr"].ToString(); objMain.m_strSTORAGEID_CHR = drvMain["STORAGEID_CHR"].ToString(); objMain.m_datSTOCKPLAN_DAT = Convert.ToDateTime(drvMain["STOCKPLAN_DAT"]); objMain.m_datNEWORDER_DAT = Convert.ToDateTime(drvMain["NEWORDER_DAT"]); objMain.m_strCOMMENT_VCHR = drvMain["COMMENT_VCHR"].ToString(); objMain.m_strMAKERID_CHR = drvMain["MAKERID_CHR"].ToString(); objMain.m_strMAKERNAME_VCHR = drvMain["MAKERNAME"].ToString(); } if (objMain == null) { return; } p_objMain = objMain; #endregion #region 子表VO clsMS_StockPlan_Detail_VO[] objSubVO = null; DataView dvSub = m_objViewer.m_dgvSubInfo.DataSource as DataView; if (dvSub != null && dvSub.Count > 0) { DataRowView drvCurrent = null; objSubVO = new clsMS_StockPlan_Detail_VO[dvSub.Count]; DateTime dtTemp; for (int iRow = 0; iRow < m_objViewer.m_dgvSubInfo.Rows.Count; iRow++) { drvCurrent = dvSub[iRow]; objSubVO[iRow] = new clsMS_StockPlan_Detail_VO(); objSubVO[iRow].m_lngSERIESID_INT = Convert.ToInt64(drvCurrent["SERIESID_INT"]); objSubVO[iRow].m_lngSERIESID2_INT = Convert.ToInt64(drvCurrent["SERIESID2_INT"]); objSubVO[iRow].m_strMEDICINEID_CHR = drvCurrent["MEDICINEID_CHR"].ToString(); objSubVO[iRow].m_strMEDICINENAME_VCHR = drvCurrent["MEDICINENAME_VCHR"].ToString(); objSubVO[iRow].m_strMEDSPEC_VCHR = drvCurrent["MEDSPEC_VCHR"].ToString(); objSubVO[iRow].m_dblAMOUNT = Convert.ToInt32(drvCurrent["AMOUNT"]); objSubVO[iRow].m_strPRODUCTORID_CHR = drvCurrent["PRODUCTORID_CHR"].ToString(); objSubVO[iRow].m_strUNIT_VCHR = drvCurrent["UNIT_VCHR"].ToString(); objSubVO[iRow].m_strASSISTCODE_CHR = drvCurrent["ASSISTCODE_CHR"].ToString(); objSubVO[iRow].m_lngSTATUS = Convert.ToInt16(drvCurrent["STATUS"]); objSubVO[iRow].m_dblCALLPRICE_INT = Convert.ToDouble(drvCurrent["CALLPRICE_INT"]); objSubVO[iRow].m_dblSTOCKSUM = Convert.ToDouble(drvCurrent["STOCKSUM"]); if (DateTime.TryParse(drvCurrent["LASTINSTORAGEDATE_DAT"].ToString(), out dtTemp)) { objSubVO[iRow].m_datLASTINSTORAGEDATE_DAT = dtTemp; } objSubVO[iRow].m_strVENDORID_CHR = drvCurrent["VENDORID_CHR"].ToString(); objSubVO[iRow].m_strVENDORNAME_VCHR = drvCurrent["vendorname"].ToString(); } } p_objSubVO = objSubVO; #endregion }
/// <summary> /// 采购 /// </summary> /// <param name="p_strStorageID">仓库ID</param> /// <param name="p_objISVO">采购主表内容</param> /// <param name="p_objDetailArr">采购子表内容</param> /// <param name="p_intSelectedSubRow">选中子表行</param> public frmStockPlan_Detail(string p_strStorageID, clsMS_StockPlan_VO p_objISVO, clsMS_StockPlan_Detail_VO[] p_objDetailArr, int p_intSelectedSubRow) : this(p_strStorageID) { ((clsCtl_StockPlan_Detail)objController).m_mthSetMedicineDetailToUI(p_objISVO, p_objDetailArr, p_intSelectedSubRow); }
/// <summary> /// 保存当前采购计划 /// </summary> internal long m_lngSaveStockPlan() { //if (m_objCurrentMain != null) //{ // if (m_objViewer.m_intCommitFolow == 0) // { // MessageBox.Show("该药品采购记录已审核,不能修改", "药品采购", MessageBoxButtons.OK, MessageBoxIcon.Error); // return -1; // } //} if (m_objCurrentMain != null && m_objCurrentMain.m_lngSTATE_INT != 1 && m_objCurrentMain.m_lngSTATE_INT != 0) { m_objViewer.m_blnHasCommit = true; } if (m_objViewer.m_dtbMedicineInfo.Rows.Count == 0) { MessageBox.Show("请先录入药品信息", "药品采购", MessageBoxButtons.OK, MessageBoxIcon.Error); return(-1); } if (Convert.ToString(m_objViewer.m_txtProviderName.Tag) == "") { MessageBox.Show("请先选择供应商", "药品采购", MessageBoxButtons.OK, MessageBoxIcon.Error); return(-1); } DateTime datOutTime; m_objDomain.m_mthGetAccountperiodTime(out datOutTime); if (Convert.ToDateTime(m_objViewer.m_dtpPlanDate.Text) < datOutTime) { MessageBox.Show("采购日期不能小于上次帐务结转的结束日期。\r\n上次结转结束日期是:" + datOutTime.ToString("yyyy年MM月dd日"), "药品采购", MessageBoxButtons.OK, MessageBoxIcon.Error); m_objViewer.m_dtpPlanDate.Focus(); return(-1); } double dblAmount = 0d; DataRow drTemp = null; for (int iRow = 0; iRow < m_objViewer.m_dtbMedicineInfo.Rows.Count; iRow++) { drTemp = m_objViewer.m_dtbMedicineInfo.Rows[iRow]; if (drTemp.RowState == DataRowState.Unchanged || drTemp.RowState == DataRowState.Deleted) { continue; } if (drTemp["MEDICINEID_CHR"] != DBNull.Value && drTemp["AMOUNT"] != DBNull.Value) { if (!double.TryParse(drTemp["AMOUNT"].ToString(), out dblAmount)) { MessageBox.Show("采购数量必须为数字", "药品采购", MessageBoxButtons.OK, MessageBoxIcon.Error); return(-1); } else { if (dblAmount <= 0) { MessageBox.Show("采购数量必须大于零", "药品采购", MessageBoxButtons.OK, MessageBoxIcon.Error); return(-1); } } } } this.m_objViewer.m_dtbMedicineInfo.AcceptChanges(); long lngRes = 0; try { bool blnIsAddNew = m_objViewer.m_lngMainSEQ == 0 ? true : false; clsMS_StockPlan_VO objMain = m_objGetMainISVO(); DataRow[] drNew = m_objViewer.m_dtbMedicineInfo.Select("MEDICINEID_CHR IS NOT NULL AND AMOUNT IS NOT NULL"); clsMS_StockPlan_Detail_VO[] objDetailArr = m_objGetDetailArr(drNew, objMain.m_lngSERIESID_INT); if (blnIsAddNew) { lngRes = m_objDomain.m_lngAddNewPlanMedInfo(m_objViewer.m_intCommitFolow, ref objMain, ref objDetailArr); if (lngRes > 0 && this.m_objMainVoList != null) { this.m_objMainVoList.Add(objMain); } } else { lngRes = m_objDomain.m_lngUpdatePlanMedInfo(m_objViewer.m_intCommitFolow, objMain, ref objDetailArr); if (lngRes > 0 && this.m_objMainVoList != null) { foreach (clsMS_StockPlan_VO vo in m_objMainVoList) { if (vo.m_lngSERIESID_INT == objMain.m_lngSERIESID_INT) { m_objMainVoList.Remove(vo); } } m_objMainVoList.Add(objMain); } } if (lngRes > 0) { m_objViewer.m_lngMainSEQ = objMain.m_lngSERIESID_INT; m_objViewer.m_txtBillNumber.Text = objMain.m_strSTOCKPLANID_VCHR; m_objCurrentMain = objMain; m_objCurrentSubArr = objDetailArr; m_mthSetSeriesIDToUI(objDetailArr); #region 去除空行 DataRow[] drNull = m_objViewer.m_dtbMedicineInfo.Select("AMOUNT IS NULL"); if (drNull != null && drNull.Length > 0) { foreach (DataRow drDel in drNull) { m_objViewer.m_dtbMedicineInfo.Rows.Remove(drDel); } } #endregion m_objViewer.m_dtbMedicineInfo.AcceptChanges(); MessageBox.Show("保存成功", "采购计划", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("保存失败", "采购计划", MessageBoxButtons.OK, MessageBoxIcon.Error); return(-1); } } catch (Exception Ex) { string strExMessage = "保存失败" + Environment.NewLine + Ex.Message; return(-1); } return(lngRes); }
/// <summary> /// 设置药品信息至界面(外部传入VO,以进行修改) /// </summary> /// <param name="p_objISVO">主表信息</param> /// <param name="p_objDetailArr">子表信息</param> /// <param name="p_intSelectedSubRow">选中子表行</param> internal void m_mthSetMedicineDetailToUI(clsMS_StockPlan_VO p_objISVO, clsMS_StockPlan_Detail_VO[] p_objDetailArr, int p_intSelectedSubRow) { if (p_objISVO == null) { return; } #region 主表 m_objViewer.m_lngMainSEQ = p_objISVO.m_lngSERIESID_INT; m_objViewer.m_txtProviderName.Text = p_objISVO.m_strVENDORNAME_VCHR; m_objViewer.m_txtProviderName.Tag = p_objISVO.m_strVENDORID_CHR; m_objViewer.m_txtMakeBillPerson.Text = p_objISVO.m_strMAKERNAME_VCHR; m_objViewer.m_txtMakeBillPerson.Tag = p_objISVO.m_strMAKERID_CHR; m_objViewer.m_txtRemark.Text = p_objISVO.m_strCOMMENT_VCHR; m_objViewer.m_dtpNewOrderDate.Text = p_objISVO.m_datNEWORDER_DAT.ToString("yyyy年MM月dd日");; m_objViewer.m_txtBillNumber.Text = p_objISVO.m_strSTOCKPLANID_VCHR; m_objCurrentMain = p_objISVO; if (p_objDetailArr == null) { return; } #endregion #region 子表 try { m_objViewer.m_dtbMedicineInfo = m_dtbInitTable(); m_objViewer.m_dtbMedicineInfo.BeginLoadData(); DataRow[] drSub = new DataRow[p_objDetailArr.Length]; for (int iRow = 0; iRow < p_objDetailArr.Length; iRow++) { drSub[iRow] = m_objViewer.m_dtbMedicineInfo.NewRow(); drSub[iRow]["SERIESID_INT"] = p_objDetailArr[iRow].m_lngSERIESID_INT; drSub[iRow]["SERIESID2_INT"] = p_objDetailArr[iRow].m_lngSERIESID2_INT; drSub[iRow]["MEDICINEID_CHR"] = p_objDetailArr[iRow].m_strMEDICINEID_CHR; drSub[iRow]["MEDICINENAME_VCHR"] = p_objDetailArr[iRow].m_strMEDICINENAME_VCHR; drSub[iRow]["MEDSPEC_VCHR"] = p_objDetailArr[iRow].m_strMEDSPEC_VCHR; drSub[iRow]["AMOUNT"] = p_objDetailArr[iRow].m_dblAMOUNT; drSub[iRow]["PRODUCTORID_CHR"] = p_objDetailArr[iRow].m_strPRODUCTORID_CHR; drSub[iRow]["UNIT_VCHR"] = p_objDetailArr[iRow].m_strUNIT_VCHR; drSub[iRow]["SortNum"] = iRow + 1; drSub[iRow]["ASSISTCODE_CHR"] = p_objDetailArr[iRow].m_strASSISTCODE_CHR; drSub[iRow]["REMARK_VCHR"] = p_objDetailArr[iRow].m_strREMARK_VCHR; drSub[iRow]["STATUS"] = p_objDetailArr[iRow].m_lngSTATUS; drSub[iRow]["CALLPRICE_INT"] = p_objDetailArr[iRow].m_dblCALLPRICE_INT; drSub[iRow]["STOCKSUM"] = p_objDetailArr[iRow].m_dblSTOCKSUM; drSub[iRow]["LASTINSTORAGEDATE_DAT"] = p_objDetailArr[iRow].m_datLASTINSTORAGEDATE_DAT; drSub[iRow]["VENDORID_CHR"] = p_objDetailArr[iRow].m_strVENDORID_CHR; drSub[iRow]["vendorname"] = p_objDetailArr[iRow].m_strVENDORNAME_VCHR; m_objViewer.m_dtbMedicineInfo.LoadDataRow(drSub[iRow].ItemArray, true); } } catch (Exception Ex) { com.digitalwave.Utility.clsLogText objLogger = new com.digitalwave.Utility.clsLogText(); bool blnRes = objLogger.LogError(Ex); } finally { m_objViewer.m_dtbMedicineInfo.EndLoadData(); } m_objViewer.m_dgvMedicineDetail.DataSource = m_objViewer.m_dtbMedicineInfo; if (p_intSelectedSubRow > 0 && m_objViewer.m_dgvMedicineDetail.Rows.Count > 0 && p_intSelectedSubRow < m_objViewer.m_dgvMedicineDetail.Rows.Count) { m_objViewer.m_dgvMedicineDetail.Rows[p_intSelectedSubRow].Selected = true; m_objViewer.m_dgvMedicineDetail.CurrentCell = m_objViewer.m_dgvMedicineDetail.Rows[p_intSelectedSubRow].Cells[0]; } m_objViewer.m_dtbMedicineInfo.AcceptChanges(); #endregion }