⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vaccountdialog.java

📁 Java写的ERP系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		{
			AcctSchemaElement ase = (AcctSchemaElement)ase_list.get(i);
			String type = ase.getSegmentType();
			//
			if (type.equals(AcctSchemaElement.SEGMENT_Org))
			{
				value = f_AD_Org_ID.getValue();
				sql.append("AD_Org_ID");
				if (value == null)
					sql.append(" IS NULL AND ");
				else
					sql.append("=").append(value).append(" AND ");
			}
			else if (type.equals(AcctSchemaElement.SEGMENT_Account))
			{
				value = f_Account_ID.getValue();
				sql.append("Account_ID");
				if (value == null)
					sql.append(" IS NULL AND ");
				else
					sql.append("=").append(value).append(" AND ");
			}
			else if (type.equals(AcctSchemaElement.SEGMENT_Product))
			{
				value = f_M_Product_ID.getValue();
				sql.append("M_Product_ID");
				if (value == null)
					sql.append(" IS NULL AND ");
				else
					sql.append("=").append(value).append(" AND ");
			}
			else if (type.equals(AcctSchemaElement.SEGMENT_BPartner))
			{
				value = f_C_BPartner_ID.getValue();
				sql.append("C_BPartner_ID");
				if (value == null)
					sql.append(" IS NULL AND ");
				else
					sql.append("=").append(value).append(" AND ");
			}
			else if (type.equals(AcctSchemaElement.SEGMENT_Campaign))
			{
				value = f_C_Campaign_ID.getValue();
				sql.append("C_Campaign_ID");
				if (value == null)
					sql.append(" IS NULL AND ");
				else
					sql.append("=").append(value).append(" AND ");
			}
			else if (type.equals(AcctSchemaElement.SEGMENT_LocationFrom))
			{
				value = f_C_LocFrom_ID.getValue();
				sql.append("C_LocFrom_ID");
				if (value == null)
					sql.append(" IS NULL AND ");
				else
					sql.append("=").append(value).append(" AND ");
			}
			else if (type.equals(AcctSchemaElement.SEGMENT_LocationTo))
			{
				value = f_C_LocTo_ID.getValue();
				sql.append("C_LocTo_ID");
				if (value == null)
					sql.append(" IS NULL AND ");
				else
					sql.append("=").append(value).append(" AND ");
			}
			else if (type.equals(AcctSchemaElement.SEGMENT_Project))
			{
				value = f_C_Project_ID.getValue();
				sql.append("C_Project_ID");
				if (value == null)
					sql.append(" IS NULL AND ");
				else
					sql.append("=").append(value).append(" AND ");
			}
			else if (type.equals(AcctSchemaElement.SEGMENT_SalesRegion))
			{
				value = f_C_SalesRegion_ID.getValue();
				sql.append("C_SalesRegion_ID");
				if (value == null)
					sql.append(" IS NULL AND ");
				else
					sql.append("=").append(value).append(" AND ");
			}
			else if (type.equals(AcctSchemaElement.SEGMENT_TrxOrg))
			{
				value = f_AD_OrgTrx_ID.getValue();
				sql.append("AD_OrgTrx_ID");
				if (value == null)
					sql.append(" IS NULL AND ");
				else
					sql.append("=").append(value).append(" AND ");
			}
			else if (type.equals(AcctSchemaElement.SEGMENT_Activity))
			{
				value = f_C_Activity_ID.getValue();
				sql.append("C_Activity_ID");
				if (value == null)
					sql.append(" IS NULL AND ");
				else
					sql.append("=").append(value).append(" AND ");
			}
			else if (type.equals(AcctSchemaElement.SEGMENT_User1))
			{
				value = f_User1_ID.getValue();
				sql.append("User1_ID");
				if (value == null)
					sql.append(" IS NULL AND ");
				else
					sql.append("=").append(value).append(" AND ");
			}
			else if (type.equals(AcctSchemaElement.SEGMENT_User2))
			{
				value = f_User2_ID.getValue();
				sql.append("User2_ID");
				if (value == null)
					sql.append(" IS NULL AND ");
				else
					sql.append("=").append(value).append(" AND ");
			}
			//
			if (ase.isMandatory() && value == null)
				sb.append(ase.getName()).append(", ");
		}	//	Fields in Element Order

		if (sb.length() != 0)
		{
			ADialog.error(m_WindowNo, this, "FillMandatory", sb.substring(0, sb.length()-2));
			return;
		}

		/**
		 *	Check if already exists
		 */
		sql.append("AD_Client_ID=").append(m_AD_Client_ID);
		Log.trace(Log.l6_Database, "VAccountDialog.action_Save check = " + sql.toString());
		int IDvalue = 0;
		String Alias = null;
		try
		{
			Statement stmt = DB.createStatement();
			ResultSet rs = stmt.executeQuery(sql.toString());
			if (rs.next())
			{
				IDvalue = rs.getInt(1);
				Alias = rs.getString(2);
			}
			rs.close();
			stmt.close();
		}
		catch (SQLException e)
		{
			Log.error ("VAccountDialog.action_Save SQL=" + sql.toString(), e);
			IDvalue = 0;
		}

		if (Alias == null)
			Alias = "";

		//	We have an account like this already - check alias
		if (IDvalue != 0 && s_AcctSchema.hasAlias()
			&& !f_Alias.getValue().toString().equals(Alias))
		{
			sql = new StringBuffer("UPDATE C_ValidCombination SET Alias=");
			if (f_Alias.getValue().toString().length() == 0)
				sql.append("NULL");
			else
				sql.append("'").append(f_Alias.getValue()).append("'");
			sql.append(" WHERE C_ValidCombination_ID=").append(IDvalue);
			int i = 0;
			try
			{
				Statement stmt = DB.createStatement();
				i = stmt.executeUpdate(sql.toString());
				stmt.close();
			}
			catch (SQLException e)
			{
				Log.error ("VAccountDialog.action_Save SQL=" + sql.toString(), e);
			}
			if (i == 0)
				ADialog.error(m_WindowNo, this, "AccountNotUpdated");
		}

		//	load and display
		if (IDvalue != 0)
		{
			loadInfo (IDvalue);
			action_Find (false);
			return;
		}


		Alias = null;
		if (f_Alias != null)
			Alias = f_Alias.getValue().toString();
		int M_Product_ID = 0;
		if (f_M_Product_ID != null && f_M_Product_ID.getValue() != null)
			M_Product_ID = ((Integer)f_M_Product_ID.getValue()).intValue();
		int C_BPartner_ID = 0;
		if (f_C_BPartner_ID != null && f_C_BPartner_ID.getValue() != null)
			C_BPartner_ID = ((Integer)f_C_BPartner_ID.getValue()).intValue();
		int AD_OrgTrx_ID = 0;
		if (f_AD_OrgTrx_ID != null && f_AD_OrgTrx_ID.getValue() != null)
			AD_OrgTrx_ID = ((Integer)f_AD_OrgTrx_ID.getValue()).intValue();
		int C_LocFrom_ID = 0;
		if (f_C_LocFrom_ID != null && f_C_LocFrom_ID.getValue() != null)
			C_LocFrom_ID = ((Integer)f_C_LocFrom_ID.getValue()).intValue();
		int C_LocTo_ID = 0;
		if (f_C_LocTo_ID != null && f_C_LocTo_ID.getValue() != null)
			C_LocTo_ID = ((Integer)f_C_LocTo_ID.getValue()).intValue();
		int C_SRegion_ID = 0;
		if (f_C_SalesRegion_ID != null && f_C_SalesRegion_ID.getValue() != null)
			C_SRegion_ID = ((Integer)f_C_SalesRegion_ID.getValue()).intValue();
		int C_Project_ID = 0;
		if (f_C_Project_ID != null && f_C_Project_ID.getValue() != null)
			C_Project_ID=  ((Integer)f_C_Project_ID.getValue()).intValue();
		int C_Campaign_ID = 0;
		if (f_C_Campaign_ID != null && f_C_Campaign_ID.getValue() != null)
			C_Campaign_ID = ((Integer)f_C_Campaign_ID.getValue()).intValue();
		int C_Activity_ID = 0;
		if (f_C_Activity_ID != null && f_C_Activity_ID.getValue() != null)
			C_Activity_ID = ((Integer)f_C_Activity_ID.getValue()).intValue();
		int User1_ID = 0;
		if (f_User1_ID != null && f_User1_ID.getValue() != null)
			User1_ID = ((Integer)f_User1_ID.getValue()).intValue();
		int User2_ID = 0;
		if (f_User2_ID != null && f_User2_ID.getValue() != null)
			User2_ID = ((Integer)f_User2_ID.getValue()).intValue();

		int retValue = DB.getValidCombination(m_AD_Client_ID, ((Integer)f_AD_Org_ID.getValue()).intValue(),
			s_AcctSchema.getC_AcctSchema_ID(), ((Integer)f_Account_ID.getValue()).intValue(), 0,
			Alias, Env.getContextAsInt(Env.getCtx(), "#AD_User_ID"), M_Product_ID, C_BPartner_ID, AD_OrgTrx_ID,
			C_LocFrom_ID, C_LocTo_ID, C_SRegion_ID, C_Project_ID,
			C_Campaign_ID, C_Activity_ID, User1_ID, User2_ID);

		//  Show Info
		loadInfo (retValue);
		action_Find (false);
	}	//	action_Save


	/**
	 *	Ignore
	 */
	private void action_Ignore()
	{
		if (f_Alias != null)
			f_Alias.setValue("");
		f_Combination.setValue("");
		f_Description.setText("");
		//
		//	Org (mandatory)
		f_AD_Org_ID.setValue(null);
		//	Account (mandatory)
		f_Account_ID.setValue(null);

		//	Product
		if (f_M_Product_ID != null)
			f_M_Product_ID.setValue(null);
		//	BPartner
		if (f_C_BPartner_ID != null)
			f_C_BPartner_ID.setValue(null);
		//	Campaign
		if (f_C_Campaign_ID != null)
			f_C_Campaign_ID.setValue(null);
		//	Loc From
		if (f_C_LocFrom_ID != null)
			f_C_LocFrom_ID.setValue(null);
		//	Loc To
		if (f_C_LocTo_ID != null)
			f_C_LocTo_ID.setValue(null);
		//	Project
		if (f_C_Project_ID != null)
			f_C_Project_ID.setValue(null);
		//	SRegion
		if (f_C_SalesRegion_ID != null)
			f_C_SalesRegion_ID.setValue(null);
		//	Org Trx
		if (f_AD_OrgTrx_ID != null)
			f_AD_OrgTrx_ID.setValue(null);
		//	Activity
		if (f_C_Activity_ID != null)
			f_C_Activity_ID.setValue(null);
		//	User 1
		if (f_User1_ID != null)
			f_User1_ID.setValue(null);
		//	User 2
		if (f_User2_ID != null)
			f_User2_ID.setValue(null);
	}	//	action_Ignore

	/**
	 *	Get selected account
	 *  @return account
	 */
	public Integer getValue()
	{
		Log.trace(Log.l3_Util, "VAccountDialog.getValue", "C_ValidCombination_ID=" + m_C_ValidCombination_ID + ", Changed=" + m_changed);
		if (!m_changed || m_C_ValidCombination_ID == 0)
			return null;
		return new Integer(m_C_ValidCombination_ID);
	}

}	//	VAccountDialog

/**
 *	Mouse Listener
 */
class VAccountDialog_mouseAdapter extends java.awt.event.MouseAdapter
{
	VAccountDialog_mouseAdapter(VAccountDialog adaptee)
	{
		this.adaptee = adaptee;
	}

	VAccountDialog adaptee;

	public void mouseClicked(MouseEvent e)
	{
		//	Table => select
		if (e.getSource() instanceof JTable && e.getClickCount() > 1)
		{
			adaptee.m_changed = true;
			adaptee.dispose();
		}
	}
}	//	VAccountDialog_mouseListener

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -